public virtual XVar refineOpenFilters(dynamic _param_openFilters) { #region pass-by-value parameters dynamic openFilters = XVar.Clone(_param_openFilters); #endregion dynamic openFiltersRefined = XVar.Array(); openFiltersRefined = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> panelFiled in this.panelSearchFields.GetEnumerator()) { dynamic key = null; key = XVar.Clone(MVCFunctions.array_search((XVar)(panelFiled.Value), (XVar)(openFilters))); if (!XVar.Equals(XVar.Pack(key), XVar.Pack(false))) { MVCFunctions.array_splice((XVar)(openFilters), (XVar)(key), new XVar(1)); } } foreach (KeyValuePair <XVar, dynamic> field in openFilters.GetEnumerator()) { if (XVar.Pack(MVCFunctions.in_array((XVar)(field.Value), (XVar)(this.allSearchFields)))) { openFiltersRefined.InitAndSetArrayItem(field.Value, null); } } return(openFiltersRefined); }
public override XVar fieldClass(dynamic _param_f) { #region pass-by-value parameters dynamic f = XVar.Clone(_param_f); #endregion dynamic ret = null; ret = XVar.Clone(base.fieldClass((XVar)(f))); if (!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(MVCFunctions.GoodFieldName((XVar)(f))), (XVar)(this.hideColumns))), XVar.Pack(false))) { ret = MVCFunctions.Concat(ret, " bs-hidden-column"); } return(ret); }
public virtual XVar getRowCells(dynamic _param_row) { #region pass-by-value parameters dynamic row = XVar.Clone(_param_row); #endregion dynamic ret = XVar.Array(); ret = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> cMap in this.cells.GetEnumerator()) { if (!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(row), (XVar)(cMap.Value["rows"]))), XVar.Pack(false))) { ret.InitAndSetArrayItem(cMap.Key, null); } } return(ret); }
protected virtual XVar haveTheSameSpChReference(dynamic _param_pattern, dynamic _param_value) { #region pass-by-value parameters dynamic pattern = XVar.Clone(_param_pattern); dynamic value = XVar.Clone(_param_value); #endregion dynamic scContainedPattern = XVar.Array(), scFromValue = null; scContainedPattern = XVar.Clone(getSpecialCharsContainingPattern((XVar)(pattern))); scFromValue = XVar.Clone(getSpecialCharsFromString((XVar)(value))); foreach (KeyValuePair <XVar, dynamic> sc in scContainedPattern.GetEnumerator()) { if (!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(sc.Value), (XVar)(scFromValue))), XVar.Pack(false))) { return(true); } } return(false); }
private static XVar findLanguage(dynamic _param_lng) { #region pass-by-value parameters dynamic lng = XVar.Clone(_param_lng); #endregion dynamic languages = XVar.Array(); languages = XVar.Clone(getLanguages()); if (!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(lng), (XVar)(languages))), XVar.Pack(false))) { return(lng); } lng = XVar.Clone(MVCFunctions.strtoupper((XVar)(lng))); foreach (KeyValuePair <XVar, dynamic> l in languages.GetEnumerator()) { if (MVCFunctions.strtoupper((XVar)(l.Value)) == lng) { return(l.Value); } } return(CommonFunctions.mlang_getcurrentlang()); }
public virtual XVar buildControlEnd(dynamic _param_validate, dynamic _param_mode) { #region pass-by-value parameters dynamic validate = XVar.Clone(_param_validate); dynamic mode = XVar.Clone(_param_mode); #endregion if (XVar.Pack(this.pageObject.isBootstrap())) { MVCFunctions.Echo("</span>"); } else { if ((XVar)(MVCFunctions.count(validate["basicValidate"])) && (XVar)(!XVar.Equals(XVar.Pack(MVCFunctions.array_search(new XVar("IsRequired"), (XVar)(validate["basicValidate"]))), XVar.Pack(false)))) { MVCFunctions.Echo(" <font color=\"red\">*</font></span>"); } else { MVCFunctions.Echo("</span>"); } } return(null); }
public virtual XVar buildControl(dynamic _param_value, dynamic _param_mode, dynamic _param_fieldNum, dynamic _param_validate, dynamic _param_additionalCtrlParams, dynamic _param_data) { #region pass-by-value parameters dynamic value = XVar.Clone(_param_value); dynamic mode = XVar.Clone(_param_mode); dynamic fieldNum = XVar.Clone(_param_fieldNum); dynamic validate = XVar.Clone(_param_validate); dynamic additionalCtrlParams = XVar.Clone(_param_additionalCtrlParams); dynamic data = XVar.Clone(_param_data); #endregion dynamic additionalClass = null, arrKeys = XVar.Array(), isHidden = null, j = null; this.searchPanelControl = XVar.Clone(isSearchPanelControl((XVar)(mode), (XVar)(additionalCtrlParams))); this.inputStyle = XVar.Clone(getInputStyle((XVar)(mode))); if (XVar.Pack(fieldNum)) { this.cfield = XVar.Clone(MVCFunctions.Concat("value", fieldNum, "_", this.goodFieldName, "_", this.id)); this.ctype = XVar.Clone(MVCFunctions.Concat("type", fieldNum, "_", this.goodFieldName, "_", this.id)); } this.iquery = XVar.Clone(MVCFunctions.Concat("field=", MVCFunctions.RawUrlEncode((XVar)(this.field)))); arrKeys = XVar.Clone(this.pageObject.pSetEdit.getTableKeys()); j = new XVar(0); for (; j < MVCFunctions.count(arrKeys); j++) { this.keylink = MVCFunctions.Concat(this.keylink, "&key", j + 1, "=", MVCFunctions.RawUrlEncode((XVar)(data[arrKeys[j]]))); } this.iquery = MVCFunctions.Concat(this.iquery, this.keylink); isHidden = XVar.Clone((XVar)(additionalCtrlParams.KeyExists("hidden")) && (XVar)(additionalCtrlParams["hidden"])); additionalClass = new XVar(""); if (XVar.Pack(this.pageObject.isBootstrap())) { if (XVar.Pack(this.pageObject.isPD())) { additionalClass = MVCFunctions.Concat(additionalClass, "bs-ctrlspan "); } else { additionalClass = MVCFunctions.Concat(additionalClass, "bs-ctrlspan rnr-nowrap "); } if (this.format == Constants.EDIT_FORMAT_READONLY) { additionalClass = MVCFunctions.Concat(additionalClass, "form-control-static "); } if ((XVar)(MVCFunctions.count(validate["basicValidate"])) && (XVar)(!XVar.Equals(XVar.Pack(MVCFunctions.array_search(new XVar("IsRequired"), (XVar)(validate["basicValidate"]))), XVar.Pack(false)))) { additionalClass = MVCFunctions.Concat(additionalClass, "bs-inlinerequired"); } } else { additionalClass = MVCFunctions.Concat(additionalClass, "rnr-nowrap "); } MVCFunctions.Echo(MVCFunctions.Concat("<span id=\"edit", this.id, "_", this.goodFieldName, "_", fieldNum, "\" class=\"", additionalClass, "\"", (XVar.Pack(isHidden) ? XVar.Pack(" style=\"display:none\"") : XVar.Pack("")), ">")); return(null); }
public virtual XVar removeRowsColumns(dynamic _param_cellRemoveFlag, dynamic _param_rowsOnly = null) { #region default values if (_param_rowsOnly as Object == null) { _param_rowsOnly = new XVar(false); } #endregion #region pass-by-value parameters dynamic cellRemoveFlag = XVar.Clone(_param_cellRemoveFlag); dynamic rowsOnly = XVar.Clone(_param_rowsOnly); #endregion dynamic canDeleteRow = null, cell = null, i = null, ret = XVar.Array(), row = null, rowCells = XVar.Array(), rowIdx = null, rowsArr = null; ret = XVar.Clone(new XVar("cols", XVar.Array(), "rows", XVar.Array())); if (XVar.Pack(!(XVar)(rowsOnly))) { dynamic canDeleteCol = null, col = null, colCells = XVar.Array(), colIdx = null, colsArr = null; col = new XVar(0); for (; col < this.width; ++(col)) { colCells = XVar.Clone(getColumnCells((XVar)(col))); canDeleteCol = new XVar(true); foreach (KeyValuePair <XVar, dynamic> _cell in colCells.GetEnumerator()) { if ((XVar)(!(XVar)(this.cells[_cell.Value][cellRemoveFlag])) && (XVar)(MVCFunctions.count(this.cells[_cell.Value]["cols"]) == 1)) { canDeleteCol = new XVar(false); break; } } if (XVar.Pack(!(XVar)(canDeleteCol))) { continue; } i = new XVar(0); for (; i < MVCFunctions.count(colCells); ++(i)) { cell = XVar.Clone(colCells[i]); colIdx = XVar.Clone(MVCFunctions.array_search((XVar)(col), (XVar)(this.cells[cell]["cols"]))); MVCFunctions.array_splice((XVar)(this.cells[cell]["cols"]), (XVar)(colIdx), new XVar(1)); colsArr = this.cells[cell]["cols"]; MVCFunctions.array_splice((XVar)(colsArr), (XVar)(colIdx), new XVar(1)); this.cells.InitAndSetArrayItem(colsArr, cell, "cols"); } ret.InitAndSetArrayItem(col, "cols", null); } } row = XVar.Clone(this.height - 1); for (; XVar.Pack(0) <= row; --(row)) { rowCells = XVar.Clone(getRowCells((XVar)(row))); canDeleteRow = new XVar(true); foreach (KeyValuePair <XVar, dynamic> _cell in rowCells.GetEnumerator()) { if ((XVar)(!(XVar)(this.cells[_cell.Value][cellRemoveFlag])) && (XVar)((XVar)(MVCFunctions.count(this.cells[_cell.Value]["rows"]) == 1) || (XVar)(XVar.Equals(XVar.Pack(this.cells[_cell.Value]["rows"][0]), XVar.Pack(row))))) { canDeleteRow = new XVar(false); break; } } if (XVar.Pack(!(XVar)(canDeleteRow))) { continue; } i = new XVar(0); for (; i < MVCFunctions.count(rowCells); ++(i)) { cell = XVar.Clone(rowCells[i]); rowIdx = XVar.Clone(MVCFunctions.array_search((XVar)(row), (XVar)(this.cells[cell]["rows"]))); rowsArr = XVar.Clone(this.cells[cell]["rows"]); MVCFunctions.array_splice((XVar)(rowsArr), (XVar)(rowIdx), new XVar(1)); this.cells.InitAndSetArrayItem(rowsArr, cell, "rows"); } ret.InitAndSetArrayItem(row, "rows", null); } return(ret); }
public virtual XVar fillTablesGrid(dynamic rowInfoArr) { dynamic copylink = null, editlink = null, parentStack = XVar.Array(), recNo = null, rowClass = null; rowClass = new XVar(false); recNo = new XVar(1); editlink = new XVar(""); copylink = new XVar(""); parentStack = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> _tbl in this.menuOrderedTables.GetEnumerator()) { dynamic childrenCount = null, parent = null, row = XVar.Array(), table = null; table = XVar.Clone(_tbl.Value["table"]); parent = XVar.Clone(_tbl.Value["parent"]); if (XVar.Pack(MVCFunctions.strlen((XVar)(table)))) { dynamic caption = null, mask = null, shortTable = null; caption = XVar.Clone(this.tables[table][1]); shortTable = XVar.Clone(this.tables[table][0]); row = XVar.Clone(XVar.Array()); if (caption == table) { row.InitAndSetArrayItem(MVCFunctions.runner_htmlspecialchars((XVar)(table)), "tablename"); } else { row.InitAndSetArrayItem(MVCFunctions.Concat("<span dir='LTR'>", MVCFunctions.runner_htmlspecialchars((XVar)(caption)), " (", MVCFunctions.runner_htmlspecialchars((XVar)(table)), ")</span>"), "tablename"); } row.InitAndSetArrayItem(MVCFunctions.Concat(" id=\"row_", shortTable, "\""), "tablerowattrs"); row.InitAndSetArrayItem(MVCFunctions.Concat("id=\"rowbox", shortTable, "\" data-table=\"", shortTable, "\" data-checked=0"), "tablecheckbox_attrs"); row.InitAndSetArrayItem(MVCFunctions.Concat(" id=\"tblcell", shortTable, "\""), "tbl_cell"); mask = XVar.Clone(this.pageMasks[table]); foreach (KeyValuePair <XVar, dynamic> x in this.permissionNames.GetEnumerator()) { if (XVar.Equals(XVar.Pack(MVCFunctions.strpos((XVar)(mask), (XVar)(x.Key))), XVar.Pack(false))) { continue; } row.InitAndSetArrayItem(true, MVCFunctions.Concat(x.Key, "_group")); row.InitAndSetArrayItem(MVCFunctions.Concat(" id=\"box", x.Key, shortTable, "\" data-checked=0"), MVCFunctions.Concat(x.Key, "_checkbox")); row.InitAndSetArrayItem(MVCFunctions.Concat(" id=\"cell", x.Key, shortTable, "\""), MVCFunctions.Concat(x.Key, "_cell")); } } else { dynamic title = null; title = XVar.Clone(_tbl.Value["title"]); row = XVar.Clone(XVar.Array()); row.InitAndSetArrayItem(MVCFunctions.runner_htmlspecialchars((XVar)(title)), "tablename"); row.InitAndSetArrayItem(" data-checked=-2", "tablecheckbox_attrs"); row.InitAndSetArrayItem(MVCFunctions.Concat(" id=\"grouprow_", _tbl.Key, "\""), "tablerowattrs"); } if (XVar.Pack(!(XVar)(parent as object != null))) { parentStack = XVar.Clone(XVar.Array()); } else { dynamic stackPos = null; stackPos = XVar.Clone(MVCFunctions.array_search((XVar)(parent), (XVar)(parentStack))); if (XVar.Equals(XVar.Pack(stackPos), XVar.Pack(false))) { parentStack.InitAndSetArrayItem(parent, null); } else { parentStack = XVar.Clone(MVCFunctions.array_slice((XVar)(parentStack), new XVar(0), (XVar)(stackPos + 1))); } row["tblrowclass"] = MVCFunctions.Concat(row["tblrowclass"], "rightsindent", MVCFunctions.count(parentStack)); } childrenCount = XVar.Clone(getItemsCount((XVar)(_tbl.Key))); if ((XVar)(_tbl.Value.KeyExists("items")) && (XVar)(childrenCount)) { row["tablename"] = MVCFunctions.Concat(row["tablename"], "<span class='tablecount' dir='LTR'> (", getItemsCount((XVar)(_tbl.Key)), ")</span>"); row["tablerowattrs"] = MVCFunctions.Concat(row["tablerowattrs"], " data-groupid=\"", _tbl.Key, "\""); row.InitAndSetArrayItem(true, "groupControl"); row.InitAndSetArrayItem(" data-state='closed'", "groupControlState"); row.InitAndSetArrayItem(" data-state='closed'", "groupControlClass"); row["tblrowclass"] = MVCFunctions.Concat(row["tblrowclass"], " menugroup"); if (XVar.Pack(!(XVar)(MVCFunctions.strlen((XVar)(table))))) { row["tblrowclass"] = MVCFunctions.Concat(row["tblrowclass"], " menugrouponly"); } } else { if (XVar.Pack(!(XVar)(MVCFunctions.strlen((XVar)(table))))) { continue; } } if (XVar.Pack(parent)) { row["tablerowattrs"] = MVCFunctions.Concat(row["tablerowattrs"], " style='display:none;'"); } rowInfoArr.InitAndSetArrayItem(row, null); } return(null); }
public virtual XVar sortTables() { dynamic addedTables = XVar.Array(), allTables = null, arr = XVar.Array(), groupsMap = XVar.Array(), menu = XVar.Array(); this.sortedTables = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> _tbl in this.tables.GetEnumerator()) { this.sortedTables.InitAndSetArrayItem(new XVar(0, _tbl.Key, 1, _tbl.Value[1]), null); } MVCFunctions.usort((XVar)(this.sortedTables), new XVar("rightsSortFunc")); this.alphaOrderedTables = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> t in this.sortedTables.GetEnumerator()) { this.alphaOrderedTables.InitAndSetArrayItem(t.Value[0], null); } this.menuOrderedTables = XVar.Clone(XVar.Array()); menu = XVar.Clone(getMenuNodes()); addedTables = XVar.Clone(XVar.Array()); groupsMap = XVar.Clone(XVar.Array()); allTables = XVar.Clone(CommonFunctions.GetTablesListWithoutSecurity()); foreach (KeyValuePair <XVar, dynamic> m in menu.GetEnumerator()) { arr = XVar.Clone(XVar.Array()); if ((XVar)(m.Value["pageType"] == "WebReports") || (XVar)(m.Value["type"] == "Separator")) { continue; } if ((XVar)((XVar)(m.Value["table"]) && (XVar)(!(XVar)(addedTables[m.Value["table"]]))) && (XVar)(!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(m.Value["table"]), (XVar)(allTables))), XVar.Pack(false)))) { addedTables.InitAndSetArrayItem(true, m.Value["table"]); arr.InitAndSetArrayItem(m.Value["table"], "table"); } if (XVar.Pack(m.Value["parent"])) { arr.InitAndSetArrayItem(groupsMap[m.Value["parent"]], "parent"); this.menuOrderedTables.InitAndSetArrayItem(MVCFunctions.count(this.menuOrderedTables), arr["parent"], "items", null); } if ((XVar)(true) || (XVar)(m.Value["type"] == "Group")) { groupsMap.InitAndSetArrayItem(MVCFunctions.count(this.menuOrderedTables), m.Value["id"]); arr.InitAndSetArrayItem(m.Value["title"], "title"); arr.InitAndSetArrayItem(XVar.Array(), "items"); arr.InitAndSetArrayItem(true, "collapsed"); } this.menuOrderedTables.InitAndSetArrayItem(arr, null); } if (MVCFunctions.count(addedTables) < MVCFunctions.count(this.alphaOrderedTables)) { dynamic unlistedId = null; unlistedId = XVar.Clone(MVCFunctions.count(this.menuOrderedTables)); arr = XVar.Clone(XVar.Array()); arr.InitAndSetArrayItem(true, "collapsed"); arr.InitAndSetArrayItem("Unlisted tables", "title"); arr.InitAndSetArrayItem(XVar.Array(), "items"); this.menuOrderedTables.InitAndSetArrayItem(arr, null); foreach (KeyValuePair <XVar, dynamic> table in this.alphaOrderedTables.GetEnumerator()) { if (XVar.Pack(!(XVar)(addedTables[table.Value]))) { this.menuOrderedTables.InitAndSetArrayItem(MVCFunctions.count(this.menuOrderedTables), unlistedId, "items", null); this.menuOrderedTables.InitAndSetArrayItem(new XVar("table", table.Value, "parent", unlistedId), null); } } } return(null); }
public XVar lookupsuggest() { try { dynamic LookupSQL = null, LookupSQLTable = null, LookupType = null, contextParams = XVar.Array(), data = XVar.Array(), displayFieldIndex = null, displayFieldName = null, displayedValue = null, field = null, isExistParent = null, likeConditionField = null, likeField = null, likeWheres = XVar.Array(), linkAndDisplaySame = null, linkFieldIndex = null, linkFieldName = null, lookupCipherer = null, lookupConnection = null, lookupField = null, lookupIndices = XVar.Array(), lookupOrderBy = null, lookupPSet = null, lookupQueryObj = null, lookupTable = null, lwDisplayField = null, masterTable = null, multiselect = null, pageType = null, parentCtrlsData = XVar.Array(), qResult = null, respObj = null, searchByLinkField = null, strLookupWhere = null, strUniqueOrderBy = null, table = null, value = null, values = XVar.Array(), var_response = XVar.Array(), viewContainer = null; MVCFunctions.Header("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); table = XVar.Clone(MVCFunctions.postvalue(new XVar("table"))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); GlobalVars.gSettings = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType), (XVar)(MVCFunctions.postvalue(new XVar("page"))))); field = XVar.Clone(MVCFunctions.postvalue(new XVar("searchField"))); if (GlobalVars.gSettings.getEntityType() == Constants.titDASHBOARD) { dynamic dashFields = XVar.Array(); dashFields = XVar.Clone(GlobalVars.gSettings.getDashboardSearchFields()); table = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(dashFields[field][0]["table"]))); GlobalVars.strTableName = XVar.Clone(CommonFunctions.GetTableByShort((XVar)(table))); field = XVar.Clone(MVCFunctions.GoodFieldName((XVar)(dashFields[field][0]["field"]))); if (XVar.Pack(!(XVar)(CommonFunctions.checkTableName((XVar)(table))))) { MVCFunctions.Echo(new XVar(0)); return(MVCFunctions.GetBuferContentAndClearBufer()); } Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", table, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); GlobalVars.gSettings = XVar.Clone(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType))); } masterTable = XVar.Clone(MVCFunctions.postvalue(new XVar("masterTable"))); if ((XVar)(masterTable != XVar.Pack("")) && (XVar)(XSession.Session.KeyExists(MVCFunctions.Concat(masterTable, "_masterRecordData")))) { contextParams.InitAndSetArrayItem(XSession.Session[MVCFunctions.Concat(masterTable, "_masterRecordData")], "masterData"); } contextParams.InitAndSetArrayItem(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("data")))), "data"); RunnerContext.push((XVar)(new RunnerContextItem((XVar)(pageType), (XVar)(contextParams)))); if (GlobalVars.strTableName != "dbo.EMPLEADO") { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } else { dynamic checkResult = null, registerFields = null; checkResult = new XVar(true); registerFields = XVar.Clone((XVar.Pack(pageType == "register") ? XVar.Pack(GlobalVars.gSettings.getPageFields()) : XVar.Pack(XVar.Array()))); if (!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(field), (XVar)(registerFields))), XVar.Pack(false))) { checkResult = new XVar(false); } if (XVar.Pack(checkResult)) { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } } isExistParent = XVar.Clone(MVCFunctions.postvalue(new XVar("isExistParent"))); searchByLinkField = XVar.Clone(MVCFunctions.postvalue(new XVar("searchByLinkField"))); parentCtrlsData = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("parentCtrlsData"))))); value = XVar.Clone(MVCFunctions.postvalue(new XVar("searchFor"))); values = XVar.Clone((XVar.Pack(MVCFunctions.postvalue(new XVar("multiselection"))) ? XVar.Pack(CommonFunctions.splitvalues((XVar)(value))) : XVar.Pack(new XVar(0, value)))); lookupField = new XVar(""); foreach (KeyValuePair <XVar, dynamic> f in GlobalVars.gSettings.getFieldsList().GetEnumerator()) { if ((XVar)(MVCFunctions.GoodFieldName((XVar)(f.Value)) == field) && (XVar)(GlobalVars.gSettings.getEditFormat((XVar)(f.Value)) == Constants.EDIT_FORMAT_LOOKUP_WIZARD)) { LookupType = XVar.Clone(GlobalVars.gSettings.getLookupType((XVar)(f.Value))); if ((XVar)(LookupType == Constants.LT_LOOKUPTABLE) || (XVar)(LookupType == Constants.LT_QUERY)) { lookupField = XVar.Clone(f.Value); break; } } } if (XVar.Pack(!(XVar)(lookupField))) { respObj = XVar.Clone(new XVar("success", false, "data", XVar.Array())); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } lookupTable = XVar.Clone(GlobalVars.gSettings.getLookupTable((XVar)(lookupField))); linkFieldName = XVar.Clone(GlobalVars.gSettings.getLinkField((XVar)(lookupField))); displayFieldName = XVar.Clone(GlobalVars.gSettings.getDisplayField((XVar)(lookupField))); linkAndDisplaySame = XVar.Clone(displayFieldName == linkFieldName); if (LookupType == Constants.LT_QUERY) { lookupConnection = XVar.Clone(GlobalVars.cman.byTable((XVar)(lookupTable))); } else { dynamic connId = null; connId = XVar.Clone(GlobalVars.gSettings.getNotProjectLookupTableConnId((XVar)(lookupField))); lookupConnection = XVar.Clone((XVar.Pack(MVCFunctions.strlen((XVar)(connId))) ? XVar.Pack(GlobalVars.cman.byId((XVar)(connId))) : XVar.Pack(GlobalVars.cman.getDefault()))); } lookupOrderBy = XVar.Clone(GlobalVars.gSettings.getLookupOrderBy((XVar)(lookupField))); if (lookupConnection.dbType == Constants.nDATABASE_MSSQLServer) { strUniqueOrderBy = XVar.Clone(lookupOrderBy); } if (LookupType == Constants.LT_QUERY) { lookupPSet = XVar.Clone(new ProjectSettings((XVar)(lookupTable), (XVar)(pageType))); lookupCipherer = XVar.Clone(new RunnerCipherer((XVar)(lookupTable))); lookupQueryObj = XVar.Clone(lookupPSet.getSQLQuery()); if (XVar.Pack(GlobalVars.gSettings.getCustomDisplay((XVar)(lookupField)))) { lookupQueryObj.AddCustomExpression((XVar)(displayFieldName), (XVar)(lookupPSet), (XVar)(GlobalVars.strTableName), (XVar)(lookupField)); } lookupQueryObj.ReplaceFieldsWithDummies((XVar)(lookupPSet.getBinaryFieldsIndices())); } else { dynamic lwLinkField = null; LookupSQLTable = new XVar("SELECT "); lwLinkField = XVar.Clone(lookupConnection.addFieldWrappers((XVar)(GlobalVars.gSettings.getLinkField((XVar)(lookupField))))); if (XVar.Pack(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) { LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, "DISTINCT "); } LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, GlobalVars.cipherer.GetLookupFieldName((XVar)(lwLinkField), (XVar)(lookupField), new XVar(null), new XVar(true))); if (lookupConnection.dbType == Constants.nDATABASE_MSSQLServer) { if ((XVar)(strUniqueOrderBy) && (XVar)(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) { LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, ",", lookupConnection.addFieldWrappers((XVar)(strUniqueOrderBy))); } } lwDisplayField = XVar.Clone(RunnerPage.sqlFormattedDisplayField((XVar)(lookupField), (XVar)(lookupConnection), (XVar)(GlobalVars.gSettings))); if (XVar.Pack(!(XVar)(linkAndDisplaySame))) { LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, ",", (XVar.Pack(lwDisplayField == lwLinkField) ? XVar.Pack(GlobalVars.cipherer.GetFieldName((XVar)(lwDisplayField), (XVar)(lookupField), new XVar(true))) : XVar.Pack(lwDisplayField))); } LookupSQLTable = MVCFunctions.Concat(LookupSQLTable, " FROM ", lookupConnection.addTableWrappers((XVar)(lookupTable)), " "); } strLookupWhere = XVar.Clone(CommonFunctions.prepareLookupWhere((XVar)(lookupField), (XVar)(GlobalVars.gSettings))); if (LookupType == Constants.LT_QUERY) { dynamic secOpt = null; secOpt = XVar.Clone(lookupPSet.getAdvancedSecurityType()); if (secOpt == Constants.ADVSECURITY_VIEW_OWN) { strLookupWhere = XVar.Clone(CommonFunctions.whereAdd((XVar)(strLookupWhere), (XVar)(CommonFunctions.SecuritySQL(new XVar("Search"), (XVar)(lookupTable))))); } } if (XVar.Pack(strLookupWhere)) { strLookupWhere = XVar.Clone(MVCFunctions.Concat(" (", strLookupWhere, ") AND ")); } if (LookupType == Constants.LT_QUERY) { if (XVar.Pack(GlobalVars.gSettings.getCustomDisplay((XVar)(lookupField)))) { likeField = XVar.Clone((XVar.Pack(searchByLinkField) ? XVar.Pack(linkFieldName) : XVar.Pack(displayFieldName))); } else { likeField = XVar.Clone(RunnerPage._getFieldSQLDecrypt((XVar)((XVar.Pack(searchByLinkField) ? XVar.Pack(linkFieldName) : XVar.Pack(displayFieldName))), (XVar)(lookupConnection), (XVar)(lookupPSet), (XVar)(GlobalVars.cipherer))); } } else { likeField = XVar.Clone(GlobalVars.cipherer.GetFieldName((XVar)(lwDisplayField), (XVar)(lookupField))); } if (XVar.Pack(searchByLinkField)) { likeConditionField = XVar.Clone((XVar.Pack(LookupType == Constants.LT_QUERY) ? XVar.Pack(linkFieldName) : XVar.Pack(lookupField))); } else { likeConditionField = XVar.Clone((XVar.Pack(LookupType == Constants.LT_QUERY) ? XVar.Pack(displayFieldName) : XVar.Pack(lookupField))); } likeWheres = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> fieldValue in values.GetEnumerator()) { if (fieldValue.Value == XVar.Pack("")) { continue; } if (LookupType == Constants.LT_QUERY) { likeWheres.InitAndSetArrayItem(MVCFunctions.Concat(likeField, lookupCipherer.GetLikeClause((XVar)(likeConditionField), (XVar)(fieldValue.Value))), null); } else { likeWheres.InitAndSetArrayItem(MVCFunctions.Concat(likeField, GlobalVars.cipherer.GetLikeClause((XVar)(likeConditionField), (XVar)(fieldValue.Value))), null); } } if (XVar.Pack(!(XVar)(MVCFunctions.count(likeWheres)))) { likeWheres.InitAndSetArrayItem("1=0", null); } strLookupWhere = MVCFunctions.Concat(strLookupWhere, MVCFunctions.implode(new XVar(" OR "), (XVar)(likeWheres))); if ((XVar)(isExistParent) && (XVar)(GlobalVars.gSettings.useCategory((XVar)(lookupField)))) { dynamic parentWhereParts = XVar.Array(); parentWhereParts = XVar.Clone(XVar.Array()); foreach (KeyValuePair <XVar, dynamic> cData in GlobalVars.gSettings.getParentFieldsData((XVar)(lookupField)).GetEnumerator()) { dynamic arLookupWhere = XVar.Array(), category = null, lookupCategory = XVar.Array(); arLookupWhere = XVar.Clone(XVar.Array()); category = XVar.Clone(parentCtrlsData[cData.Value["main"]]); lookupCategory = XVar.Clone((XVar.Pack(category == XVar.Pack("")) ? XVar.Pack(XVar.Array()) : XVar.Pack(CommonFunctions.splitvalues((XVar)(category))))); foreach (KeyValuePair <XVar, dynamic> arLookupCategory in lookupCategory.GetEnumerator()) { dynamic catField = null, cvalue = null; cvalue = XVar.Clone(CommonFunctions.make_db_value((XVar)(cData.Value["main"]), (XVar)(arLookupCategory.Value))); if (XVar.Pack(lookupPSet)) { catField = XVar.Clone(RunnerPage._getFieldSQLDecrypt((XVar)(cData.Value["lookup"]), (XVar)(lookupConnection), (XVar)(lookupPSet), (XVar)(GlobalVars.cipherer))); } else { catField = XVar.Clone(lookupConnection.addFieldWrappers((XVar)(cData.Value["lookup"]))); } arLookupWhere.InitAndSetArrayItem(MVCFunctions.Concat(catField, "=", cvalue), null); } if (XVar.Pack(MVCFunctions.count(arLookupWhere))) { parentWhereParts.InitAndSetArrayItem(MVCFunctions.Concat("(", MVCFunctions.implode(new XVar(" OR "), (XVar)(arLookupWhere)), ")"), null); } } if (MVCFunctions.count(parentWhereParts) == MVCFunctions.count(GlobalVars.gSettings.getParentFieldsData((XVar)(lookupField)))) { strLookupWhere = XVar.Clone(CommonFunctions.whereAdd((XVar)(strLookupWhere), (XVar)(MVCFunctions.Concat("(", MVCFunctions.implode(new XVar(" AND "), (XVar)(parentWhereParts)), ")")))); } else { respObj = XVar.Clone(new XVar("success", false, "data", XVar.Array())); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } } if (XVar.Pack(MVCFunctions.strlen((XVar)(lookupOrderBy)))) { lookupOrderBy = XVar.Clone(lookupConnection.addFieldWrappers((XVar)(lookupOrderBy))); if (XVar.Pack(GlobalVars.gSettings.isLookupDesc((XVar)(lookupField)))) { lookupOrderBy = MVCFunctions.Concat(lookupOrderBy, " DESC"); } } if (LookupType == Constants.LT_QUERY) { LookupSQL = XVar.Clone(lookupQueryObj.buildSQL_default((XVar)(strLookupWhere))); if (XVar.Pack(MVCFunctions.strlen((XVar)(lookupOrderBy)))) { LookupSQL = MVCFunctions.Concat(LookupSQL, " ORDER BY ", lookupOrderBy); } else { LookupSQL = MVCFunctions.Concat(LookupSQL, lookupQueryObj.OrderByToSql()); } } else { LookupSQL = XVar.Clone(MVCFunctions.Concat(LookupSQLTable, " where ", strLookupWhere)); if ((XVar)(!(XVar)(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) || (XVar)(Constants.nDATABASE_Access != lookupConnection.dbType)) { if (XVar.Pack(lookupOrderBy)) { LookupSQL = MVCFunctions.Concat(LookupSQL, " ORDER BY ", lookupOrderBy); } } } lookupIndices = XVar.Clone(CommonFunctions.GetLookupFieldsIndexes((XVar)(GlobalVars.gSettings), (XVar)(lookupField))); linkFieldIndex = XVar.Clone(lookupIndices["linkFieldIndex"]); displayFieldIndex = XVar.Clone(lookupIndices["displayFieldIndex"]); viewContainer = XVar.Clone(new ViewControlsContainer((XVar)(GlobalVars.gSettings), new XVar(Constants.PAGE_LIST), new XVar(null))); var_response = XVar.Clone(XVar.Array()); qResult = XVar.Clone(lookupConnection.query((XVar)(LookupSQL))); multiselect = XVar.Clone(GlobalVars.gSettings.multiSelect((XVar)(lookupField))); while (XVar.Pack(data = XVar.Clone(qResult.fetchNumeric()))) { if ((XVar)(LookupType == Constants.LT_QUERY) && (XVar)(GlobalVars.gSettings.isLookupUnique((XVar)(lookupField)))) { dynamic uniqueArray = XVar.Array(); if (XVar.Pack(!(XVar)(uniqueArray as object != null))) { uniqueArray = XVar.Clone(XVar.Array()); } if (XVar.Pack(MVCFunctions.in_array((XVar)(data[displayFieldIndex]), (XVar)(uniqueArray)))) { continue; } uniqueArray.InitAndSetArrayItem(data[displayFieldIndex], null); } data.InitAndSetArrayItem(GlobalVars.cipherer.DecryptField((XVar)(lookupField), (XVar)(data[linkFieldIndex])), linkFieldIndex); if (LookupType == Constants.LT_QUERY) { data.InitAndSetArrayItem(GlobalVars.cipherer.DecryptField((XVar)(displayFieldName), (XVar)(data[displayFieldIndex])), displayFieldIndex); } displayedValue = XVar.Clone(data[displayFieldIndex]); if (XVar.Pack(MVCFunctions.in_array((XVar)(GlobalVars.gSettings.getViewFormat((XVar)(lookupField))), (XVar)(new XVar(0, Constants.FORMAT_DATE_SHORT, 1, Constants.FORMAT_DATE_LONG, 2, Constants.FORMAT_DATE_TIME))))) { dynamic ctrlData = XVar.Array(); ctrlData = XVar.Clone(XVar.Array()); ctrlData.InitAndSetArrayItem(data[linkFieldIndex], lookupField); displayedValue = XVar.Clone(viewContainer.getControl((XVar)(lookupField)).getTextValue((XVar)(ctrlData))); } var_response.InitAndSetArrayItem(data[linkFieldIndex], null); var_response.InitAndSetArrayItem(displayedValue, null); } respObj = XVar.Clone(new XVar("success", true, "data", MVCFunctions.array_slice((XVar)(var_response), new XVar(0), new XVar(40)))); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }
public XVar autocomplete() { try { dynamic contextParams = XVar.Array(), control = null, editControls = null, field = null, isExistParent = null, masterTable = null, mode = null, pageName = null, pageType = null, parentCtrlsData = null, respObj = null, shortTableName = null; ProjectSettings pSet; MVCFunctions.Header("Expires", "Thu, 01 Jan 1970 00:00:01 GMT"); shortTableName = XVar.Clone(MVCFunctions.postvalue(new XVar("shortTName"))); Assembly.GetExecutingAssembly().GetType(MVCFunctions.Concat("runnerDotNet.", MVCFunctions.Concat("", shortTableName, ""), "_Variables")).InvokeMember("Apply", BindingFlags.InvokeMethod, null, null, null); field = XVar.Clone(MVCFunctions.postvalue(new XVar("field"))); pageType = XVar.Clone(MVCFunctions.postvalue(new XVar("pageType"))); pageName = XVar.Clone(MVCFunctions.postvalue(new XVar("page"))); GlobalVars.cipherer = XVar.Clone(new RunnerCipherer((XVar)(GlobalVars.strTableName))); pSet = XVar.UnPackProjectSettings(new ProjectSettings((XVar)(GlobalVars.strTableName), (XVar)(pageType), (XVar)(pageName))); if (GlobalVars.strTableName != "dbo.EMPLEADO") { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } else { dynamic checkField = null, registerFields = null; checkField = new XVar(true); registerFields = XVar.Clone((XVar.Pack(pageType == "register") ? XVar.Pack(pSet.getPageFields()) : XVar.Pack(XVar.Array()))); if (!XVar.Equals(XVar.Pack(MVCFunctions.array_search((XVar)(field), (XVar)(registerFields))), XVar.Pack(false))) { checkField = new XVar(false); } if (XVar.Pack(checkField)) { if (XVar.Pack(!(XVar)(CommonFunctions.isLogged()))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } if ((XVar)((XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Edit")))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Add"))))) && (XVar)(!(XVar)(CommonFunctions.CheckSecurity((XVar)(XSession.Session[MVCFunctions.Concat("_", GlobalVars.strTableName, "_OwnerID")]), new XVar("Search"))))) { return(MVCFunctions.GetBuferContentAndClearBufer()); } } } editControls = XVar.Clone(new EditControlsContainer(new XVar(null), (XVar)(pSet), (XVar)(pageType), (XVar)(GlobalVars.cipherer))); control = XVar.Clone(editControls.getControl((XVar)(field))); contextParams = XVar.Clone(XVar.Array()); contextParams.InitAndSetArrayItem(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("data")))), "data"); masterTable = XVar.Clone(MVCFunctions.postvalue(new XVar("masterTable"))); if ((XVar)(masterTable != XVar.Pack("")) && (XVar)(XSession.Session.KeyExists(MVCFunctions.Concat(masterTable, "_masterRecordData")))) { dynamic masterControlsData = XVar.Array(), masterData = XVar.Array(); masterData = XVar.Clone(XSession.Session[MVCFunctions.Concat(masterTable, "_masterRecordData")]); masterControlsData = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("masterData"))))); foreach (KeyValuePair <XVar, dynamic> mValue in masterControlsData.GetEnumerator()) { masterData.InitAndSetArrayItem(mValue.Value, mValue.Key); } contextParams.InitAndSetArrayItem(masterData, "masterData"); } RunnerContext.push((XVar)(new RunnerContextItem(new XVar(Constants.CONTEXT_ROW), (XVar)(contextParams)))); parentCtrlsData = XVar.Clone(MVCFunctions.my_json_decode((XVar)(MVCFunctions.postvalue(new XVar("parentCtrlsData"))))); isExistParent = XVar.Clone(MVCFunctions.postvalue(new XVar("isExistParent"))); mode = XVar.Clone(MVCFunctions.intval((XVar)(MVCFunctions.postvalue(new XVar("mode"))))); respObj = XVar.Clone(new XVar("success", true, "data", control.getLookupContentToReload((XVar)(XVar.Equals(XVar.Pack(isExistParent), XVar.Pack("1"))), (XVar)(mode), (XVar)(parentCtrlsData)))); MVCFunctions.Echo(CommonFunctions.printJSON((XVar)(respObj))); RunnerContext.pop(); MVCFunctions.Echo(new XVar("")); return(MVCFunctions.GetBuferContentAndClearBufer()); } catch (RunnerRedirectException ex) { return(Redirect(ex.Message)); } }