Ejemplo n.º 1
0
        public FrmMain()
        {
            InitializeComponent();
            dgvFiles.AutoGenerateColumns = false;

            Dictionary <string, string> dic = ConfigDA.List();

            txt_version_no_old.Text = dic["client_version_no"];
            txt_version_old.Text    = dic["client_version"];
            txt_version_new.Text    = DateTime.Now.ToString("yyyyMMdd") + "01";

            string            dir       = ConfigurationManager.AppSettings["ClientDir"];
            List <ClientFile> files_old = ClientFileDA.List();
            List <ClientFile> files_new = new List <ClientFile>();

            GetDirectorFiles(dir, ref files_new);

            List <ClientFileCompare> files_compare = files_old.Select(f => new ClientFileCompare()
            {
                name    = f.name,
                size    = f.size,
                time    = f.time,
                version = f.version
            }).ToList();

            foreach (ClientFile fn in files_new)
            {
                fn.name = fn.name.Substring(dir.Length).Replace('\\', '/');

                ClientFileCompare fc = files_compare.Find(f => f.name == fn.name);
                if (fc == null)
                {
                    files_compare.Add(new ClientFileCompare()
                    {
                        name         = fn.name,
                        size_new     = fn.size,
                        time_new     = fn.time,
                        need_upgrade = "是"
                    });
                }
                else
                {
                    fc.size_new     = fn.size;
                    fc.time_new     = fn.time;
                    fc.need_upgrade = fc.time != fc.time_new ? "是" : "否";
                }
            }
            dgvFiles.DataSource = files_compare.OrderByDescending(f => f.need_upgrade).ToList();
            files_upgrade       = files_compare.Where(f => f.time != f.time_new).ToList();
            btnSave.Text       += "\r\n(可发布" + files_upgrade.Count + "个文件)";
        }
Ejemplo n.º 2
0
        public Result <VersionFiles> VersionFiles(int current_version)
        {
            VersionFiles version = new VersionFiles()
            {
                version    = Config.client_version,
                version_no = Config.client_version_no
            };

            if (current_version >= Config.client_version)
            {
                return(Result(ApiResultEnum.LatestVersion, version));
            }

            version.files            = ClientFileDA.List(current_version);
            version.total_file_count = version.files.Count;
            version.total_size       = version.files.Sum(f => f.size);
            return(Result(ApiResultEnum.Success, version));
        }