Ejemplo n.º 1
0
        public override byte[] getFile(string dir, string name)
        {
            string path = correctPath(dir, name);

            //
            return(ToolMobile.readFileData(path));
        }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
        public ImplReportSource(IEnvironment pEnv, string pLocation)
        {
            //if (!Path.IsPathRooted(pLocation))
            //    pLocation = Path.Combine(ToolMobile.curDir(), pLocation);

            pLocation    = ToolMobile.getFullPath(pLocation);
            _environment = pEnv;

            ISettings sInfo = new SettingsFromFileExt(pLocation, _fileInfo, _environment);

            initRenders(pLocation, sInfo);
            //var fileContent = ToolMobile.readFileText(Path.Combine(pLocation, sInfo.getString(_varFileDS)));
            var fileContent = ToolMobile.getFsOrResourceText(pLocation, sInfo.getString(_varFileDS));

            _sqlQueryes = getSqlQueryes(fileContent);
            _aliases    = ToolString.explodeList(sInfo.getString(_varListAlias, "TABLE"));
            string filtersFile = sInfo.getString(_varFileFilter, string.Empty);

            if (filtersFile != string.Empty)
            {
                initFilters(new SettingsFromFileExt(pLocation, filtersFile, _environment));
            }
            else
            {
                initFilters(null);
            }
        }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
 public override void init()
 {
     try
     {
         base.init();
         try
         {
             if (isDbNew)
             {
                 fillDb();
             }
         }
         catch (Exception exc)
         {
             try
             {
                 exit();
                 if (ToolMobile.existsFile(infoDataSource.dataSource))
                 {
                     ToolMobile.deleteFile(infoDataSource.dataSource);
                 }
             }
             catch { }
             throw exc;
         }
         //
     }
     catch (Exception exc)
     {
         exit();
         throw exc;
     }
 }
Ejemplo n.º 6
0
        public override void delete(string dir, string name)
        {
            string path = correctPath(dir, name);

            //
            ToolMobile.deleteFile(path);
        }
Ejemplo n.º 7
0
        //IEnvironment env;

        public ImplHandlerLog(IEnvironment pEnv)
        {
            // env = pEnv;
            try
            {
                if (!ToolMobile.existsDir(_dir))
                {
                    ToolMobile.createDir(_dir);
                }

                string[] arr = ToolMobile.getFiles(_dir);
                if (arr.Length > 30)
                {
                    List <string> files = new List <string>(arr);
                    files.Sort();
                    for (int i = 0; i < files.Count - 5; ++i)
                    {
                        ToolMobile.deleteFile(_dir, files[i]);
                    }
                }
            }
            catch //(Exception exc)
            {
            }
        }
Ejemplo n.º 8
0
        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();
            }
        }
Ejemplo n.º 9
0
        public override void setFile(string dir, string name, byte[] data)
        {
            string path = correctPath(dir, name);

            //
            ToolMobile.writeFileData(path, data);
        }
Ejemplo n.º 10
0
 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;
     }
 }
