public object done() { try { _report.refreshSource(); util.renderingData = _report.getResult() as string; if (util.renderingData == null) { util.renderingData = string.Empty; } if (util.renderingInfo.isDirect) { util.renderTo(null); } else { // ToolMobile.startForm(typeof(MobFormShowData), new string[] { ConstCmdLine.value }, new string[] { _data }); ToolMobile.startForm(typeof(MobFormShowData), new string[] { MobFormShowData.PRM_RENDER }, new Java.IO.ISerializable[] { util }); } } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } return(null); }
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { try { Node group_ = _tree.RootNode.getChildAt(groupPosition); if (group_ != null) { Node child_ = group_.getChildAt(childPosition); if (child_ != null) { var item = child_.Text; if (convertView == null) { convertView = getView(Resource.Layout.MobTreeViewChild); } var textBox = convertView.FindViewById <TextView>(Resource.Id.cTreeNodeText); textBox.SetText(item, TextView.BufferType.Normal); //textBox.SetTypeface(Android.Graphics.Typeface.Monospace, Android.Graphics.TypefaceStyle.Bold); return(convertView); //MobLabel l = convertView as MobLabel; //if (l == null) // l = new MobLabel(_context); //l.Text = item; //return l; } } } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } return(null); }
static void initLang() { if (cache != null) { return; } try { var cache_tmp = new Dictionary <string, SortedDictionary <string, string> >(); var xmlDoc = new XmlDocument(); var lang_xml = ToolMobile.getFsOrResourceText("config/sys", "lang.xml"); xmlDoc.LoadXml( lang_xml ); var root = xmlDoc["settings"]; foreach (var lang in langs) { var langCache = new SortedDictionary <string, string>(); foreach (var node in root.ChildNodes) { var el = node as XmlElement; if (el != null) { var from = el.Name; var to = ToolXml.getAttribValue(el, lang, el.Name); langCache[from] = to; } } cache_tmp[lang] = langCache; } cache = cache_tmp; } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } }
public static void startEnv() { IEnvironment environment = null; try { environment = new MobEnvironment(); ToolMobile.setEnvironment(environment); environment.setFileSystem(new ImplFileSystem()); // environment.setLangSettings(new SettingsFromFileExt(Path.Combine(SettingsFileName.DIRECTORY_CONFIG, SettingsFileName.DIRECTORY_SYS), SettingsFileName.NAME_LANG, environment)); environment.setAppSettings(new SettingsFromFileExt(Path.Combine(SettingsFileName.DIRECTORY_CONFIG, SettingsFileName.DIRECTORY_SYS), SettingsFileName.NAME_APP, environment)); // environment.setLoginSettings(new SettingsFromFileExt(Path.Combine(SettingsFileName.DIRECTORY_CONFIG, SettingsFileName.DIRECTORY_SYS), SettingsFileName.NAME_LOGIN, environment)); // environment.setDsSettings(new SettingsFromFileExt(Path.Combine(SettingsFileName.DIRECTORY_CONFIG, SettingsFileName.DIRECTORY_SYS), SettingsFileName.NAME_DS, environment)); environment.setSettingsStore(new SettingsStoreFromDirectory(Path.Combine(SettingsFileName.DIRECTORY_CONFIG, SettingsFileName.DIRECTORY_UI), environment)); IUserImage list = new ImplUserImage(); environment.setImages(list); ToolMobile.log("environment init starting"); environment.init(); // IPagedSource psSysSet = new PagedSourceFirmParams(environment); ToolMobile.log("set firm parameters"); environment.setSysSettings(new SettingsFromTable(psSysSet.getAll(), TableFIRMPARAMS.CODE, TableFIRMPARAMS.VALUE)); ToolMobile.log("environment started"); } catch (Exception exc) { ToolMobile.log("environment start error: " + exc.Message); ToolMobile.setExceptionInner(exc); // environment.getExceptionHandler().setException(exc, delegate() { Close(); }); ToolMobile.setEnvironment(null); } }
public static void disposeControl(object pControl) { if (pControl == null) { return; } try { //add, destructed orlinks will be lost object[] arr_ = ToolControl.destruct(pControl); foreach (object o_ in arr_) { ToolDispose.dispose(o_); } } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } }
//protected virtual int getPort(bool pForSending) //{ // int port_ = CurrentVersion.ENV.getServerPort(); // //if (pForSending) // //{ // // int firmNr_ = environment.getSysSettings().getInt(SettingsSysMob.MOB_SYS_FIRM, 1); // // port_ = CurrentVersion.getPortByFirmNr(firmNr_); // //} // return port_; //} bool connect(bool pForSending) { // Activate connections startConnectionManager(); // string server = CurrentVersion.ENV.getServerIp(); // environment.getAppSettings().getString(SettingsAvaAgent.MOB_SERVER_S); int port = CurrentVersion.ENV.getServerPort(); // getPort(pForSending);//CurrentVersion.ENV.getServerPort();// environment.getAppSettings().getInt(SettingsAvaAgent.MOB_PORT_I, 6000); ToolMobile.setRuntimeMsg("Connection: to server [" + server + "] via port [" + port + "]"); IPAddress ip = IPAddress.Parse(server); //Thread thread = new Thread(new ThreadStart(this._close)); //thread.Start(); System.Threading.Tasks.Task t = client.ConnectAsync(ip, port); try { t.Wait(timeout); } catch (Exception exc) { ToolMobile.setExceptionInner(t.Exception); } if (!client.Client.Connected) { throw new MyExceptionError(MessageCollection.T_MSG_ERROR_CONNECTION); } //thread.Abort(); stream = client.GetStream(); return(true); }
protected override void OnCreate(Bundle savedInstanceState) { try { LayoutInflater.Factory = CustomViewFactory.getInstance(); base.OnCreate(savedInstanceState); initForm(); } catch (Exception exc) { ToolMobile.setExceptionInner(exc); var err = ToolException.unwrap(exc); Close(); Android.Widget.Toast.MakeText(this.ApplicationContext, err, Android.Widget.ToastLength.Long).Show(); } }
public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent) { try { Node group_ = _tree.RootNode.getChildAt(groupPosition); if (group_ != null) { var item = group_.Text; if (convertView == null) { convertView = getView(Resource.Layout.MobTreeViewGroup); } // convertView = getView(group_.getChildCount() > 0 ? Resource.Layout.MobTreeViewGroup : Resource.Layout.MobTreeViewChild); var textBox = convertView.FindViewById <TextView>(Resource.Id.cTreeNodeText); textBox.Text = item; return(convertView); //MobLabel l = convertView as MobLabel; //if (l == null) // l = new MobLabel(_context); //l.Text = item; //return l; } } catch (Exception exc) { ToolMobile.setExceptionInner(exc); } return(null); }
protected override void connect() { if (!ToolMobile.existsFile(infoDataSource.dataSource)) { isDbNew = true; } try { connection = SqlExecute.getConnection(infoDataSource.dataSource); } catch (Exception exc) { ToolMobile.setExceptionInner(exc); if (isDbNew && ToolMobile.existsFile(infoDataSource.dataSource)) { ToolMobile.deleteFile(infoDataSource.dataSource); } throw exc; } }
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(); } } }