void loadFilterData() { try { object[] vals_ = stateHelper.filterLoad(FilterCols); if (filterWrap != null) { filterWrap.Selected = vals_; } //if (vals_ == null || vals_.Length == 0) // return; //var tree_ = getFilter(); //var node_ = vals_.Length > 0 ? tree_.RootNode.Search(vals_[0].ToString()) : null; //if (node_ != null && vals_.Length > 1) // node_ = node_.Search(vals_[1].ToString()); //if (node_ != null) // tree_.SelectedNode = node_; //setFilter(node_); } catch (Exception exc) { ToolMobile.setException(exc); } }
internal void callHandler(bool pOk) { try { if (pOk) { if (handlerOk != null) { handlerOk.Invoke(this, EventArgs.Empty); } } else { if (handlerCancel != null) { handlerCancel.Invoke(this, EventArgs.Empty); } } } catch (Exception exc) { ToolMobile.setException(exc); } finally { handlerOk = handlerCancel = null; } }
public virtual void refresh(object obj) { try { getGrid().beginDataLoad(); // // DataTable table = (DataTable)getGrid().DataSource; if (extender != null && environment != null) { extender.refresh(); // convertData(table); // // _fillSpeColumns(null); // getGrid().refreshBind(); //sql columns extender.searchRecord(obj); } } catch (Exception exc) { ToolMobile.setException(exc); } finally { getGrid().endDataLoad(); } }
protected bool startSave() { try { FinishDataEditing(); if (_checkLevel) { DataRow row = ToolRow.getFirstRealRow(_tableSchema); double amount = (double)ToolCell.isNull(row[TableDUMMY.AMOUNT], 0.0); double onhand = (double)ToolCell.isNull(_curMatRecord[TableDUMMY.ONHAND], 0.0); if ((amount - onhand) > ConstValues.minPositive) { ToolMsg.show(this, MessageCollection.T_MSG_INVALID_QUANTITY, null); return(false); } } DataRow _rowActiveUnit = this.BindingContext.getBindingItemRecord(cUnit); // if (_rowActiveUnit != null) { switch (handler.converCol(handler.column)) { case TableDUMMY.AMOUNT: ToolCell.set(handler.row, TableSTLINE.AMOUNT, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.AMOUNT]); // if (_rowActiveUnit != null) { ToolCell.set(handler.row, TableSTLINE.UNIT, _rowActiveUnit[TableDUMMY.UNIT]); ToolCell.set(handler.row, TableSTLINE.UNITREF, _rowActiveUnit[TableDUMMY.UNITREF]); ToolCell.set(handler.row, TableSTLINE.UINFO1, _rowActiveUnit[TableDUMMY.UNITCF01]); ToolCell.set(handler.row, TableSTLINE.UINFO2, _rowActiveUnit[TableDUMMY.UNITCF02]); } // return(true); case TableDUMMY.PRICE: ToolCell.set(handler.row, TableSTLINE.PRICE, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.PRICE]); return(true); case TableDUMMY.DISCPER: ToolCell.set(handler.row, TableSTLINE.DISCPER, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.DISCPER]); return(true); case TableDUMMY.TOTAL: ToolCell.set(handler.row, TableSTLINE.TOTAL, ToolRow.getFirstRealRow(_tableSchema)[TableDUMMY.TOTAL]); return(true); } } } catch (Exception exc) { ToolMobile.setException(exc); } return(false); }
protected override void OnCreate(Bundle savedInstanceState) { try { if (Creating != null) { Creating.Invoke(this, EventArgs.Empty); } //ToolMobile.log("set form [" + this.GetType().FullName + "] layout"); base.OnCreate(savedInstanceState); // setEnvironment(ToolMobile.getEnvironment()); if (designId >= 0) { SetContentView(designId == 0 ? Resource.Layout.form : designId); } if (Created != null) { Created.Invoke(this, EventArgs.Empty); } this.Window.SetSoftInputMode(SoftInput.StateAlwaysHidden); // (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); } catch (Exception exc) { ToolMobile.setException(exc); } }
public static void read(object pObj, string pName, IEnvironment pEnv, ISettings pSettings) { if (pObj == null) { return; } if (string.IsNullOrEmpty(pName)) { return; } try { // ToolMobile.log("object read settings [" + pName + "]"); pSettings.enumarateFirst(pName); if (pSettings.isEnumerValid()) { foreach (string property in pSettings.getAllAttrEnumer()) { // ToolMobile.log("object read settings property [" + pName + "]/[" + property + "]"); string propertyObj = property.TrimEnd('_'); PropertyInfo pinf = pObj.GetType().GetProperty(propertyObj); if (pinf != null) { object value = pinf.GetValue(pObj, null); if (pinf.PropertyType.IsEnum) { value = Convert.ToInt32(value); } value = pSettings.getAttrEnumer(property, (pinf.PropertyType.IsEnum ? typeof(int) : pinf.PropertyType), value); pinf.SetValue(pObj, value, null); } else { FieldInfo finf = pObj.GetType().GetField(propertyObj); if (finf != null) { object value = finf.GetValue(pObj); if (finf.FieldType.IsEnum) { value = Convert.ToInt32(value); } value = pSettings.getAttrEnumer(property, (finf.FieldType.IsEnum ? typeof(int) : finf.FieldType), value); finf.SetValue(pObj, value); } } } } } catch (Exception exc) { ToolMobile.setException(exc); throw new MyExceptionError(MessageCollection.T_MSG_ERROR_RUNTIME, new object[] { pName }, exc); } }
bool doQuickFilter() { if (_doQuickFilter) { return(false); } try { _doQuickFilter = true; var ctrl_ = getQuiqFilterText(); if (ctrl_ == null) { return(false); } var f = ctrl_.Text.Trim(); var c = getQuiqFilterColumn(f); if (c == null) { return(false); } var hasFilter_ = !string.IsNullOrEmpty(f); getFilterGridPanel().Visible = !hasFilter_; refresh(); if (cleanQuickFilterAfterSearch(f)) { doQuickFilterClean(); } return(true); } catch (Exception exc) { ToolMobile.setException(exc); } finally { _doQuickFilter = false; } return(false); }
public void renderTo(object pTarget) { try { if (renderingInfo == null || renderingData == null) { return; } { if (pTarget == null || (pTarget as string == "printer")) { outToPrinter(); return; } } { //var x = pTarget as TextView; //if (x != null) //{ // outToView(x); // return; //} var x = pTarget as ViewGroup; if (x != null) { outToView(x); return; } } { if ((pTarget as string == "share")) { share(); return; } } } catch (Exception exc) { ToolMobile.setException(exc); } }
void loadRecordId() { try { object val = stateHelper.recordIdLoad(); if (extender != null) { extender.searchRecord(val); } } catch (Exception exc) { ToolMobile.setException(exc); } }
protected virtual void returnData(DataRow row) { try { if (row != null && reference != null) { if (reference.addData(row)) { Close(); } } } catch (Exception exc) { ToolMobile.setException(exc); } }
void doQuickFilterClean() { try { var ctrl_ = getQuiqFilterText(); if (ctrl_ == null) { return; } var f = ctrl_.Text = string.Empty; } catch (Exception exc) { ToolMobile.setException(exc); } }
void doCmd(int pCmd) { try { switch (pCmd) { case 1: { renderTo("share"); } break; } } catch (Exception exc) { ToolMobile.setException(exc); } }
void cBtnUnit_Click(object sender, EventArgs e) { try { List <string> list = new List <string>(); foreach (DataRow r in _tableSchema.Rows) { list.Add(r[TableDUMMY.UNIT].ToString()); } ToolMsg.askList(this, list.ToArray(), delegate(object s, DialogClickEventArgs a) { this.BindingContext.setBindingItemPosition(cUnit, a.Which); }); } catch (Exception exc) { ToolMobile.setException(exc); } }
void _tableSchema_ColumnChanged(object sender, DataColumnChangeEventArgs e) { try { if (e.Row.RowState != DataRowState.Detached) { if (!_blockPoint.isBlocked()) { double curCf = (double)e.Row[TableDUMMY.CONVFACT]; double curAmount = (double)e.Row[TableDUMMY.AMOUNT]; double curPrice = (double)e.Row[TableDUMMY.PRICE]; double curTot = (double)e.Row[TableDUMMY.TOTAL]; double curDiscper = (double)e.Row[TableDUMMY.DISCPER]; switch (e.Column.ColumnName) { case TableDUMMY.AMOUNT: refreshVal(curAmount, curCf, TableDUMMY.AMOUNT, false); break; case TableDUMMY.PRICE: refreshVal(curPrice, curCf, TableDUMMY.PRICE, true); break; case TableDUMMY.TOTAL: refreshVal(curTot, TableDUMMY.TOTAL); break; case TableDUMMY.DISCPER: refreshVal(curDiscper, TableDUMMY.DISCPER); break; } } } } catch (Exception exc) { ToolMobile.setException(exc); } }
void doCmd(ContexMenuCmd pCmd) { try { switch (pCmd) { case ContexMenuCmd.changeAgent: CurrentVersion.ENV.initNs((o, e) => { ToolMobile.restartEnvironment(); this.Recreate(); }); break; case ContexMenuCmd.export: environment.toActivity("tool.data.export", null).done(); break; case ContexMenuCmd.import: environment.toActivity("tool.data.import", null).done(); break; case ContexMenuCmd.test: { StartActivity(typeof(ActivityTest)); } break; } } catch (Exception exc) { ToolMobile.setException(exc); } }
public virtual void loadFilterStruct() { try { getGrid().beginDataLoad(); if (!HasFilter) { getFilterTreePanel().Visible = false; getFilterGridPanel().Visible = false; } else { getFilterTreePanel().Visible = false; List <MobDataGrid> list = new List <MobDataGrid>(); { if (FilterCols.Length > 0) { list.Add(getFilterGrid1()); } if (FilterCols.Length > 1) { list.Add(getFilterGrid2()); } else { getFilterGrid2().Visible = false; } } filterWrap = new ImplFilterWrapGrid(list.ToArray()); //filterWrap = new ImplFilterWrapTree(getFilterTree()); filterWrap.FilterChanged += filterWrap_FilterChanged; //getFilter().NodeClick += MobDataReferenceGridFormBase_NodeClick; string stateNameFilterTree = globalStoreName() + "/filtertree"; object[][] tree_ = environment.getStateData(stateNameFilterTree) as object[][]; if (tree_ == null) { string name_ = getDsName(); ITableDescriptor td_ = environment.getDbDescriptor().getTable(name_); if (td_ == null) { throw new MyExceptionError("Cant find table [" + name_ + "] descriptor"); } string tabFullName_ = td_.getNameFull(); string sql_ = string.Format("SELECT DISTINCT {0} FROM {1}", ToolString.joinList(FilterCols), tabFullName_); DataTable tab_ = SqlExecute.execute(environment, sql_, null); tree_ = ToolTable.getGroups(tab_, FilterCols); } filterWrap.fill(tree_); // getFilter().fillTree(tree_); environment.setStateData(stateNameFilterTree, tree_); } } catch (Exception exc) { ToolMobile.setException(exc); } finally { getGrid().endDataLoad(); } }
void doneAsync() { lock (environment) { ISettings oldSysSettings = environment.getSysSettings(); try { // bool localDebugImport = false; #if DEBUG localDebugImport = false; #endif log.set(MessageCollection.T_MSG_OPERATION_STARTING); // ToolMobile.setRuntimeMsg("Data import starting"); if (!localDebugImport) { checkDataSource(); } // string fileWorkDir = Path.Combine(ToolMobile.curDir(), "data"); ToolMobile.createDir(fileWorkDir); string fileInputZip = Path.Combine(fileWorkDir, "fromava.zip"); string fileInputXml = Path.Combine(fileWorkDir, "fromava.xml"); // bool state = false; //Source if (localDebugImport)//CurrentVersion.ENV.isLocalExim() { //!!// } else { { // log.set(MessageCollection.T_MSG_DATA_RECEIVING); // AgentData ad = new AgentData(environment); ServerResult sr; ad.chackOperationResult(sr = ad.resiveData()); byte[] data = sr.data; // log.set(MessageCollection.T_MSG_DATA_WRITING); // ToolMobile.writeFileData(fileInputZip, data); ToolZip.decompress(fileInputZip, Path.GetDirectoryName(fileInputZip)); } } //Get log.set(MessageCollection.T_MSG_DATA_READING); // XmlDocument doc = new XmlDocument(); doc.Load(fileInputXml); // if (isSameData(doc, oldSysSettings)) { throw new Exception(MessageCollection.T_MSG_DATA_OLD); } // var commited = false; try { environment.beginBatch(); // #region delete firm prm log.set(MessageCollection.T_MSG_DATA_DELETING); // { string[] arrTables = new string[] { TableFIRMPARAMS.TABLE_FULL_NAME }; string[] arrDesc = new string[] { environment.translate(WordCollection.T_ADDITIONAL) }; deleteTables(arrTables, arrDesc); } // // #endregion // #region import firm prm // log.set(MessageCollection.T_MSG_DATA_IMPORT); // { AdapterUserRecords[] arrAdapters = new AdapterUserRecords[] { new AdapterUserFirmParams(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetFirmParams(environment))) }; string[] arrDesc = new string[] { environment.translate(WordCollection.T_ADDITIONAL) }; importRecords(doc, arrAdapters, arrDesc); } #endregion // #region sys settings environment.setSysSettings(getSysSettings()); //environment.getSysSettings().set(SettingsSysMob.MOB_SYS_LAST_IMPORT, DateTime.Now); #endregion // #region delete rec log.set(MessageCollection.T_MSG_DATA_DELETING); // { string[] arrTables = new string[] { TableCLCARD.TABLE_FULL_NAME, TableITEMS.TABLE_FULL_NAME, TableWHOUSE.TABLE_FULL_NAME, TableINFOFIRM.TABLE_FULL_NAME, TableINFOPERIOD.TABLE_FULL_NAME, TableINFODOCSAVE.TABLE_FULL_NAME }; string[] arrDesc = new string[] { environment.translate(WordCollection.T_CLIENT), environment.translate(WordCollection.T_MATERIAL), environment.translate(WordCollection.T_WAREHOUSE), environment.translate(WordCollection.T_INFO), environment.translate(WordCollection.T_INFO), environment.translate(WordCollection.T_INFO) }; deleteTables(arrTables, arrDesc); } // // #endregion // #region docs log.set(MessageCollection.T_MSG_DOCS_DELETING); // DateTime limDate = environment.getSysSettings().getDateTime(SettingsSysMob.MOB_SYS_CMD_DELETE_DOCS_BEFORE, new DateTime(DateTime.Now.Year, 1, 1)); { string[][] arrTablesGroup = new string[][] { new string[] { TableINVOICE.TABLE_FULL_NAME, TableSTLINE.TABLE_LONG }, new string[] { TableORFICHE.TABLE_FULL_NAME, TableORFLINE.TABLE_LONG }, new string[] { TableKSLINES.TABLE_FULL_NAME } }; string[] arrDesc = new string[] { environment.translate(WordCollection.T_DOC_STOCK_TRANS), environment.translate(WordCollection.T_DOC_STOCK_ORDERS), environment.translate(WordCollection.T_DOC_FINANCE) }; deleteDocTables(arrTablesGroup, arrDesc, limDate); } #endregion // #region import // log.set(MessageCollection.T_MSG_DATA_IMPORT); // { AdapterUserRecords[] arrAdapters = new AdapterUserRecords[] { new AdapterUserClient(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetClient(environment))), new AdapterUserMaterial(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetMaterial(environment))), new AdapterUserWarehouse(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetWarehouse(environment))), new AdapterUserInfoFirm(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetInfoFirm(environment))), new AdapterUserInfoPeriod(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetInfoPeriod(environment))), new AdapterUserInfoDocSave(environment, new ImplAdapterDataSetStub(environment, new AdapterDataSetInfoDocSave(environment))) }; string[] arrDesc = new string[] { environment.translate(WordCollection.T_CLIENT), environment.translate(WordCollection.T_MATERIAL), environment.translate(WordCollection.T_WAREHOUSE), environment.translate(WordCollection.T_INFO), environment.translate(WordCollection.T_INFO), environment.translate(WordCollection.T_INFO) }; importRecords(doc, arrAdapters, arrDesc); } #endregion //clear // environment.clearStateData(); // //ToolMobile.setRuntimeMsg("Data importded, commit started"); environment.commitBatch(); // state = true; commited = true; // ToolMobile.setRuntimeMsg("Data importded, commited"); #region files { try { var files = doc.SelectSingleNode("DATA/ITEM[@ei_code='ADP_FILES']"); if (files != null) { foreach (var file in files) { var el = file as XmlElement; if (el != null) { var dir = ToolXml.getAttribValue(el, "dir", null); var name = ToolXml.getAttribValue(el, "name", null); var value_ = ToolXml.getAttribValue(el, "value", null); if (dir != null && name != null && value_ != null) { if (Path.IsPathRooted(dir)) { log.error(WordCollection.T_FILE + ": Path rooted: " + dir); } else { if (!ToolMobile.existsDir(dir)) { ToolMobile.createDir(dir); } var path = Path.Combine(dir, name); log.set(WordCollection.T_FILE + ": " + path); var data = Convert.FromBase64String(value_); ToolMobile.writeFileData(path, data); } } } } } } catch (Exception exc) { ToolMobile.setExceptionInner(exc); log.error("Files import error"); ToolMobile.setException(exc); } } #endregion } catch (Exception exc) { try { ToolMobile.setExceptionInner(exc); } catch { } try { if (!commited) { ToolMobile.setRuntimeMsg("Data import error, rollback started"); environment.rollbackBatch(); ToolMobile.setRuntimeMsg("Data import error, rollback ended"); } } catch { } environment.setSysSettings(oldSysSettings); throw new Exception(exc.Message, exc); } //if (commited) //{ // var dir = "cache"; // if (ToolMobile.existsDir(dir)) // ToolMobile.deleteDir(dir); //} } catch (Exception exc) { ToolMobile.setExceptionInner(exc); var err = ToolException.unwrap(exc); ToolMobile.setRuntimeMsg(err); ToolMobile.getContextLast().RunOnUiThread(() => { try { Android.Widget.Toast.MakeText(Android.App.Application.Context, err, Android.Widget.ToastLength.Long).Show(); } catch { } }); // ActivityExt.errMessageOnResume = err; log.error(ToolException.unwrap(exc)); environment.getExceptionHandler().setException(exc); } finally { log.set(MessageCollection.T_MSG_OPERATION_FINISHING); Thread.Sleep(1000); log.hide(); } } }