public static void PARSE(string pLine)
                {
                    if (pLine == null)
                    {
                        return;
                    }

                    ENVITM itm = new ENVITM();

                    ++indx_;

                    if (!pLine.StartsWith("//"))
                    {
                        string[] arr_ = ToolString.breakList(pLine);

                        itm.key = (arr_.Length > 0 ? arr_[0] : string.Empty).Trim();
                        itm.val = (arr_.Length > 1 ? arr_[1] : string.Empty);
                    }
                    else
                    {
                        itm.key       = "dummy_" + indx_;
                        itm.val       = pLine;
                        itm.isComment = true;
                    }

                    if (itm.key != string.Empty)
                    {
                        envKeys_[itm.key] = itm;
                    }
                }
Example #2
0
                internal bool tryOpen()
                {
                    try
                    {
                        if (mmSocket == null)
                        {
                            mmSocket = new TcpClient();
                        }

                        if (mmSocket != null && !mmSocket.Connected)
                        {
                            string addr_ = CurrentVersion.ENV.getPrinter();

                            string[] arr_ = ToolString.breakList(':', addr_);

                            mmSocket.Connect(arr_[0], int.Parse(arr_[1]));

                            return(writeLine(" ", false));
                        }
                    }
                    catch (Exception exc)
                    {
                    }
                    return(false);
                }
 public static string getName(string pCmd)
 {
     string[] args = ToolString.explodeList(partsSep, pCmd);
     if (args.Length > 0)
     {
         return(args[0]);
     }
     return(pCmd);
 }
 public static string setName(string pCmd, string pName)
 {
     string[] args = ToolString.explodeList(partsSep, pCmd);
     if (args.Length > 0)
     {
         args[0] = pName;
     }
     return(ToolString.joinList(partsSep, args));
 }
 public static string getArgValue(string pCmdLine, string pCmdArgName, string pDef)
 {
     string[] args = ToolString.explodeList(partsSep, pCmdLine);
     foreach (string arg in args)
     {
         ArguemntItem item_ = ArguemntItem.parse(arg);
         if (item_.name.ToLowerInvariant() == pCmdArgName.ToLowerInvariant())
         {
             return(item_.value);
         }
     }
     return(pDef);
 }
        public static string setArgValue(string pCmdLine, string pCmdArgName, string pCmdArgValue)
        {
            string[] args = ToolString.explodeList(partsSep, pCmdLine);
            for (int i = 0; i < args.Length; ++i)
            {
                ArguemntItem item_ = ArguemntItem.parse(args[i]);
                if (item_.name.ToLowerInvariant() == pCmdArgName.ToLowerInvariant())
                {
                    args[i] = ArguemntItem.format(new ArguemntItem(pCmdArgName, pCmdArgValue));
                    return(ToolString.joinList(partsSep, args));
                }
            }

            return(addArgValue(pCmdLine, pCmdArgName, pCmdArgValue));
        }
        public static ArguemntItem[] getArgs(string pCmdLine)
        {
            List <ArguemntItem> list_ = new List <ArguemntItem>();

            string[] args = ToolString.explodeList(partsSep, pCmdLine);
            foreach (string arg in args)
            {
                list_.Add(ArguemntItem.parse(arg));
            }

            if (list_.Count > 0)
            {
                list_.RemoveAt(0);
            }

            return(list_.ToArray());
        }