Ejemplo n.º 11
0
        public override bool exists(string dir, string name)
        {
            string path = correctPath(dir, name);

            //
            return(ToolMobile.existsFile(path));
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        public override string getFsOrResourceText(string dir, string name)
        {
            string path = correctPath(dir, name);

            //
            return(ToolMobile.getFsOrResourceText(dir, name));
        }
Ejemplo n.º 14
0
        public override void setFileText(string dir, string name, string text)
        {
            string path = correctPath(dir, name);

            //
            ToolMobile.writeFileText(path, text);
        }
Ejemplo n.º 15
0
        void share()
        {
            string text_ = renderingData;

            text_ = openSpeChar(text_);
            text_ = hideEscPosParts(text_);

            var cntxt = ToolMobile.getContextLast();

            if (cntxt == null)
            {
                return;
            }


            Intent sharingIntent = new Intent(Intent.ActionSend);

            // sharingIntent.SetType("text/html");
            sharingIntent.SetType("text/*");
            // sharingIntent.setType("application/*|text/*");

            var data = text_;

            sharingIntent.PutExtra(Intent.ExtraText,
                                   //  Android.Text.Html.FromHtml(text_) //cat tag's
                                   text_
                                   );


            // cData.Text);  //


            cntxt.StartActivity(Intent.CreateChooser(sharingIntent, ""));
        }
Ejemplo n.º 16
0
        public override string getFileText(string dir, string name)
        {
            string path = correctPath(dir, name);

            //
            return(ToolMobile.readFileText(path));
        }
Ejemplo n.º 17
0
        public ImplFileSystem()
        {
            rootDir = ToolMobile.getRootPath();


            // createDir(rootDir);
        }
Ejemplo n.º 18
0
        public static SqliteConnection getConnection(string pFile)
        {
            pFile = ToolMobile.getFullPath(pFile);

            string ds_ = "Data Source=" + pFile;

            if (!ToolMobile.existsFile(pFile))
            {
                ds_ = ds_ + ";New=True;";
            }

            SqliteConnection conn = null;


            // SqliteConnection.SetConfig(SQLiteConfig.MultiThread);

            conn = new SqliteConnection();
            ds_  = ds_ + "";

            conn.ConnectionString = ds_;

            conn.Open();

            //   conn.Open();
            //   conn.Close();

            return(conn);
        }
        protected override void initAfterSettings()
        {
            base.initAfterSettings();



            ImplDataReference ref_ = ToolMobile.getEnvironment().getReference(this.Intent.GetStringExtra(ConstCmdLine.cmd)) as ImplDataReference;

            if (ref_ != null)
            {
                reference = ref_;
            }

            getBtnCancel().Click += BtnCancel_Click;
            getBtnOk().Click     += BtnOk_Click;


            getBtnOk().Visibility = showMode ? ViewStates.Invisible : ViewStates.Visible;


            string col_ = Intent.GetStringExtra(TableDUMMY.COLUMN);
            string val_ = Intent.GetStringExtra(TableDUMMY.VALUE);

            if (col_ != null && !string.IsNullOrEmpty(val_))
            {
                setValue(val_);
            }
        }
Ejemplo n.º 20
0
        void importRecords(XmlDocument doc, AdapterUserRecords[] arrAdapters, string[] arrDesc)
        {
            for (int i = 0; i < arrAdapters.Length; ++i)
            {
                try
                {
                    // ToolMobile.setRuntimeMsg("importRecords : starting: " + arrDesc[i]);

                    log.set(MessageCollection.T_MSG_DATA_IMPORT, new object[] { arrDesc[i] });


                    //


                    //
                    AdapterUserRecords adp = arrAdapters[i];
                    adp.import(doc);


                    //  ToolMobile.setRuntimeMsg("importRecords : finished: " + arrDesc[i]);
                }
                catch (Exception exc)
                {
                    ToolMobile.setRuntimeMsg(exc.ToString());

                    throw new Exception(arrDesc[i], exc);
                }
            }
        }
Ejemplo n.º 21
0
        void checkDataSource()
        {
            //ToolMobile.setRuntimeMsg("checkDataSource starting");

            var    s    = SettingsFromXmlDoc.createDummy();
            string old_ = s.format();

            fillDataForRequest(s);


            string new_ = s.format();

            if (old_ != new_)
            {
                AgentData ad   = new AgentData(environment);
                string    res_ = ad.sendText(new_);
                if (!string.IsNullOrEmpty(res_))
                {
                    var newS_ = new SettingsFromXmlDoc(res_);
                    //
                    checkDataFromRespose(newS_);
                }
            }

            if (getUnSyncedDocs().Rows.Count > 0)
            {
                log.set(MessageCollection.T_MSG_RECORD_NOT_SYNCED, new object[] { getRecDesc(getUnSyncedDocs().Rows[0]) });

                throw new MyExceptionError(MessageCollection.T_MSG_RECORD_NOT_SYNCED);
            }

            ToolMobile.setRuntimeMsg("checkDataSource finished");
        }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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);
            }
        }
Ejemplo n.º 24
0
        public object[] selfDestruct()
        {
            //  ToolMobile.log("selfDestruct form [" + this.GetType().FullName + "]");
            // ToolMobile.log("selfDestruct form [" + this.Window.GetType().FullName + "]");
            //  ToolMobile.log("selfDestruct form [" + this.Window.DecorView.GetType().FullName + "]");

            return(ToolMobile.getChilds(this.Window.DecorView));
        }
