public static string ParseProfessional(ProfessionalEnum professional)
        {
            var result = "";

            switch (professional)
            {
            case ProfessionalEnum.Decoration:
                result = "建筑装饰";
                break;

            case ProfessionalEnum.Installation:
                result = "安装";
                break;

            case ProfessionalEnum.Municipal:
                result = "市政";
                break;

            case ProfessionalEnum.Green:
                result = "绿化";
                break;

            case ProfessionalEnum.Gardens:
                result = "园林";
                break;
            }

            return(result);
        }
        public static bool SetFields(Excel excel, DataRow row, ProfessionalEnum professional)
        {
            excel.ID       = System.Guid.NewGuid().ToString();
            excel.ParentID = "";

            excel.XH    = row.Pick(0, "");
            excel.QDBH  = row.Pick(1, "");
            excel.QDMC  = row.Pick(2, "");
            excel.DW    = row.Pick(3, "");
            excel.GCL   = row.Pick(4, "");
            excel.GCLXS = row.Pick(5, "");
            excel.ZY    = ParseProfessional(professional);

            return(true);
        }
Beispiel #3
0
        public IdentityResult[] IdentityQuotaOnly(ProfessionalEnum professional, Excel[] excels)
        {
            IdentityResult        result  = null;
            List <IdentityResult> results = new List <IdentityResult>();

            try
            {
                foreach (var excel in excels)
                {
                    result = Process(professional, excel);
                    foreach (var i in result.RulesMatched)
                    {
                        result.ExcelsMatched.Add(RulesAdapter.ConvertToExcels(i, excel.ID, 0));
                    }
                    // excel.ResultForProgram = Excels.FormatSubheadings(result.RulesMatched.ToArray());
                    // excel.ResultForUser = Excels.FormatSubheadings(excel.Subheading.ToArray());

                    if (result.State == IdentityResultStateEnum.Success)
                    {
                        result.Message = "成功";
                    }
                    else
                    {
                        //result.Message = "不能匹配";
                        if (result.RulesMatched.Count > 0)
                        {
                            result.State   = IdentityResultStateEnum.Success;
                            result.Message = "成功";
                        }
                        else
                        {
                            result.Message = "不能匹配";
                            result.State   = IdentityResultStateEnum.Unable;
                        }
                    }
                    results.Add(result);

                    Thread.Sleep(0);
                }
            }
            catch (Exception e)
            {
            }

            return(results.ToArray());
        }
        public static System.Collections.Generic.List <Excel> Parse(ProfessionalEnum professional, DataTable table)
        {
            System.Collections.Generic.List <Excel> excels = new System.Collections.Generic.List <Excel>();
            Excel excel = new Excel();

            foreach (DataRow row in table.Rows)
            {
                //excel.SerializeString = excel.Serialize();
                Excel.SetFields(excel, row, professional);
                if (string.IsNullOrEmpty(excel.XH))
                {
                    continue;
                }

                excels.Add(excel);
                excel = new Excel();

                //不解析子目仅仅解析清单
                //string LB = row.Field<string>("类别");
                //string text = LB;
                //if (text != null)
                //{
                //    if (!(text == "清单"))
                //    {
                //        if (text == "子目")
                //        {
                //            Excels subheading = new Excels();
                //            Excels.SetFields(subheading, row);
                //            subheading.IsSubheading = true;
                //            subheading.ParentID = excel.ID;
                //            excel.Subheading.Add(subheading);
                //        }
                //    }
                //    else
                //    {
                //        excel.SerializeString = excel.Serialize();
                //        excel = new Excels();
                //        excels.Add(excel);
                //        Excels.SetFields(excel, row);
                //    }
                //}
            }
            return(excels);
        }
Beispiel #5
0
        /// <summary>
        /// 开始标识
        /// </summary>
        //public void StartIdentity(DataTable table)
        //{
        //    var excels = Excel.Parse(table);
        //    StartIdentity(excels);
        //}

        //public void StartIdentity(string fileName)
        //{
        //    var excels = Excel.Parse(new ExcelAdapter(fileName).QueryDatatable("SELECT * FROM [Sheet1$]", "sheet1"));
        //    StartIdentity(excels);
        //}



        public IdentityResult Process(ProfessionalEnum professional, Excel excels)
        {
            excels.Log("开始标识" + excels.QDMC);

            //通过专业匹配数据
            var matchedProfessional = Rules.QDFLB.Select("QDFL = '" + excels.ZY + "'");

            //通过编码匹配数据
            var QDFLBs_BM = matchedProfessional.Where(delegate(DataRow row)
            {
                var value = row.Pick("QDBM")["QDBM"];

                if (string.IsNullOrEmpty(value))
                {
                    return(false);
                }

                var QDBMs = value.Split(',');
                foreach (var QDBM in QDBMs)
                {
                    if (excels.QDBH.StartsWith(QDBM))
                    {
                        return(true);
                    }
                }

                return(false);
            }).ToList();

            //通过ZYFL5匹配数据
            var QDFLBs_ZYFL5 = matchedProfessional.Where(delegate(DataRow row)
            {
                var profession = row.Pick("ZYFL5")["ZYFL5"];

                if (string.IsNullOrEmpty(profession))
                {
                    return(true);
                }

                var express = new Fields("express", profession);
                var pattern = Pattern.Parse(express);
                if (pattern == null)
                {
                    return(false);
                }

                var name   = FormatNameUseGlobalRule(excels.QDMC, excels.ZY);
                var sample = new Fields("sample", name);
                return(pattern.IsMatch(sample));
            }).ToList();

            var QDFLBs_BZ1 = QDFLBs_ZYFL5.Where(delegate(DataRow row)
            {
                var value = row.Pick("BZ1")["BZ1"];
                if (string.IsNullOrEmpty(value))
                {
                    return(true);
                }

                return(excels.QDMC.Contains(value));
            }).ToList();

            if (excels.QDBH.Length < 9 || QDFLBs_BM.Count == 0)
            {
                return(ProcessOther(excels, Rules));
            }

            var            index     = -1;
            IdentityResult identityA = new IdentityResult(excels.ID);
            IdentityResult identityB = new IdentityResult(excels.ID);
            IdentityResult identityC = new IdentityResult(excels.ID);

            //A环节
            while (++index < QDFLBs_BM.Count)
            {
                var QDFLB = QDFLBs_BM[index];
                var BZ1   = QDFLB.Field <string>("BZ1");
                var ZYFL5 = QDFLB.Field <string>("ZYFL5");

                if (ZYFL5 == "图集")
                {
                    var identity = ProcessImages(excels, Rules, BZ1);
                    if (identity.State == IdentityResultStateEnum.Success)
                    {
                        identityA.State = IdentityResultStateEnum.Success;
                        identityA.RulesMatched.AddRange(identity.RulesMatched);
                    }
                }
                else
                {
                    excels.Log(ZYFL5 + "非图集");
                }
            }

            if (identityA.State == IdentityResultStateEnum.Success)
            {
                return(identityA);
            }

            index = 0;
            excels.Log("进入 B 流程");

            //B环节
            {
                var identity = ProcessDefault(excels, Rules);
                if (identity.State == IdentityResultStateEnum.Success)
                {
                    identityB.State = IdentityResultStateEnum.Success;
                    identityB.RulesMatched.AddRange(identity.RulesMatched);
                }
            }

            if (identityB.State != IdentityResultStateEnum.Success)
            {
                excels.Log("进入 D 流程");
                return(ProcessOther(excels, Rules));
            }
            else
            {
                return(identityB);
            }
        }