using framework_business;
using framework_library;
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
public partial class controls_admin_surface : System.Web.UI.UserControl
{
private const string controlPath = "~/controls/";
private const string surfacePath = "~/controls/surface/";
private const string tempPath = "~/upload/temp/";
#region methods
///
/// Method to Bind Surface Data
///
private void BindSurfaceData()
{
try
{
ArrayList SurfaceList = xData.GetTypedCollection("recId", typeof(oSurface), "surface");
rptSurfaceList.DataSource = SurfaceList;
rptSurfaceList.DataBind();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Populate Form Values
///
///
///
/// REVISION 001: Added field to pal_Surface.isDefaultToForm. Indicates whether default view of surface app is form or grid (for multi surface app functionality)
/// AUTHOR: Charlene van Heerden
/// DATE MODIFIED: 11 December 2015
///
private void PopulatePageFormValues(ref oSurface _Surface)
{
try
{
txtSurface.Value = _Surface.surface;
chkActive.Checked = _Surface.isActive;
chkModal.Checked = _Surface.isModal;
chkPublished.Checked = _Surface.isPublished;
chkDefaultToForm.Checked = _Surface.isDefaultToForm;
chkIsWizzard.Checked = _Surface.isWizzard;
chkIsComparable.Checked = _Surface.isComparable;
if (chkIsComparable.Checked)
{
txtColumnCount.Text = _Surface.columnCount.ToString();
divColumnCount.Visible = true;
}
chkIsLinkedSurface.Checked = _Surface.isLinkedSurface;
chkIsDisableRequired.Checked = _Surface.isDisableRequired;
BindLinkedSurfaces(_Surface.recId);
divLinkedSurfaces.Visible = chkIsLinkedSurface.Checked;
chkLinkUser.Checked = _Surface.linkUser;
chkCapitalize.Checked = _Surface.isCapitalizeInput;
//CVH 2016-10-21 Adding custom action on surface save
chkCustomActionOnSave.Checked = false;
foreach (oSurfaceAction act in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceAction), "recId", _Surface.surfaceActionId.ToString()))
{
if (act.action == "Surface Save")
chkCustomActionOnSave.Checked = true;
}
if (_Surface.isPublished)
{
btnPublish.Visible = true;
btnPublish.Text = "Re-Publish Layout";
if (Debugger.IsAttached)
{
chkRecreateCode.Visible = true;
}
}
else//only show publish button in dev mode
{
if (Debugger.IsAttached)
{
btnPublish.Visible = true;
chkRecreateCode.Visible = true;
}
else
{
btnPublish.Visible = false;
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Save Form Values
///
///
///
/// REVISION 001: Added field to pal_Surface.isDefaultToForm. Indicates whether default view of surface app is form or grid (for multi surface app functionality)
/// AUTHOR: Charlene van Heerden
/// DATE MODIFIED: 11 December 2015
///
private void SavePageFormValues(ref oSurface _Surface)
{
try
{
_Surface.surface = txtSurface.Value;
_Surface.isActive = chkActive.Checked;
_Surface.name = utils.stripCharacters(txtSurface.Value).Replace(" ", "");
_Surface.isModal = chkModal.Checked;
_Surface.isPublished = chkPublished.Checked;
/* Rev 001 isDefaultToForm field added to pal_Surface
* Charlene van Heerden
* 11 December 2015
*/
_Surface.isDefaultToForm = chkDefaultToForm.Checked;
_Surface.isWizzard = chkIsWizzard.Checked;
_Surface.isComparable = chkIsComparable.Checked;
if (divColumnCount.Visible)
_Surface.columnCount = Convert.ToInt32(txtColumnCount.Text);
_Surface.isLinkedSurface = chkIsLinkedSurface.Checked;
_Surface.isDisableRequired = chkIsDisableRequired.Checked;
_Surface.linkUser = chkLinkUser.Checked;
_Surface.isCapitalizeInput = chkCapitalize.Checked;
//CVH 2016-10-21 Adding custom action on surface save
_Surface.surfaceActionId = 0;
if (chkCustomActionOnSave.Checked)
{
foreach (oSurfaceAction act in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceAction), "action", "Surface Save"))
{
_Surface.surfaceActionId = act.recId;
break;
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Method to Toggle Panels
///
///
private void TogglePanels(string panelName)
{
switch (panelName)
{
case "pnlSurfaceApp":
pnlSurfaceApp.Visible = true;
pnlSurfaceList.Visible = false;
break;
case "pnlSurfaceList":
pnlSurfaceApp.Visible = false;
pnlSurfaceList.Visible = true;
break;
}
//clear result
pnlResult.Visible = false;
}
///
/// Method to Build User Control
///
///
private static void BuildControl(oSurface surface)
{
foreach (oModule moduleItem in xData.GetTypedByCriteriaSpecific("recId", typeof(oModule), "recId", pNums.Module.Surface.GetHashCode().ToString()))
{
surfaceHandler.BuildSurfaceAppTemplate(surface, controlPath + moduleItem.control, surfacePath, true);
}
}
#endregion
#region surface field methods
///
/// Method to Toggle Panels for Surface Fields
///
///
private void TogglePanelsSurfaceFields(string panelName)
{
switch (panelName)
{
case "pnlSurfaceField":
pnlSurfaceField.Visible = true;
pnlSurfaceFields.Visible = false;
break;
case "pnlSurfaceFields":
pnlSurfaceField.Visible = false;
pnlSurfaceFields.Visible = true;
break;
}
upSurfaceFields.Update();
}
///
/// Bind Parent Fields
///
private void BindFilterTabs()
{
oSurface surface = new oSurface();
try
{
if (utils.verifySession("surface"))
{
surface = (oSurface)Session["surface"];
int fieldTypeId = 1;//default to tab
DataTable typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", surface.recId + "," + fieldTypeId, "sequence");
ddTabs.DataSource = typeData;
ddTabs.DataTextField = "surfaceFieldDisplay";
ddTabs.DataValueField = "recId";
ddTabs.DataBind();
ddTabs.Items.Insert(0, new ListItem("tabs..", "0"));
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Bind Parent Fields
///
private void BindFilterGroups()
{
oSurface surface = new oSurface();
try
{
if (utils.verifySession("surface"))
{
surface = (oSurface)Session["surface"];
//int fieldTypeId = 2;//groups
string fieldTypeId = "2|16";
int parentId = 0;
if (ddTabs.SelectedValue != null && ddTabs.SelectedValue != "0")
int.TryParse(ddTabs.SelectedValue, out parentId);
DataTable typeData = new DataTable();
if (parentId > 0)
typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId,parentId", surface.recId + ",~()" + fieldTypeId + "," + parentId, "sequence");
else
typeData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", surface.recId + ",~()" + fieldTypeId, "sequence");
ddGroups.DataSource = typeData;
ddGroups.DataTextField = "surfaceFieldDisplay";
ddGroups.DataValueField = "recId";
ddGroups.DataBind();
ddGroups.Items.Insert(0, new ListItem("groups..", "0"));
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Method to Bind Surface Data
///
private void BindSurfaceFields()
{
try
{
if (utils.verifySession("surface"))
{
oSurface surface = (oSurface)Session["surface"];
ArrayList FieldList = new ArrayList();
int parentId = 0;
if (ddGroups.SelectedValue != null && ddGroups.SelectedValue != "0")
int.TryParse(ddGroups.SelectedValue, out parentId);
else if (ddTabs.SelectedValue != null && ddTabs.SelectedValue != "0")
int.TryParse(ddTabs.SelectedValue, out parentId);
if (parentId > 0)
FieldList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId, parentId", surface.recId + "," + parentId, "sequence,parentId");
else
FieldList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "surfaceId", surface.recId.ToString(), "sequence,parentId");
rptSurfaceFields.DataSource = FieldList;
rptSurfaceFields.DataBind();
}
else
{
rptSurfaceFields.DataSource = null;
rptSurfaceFields.DataBind();
}
lblPipe.Visible = rptSurfaceFields.Items.Count > 0;
btnGrid.Visible = rptSurfaceFields.Items.Count > 0;
upSurfaceFields.Update();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
#region Backup
//private void SetActionFieldValuesBACKUP(oSurfaceField _SurfaceField)
//{
// if (ddActionTypes.Items.FindByValue(_SurfaceField.actionType.ToString()) != null)
// {
// ddActionTypes.SelectedValue = _SurfaceField.actionType.ToString();
// BindActions(_SurfaceField.actionType.ToString());
// if (_SurfaceField.actionType == pNums.ActionType.ToggleView.GetHashCode())
// actionValueGroup.Visible = true;
// else
// actionValueGroup.Visible = false;
// actionSourceGroup2.Visible = false;
// if (ddActions.Items.FindByValue(_SurfaceField.action.ToString()) != null)
// {
// ddActions.SelectedValue = _SurfaceField.action.ToString();
// string action = ddActions.SelectedItem.Text;
// switch (action)
// {
// case "VAT":
// BindActionSource(pNums.FieldType.Decimal.GetHashCode().ToString());
// break;
// case "Age":
// BindActionSource(pNums.FieldType.Date.GetHashCode().ToString() + "|" + pNums.FieldType.Text.GetHashCode().ToString());
// break;
// case "Gender":
// BindActionSource(pNums.FieldType.Text.GetHashCode().ToString());
// break;
// case "Copy":
// string destType = ddFieldTypes.SelectedValue;
// BindActionSource(destType);
// txtActionValue.Text = _SurfaceField.actionValue;
// break;
// case "Visible":
// //CVH 2016-10-10 Only catering for fieldtype Checkboxlist and RadioButtonList
// //CVH 2017-01-18 Add toggle view for picklist
// //CVH 2017-02-15 Add toggle view for grid
// BindActionSource(pNums.FieldType.CheckboxList.GetHashCode().ToString() + "|" + pNums.FieldType.RadioButtonList.GetHashCode().ToString() + "|" + pNums.FieldType.Picklist.GetHashCode().ToString() + "|" + pNums.FieldType.Grid.GetHashCode(), _SurfaceField.surfaceId);
// txtActionValue.Text = _SurfaceField.actionValue;
// break;
// case "Divide":
// BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), _SurfaceField.surfaceId);
// actionSourceGroup2.Visible = true;
// if (ddActionSource2.Items.FindByValue(_SurfaceField.actionValue) != null)
// ddActionSource2.Items.FindByValue(_SurfaceField.actionValue).Selected = true;
// break;
// case "Lookup":
// BindActionSource(pNums.FieldType.Text.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString() + "|" + pNums.FieldType.FormulaField.GetHashCode().ToString(), _SurfaceField.surfaceId);
// BindLookupCalcSurface();
// lookupCalcSurfaceGroup.Visible = true;
// if (ddLookupCalcSurface.Items.FindByValue(_SurfaceField.actionValue) != null)
// ddLookupCalcSurface.Items.FindByValue(_SurfaceField.actionValue).Selected = true;
// break;
// case "Sum":
// //Aggregation Sum (could be a Calculation Sum later)
// if (_SurfaceField.actionType == (int)pNums.ActionType.Aggregation)
// {
// actionSourceGroup.Visible = false;
// actionSourceGroup2.Visible = false;
// BindAggregationSurface();
// aggregationSurfaceGroup.Visible = true;
// if (ddAggregationSurface.Items.FindByValue(_SurfaceField.actionValue) != null)
// {
// ddAggregationSurface.Items.FindByValue(_SurfaceField.actionValue).Selected = true;
// BindActionSource(pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), int.Parse(_SurfaceField.actionValue));
// if (ddActionSource.Items.FindByValue(_SurfaceField.actionSource.ToString()) != null)
// ddActionSource.Items.FindByValue(_SurfaceField.actionSource.ToString()).Selected = true;
// }
// }
// break;
// case "Text Colour":
// stylingTextColourGroup.Visible = true;
// ddStylingTextColourRule.ClearSelection();
// txtStylingTextColourValue.Text = "";
// ddStylingTextColourColour.ClearSelection();
// if (_SurfaceField.actionValue != String.Empty)
// {
// // Rule|Value|Colour eg "<|60|Red"
// int styleCount = 0;
// foreach (string style in _SurfaceField.actionValue.Split('|'))
// {
// if (styleCount == 0)
// {
// if (style == "<" && ddStylingTextColourRule.Items.FindByValue("Less Than") != null)
// ddStylingTextColourRule.Items.FindByValue("Less Than").Selected = true;
// }
// else if (styleCount == 1)
// {
// txtStylingTextColourValue.Text = style;
// }
// else if (styleCount == 2)
// {
// if (ddStylingTextColourColour.Items.FindByValue(style) != null)
// ddStylingTextColourColour.Items.FindByValue(style).Selected = true;
// }
// styleCount++;
// }
// }
// break;
// case "Average":
// if (_SurfaceField.actionType == (int)pNums.ActionType.FieldAggregation)
// {
// fieldAggregationGroup.Visible = true;
// BindFieldAggregationList();
// foreach (string fields in _SurfaceField.actionValue.Split('|'))
// {
// if (lstFieldAggregation.Items.FindByValue(fields) != null)
// {
// lstFieldAggregation.Items.FindByValue(fields).Selected = true;
// }
// }
// }
// break;
// case "Ranking":
// BindActionSource(pNums.FieldType.FormulaField.GetHashCode().ToString() + "|" + pNums.FieldType.Number.GetHashCode().ToString() + "|" + pNums.FieldType.Decimal.GetHashCode().ToString(), _SurfaceField.surfaceId);
// DataTable actionSourceData = new DataTable();
// if (_SurfaceField.surfaceId == 0)
// actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive", "1", "recId");
// else
// actionSourceData = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "isActive,surfaceId", "1," + _SurfaceField.surfaceId.ToString(), "recId");
// ddActionSource2.DataSource = actionSourceData;
// ddActionSource2.DataTextField = "surfaceFieldName";
// ddActionSource2.DataValueField = "recId";
// ddActionSource2.DataBind();
// lblddActionSource2.Text = "Group By";
// actionSourceGroup2.Visible = true;
// break;
// case "Distinction Count":
// if (_SurfaceField.actionType == (int)pNums.ActionType.FieldAggregation)
// {
// fieldAggregationGroup.Visible = true;
// BindFieldAggregationList();
// foreach (string fields in _SurfaceField.actionValue.Split('|'))
// {
// if (lstFieldAggregation.Items.FindByValue(fields) != null)
// {
// lstFieldAggregation.Items.FindByValue(fields).Selected = true;
// }
// }
// }
// break;
// default:
// break;
// }
// if (ddActionSource.Items.FindByValue(_SurfaceField.actionSource.ToString()) != null)
// {
// ddActionSource.SelectedValue = _SurfaceField.actionSource.ToString();
// }
// }
// }
//}
#endregion
#endregion
#region surface field events
///
/// Add New Field
///
///
///
protected void btnNewField_Click(object sender, EventArgs e)
{
oSurface Surface = new oSurface();
try
{
if (utils.verifySession("surface"))
{
surfaceField.ReloadControl(true, new oSurfaceField());
}
//show Surface field Form
TogglePanelsSurfaceFields("pnlSurfaceField");
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Manage Picklists
///
///
///
protected void btnManagePicklists_Click(object sender, EventArgs e)
{
try
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myPicklistModal", "$('#modLoookups').modal();", true);
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Lookup categories
///
///
///
protected void btnLookCat_Click(object sender, EventArgs e)
{
try
{
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myCatModal", "$('#modLookupCategories').modal();", true);
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// manage Grid Options
///
///
///
protected void btnGrid_Click(object sender, EventArgs e)
{
try
{
//btnSave_Click(sender, e);
surfaceGrids1.ReloadControl();
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myGridOptionsModal", "$('#modGridOptions').modal();", true);
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Save Surface field
///
///
///
///
/// REVISION 001: Enable Grid field type. Confirm that surface app loading as Grid Field type is not the current surface app being created
/// AUTHOR: Charlene van Heerden
/// DATE MODIFIED: 10 December 2015
///
protected void btnSaveSurfaceField_Click(object sender, EventArgs e)
{
try
{
if (surfaceField.SaveControlData())
{
BindFilterTabs();
BindSurfaceFields();
upSurfaceFields.Update();
}
//if (ddFieldTypes.SelectedValue == pNums.FieldType.Tab.GetHashCode().ToString())
//{
// ddTabs.SelectedValue = SurfaceField.recId.ToString();
// BindFilterGroups();
//}
//else if (ddFieldTypes.SelectedValue == pNums.FieldType.Group.GetHashCode().ToString() ||
// ddFieldTypes.SelectedValue == pNums.FieldType.HeaderGroup.GetHashCode().ToString())
//{
// BindFilterGroups();
// if (ddGroups.Items.FindByValue(SurfaceField.recId.ToString()) != null)
// ddGroups.SelectedValue = SurfaceField.recId.ToString();
//}
//else
//{
// if (ddGroups.Items.FindByValue(SurfaceField.recId.ToString()) != null)
// ddGroups.SelectedValue = SurfaceField.recId.ToString();
//}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Cancel Surface field
///
///
///
protected void btnCancelSurfaceField_Click(object sender, EventArgs e)
{
try
{
Session["surfaceFieldId"] = 0;
utils.disposeSession("surfaceField");
//show cat list
TogglePanelsSurfaceFields("pnlSurfaceFields");
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Item Databound
///
///
///
protected void rptSurfaceFields_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
try
{
if (e.Item.ItemIndex != -1)
{
Label lblFieldType = ((Label)e.Item.FindControl("lblFieldType"));
pNums.FieldType typ = (pNums.FieldType)Enum.ToObject(typeof(pNums.FieldType), int.Parse(lblFieldType.Text));
switch (typ)
{
case pNums.FieldType.RelationalField:
lblFieldType.Text = "Relational Field";
break;
case pNums.FieldType.Mediswitch:
lblFieldType.Text = "Mediswitch MSV";
break;
default:
lblFieldType.Text = typ.ToString();
break;
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Edit Field
///
///
///
protected void lnkEditField_Click(object sender, EventArgs e)
{
try
{
oSurfaceField _SurfaceField = new oSurfaceField();
ArrayList FieldList = new ArrayList();
if (sender.GetType() == typeof(LinkButton))
{
//
int recId = int.Parse(((LinkButton)sender).CommandArgument);
if (recId > 0)
{
//get field
FieldList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", recId.ToString());
//enumerate list
foreach (oSurfaceField field in FieldList)
{
//assign object
_SurfaceField = field;
}
if (utils.verifySession("surface"))
{
surfaceField.ReloadControl(false, _SurfaceField);
TogglePanelsSurfaceFields("pnlSurfaceField");
}
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Remove field
///
///
///
protected void lnkRemoveField_Click(object sender, EventArgs e)
{
try
{
oSurface Surface = new oSurface();
if (utils.verifySession("surface"))
{ Surface = (oSurface)Session["surface"]; }
if (Surface.isPublished && !Debugger.IsAttached)
{
pnlResultSurfaceField.Visible = true;
lblResultSurfaceField.Text = "the field cannot be deleted as the App has been published.";
}
else if (sender.GetType() == typeof(LinkButton))
{
//
int recId = int.Parse(((LinkButton)sender).CommandArgument);
//Delete field
if (xData.DeleteTyped("recId", recId.ToString(), typeof(oSurfaceField)))
{
//rebind pages grid
BindSurfaceFields();
pnlResultSurfaceField.Visible = true;
//display successful result
lblResultSurfaceField.Text = "the selected field was deleted successfully.";
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Close Picklist Modal
///
///
///
protected void btnClosePicklist_Click(object sender, EventArgs e)
{
try
{
surfaceField.ReloadControl(false, new oSurfaceField(), true);
upSurfaceFields.Update();
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myPicklistModalHide", "$('#modLoookups').modal('toggle');", true);
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Bind Lookup categories
///
///
///
protected void btnClose_Click(object sender, EventArgs e)
{
try
{
surfaceField.ReloadControl(false, new oSurfaceField(), true);
upSurfaceFields.Update();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Close Categpry
///
///
///
protected void btnCloseCategory_Click(object sender, EventArgs e)
{
try
{
surfaceField.ReloadControl(false, new oSurfaceField(), true);
surfaceLookups1.ReloadControl();
upSurfaceFields.Update();
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myPicklistModal", "$('#modLoookups').modal('toggle');", true);
}
catch (Exception ex)
{
exception.HandleException("surfaceLookups", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Close Grid Options
///
///
///
protected void btnCloseGridOptions_Click(object sender, EventArgs e)
{
try
{
upSurfaceFields.Update();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
#endregion
#region events
///
/// Page Load Event
///
///
///
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
BindSurfaceData();
//BindFieldTypes();
//BindSurfaceDateTypes();
//BindControls();
//BindSequence();
//BindLookupCategories();
//BindSurfaceApps();
//BindContent();
//BindComposite();
//BindActionTypes();
//BindLabelSourceSurface();
//BindAggregationSurface();
//BindAccessLevel();
//BindValidationTypes();
//BindCustomSourceTables();
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Bind Linked Surfaces
///
///
private void BindLinkedSurfaces(int surfaceId)
{
try
{
DataTable surfaceApps = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurface), "isActive,recId", "1,~<>" + surfaceId.ToString(), "surface");
lstLinkedSurfaces.DataSource = surfaceApps;
lstLinkedSurfaces.DataTextField = "surface";
lstLinkedSurfaces.DataValueField = "recId";
lstLinkedSurfaces.DataBind();
foreach (oSurfaceLink surfaceLink in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "surfaceId", surfaceId.ToString(), ""))
{
lstLinkedSurfaces.Items.FindByValue(surfaceLink.linkedSurfaceId.ToString()).Selected = true;
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Preview
///
///
///
protected void lnkPreview_Click(object sender, EventArgs e)
{
oSurface Surface = new oSurface();
try
{
if (utils.verifySession("surface"))
{
Surface = (oSurface)Session["surface"];
Session["surfaceApp"] = Surface;
PlaceHolder plcPreview = (PlaceHolder)Page.Master.FindControl("plcPreview");
UpdatePanel upPreview = (UpdatePanel)Page.Master.FindControl("upPreview");
if (!File.Exists(Server.MapPath(surfacePath + Surface.name + ".ascx.cs")))
{ BuildControl(Surface); }
plcPreview.Controls.Clear();
//UserControl uc = (UserControl)LoadControl(surfacePath + Surface.name + ".ascx");
ISurfaceBase uc = (ISurfaceBase)LoadControl(surfacePath + Surface.name + ".ascx");
uc.SurfaceApp = Surface;
plcPreview.Controls.Add(uc);
upPreview.Update();
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "myModalPreview", "$('#modPreview').modal();", true);
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// New Surface Click
///
///
///
protected void btnNewSurface_Click(object sender, EventArgs e)
{
try
{
//show Surface Specific
TogglePanels("pnlSurfaceApp");
Session["surfaceId"] = 0;
utils.disposeSession("surface");
oSurface Surface = new oSurface();
PopulatePageFormValues(ref Surface);
Session["surfaceFieldId"] = 0;
utils.disposeSession("surfaceField");
BindSurfaceFields();
BindFilterTabs();
BindFilterGroups();
TogglePanelsSurfaceFields("pnlSurfaceFields");
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Edit the Surface page
///
///
///
protected void lnkEdit_Click(object sender, EventArgs e)
{
oSurface _Surface = new oSurface();
ArrayList catList = new ArrayList();
try
{
if (sender.GetType() == typeof(LinkButton))
{
//
int recId = int.Parse(((LinkButton)sender).CommandArgument);
if (recId > 0)
{
Session["surfaceId"] = recId;
//get cat
catList = xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", recId.ToString());
//enumerate list
foreach (oSurface cat in catList)
{
//assign object
_Surface = cat;
//populate page form
PopulatePageFormValues(ref _Surface);
Session["surface"] = _Surface;
break;
}
//show Surface Form
TogglePanels("pnlSurfaceApp");
BindSurfaceFields();
BindFilterTabs();
BindFilterGroups();
TogglePanelsSurfaceFields("pnlSurfaceFields");
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Remove the Surface
///
///
///
///
/// REVISION 001: Add function to delete SurfaceGridOptions before deleting SurfaceGrid, otherwise get FK error when deleting Surface
/// AUTHOR: Charlene van Heerden
/// DATE: 7 December 2015
///
protected void lnkRemove_Click(object sender, EventArgs e)
{
try
{
if (sender.GetType() == typeof(LinkButton))
{
//
int recId = int.Parse(((LinkButton)sender).CommandArgument);
foreach (oSurface surfApp in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", recId.ToString()))
{
//JR 2017-02-22 - it's too risky to delete everything. will just set surface to inactive. so delete needs to have manual developer intervention
surfApp.isActive = false;
xData.UpdateTyped("recId", surfApp.recId.ToString(), typeof(oSurface), surfApp);
////remove date
//if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceFieldData)))
//{
// if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceItem)))
// {
// //remove suface app fields
// if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceField)))
// {
// /* REV 001: Delete SurfaceGridOptions
// * Charlene van Heerden
// * 7 December 2015
// */
// //Delete surface grid options
// if (xData.DeleteTyped("surfaceId", recId.ToString(), typeof(oSurfaceGridOptions)))
// {
// //Delete surface
// if (xData.DeleteTyped("recId", recId.ToString(), typeof(oSurface)))
// {
// //delete the control
// File.Delete(HttpContext.Current.Server.MapPath(surfacePath + surfApp.name + ".ascx"));
// File.Delete(HttpContext.Current.Server.MapPath(surfacePath + surfApp.name + ".ascx.cs"));
// //rebind pages grid
// BindSurfaceData();
// pnlResult.Visible = true;
// //display successful result
// lblResult.Text = "the selected Surface was deleted successfully.";
// }
// }
// }
// }
//}
//rebind pages grid
BindSurfaceData();
pnlResult.Visible = true;
//display successful result
lblResult.Text = "the selected Surface was deactivated successfully.";
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Cancel
///
///
///
protected void btnCancel_Click(object sender, EventArgs e)
{
try
{
Session["surfaceId"] = 0;
utils.disposeSession("surface");
BindSurfaceData();
//show cat list
TogglePanels("pnlSurfaceList");
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Save Click
///
///
///
protected void btnSave_Click(object sender, EventArgs e)
{
oSurface Surface = new oSurface();
try
{
if (utils.verifySession("surface"))//update mode
{
Surface = (oSurface)Session["surface"];
//save form values
SavePageFormValues(ref Surface);
if (xData.UpdateTyped("recId", Surface.recId.ToString(), typeof(oSurface), Surface))
{
SaveLinkedSurfaces(Surface.recId);
BuildControl(Surface);
Session["surfaceId"] = Surface.recId;
Session["surface"] = Surface;
BindSurfaceData();
pnlResult.Visible = true;
lblResult.Text = "your changes were updated successfully.";
}
}
else
{
if (!xData.VerifyExists("recId", typeof(oSurface), "name", utils.stripCharacters(txtSurface.Value).Replace(" ", "")))
{
Surface.isActive = true;
Surface.dateCreated = DateTime.Now;
//save form values
SavePageFormValues(ref Surface);
Surface.recId = xData.SaveTyped("recId", typeof(oSurface), Surface);
if (Surface.recId > 0)
{
SaveLinkedSurfaces(Surface.recId);
BuildControl(Surface);
Session["surfaceId"] = Surface.recId;
Session["surface"] = Surface;
BindSurfaceData();
pnlResult.Visible = true;
lblResult.Text = "your surface app was created successfully.";
}
}
else
{
pnlResult.Visible = true;
lblResult.Text = "A surface app with this name already exists on the system";
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
private void SaveLinkedSurfaces(int recId)
{
try
{
foreach (oSurfaceLink linkitem in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "surfaceId", recId.ToString()))
{
bool found = false;
foreach (ListItem item in lstLinkedSurfaces.Items.GetSelectedItems())
{
if (item.Value.ToString() == linkitem.linkedSurfaceId.ToString())
found = true;
}
if (!found)
xData.DeleteTyped("recId", linkitem.recId.ToString(), typeof(oSurfaceLink));
}
foreach (ListItem item in lstLinkedSurfaces.Items.GetSelectedItems())
{
bool found = false;
foreach (oSurfaceLink linkitem in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "surfaceId,linkedSurfaceId", recId.ToString() + "," + item.Value.ToString()))
{
found = true;
}
if (!found)
{
oSurfaceLink surfaceLink = new oSurfaceLink();
surfaceLink.surfaceId = recId;
surfaceLink.linkedSurfaceId = Convert.ToInt32(item.Value.ToString());
xData.SaveTyped("recId", typeof(oSurfaceLink), surfaceLink);
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Tabls Selections Changed
///
///
///
protected void ddTabs_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindFilterGroups();
BindSurfaceFields();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Groups Selection ch
///
///
///
protected void ddGroups_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindSurfaceFields();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// File Uploaded
///
///
///
protected void radDataUpload_FileUploaded(object sender, FileUploadedEventArgs e)
{
try
{
if (utils.verifySession("surface"))
{
if (File.Exists(Server.MapPath("upload/data/data.xlsx")))
{ File.Delete(Server.MapPath("upload/data/data.xlsx")); }
oSurface surface = (oSurface)Session["surface"];
utils.validateFolder(Server.MapPath("upload/data/"));
radDataUpload.TargetFolder = Server.MapPath("upload/data/");
string newfilename = "data.xlsx";
e.File.SaveAs(radDataUpload.TargetFolder + newfilename, true);
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Upload File
///
///
///
protected void lnkUpload_Click(object sender, EventArgs e)
{
DataTable importData = new DataTable();
try
{
if (utils.verifySession("surface"))
{
oSurface surface = (oSurface)Session["surface"];
if (File.Exists(Server.MapPath("upload/data/data.xlsx")))
{
importData = utils.getDataTableFromExcel(Server.MapPath("upload/data/data.xlsx"));
if (importData.Rows.Count > 0)//we have records
{
if (surfaceHandler.ImportDataToSurface(importData, surface.recId))
{
BuildControl(surface);
pnlResultExport.Visible = true;
lblResultExport.Text = "Data imported sucessfully.";
}
}
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Export Template
///
///
///
protected void lnkExportTemplate_Click(object sender, EventArgs e)
{
try
{
if (utils.verifySession("surface"))
{
oSurface surface = (oSurface)Session["surface"];
DataTable data = xData.GetSurfaceDataAll(surface.recId, false);
data.Clear();
if (File.Exists(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")))
File.Delete(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"));
data.Columns.Remove("itemID");
data.Columns.Remove("surfaceId");
data.Columns.Remove("isActive");
foreach (DataColumn col in data.Columns)
{
col.ColumnName = col.ColumnName.Replace("_", "-:-");
}
//data.Clear();
utils.ExportDataTabletoExcel(data, Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"));
Response.Clear();
//Set the appropriate ContentType.
Response.ContentType = "Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx" + "");
Response.TransmitFile(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"));
Response.Flush();
Response.SuppressContent = true;
ApplicationInstance.CompleteRequest();
pnlResultExport.Visible = true;
lblResultExport.Text = "Template exported sucessfully.";
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// Export Data
///
///
///
protected void lnkExport_Click(object sender, EventArgs e)
{
try
{
if (utils.verifySession("surface"))
{
oSurface surface = (oSurface)Session["surface"];
DataTable data = xData.GetSurfaceDataAll(surface.recId, false);
if (File.Exists(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx")))
File.Delete(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"));
data.Columns.Remove("itemID");
data.Columns.Remove("surfaceId");
data.Columns.Remove("isActive");
foreach (DataColumn col in data.Columns)
{
col.ColumnName = col.ColumnName.Replace("_", "-:-");
}
//data.Clear();
utils.ExportDataTabletoExcel(data, Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"));
Response.Clear();
//Set the appropriate ContentType.
Response.ContentType = "Application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx" + "");
Response.TransmitFile(Server.MapPath(tempPath + utils.stripCharacters(surface.surface).Replace(" ", "") + ".xlsx"));
Response.Flush();
Response.SuppressContent = true;
ApplicationInstance.CompleteRequest();
pnlResultExport.Visible = true;
lblResultExport.Text = "Data exported sucessfully.";
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, Session["user"]);
Response.Redirect("/error", false);
}
}
///
/// check comparable
///
///
///
protected void chkIsComparable_CheckedChanged(object sender, EventArgs e)
{
divColumnCount.Visible = chkIsComparable.Checked;
upSurface.Update();
}
///
/// Checked Changed
///
///
///
protected void chkIsLinkedSurface_CheckedChanged(object sender, EventArgs e)
{
BindLinkedSurfaces(0);
divLinkedSurfaces.Visible = chkIsLinkedSurface.Checked;
}
///
/// Link Filter Click event
///
///
///
protected void lnkLinkFilter_Click(object sender, EventArgs e)
{
try
{
BindLinkedSurfaceFilters();
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "modLinkFilters", "$('#modLinkFilters').modal();", true);
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Bind Linked Filters
///
private void BindLinkedSurfaceFilters()
{
try
{
if (utils.verifySession("surface"))
{
int surfaceId = ((oSurface)Session["surface"]).recId;
DataTable dtLinkedSurfaces = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLink), "surfaceId", surfaceId.ToString());
grdLinkFilters.DataSource = dtLinkedSurfaces;
grdLinkFilters.DataBind();
//upLinkPanel.Update();
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Row DataBound
///
///
///
protected void grdLinkFilters_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView rowView = (DataRowView)e.Row.DataItem;
Label lblId = (Label)e.Row.FindControl("lblId");
lblId.Text = rowView["recId"].ToString();
Label lblLinkedSurface = (Label)e.Row.FindControl("lblLinkedSurface");
lblLinkedSurface.Text = ((oSurface)xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "recId", rowView["linkedSurfaceId"].ToString())[0]).surface;
DropDownList ddlLinkedFilterField = (DropDownList)e.Row.FindControl("ddlLinkedFilterField");
ListBox lstLinkedFilterValue = (ListBox)e.Row.FindControl("lstLinkedFilterValue");
DataTable dtFilterFields = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceField), "surfaceId,surfaceFieldTypeId", rowView["linkedSurfaceId"].ToString() + ",6");
ddlLinkedFilterField.DataSource = dtFilterFields;
ddlLinkedFilterField.DataTextField = "surfaceFieldName";
ddlLinkedFilterField.DataValueField = "recId";
ddlLinkedFilterField.DataBind();
ddlLinkedFilterField.Items.Insert(0, new ListItem("select...", "0"));
foreach (oSurfaceLink link in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "recId", rowView["recId"].ToString()))
{
if (ddlLinkedFilterField.Items.FindByValue(link.filterField.ToString()) != null)
ddlLinkedFilterField.SelectedValue = link.filterField.ToString();
int lookupCatId = 0;
foreach (oSurfaceField sfield in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", link.filterField.ToString()))
{
lookupCatId = sfield.lookupCategory;
}
DataTable dtFilterValues = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLookup), "categoryId,isActive", lookupCatId.ToString() + ",1", "sequence");
lstLinkedFilterValue.DataSource = dtFilterValues;
lstLinkedFilterValue.DataTextField = "display";
lstLinkedFilterValue.DataValueField = "display";
lstLinkedFilterValue.DataBind();
foreach (string fields in link.filterValue.Split(','))
{
if (lstLinkedFilterValue.Items.FindByValue(fields.Replace("'", "")) != null)
{
lstLinkedFilterValue.Items.FindByValue(fields.Replace("'", "")).Selected = true;
}
}
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Selected Index changed
///
///
///
protected void ddlLinkedFilterField_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
DropDownList ddlLinkedFilterField = sender as DropDownList;
string fieldId = ddlLinkedFilterField.SelectedValue;
GridViewRow row = (GridViewRow)ddlLinkedFilterField.Parent.Parent;
ListBox lstLinkedFilterValue = (ListBox)row.FindControl("lstLinkedFilterValue");
int lookupCatId = ((oSurfaceField)xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceField), "recId", fieldId)[0]).lookupCategory;
DataTable dtFilterValues = xData.GetTypedByCriteriaSpecificTable("recId", typeof(oSurfaceLookup), "categoryId,isActive", lookupCatId.ToString() + ",1", "sequence");
lstLinkedFilterValue.DataSource = dtFilterValues;
lstLinkedFilterValue.DataTextField = "display";
lstLinkedFilterValue.DataValueField = "display";
lstLinkedFilterValue.Items.Insert(0, new ListItem("select..."));
lstLinkedFilterValue.DataBind();
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Save Link Filters
///
///
///
protected void btnSaveLinkFilters_Click(object sender, EventArgs e)
{
try
{
foreach (GridViewRow row in grdLinkFilters.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
Label lblId = (Label)row.FindControl("lblId");
Label lblLinkedSurface = (Label)row.FindControl("lblLinkedSurface");
DropDownList ddlLinkedFilterField = (DropDownList)row.FindControl("ddlLinkedFilterField");
ListBox lstLinkedFilterValue = (ListBox)row.FindControl("lstLinkedFilterValue");
foreach (oSurfaceLink linkItem in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurfaceLink), "recId", lblId.Text.ToString()))
{
if (ddlLinkedFilterField.SelectedValue != "0")
{
linkItem.filterField = Convert.ToInt32(ddlLinkedFilterField.SelectedValue);
linkItem.filterValue = "";
foreach (ListItem item in lstLinkedFilterValue.Items.GetSelectedItems())
{
if (item.Selected)
linkItem.filterValue += "'" + item.Value.ToString() + "',";
}
if (linkItem.filterValue.Length > 0)
{
linkItem.filterValue = linkItem.filterValue.Substring(0, linkItem.filterValue.Length - 1);
}
xData.UpdateTyped("recId", linkItem.recId.ToString(), typeof(oSurfaceLink), linkItem);
}
}
}
}
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "modLinkFilters", "$('#modLinkFilters').modal();", true);
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Publish App to custom control
///
///
///
protected void btnPublish_Click(object sender, EventArgs e)
{
try
{
oSurface Surface = new oSurface();
if (utils.verifySession("surface"))//update mode
{
Surface = (oSurface)Session["surface"];
if (surfaceHandler.PublishSurfaceApp(Surface, chkRecreateCode.Checked))
{
Surface.isPublished = true;
chkPublished.Checked = true;
xData.UpdateTyped("recId", Surface.recId.ToString(), typeof(oSurface), Surface);
pnlResult.Visible = true;
lblResult.Text = "Your App was published successfully.";
Session["surface"] = Surface;
}
}
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Re-Create all apps
///
///
///
protected void btnRecreateApps_Click(object sender, EventArgs e)
{
try
{
foreach (oSurface surf in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "isActive", "1"))
{
BuildControl(surf);
}
pnlResult.Visible = true;
lblResult.Text = "All Apps have been re-created";
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
///
/// Republish all apps that are published
///
///
///
protected void btnRepublishApps_Click(object sender, EventArgs e)
{
try
{
foreach (oSurface surf in xData.GetTypedByCriteriaSpecific("recId", typeof(oSurface), "isActive,isPublished", "1,1"))
{
surfaceHandler.PublishSurfaceApp(surf, false);
}
pnlResult.Visible = true;
lblResult.Text = "All Apps have been re-published";
}
catch (Exception ex)
{
exception.HandleException("surface:", MethodBase.GetCurrentMethod().Name, ex, 0);
Response.Redirect("/error", false);
}
}
#endregion
}