Esempio n. 1
0
 public void StopStep(IEnumerator <Step> iEnumerator)
 {
     if (iEnumerator == null)
     {
         return;
     }
     if (mStepGroups == null)
     {
         return;
     }
     if (!mStepGroups.ContainsKey(iEnumerator))
     {
         return;
     }
     mStepGroups.Remove(iEnumerator);
     iEnumerator.Dispose();
     //if(iEnumerator)
 }
Esempio n. 2
0
        public void ReadFile(XFileInfo fileinfo)
        {
            string path_excel = fileinfo.Name;

            var time_start = DateTime.Now;

            if (File.Exists(path_excel))
            {
                FileStream fsExcel = File.OpenRead(path_excel);
                IWorkbook  wk      = new XSSFWorkbook(fsExcel);

                int stcount = wk.NumberOfSheets;
                for (int stc = 0; stc < stcount; stc++)
                {
                    ISheet sheet = wk.GetSheetAt(stc);

                    string   sheetName = sheet.SheetName;
                    string[] nodes     = sheetName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);

                    string pagename   = sheet.SheetName;
                    string pagenamecn = sheet.SheetName;
                    if (nodes.Length >= 2)
                    {
                        pagename   = nodes[1];
                        pagenamecn = nodes[0];
                    }

                    var page = new PageInfo(pagename);
                    page.NameCn    = pagenamecn;
                    page.NameFile  = Path.GetFileName(path_excel);
                    page.ValidType = fileinfo.ValidType;

                    IRow rowHeadC = sheet.GetRow(1);
                    if (rowHeadC == null)
                    {
                        continue;
                    }
                    for (int k = 0; k <= rowHeadC.LastCellNum; k++)
                    {
                        ICell cell = rowHeadC.GetCell(k);
                        if (cell != null)
                        {
                            page.HeadC.Add(cell.ToString());
                        }
                        else
                        {
                            page.HeadC.Add("");
                        }
                    }
                    IRow rowHead = sheet.GetRow(2);
                    if (rowHead == null)
                    {
                        continue;
                    }
                    for (int k = 0; k <= rowHead.LastCellNum; k++)
                    {
                        ICell cell = rowHead.GetCell(k);
                        if (cell != null)
                        {
                            string   strheadenum      = cell.ToString();
                            string[] strheadenumnodes = strheadenum.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                            if (strheadenumnodes.Length >= 2)
                            {
                                page.Head.Add(strheadenumnodes[0]);
                                page.HeadEnum.Add(strheadenumnodes[1]);
                            }
                            else
                            {
                                page.Head.Add(strheadenum);
                                page.HeadEnum.Add(strheadenum);
                            }
                        }
                        else
                        {
                            page.Head.Add("");
                            page.HeadEnum.Add("");
                        }
                    }
                    IRow rowTypeClient = sheet.GetRow(3);
                    if (rowTypeClient == null)
                    {
                        continue;
                    }
                    for (int k = 0; k <= page.Head.Count; k++)
                    {
                        ICell cell = rowTypeClient.GetCell(k);
                        if (cell != null)
                        {
                            string TypeClient = cell.ToString();
                            if (TypeClient == "float")
                            {
                                TypeClient = "double";
                            }
                            page.TypeClient.Add(TypeClient);
                        }
                        else
                        {
                            page.TypeClient.Add("");
                        }
                    }
                    IRow rowTypeServer = sheet.GetRow(4);
                    if (rowTypeServer == null)
                    {
                        continue;
                    }
                    for (int k = 0; k <= page.Head.Count; k++)
                    {
                        ICell cell = rowTypeServer.GetCell(k);
                        if (cell != null)
                        {
                            page.TypeServer.Add(cell.ToString());
                        }
                        else
                        {
                            page.TypeServer.Add("");
                        }
                    }

                    for (int j = 5; j <= sheet.LastRowNum; j++)
                    {
                        IRow row = sheet.GetRow(j);
                        if (row == null)
                        {
                            continue;
                        }
                        if (row.GetCell(0) == null)
                        {
                            continue;
                        }
                        if (row.GetCell(0).ToString() == "")
                        {
                            continue;
                        }
                        var listrowvalue = new List <string>();
                        for (int k = 0; k < page.Head.Count; k++)
                        {
                            ICell  cell    = row.GetCell(k);
                            string s_value = GetTextFromCell(cell);
                            if (s_value == "")
                            {
                                s_value = "0";
                            }

                            if (!string.IsNullOrEmpty(page.HeadEnum[k]))
                            {
                                if (DictListEnums.TryGetValue(page.HeadEnum[k], out var DictList))
                                {
                                    if (DictList.ContainsKey(s_value))
                                    {
                                        s_value = DictList[s_value];
                                    }
                                }
                            }
                            listrowvalue.Add(s_value);
                        }
                        page.ListValue.Add(listrowvalue);
                    }
                    if (page.IsLegal())
                    {
                        DictPages.Add(page.Name, page);
                    }
                }
            }
            UpdateFileTs(fileinfo, DateTime.Now - time_start);
        }