Example #1
0
        static int Main(string[] args)
        {
            var options   = new CommandParameters();
            var parser    = new Parser();
            int errorCode = 0x0;

            if (parser.ParseArguments(args, options))
            {
                var location = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (!options.SkipNetworkUpdate)
                {
                    AutoUpdateOptions update = AutoUpdateHelper.CreateAutoUpdateOptions();
                    update.Path    = string.Format("{0}.{1}.{2}", VersionInfo.Major, VersionInfo.Minor, VersionInfo.Build);
                    update.ShowAll = options.ShowAll;
                    if (!AutoUpdateHelper.Publish(update, location, options.PublishPath))
                    {
                        errorCode |= 0x1;
                    }
                }
                if (!options.SkipGalleryUpdate)
                {
                    if (!AutoUpdateHelper.PublishToGallery(location))
                    {
                        errorCode |= 0x2;
                    }
                }
            }
            else
            {
                errorCode = 0x4;
            }
            return(errorCode);
        }
Example #2
0
        private List <CompareFileEntity> GetNeedUpdateFileList()
        {
            //获取本地版本与服务器差异
            List <FileEntity> localfelist = new List <FileEntity>();
            DirectoryInfo     dic         = new DirectoryInfo(Application.StartupPath);

            AutoUpdateHelper.GetChildFile(dic, localfelist, "/");

            List <FileEntity> serverfelist = new List <FileEntity>();

            AutoUpdateSvc.FileEntity[] sflist = updatesvc.GetServerFileList();
            foreach (var item in sflist)
            {
                serverfelist.Add(ConvertToFileEntity(item));
            }


            List <FileEntity> ignorefelist = new List <FileEntity>();

            AutoUpdateSvc.FileEntity[] iglist = updatesvc.GetIgnoreFileList();
            foreach (var item in iglist)
            {
                ignorefelist.Add(ConvertToFileEntity(item));
            }

            List <CompareFileEntity> comlist = new List <CompareFileEntity>();

            comlist = AutoUpdateHelper.GetUpdateFileList(serverfelist, localfelist, ignorefelist);


            return(comlist);
        }
Example #3
0
        public List <FileEntity> GetServerFileList()
        {
            List <FileEntity> felist = new List <FileEntity>();
            DirectoryInfo     dic    = new DirectoryInfo(Server.MapPath("~/") + "ServerFiles/");

            AutoUpdateHelper.GetChildFile(dic, felist, "/");
            return(felist);
        }
 void UpdateMenuOnClick(object sender, EventArgs e)
 {
     if (UpdateOptions == null)
     {
         return;
     }
     AutoUpdateHelper.Update(UpdateOptions, Options.AutoUpdaterPath);
 }
        public void GenerateDefault()
        {
            devExpressMenu = new VSDevExpressMenu(dte);
            rootMenuHierarchy[string.Empty] = devExpressMenu;
            string wizardMenuText           = "Show tool window";
            VsDevExpressMenuItem wizardMenu = devExpressMenu.CreateOrGetItem(wizardMenuText);

            wizardMenu.Click += WizardMenuClick;
            var portWindowCommand = dte.Commands.Cast <Command>().FirstOrDefault(x => x.Name == "View.DXVcsToolsportwindow");

            wizardMenu.Shortcut = GetShortcutText(portWindowCommand);

            string blameMenuText           = "Show blame window";
            VsDevExpressMenuItem blameMenu = devExpressMenu.CreateOrGetItem(blameMenuText);

            blameMenu.Click += BlameMenuClick;
            var blameWindowCommand = dte.Commands.Cast <Command>().FirstOrDefault(x => x.Name == "View.DXVcsToolsblamewindow");

            blameMenu.Shortcut = GetShortcutText(blameWindowCommand);

            if (Options.UseNavigateMenu)
            {
                VsDevExpressMenuItem navigateMenu = devExpressMenu.CreateOrGetItem("Configure navigate menu...");
                navigateMenu.Click += NavigateMenuClick;
            }
            VsDevExpressMenuItem settingsMenu = devExpressMenu.CreateOrGetItem("Settings...");

            settingsMenu.Click += SettingsMenuOnClick;

            if (Options.ConfigVersion < VersionInfo.ToIntVersion())
            {
                VsDevExpressMenuItem resetConfigMenu = devExpressMenu.CreateOrGetItem(resetConfigHeader);
                resetConfigMenu.Click += ResetConfigMenuOnClick;
            }

            if (Options.EnableAutoUpdate)
            {
                VsDevExpressMenuItem updateMenu = devExpressMenu.CreateOrGetItem(updateHeader);
                updateMenu.Click      += UpdateMenuOnClick;
                updateMenu.Enabled     = false;
                updateMenu.IsSeparator = true;
                updateMenu.Icon        = Image.FromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("DXVcsTools.Resources.Update.png"));
                UpdateOptions          = null;
                BackgroundHelper.DoInBackground(
                    () => UpdateOptions      = AutoUpdateHelper.GetUpdateOptions(Options.AutoUpdaterPath),
                    () => updateMenu.Enabled = UpdateOptions.Return(x => x.Version > VersionInfo.ToIntVersion(), () => false));
            }
        }
Example #6
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            btnUpdate.Enabled = false;

            string path        = Application.StartupPath;
            string temppath    = path + "/Temp";
            string downloadurl = updatesvc.GetDownLoadLink();

            //新建Temp文件夹
            if (!Directory.Exists(temppath))
            {
                Directory.CreateDirectory(temppath);
            }

            List <CompareFileEntity> comlist = GetNeedUpdateFileList();

            pgbCurrentFile.Maximum = comlist.Count * 2;
            int n = 1;

            //下载所有文件
            lblCurrentFile.Text = "开始下载所有文件!";
            foreach (var item in comlist)
            {
                pgbCurrentFile.Value = n++;
                lblCurrentFile.Text  = "正在下载:" + item.FilePath + item.FileName;
                AutoUpdateHelper.DownLoadSingleFile(downloadurl, item.FilePath, item.FileName, temppath);
                lblCurrentFile.Text = "完成:" + item.FilePath + item.FileName;
            }

            lblCurrentFile.Text = "开始更新所有文件!";
            //更新所有文件
            foreach (var item in comlist)
            {
                pgbCurrentFile.Value = n++;
                lblCurrentFile.Text  = "正在更新:" + item.FilePath + item.FileName;
                try
                {
                    AutoUpdateHelper.UpdateTempSingleFile(item, temppath, path);
                }
                catch (Exception ex)
                {
                    lblCurrentFile.Text = ex.Message;
                }
                lblCurrentFile.Text = "完成:" + item.FilePath + item.FileName;
            }

            //删除Temp文件夹
            lblCurrentFile.Text = "开始清除缓存!";
            if (Directory.Exists(temppath))
            {
                lblCurrentFile.Text = "正在删除临时文件";
                try
                {
                    AutoUpdateHelper.DeleteDirectory(temppath);
                }
                catch (Exception ex)
                {
                    lblCurrentFile.Text = ex.Message;
                }
            }

            dgvUpdateFileList.DataSource = ConvertUpdateListToDataTable(GetNeedUpdateFileList());
            lblCurrentFile.Text          = "修改本地版本号!";
            SetClientVersion(updatesvc.GetServerVersion());
            lblCurrentFile.Text = "更新完成!";

            MessageBox.Show("更新完成!");
            //重新加载
        }