zoukankan      html  css  js  c++  java
  • Winform版本发布更新

    版本发布:

    一、局域网共享文件方式

    发布界面:

    QQ截图20150314154855

    更新界面:

    QQ截图20150314155104

    二、FTP方式

    发布界面

    QQ截图20150314155004

    更新界面:

    QQ截图20150314155246

    (只会更新有变动的文件)
    同步新增,替换与删除
    实现方式XML(文件名+文件最后修改时间)
    状态判断:LINQ(通过对比本地XML和服务器XML的不同)

     

    XML实质是一张DataSet

    包含两张表

    #region 获得数据集结构
            /// <summary>
            /// 获得数据集结构
            /// </summary>
            /// <returns></returns>
            protected DataSet GenerateDataSchema()
            {
                DataTable dtV = new DataTable(DataSchema.VersionSchema.TableName);
                dtV.Columns.Add(DataSchema.VersionSchema.Version);
    
    
                DataTable dtD = new DataTable(DataSchema.DetailSchema.TableName);
                dtD.Columns.Add(DataSchema.DetailSchema.Name, typeof(System.String));//名称
                dtD.Columns.Add(DataSchema.DetailSchema.EditDate, typeof(System.DateTime));//修改时间
                dtD.Columns.Add(DataSchema.DetailSchema.Size, typeof(System.String));//大小
                dtD.Columns.Add(DataSchema.DetailSchema.Path, typeof(System.String));//路径
    
    
                DataSet ds = new DataSet();
    
                ds.Tables.Add(dtV);
                ds.Tables.Add(dtD);
    
                return ds;
            }
            #endregion

     

    LINQ服务器和本地对比代码:

    版本发布:

    //需要新增的
                //需要删除的
                //需要替换的
    
                var DataEdit = from dtLocation in LocalDetailFiles.AsEnumerable()
                               join dtServer in ServerDetailFiles.AsEnumerable()
                               on dtLocation.Field<string>(DataSchema.DetailSchema.Path) + dtLocation.Field<string>(DataSchema.DetailSchema.Name) equals
                                  dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name)
                               where dtLocation.Field<DateTime>(DataSchema.DetailSchema.EditDate) > dtServer.Field<DateTime>(DataSchema.DetailSchema.EditDate)
                               select new
                               {
                                   Name = dtLocation.Field<string>(DataSchema.DetailSchema.Name),
                                   Path = dtLocation.Field<string>(DataSchema.DetailSchema.Path)
                               };
                var DataAdd = from dtLocal in LocalDetailFiles.AsEnumerable()
                              where !ServerDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtLocal.Field<string>(DataSchema.DetailSchema.Path) + dtLocal.Field<string>(DataSchema.DetailSchema.Name))
                              select new
                              {
                                  Name = dtLocal.Field<string>(DataSchema.DetailSchema.Name),
                                  Path = dtLocal.Field<string>(DataSchema.DetailSchema.Path)
                              };
                var DataDelete = from dtServer in ServerDetailFiles.AsEnumerable()
                                 where !LocalDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name))
                                 select new
                                 {
                                     Name = dtServer.Field<string>(DataSchema.DetailSchema.Name),
                                     Path = dtServer.Field<string>(DataSchema.DetailSchema.Path)
                                 };
    
                dtUpdateFiles = new DataTable();
                dtUpdateFiles.Columns.Add("Name", typeof(System.String));
                dtUpdateFiles.Columns.Add("Path", typeof(System.String));
                dtUpdateFiles.Columns.Add("Type", typeof(System.String));
    
                foreach (var v in DataAdd)
                {
                    DataRow dr = dtUpdateFiles.Rows.Add();
                    dr["Type"] = "1";
                    dr["Name"] = v.Name;
                    dr["Path"] = v.Path;
    
                    //ListViewItem item = new ListViewItem("新增");
                    //item.SubItems.Add(v.Name);//文件名
                    //item.SubItems.Add(v.Path);//路径
                    //LVFile.Items.Add(item);
                }
                foreach (var v in DataEdit)
                {
                    DataRow dr = dtUpdateFiles.Rows.Add();
                    dr["Type"] = "2";
                    dr["Name"] = v.Name;
                    dr["Path"] = v.Path;
    
                    //ListViewItem item = new ListViewItem("替换");
                    //item.SubItems.Add(v.Name);//文件名
                    //item.SubItems.Add(v.Path);//路径
                    //LVFile.Items.Add(item);
                }
                foreach (var v in DataDelete)
                {
                    DataRow dr = dtUpdateFiles.Rows.Add();
                    dr["Type"] = "3";
                    dr["Name"] = v.Name;
                    dr["Path"] = v.Path;
    
                    //ListViewItem item = new ListViewItem("删除");
                    //item.SubItems.Add(v.Name);//文件名
                    //item.SubItems.Add(v.Path);//路径
                    //LVFile.Items.Add(item);
                }

    版本更新:

    //需要新增的
                //需要删除的
                //需要替换的
    
                var DataEdit = from dtServer in ServerDetailFiles.AsEnumerable()
                               join dtLocation in LocalDetailFiles.AsEnumerable()
                               on dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name) equals
                                    dtLocation.Field<string>(DataSchema.DetailSchema.Path) + dtLocation.Field<string>(DataSchema.DetailSchema.Name)
                               where dtServer.Field<DateTime>(DataSchema.DetailSchema.EditDate) > dtLocation.Field<DateTime>(DataSchema.DetailSchema.EditDate)
                               select new
                               {
                                   Name = dtServer.Field<string>(DataSchema.DetailSchema.Name),
                                   Path = dtServer.Field<string>(DataSchema.DetailSchema.Path)
                               };
                var DataAdd = from dtServer in ServerDetailFiles.AsEnumerable()
                              where !LocalDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtServer.Field<string>(DataSchema.DetailSchema.Path) + dtServer.Field<string>(DataSchema.DetailSchema.Name))
                              select new
                              {
                                  Name = dtServer.Field<string>(DataSchema.DetailSchema.Name),
                                  Path = dtServer.Field<string>(DataSchema.DetailSchema.Path)
                              };
                var DataDelete = from dtLocation in LocalDetailFiles.AsEnumerable()
                                 where !ServerDetailFiles.AsEnumerable().Any(y => y.Field<string>(DataSchema.DetailSchema.Path) + y.Field<string>(DataSchema.DetailSchema.Name) == dtLocation.Field<string>(DataSchema.DetailSchema.Path) + dtLocation.Field<string>(DataSchema.DetailSchema.Name))
                                 select new
                                 {
                                     Name = dtLocation.Field<string>(DataSchema.DetailSchema.Name),
                                     Path = dtLocation.Field<string>(DataSchema.DetailSchema.Path)
                                 };

    慎于行,敏于思!GGGGGG
  • 相关阅读:
    web基础(Myeclipse、IDEA新建Servlet工程)
    web基础(myeclipse新建web工程、tomcat服务器)
    http协议(http请求、响应、抓包、get和post请求)
    jsp(简介、脚本和注释、运行原理)
    类与对象(类、对象、对象的比较)
    变量(成员变量、局部变量)、堆栈
    目录的基本操作
    目录切换命令
    数组(一维数组、二维数组、与数组相关的函数)
    流程控制(顺序结构、条件语句、选择语句、循环语句)
  • 原文地址:https://www.cnblogs.com/GarsonZhang/p/4337870.html
Copyright © 2011-2022 走看看