Ejemplo n.º 1
0
 private void SaveData()
 {
     int iFind = -1;
     SpareEntities db = EntitiesFactory.CreateSpareInstance();
     for (int i = 0; i < gr.Length; i++)
     {
         if (gr[i].Check)
         {
             FileStream fs = new FileStream(gr[i].FullName, FileMode.Open, FileAccess.Read);
             UpdateControl.SaveFile2DB(db,"Update", gr[i].FileName, fs);
             iFind = servers.Find(gr[i].FileName);
             if (iFind >= 0)
             {
                 if (servers[iFind].ModifyDate < DateTime.Parse(gr[i].lModifyDate))
                 {
                     servers[iFind].ModifyDate = DateTime.Parse(gr[i].lModifyDate);
                     servers[iFind].FileSize = long.Parse(gr[i].lFileSize);
                 }
             }
             else
             {
                 UpdateItem item = new UpdateItem();
                 item.FileName = gr[i].FileName;
                 item.FileSize = long.Parse(gr[i].lFileSize);
                 item.ModifyDate = DateTime.Parse(gr[i].lModifyDate);
                 servers.Add(item);
             }
         }
     }
     UpdateControl.SaveObj(db,"Updates", "Updates", servers);
     EntitiesFactory.SaveDb(db);
     MessageHelper.ShowInfo("保存成功!");
     RefreshData();
 }
Ejemplo n.º 2
0
        public static void GetLocalFilesInfo(Updates localFiles, DirectoryInfo di)
        {
            FileInfo[] fis = di.GetFiles();
            foreach (FileInfo fi in fis)
            {
                if (".PDB .XML".Contains(fi.Extension.ToUpper()))
                {
                    continue;
                }

                UpdateItem item = new UpdateItem();
                item.FullName   = fi.FullName;
                item.FileName   = GetRelativePath(Application.StartupPath, fi.FullName);
                item.FileSize   = fi.Length;
                item.ModifyDate = fi.LastWriteTime;
                localFiles.Add(item);
            }
            DirectoryInfo[] dis = di.GetDirectories();
            foreach (DirectoryInfo dinfo in dis)
            {
                GetLocalFilesInfo(localFiles, dinfo);
            }
        }