Beispiel #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();
 }
Beispiel #2
0
        private void RefreshData()
        {
            locals.Clear();
            UpdateControl.GetLocalFilesInfo(locals, new System.IO.DirectoryInfo(Application.StartupPath));

            servers = UpdateControl.GetServerFilesInfo();
            if (servers == null)
            {
                servers = new Updates();
            }
            gr = new Updates.grdRecord[locals.Count];
            for (int i = 0; i < locals.Count; i++)
            {
                gr[i] = new Updates.grdRecord(locals[i].FileName, locals[i].ModifyDate.ToString(), "", locals[i].FileSize.ToString(), "", locals[i].FullName);
            }
            foreach (UpdateItem item in servers)
            {
                for (int i = 0; i < gr.Length; i++)
                {
                    if (gr[i].FileName == item.FileName)
                    {
                        gr[i].sFileSize = item.FileSize.ToString();
                        gr[i].sModifyDate = item.ModifyDate.ToString();
                        break;
                    }
                }
            }
            for (int i = 0; i < gr.Length; i++)
            {
                if (gr[i].sFileSize == "" || gr[i].sModifyDate == "" || DateTime.Parse(gr[i].sModifyDate) < DateTime.Parse(gr[i].lModifyDate))
                {
                    gr[i].Check = true;
                }
                if (gr[i].FileName.ToUpper() == System.IO.Path.GetFileName(Application.ExecutablePath).ToUpper())
                {
                    gr[i].Check = true;
                }
            }
            grid.PrimaryGrid.DataSource = gr;
        }