using framework_business;
using framework_library;
using System;
using System.IO;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class controls_composite_composite : ICompositeBase
{
private const string controlPath = "~/controls/";
private const string surfacePath = "~/controls/surface/";
#region methods
#endregion
#region events
///
/// Page initiliazie event
///
///
///
protected void Page_Init(object sender, EventArgs e)
{
}
///
/// Page Load Event
///
///
///
///
/// REVISION 001: If surface option Default To Form = Y, show form panel instead of grid panel
/// AUTHOR: Charlene van Heerden
/// DATE MODIFIED: 11 December 2015
///
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
LoadControls();
}
private void LoadControls()
{
try
{
if (base.CompositeCanvas != null)
{
oComposite composite = base.CompositeCanvas;
foreach (oCanvas canvas in xData.GetTypedByCriteriaSpecific("recId", typeof(oCanvas), "parentId", composite.canvasId.ToString(), "sequence"))
{
if (handler.validateCanvas(canvas))
{
foreach (oCanvasMetaData met in xData.GetTypedByCriteriaSpecific("recId", typeof(oCanvasMetaData), "canvasId", canvas.recId.ToString()))
{
foreach (oModule mod in xData.GetTypedByCriteriaSpecific("recId", typeof(oModule), "recId", met.moduleId.ToString()))
{
if (mod.control != String.Empty)
{
foreach (Control cntrl in this.Controls)
{
if (cntrl.GetType() == typeof(PlaceHolder))
{
PlaceHolder placeHolder = (PlaceHolder)cntrl;
if (placeHolder.ID == "plc" + canvas.name)
{
if (met.moduleId == pNums.Module.Surface.GetHashCode())
{
//get surface app
foreach (oSurface surfApp in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", met.entityId.ToString()))
{
if (canvas.isDefaultToForm)
{ surfApp.isDefaultToForm = canvas.isDefaultToForm; }
if (!File.Exists(Server.MapPath(surfacePath + surfApp.name + ".ascx")))
{ surfaceHandler.BuildSurfaceAppTemplate(surfApp, controlPath + mod.control, surfacePath, true); }
ISurfaceBase uc = (ISurfaceBase)LoadControl(surfacePath + surfApp.name + ".ascx");
uc.SurfaceApp = surfApp;
placeHolder.Controls.Clear();
placeHolder.Controls.Add(uc);
}
}
else
{
placeHolder.Controls.Clear();
ICanvasBase uc = (ICanvasBase)LoadControl(controlPath + mod.control);
uc.CanvasContent = canvas;
placeHolder.Controls.Add(uc);
}
break;
}
}
}
}
}
}
}
}
}
}
catch (Exception ex)
{
exception.HandleException("composite:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
#endregion
}