Example #8
0
        public static int[] strToIntArr(string list)
        {
            XmlFormating _format = new XmlFormating();

            string[]   items    = ToolString.trim(ToolString.explodeList(list));
            List <int> valsList = new List <int>();

            foreach (string itm in items)
            {
                if (itm != string.Empty)
                {
                    object obj = _format.parse(itm, typeof(int));
                    if (obj != null)
                    {
                        valsList.Add((int)obj);
                    }
                }
            }
            return(valsList.ToArray());
        }
            public static void initNs(EventHandler pHandler)
            {
                string val_ = ENV.getEnvString(NSLIST, string.Empty);

                if (string.IsNullOrEmpty(val_))
                {
                    return;
                }

                var arr_ = ToolString.explodeList(val_);

                ToolMsg.askList(null, arr_, (s, e) =>
                {
                    if (pHandler != null)
                    {
                        var ns_  = arr_[e.Which];
                        nsPerfix = ns_;
                        pHandler.Invoke(s, EventArgs.Empty);
                    }
                });
            }
                public object done()
                {
                    try
                    {
                        if (!step1filterInited)
                        {
                            var hasFilter = false;

                            string filterType = null;
                            string filterCol  = null;
                            string filterRef  = null;

                            ++index;

                            for (; index < _args.Length; ++index)
                            {
                                var itm = _args[index];

                                if (itm.name.StartsWith("filter_"))
                                {
                                    hasFilter = true;

                                    break;
                                }
                            }

                            if (hasFilter)
                            {
                                var filterParts = ToolString.explodeList(_args[index].value);

                                filterType = filterParts.Length > 0 ? filterParts[0] : null;
                                filterCol  = filterParts.Length > 1 ? filterParts[1] : null;
                                filterRef  = filterParts.Length > 2 ? filterParts[2] : null;

                                var refObj_ = _environment.getReference(filterRef);
                                if (refObj_ == null)
                                {
                                    throw new Exception("Undefined ref: " + filterRef);
                                }

                                refObj_.begin(null, null, false, (s, a) =>
                                {
                                    try
                                    {
                                        var row = refObj_.getSelected();

                                        _args[index].value = XmlFormating.helper.format(row != null ? row[filterCol] : "");

                                        this.done();
                                    }
                                    catch (Exception exc)
                                    {
                                        _environment.getExceptionHandler().setException(exc);
                                    }
                                });

                                return(null);
                            }

                            if (index >= _args.Length)
                            {
                                step1filterInited = true;
                            }
                        }



                        doneRender();
                    }
                    catch (Exception exc)
                    {
                        _environment.getExceptionHandler().setException(exc);
                    }

                    return(null);
                }
        protected virtual void initSqlConstExtern()
        {
            string cnfgConst = settingsApp.getString(SettingsNamesApp.APP_SQL_CONST_S, string.Empty);

            _listSqlConst = ToolString.explodeForParameters(cnfgConst, _listSqlConst);
        }
Example #12
0
        static string convert(string pData)
        {
            //#barcode,12345678#
            //#cut#
            //#clean#
            //#center#

            char xchar = '#';

            StringReader  sr = new StringReader(pData);
            StringBuilder sb = new StringBuilder();

            string line = null;

            while ((line = sr.ReadLine()) != null)
            {
                if (line.StartsWith(xchar.ToString()) && line.EndsWith(xchar.ToString()))
                {
                    line = line.Trim(xchar);
                    var arr = ToolString.explodeList(line);
                    if (arr.Length > 0)
                    {
                        string cmd  = arr.Length > 0 ? arr[0] : null;
                        string arg1 = arr.Length > 1 ? arr[1] : null;
                        string arg2 = arr.Length > 2 ? arr[2] : null;
                        string arg3 = arr.Length > 3 ? arr[3] : null;

                        MemoryStream ms = new MemoryStream();
                        BinaryWriter bw = new BinaryWriter(ms);
                        switch (cmd)
                        {
                        case "barcode":
                            if (arg1 != null)
                            {
                                PosPrinter.Reinit(bw);
                                PosPrinter.OutCenter(bw);
                                PosPrinter.OutHeight(bw, 60);
                                PosPrinter.Barcode(bw, arg1);
                                PosPrinter.Text(bw, arg1);
                                PosPrinter.Reinit(bw);
                            }
                            else
                            {
                                sb.AppendLine("error");
                            }
                            break;

                        case "cut":
                        {
                            PosPrinter.Cut(bw);
                        }
                        break;

                        case "clean":
                        {
                            PosPrinter.Reinit(bw);
                        }
                        break;

                        case "center":
                        {
                            PosPrinter.OutCenter(bw);
                        }
                        break;
                        }

                        bw.Flush();
                        var newdata = ms.ToArray();

                        var newline = Encoding.ASCII.GetString(newdata);

                        sb.AppendLine(newline);
                    }
                }
                else
                {
                    sb.AppendLine(line);
                }
            }



            return(sb.ToString());
        }
Example #13
0
 public static string[] explodeListLogical(string str)
 {
     return(ToolString.removeEmpty(ToolString.trim(ToolString.explodeList(str))));
 }