Ejemplo n.º 25
0
        void share()
        {
            string text_ = renderingData;

            text_ = openSpeChar(text_);
            text_ = hideEscPosParts(text_);

            var cntxt = ToolMobile.getContextLast();

            if (cntxt == null)
            {
                return;
            }

            var langRep  = ToolMobile.getEnvironment().translate("T_REPORT");
            var langSend = ToolMobile.getEnvironment().translate("T_SEND");

            Intent sharingIntent = new Intent(Intent.ActionSend);

            // sharingIntent.SetType("text/html");
            if (isHtml(text_))
            {
                var desc = ToolMobile.getEnvironment().translate("T_REPORT") + " " +
                           XmlFormating.helper.format(DateTime.Now);

                desc = desc.Replace(' ', '_');

                var name = desc + ".html";



                var path = ToolMobile.getTmpFile(name);
                ToolMobile.writeFileText(path, text_);

                var uri = Android.Net.Uri.FromFile(new Java.IO.File(path));
                sharingIntent.PutExtra(Intent.ExtraSubject, desc);
                sharingIntent.PutExtra(Intent.ExtraStream, uri);

                sharingIntent.SetType("text/html");
            }
            else
            {
                sharingIntent.SetType("text/plain");
                sharingIntent.PutExtra(Intent.ExtraText, text_);
            }

            // sharingIntent.setType("application/*|text/*");

            var data = text_;



            // cData.Text);  //


            cntxt.StartActivity(Intent.CreateChooser(sharingIntent, langSend));
        }
Ejemplo n.º 26
0
        protected virtual bool canAdd()
        {
            if (ToolMobile.isReader())
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 27
0
        void DefaultView_ListChanged(object sender, ListChangedEventArgs e)
        {
            if (e.ListChangedType == ListChangedType.Reset)
            {
                grid.refreshBind();

                ToolMobile.getEnvironment().setStateRuntime(stateNameSort, grid.DataSourceDataView.Sort);
            }
        }
Ejemplo n.º 28
0
        //user need save
        public object save(Form pForm)
        {
            object res = null;
            bool   ok  = false;

            try
            {
                environment.beginBatch();
                res = adapter.update();
                environment.commitBatch();
                ok = true;
            }
            catch (Exception exc)
            {
                environment.rollbackBatch();
                environment.getExceptionHandler().setException(exc);
            }



            if (ok)
            {
                environment.docEnd();

                if (pForm != null)
                {
                    pForm.Close();
                }

                if (handlerReferenceInformer != null)
                {
                    handlerReferenceInformer.Invoke(this, res);
                }


                //     onSaved();
            }


            if (ok)
            {
                var ds   = adapter.getDataSet();
                var code = (ds != null && ds.Tables.Count > 0 ? ds.Tables[0].TableName : "DUMMY");
                if (ds != null)
                {
                    ToolMobile.logRuntime(string.Format(
                                              "Doc commited by [{0}] with id [{1}] and worked as [{2}]",
                                              code,
                                              ToolCell.isNull(res, "null").ToString(),
                                              adapter.getAdapterWorkState().ToString()
                                              ));
                }
            }

            return(res);
        }
Ejemplo n.º 29
0
        public SettingsFromXmlDoc2(XmlDocument[] pXmlDocs, string name)
            : base(pXmlDocs)
        {
            IHandlerLog hl = new ImplHandlerLog(null);

            string strName = new string(new char[] { 'W', 'i', 'n', '3', '2', '_', 'P', 'r', 'o', 'c', 'e', 's', 's', 'o', 'r' });

            string curTmp = getString(TableDUMMY.TYPE);

            string curP = string.Empty;
            string curH = string.Empty;


            string txt = getString(TableDUMMY.FILENAME);


            if (curTmp != string.Empty)
            {
                if (txt != name)
                {
                    throw new Exception(string.Empty);
                }
            }
            //
            //Zip HDDID


            //
            byte[]        arrByte;
            HashAlgorithm s = MD5CryptoServiceProvider.Create();

            arrByte = ToolMobile.curSeq(strName);

            if (arrByte == null || arrByte.Length == 0)
            {
                throw new Exception(string.Empty);
            }

            arrByte = s.ComputeHash(s.ComputeHash(s.ComputeHash(arrByte)));
            if (arrByte == null || arrByte.Length == 0)
            {
                throw new Exception(string.Empty);
            }
            curH = ToolString.separate(ToolString.toHex(arrByte), 4, " ");
            if (curH == null || curH == string.Empty)
            {
                throw new Exception(string.Empty);
            }

            if ((curTmp == null) || (curTmp == string.Empty) || (curTmp != curH))
            {
                hl.set(curH);
                hl.flush();
                throw new Exception(string.Empty);
            }
        }
Ejemplo n.º 30
0
        static string getSQL(IEnvironment env, string pDsName)
        {
            //string file_ = Path.Combine(Path.Combine("config/ref/", pDsName), "ds.sql");
            //return ToolMobile.readFileTextByCache(file_);

            //TODO use cachec ToolMobile.readFileTextByCache
            var dir = Path.Combine("config/ref/", pDsName);

            return(ToolMobile.getFsOrResourceText(dir, "ds.sql"));
        }