コード例 #1
0
ファイル: ProceedDoc.cs プロジェクト: TabVV/TProh
        private int Read2D(BarcodeScannerEventArgs e)
        {
            int nRet = AppC.RC_OK,
                nLev;
            string s;



            s = e.Data;

            if (xAllDef == null)
            {
                DirectoryInfo di = new DirectoryInfo(xPars.sDataPath);
                FileInfo[]    fi = di.GetFiles("*.def");
                Def2Data      xOneDef;

                xAllDef = new List <Def2Data>();

                for (int i = 0; i < fi.Length; i++)
                {
                    xOneDef = new Def2Data();
                    nRet    = Read2DDef(fi[i].FullName, Encoding.GetEncoding(1251), xOneDef);
                    if (nRet == AppC.RC_OK)
                    {
                        nLev         = 0;
                        xOneDef.lDef = CreateArrOp(lDoc, ref nLev, 0);
                        xAllDef.Add(xOneDef);
                    }
                    else
                    {
                        ServClass.ErrorMsg(fi[i].FullName + "-ошибка в описании!");
                    }
                }

                xSer2D = new Ser2DSym(xNSI);
            }

            nRet = New2D(e.BinData, e.LenBinData);
            s    = "";
            if (nRet == AppC.RC_OK)
            {
                switch (xSer2D.State)
                {
                case READ2D_STATE.R_WAIT_SER:
                    s = "Записан - <" + sLastDoc + ">";
                    break;

                case READ2D_STATE.R_WAIT_NEXT:
                    break;
                }
            }
            //Show2DResult(REG_2D_SHOW, s);
            return(nRet);
        }
コード例 #2
0
ファイル: ProceedDoc.cs プロジェクト: TabVV/TProh
        private bool IsGood2D(byte[] b, int nLen)
        {
            bool     bRet = AppC.RC_CANCELB;
            Def2Data xDef = null;
            int      i, iM, j;

            if (xSer2D.State == READ2D_STATE.R_WAIT_SER)
            {// описание еще не зафиксировано
                iM = xAllDef.Count;
            }
            else
            {// ссылка на описание уже в контейнере 2D
                xDef = xSer2D.xСDef2D;
                iM   = 1;
            }

            for (i = 0; i < iM; i++)
            {
                if ((i > 0) || (xDef == null))
                {
                    xDef = xAllDef[i];
                }
                if (xDef.bID_Def.Length <= nLen)
                {
                    bRet = AppC.RC_OKB;
                    for (j = 0; j < xDef.bID_Def.Length; j++)
                    {
                        if (b[j] != xDef.bID_Def[j])
                        {
                            bRet = AppC.RC_CANCELB;
                            break;
                        }
                    }
                    if (bRet == AppC.RC_OKB)
                    {
                        if (xSer2D.State == READ2D_STATE.R_WAIT_SER)
                        {
                            xSer2D.xСDef2D = xDef;
                        }
                        break;
                    }
                }
            }

            return(bRet);
        }
コード例 #3
0
ファイル: ProceedDoc.cs プロジェクト: TabVV/TProh
        private int Parse1stLine(string sF, Def2Data xDef)
        {
            int nRet = AppC.RC_OK;

            try
            {
                Dictionary <string, string> aPars = SrvCommParse(sF, new char[] { '|' });
                xDef.sID_OAO = aPars["IDDEF"];
                xDef.bID_Def = Encoding.UTF8.GetBytes(xDef.sID_OAO);
            }
            catch
            {
                nRet         = AppC.RC_NOID;
                xDef.sID_OAO = "";
            }

            return(nRet);
        }
コード例 #4
0
ファイル: ProceedDoc.cs プロジェクト: TabVV/TProh
        private int Read2DDef(string sF, Encoding enc, Def2Data xDef)
        {
            int nRet = AppC.RC_OK;

            try
            {
                using (StreamReader sr = new StreamReader(sF, enc))
                {
                    String l;
                    lDoc = new List <string>();
                    while (((l = sr.ReadLine()) != null) && (nRet == AppC.RC_OK))
                    {
                        if (l.Substring(0, 2) != @"//")
                        {
                            if ((lDoc.Count == 0) && (l.IndexOf(sLevSign) < 0))
                            {
                                nRet = Parse1stLine(l, xDef);
                            }
                            else
                            {
                                lDoc.Add(l);
                            }
                        }
                    }
                }
                if (xDef.sID_OAO == "")
                {
                    nRet = AppC.RC_NOID;
                }
            }
            catch
            {
                nRet = AppC.RC_NOFILE;
            }

            return(nRet);
        }