Beispiel #1
0
 /// <summary>
 /// 扫描文件导入数据库
 /// </summary>
 public void ScanDirInfo()
 {
     String[] drives = Environment.GetLogicalDrives();
     if (File.Exists(drives[drives.Length - 1] + "List.lis"))
     {
         string filecontent = WriteDataToFile.ReadFile(drives[drives.Length - 1] + "List.lis");
         filecontent = filecontent.Remove(filecontent.Length - 1);
         string[] ct        = filecontent.Split(';');
         char[]   f1        = ct[0].ToArray();
         string[] TaskNames = filecontent.Remove(0, 2).Split(';');                  //任务名称集合
         int      num       = Convert.ToInt32(f1[0].ToString() + f1[1].ToString()); //预定任务数量
         if (num != ct.Length)
         {
             //错误
             num = ct.Length;
             WriteDataToFile.UpadataStringOfFile(drives[drives.Length - 1] + "List.lis", 0,
                                                 NumCorrection.KeepNum(num.ToString(), 2, HeadOrTail.Head));
         }
         foreach (var Tn in TaskNames)
         {
             string taskPath = drives[drives.Length - 1] + Tn;
             int    hashcode = UseUpanDoWork.LocalUsb.ReadJob(taskPath + "\\" + "Jobtask.dat").Information.GetHashCode();
             if (false == WorkingSets.local.rowsIsOfResuly(hashcode.ToString()))
             {
                 Insertdatabyupan inser = new Insertdatabyupan(taskPath);
                 inser.InsertUpandatatodatabase();
             }
             else
             {
                 continue;
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 创建所有的文件和任务单
        /// </summary>
        /// <param name="basepath"></param>
        /// <param name="ListlisName"></param>
        /// <param name="job"></param>
        public static void writefile(string basepath, string ListlisName, JobList job, List <MeasurementItemStruct> miList)
        {
            if (!File.Exists(basepath))//根文件
            {
                WriteDataToFile.DeelDirectoryInfo(basepath, Mode.Create);
            }
            string testlispath = basepath + "\\" + ListlisName;

            if (!File.Exists(testlispath))//testlist文件
            {
                WriteDataToFile.FileBaseDeel(testlispath, MyFileMode.Create);
                WriteDataToFile.WriteFile(testlispath, "00");
            }
            string TaskPath = basepath + "Ta" + DateTime.Now.DayOfYear.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString();

            if (!File.Exists(TaskPath))
            {
                WriteDataToFile.DeelDirectoryInfo(TaskPath, Mode.Create);
            }
            string transpath        = TaskPath + "\\TRANS.lis";
            string DcresistancePath = TaskPath + "\\ZLDZ.lis";
            string DciPath          = TaskPath + "\\JYDZ.lis";
            string caopath          = TaskPath + "\\JZSH.lis";
            string Oltcpayh         = TaskPath + "\\YZFJ.lis";
            string TestLispath      = TaskPath + "\\" + "TEST.lis";

            if (File.Exists(transpath))
            {
                WriteDataToFile.FileBaseDeel(transpath, MyFileMode.Clear);
            }
            if (File.Exists(DcresistancePath))
            {
                WriteDataToFile.FileBaseDeel(DcresistancePath, MyFileMode.Clear);
            }
            if (File.Exists(DciPath))
            {
                WriteDataToFile.FileBaseDeel(DciPath, MyFileMode.Clear);
            }
            if (File.Exists(caopath))
            {
                WriteDataToFile.FileBaseDeel(caopath, MyFileMode.Clear);
            }
            if (File.Exists(Oltcpayh))
            {
                WriteDataToFile.FileBaseDeel(Oltcpayh, MyFileMode.Clear);
            }
            if (File.Exists(TestLispath))
            {
                WriteDataToFile.FileBaseDeel(TestLispath, MyFileMode.Clear);
            }
            CreateListlis(testlispath, "Ta" + DateTime.Now.DayOfYear.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString());
            CreateTransList(transpath, job);
            CreateWorkList(DcresistancePath, DciPath, caopath, Oltcpayh);
            CreateTestList(TestLispath);
            CreateBaseMessageIni(TaskPath + "\\Information.ini");            //保存用户信息
            UseUpanDoWork.LocalUsb.saveJob(job, TaskPath + "\\Jobtask.dat"); //保存job单
            UseUpanDoWork.LocalUsb.savListmi(miList, TaskPath + "\\Listmitask.dat");
            Insertdatabyupan Ins = new Insertdatabyupan(TaskPath);

            job = Ins.UpdataJob(TaskPath);
            UseUpanDoWork.LocalUsb.saveJob(job, TaskPath + "\\Jobtask.dat");//保存job单
        }