示例#1
0
        public static KKSImportInfo <T> ImportKKSFromDirectory <T>(string folderPath, List <T> kksList) where T : KKSCode, new()
        {
            //List<KKSCode> kksList = bll.KKSCodes.ToList();
            KKSImportInfo <T> importInfo = new KKSImportInfo <T>();

            DirectoryInfo dirInfo = new DirectoryInfo(folderPath);

            foreach (DirectoryInfo subDir in dirInfo.GetDirectories())
            {
                foreach (FileInfo fileInfo in subDir.GetFiles())
                {
                    string strFolderName = fileInfo.Directory.Name;
                    //DataTable dtTable = ExcelHelper.Load(new FileInfo(fileInfo.FullName), false).Tables[0].Copy();
                    DataSet ds = ExcelHelper.Load(new FileInfo(fileInfo.FullName), false);
                    if (ds == null || ds.Tables.Count < 1)
                    {
                        continue;
                    }
                    DataTable dtTable = ds.Tables[0].Copy();
                    dtTable.Rows.RemoveAt(0);
                    dtTable.Rows.RemoveAt(0);
                    List <T> list1 = CreateKKSCodeListFromDataTable <T>(strFolderName,
                                                                        dtTable);
                    foreach (T item in list1)
                    {
                        ToKKSCodeList <T>(item, kksList, importInfo);
                    }
                }
            }

            //bll.KKSCodes.EditRange(bll.Db, listEditInfo); //修改的部分
            //bll.KKSCodes.AddRange(bll.Db, listAddInfo); //新增的部分

            return(importInfo);
        }
示例#2
0
        public static void ToKKSCodeList <T>(T kks, List <T> kksList, KKSImportInfo <T> importInfo) where T : IKKSCode, new()
        {
            bool bFlag = false;

            if (kksList != null)
            {
                T kks0 = kksList.Find(i => i.Code == kks.Code && i.System == kks.System);
                if (kks0 != null)
                {
                    if (kks0.Name != kks.Name)
                    {
                        bFlag     = true;
                        kks0.Name = kks.Name;
                    }

                    if (kks0.DesinCode != kks.DesinCode)
                    {
                        bFlag          = true;
                        kks0.DesinCode = kks.DesinCode;
                    }

                    if (bFlag)
                    {
                        bFlag = false;
                        importInfo.listEditInfo.Add(kks0);
                    }

                    return;
                }
                else
                {
                    kks0 = importInfo.listAddInfo.Find(i => i.Code == kks.Code && i.System == kks.System);
                    if (kks0 != null)
                    {
                        return;
                    }
                }
            }
            importInfo.listAddInfo.Add(kks);
        }
示例#3
0
 public static void TableToList(string strFolderName, DataTable dtTable, List <KKSCode> kksList, KKSImportInfo <KKSCode> importInfo1)
 {
     foreach (DataRow dr in dtTable.Rows)
     {
         var kks1 = CreateKKSCodeFromDataRow <KKSCode>(strFolderName, dr);//根据表格内容创建KKS对象
         ToKKSCodeList <KKSCode>(kks1, kksList, importInfo1);
     }
 }