예제 #1
0
 /// <summary>
 /// 根据版本信息,下载相应版本的Config.xml文件
 /// </summary>
 /// <param name="list"></param>
 protected void DownloadVersion()
 {
     try
     {
         _appUpdate.ServerVersions.Sort();
         int precent = 0;
         int count   = 0;
         int total   = _appUpdate.ServerVersions.Count;
         foreach (Version v in _appUpdate.ServerVersions)
         {
             precent++;
             string serverconfigurl = _appUpdate.LocalVersion.ServerUrl;
             serverconfigurl += serverconfigurl.EndsWith("/") ? v.ValueVersion.ToString() : "/" + v.ValueVersion;
             serverconfigurl += "/Config.xml";
             string localconfigpath = _appUpdate.LocalFileDir;
             localconfigpath += localconfigpath.EndsWith("\\") ? v.ValueVersion.ToString() : "\\" + v.ValueVersion;
             localconfigpath += "\\Config.xml";
             CreateDirtory(localconfigpath);
             _appUpdate.DownloadFile(serverconfigurl, localconfigpath);
             XmlFiles    xmlconfigfile = new XmlFiles(localconfigpath);
             XmlNodeList filenodes     = xmlconfigfile.GetNodeList("//File");
             count += filenodes == null ? 0 : filenodes.Count;
             VersionProgressChanged(precent);
         }
         VersionProgressComplete(count);
     }
     catch (Exception ex)
     {
         ShowMessage("错误:" + ex.Message);
     }
 }
예제 #2
0
        private string serverXmlFile = "http://update.geit.com.cn/UBoardMate/UBoardCamera/update.xml";//服务器XML文档地址(默认中文)
        //获取服务器上的版本号
        public String GetFileNameInfo()
        {
            XmlFiles    serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlNodeList newNodeList    = serverXmlFiles.GetNodeList("UpdateInfo/AppVersion");

            return(newNodeList.Item(0).Value.Trim());
        }
예제 #3
0
        static bool CheckNeedUpdate()
        {
            string   localXmlFile    = Application.StartupPath + "\\UpdateList.xml";
            string   serverXmlFile   = string.Empty;
            string   updateUrl       = string.Empty;
            string   tempUpdatePath  = string.Empty;
            XmlFiles updaterXmlFiles = null;

            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                return(false);
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "UpdateList.xml";

            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Application.StartupPath + "\\update\\";
                //tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";

                if (!appUpdater.DownAutoUpdateFile(tempUpdatePath))
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return(false);
            }
            int availableUpdate = 0;

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            if (availableUpdate > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public async Task <IActionResult> PutXmlFiles(int id, XmlFiles xmlFiles)
        {
            if (id != xmlFiles.Fid)
            {
                return(BadRequest());
            }

            _context.Entry(xmlFiles).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!XmlFilesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <XmlFiles> > PostXmlFiles(XmlFiles xmlFiles)
        {
            _context.XmlFiles.Add(xmlFiles);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetXmlFiles", new { id = xmlFiles.Fid }, xmlFiles));
        }
예제 #6
0
        private void FormView_Load(object sender, System.EventArgs e)
        {
            string strFileName;
            XmlAttributeCollection Attr;

            listViewFiles.Clear();
            listViewFiles.View           = View.List;
            listViewFiles.Scrollable     = true;
            listViewFiles.Sorting        = SortOrder.Ascending;
            listViewFiles.SmallImageList = imageListStatus;
            //first add files from manifest file
            try{
                strFileName = string.Format("{0}\\{1}_{2}_{3}_manifest.xml", m_strDownloadDirectory, m_strCustomerCode, m_strSiteCode, m_strManifestNumber);
                XmlDocument   manifest = new XmlDocument();
                XmlTextReader reader   = new XmlTextReader(strFileName);
                manifest.Load(reader);
                XmlNode filesnode = manifest.SelectSingleNode("/serverDownloadInfo/files");
                foreach (System.Xml.XmlNode XmlFiles in filesnode.ChildNodes)
                {
                    XmlNode PDFFile = XmlFiles.SelectSingleNode("pdfFile");
                    Attr = PDFFile.Attributes;
                    AddFileToListItems(Attr.GetNamedItem("size").Value, Attr.GetNamedItem("formId").Value, ".pdf");
                    XmlNode XfdfFile = XmlFiles.SelectSingleNode("xfdfFile");
                    Attr = XfdfFile.Attributes;
                    AddFileToListItems(Attr.GetNamedItem("size").Value, Attr.GetNamedItem("FormInstanceID").Value, ".xfdf");
                }
            }catch (Exception) {
                MessageBox.Show("No download results are available to show.", "Download Manager");
                this.Close();
            }
        }
예제 #7
0
        public void chkUpd()
        {
            var url = "http://10.4.12.52:8000/Update/PriceTagPrint/UpdateList.xml";

            if (!File.Exists("UpdateList.xml"))
            {
                Common.HttpHelper.HttpDownload(url, AppDomain.CurrentDomain.BaseDirectory);
            }
            var appVer    = new XmlFiles("UpdateList.xml").GetNodeValue("//Version");
            var appNewVer = new XmlFiles(url).GetNodeValue("//Version");

            if (appVer.Trim() != appNewVer.Trim())
            {
                if (MessageBox.Show("有新的更新程序", "系统更新", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return;
                }
                if (!File.Exists("AutoUpdate.exe"))
                {
                    MessageBox.Show("更新程序不存在,请联系管理员!");
                    txbUserPassWd.Enabled = false;
                    return;
                }
                System.Diagnostics.Process.Start("AutoUpdate.exe");
                Process.GetCurrentProcess().Kill();
            }
        }
예제 #8
0
        /*----------display back to the repoStorage menu-----------*/

        private void GetTopMenu(object sender, RoutedEventArgs e)
        {
            Menu.Items.Clear();
            Files.Items.Clear();
            SelectedFiles.Items.Clear();
            XmlFiles.Clear();
            displayMenu();
        }
예제 #9
0
 /// <summary>
 /// Метод переноса файла списка xml на отработку после формирования
 /// </summary>
 /// <param name="pathnew">Путь к сформированым спискам </param>
 public void MoveFile(string pathnew)
 {
     if (System.IO.File.Exists(File.Path))
     {
         System.IO.File.Delete(pathnew + File.Name);
     }
     System.IO.File.Move(File.Path, pathnew + File.Name);
     XmlFiles.Remove(XmlFiles.Single(name => name.Path == File.Path));
 }
예제 #10
0
        /*----------select files to show in the Selected Files listbox-----------*/

        private void Files_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ButtonBuild.IsEnabled = false;
            string fileName = Files.SelectedValue as string;

            if (!SelectedFiles.Items.Contains(fileName))
            {
                SelectedFiles.Items.Add(fileName);
                XmlFiles.Add(fileName);
            }
        }
        public async Task <IActionResult> Create([Bind("Fid,FileName,Xmldata,IsProcessed,ProcessingPercentage,TelegramsCount,CancellationToken")] XmlFiles xmlFiles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(xmlFiles);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(xmlFiles));
        }
예제 #12
0
파일: AppUpdater.cs 프로젝트: chrgu000/DEMO
        /// <summary>
        /// 检查更新文件
        /// </summary>
        /// <param name="serverXmlFile"></param>
        /// <param name="localXmlFile"></param>
        /// <param name="updateFileList"></param>
        /// <returns></returns>
        public int CheckForUpdate(string serverXmlFile, string localXmlFile, out Hashtable updateFileList)
        {
            updateFileList = new Hashtable();
            if (!File.Exists(localXmlFile) || !File.Exists(serverXmlFile))
            {
                return(-1);
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles  = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");

            int k = 0;

            for (int i = 0; i < newNodeList.Count; i++)
            {
                string[] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer      = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for (int j = 0; j < oldNodeList.Count; j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer      = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);
                }
                int pos = oldFileAl.IndexOf(newFileName);
                if (pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k, fileList);
                    k++;
                }
                else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) > 0)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    updateFileList.Add(k, fileList);
                    k++;
                }
            }
            return(k);
        }
예제 #13
0
        public void TestWriteReadCycle()
        {
            data.SetValue(@"test\abc\v1", "v1");
            data.SetValue(@"test\v2", "v2");
            data.SetValue(@"test\zxy\v3", "3");

            XmlFiles xml = new XmlFiles();

            xml.SetData(data);
            xml.WriteData(testFile);
            string xmlString = xml.ToString();

            xml.ReadData(testFile, true);
        }
예제 #14
0
 /// <summary>
 /// Метод добавление в Модель Объектов!!!
 /// </summary>
 /// <param name="path">Путь к файлам</param>
 public void AddXmlFile(string path)
 {
     XmlFiles.Clear();
     lock (Lock)
     {
         var filelogica = new FileLogica();
         Directory.CreateDirectory(path);
         foreach (var file in FileLogica.FileinfoMass(path))
         {
             XmlFiles.Add(new ListViewModelXmlFileGenerateProperty {
                 Icon = filelogica.Extracticonfile(file.FullName), Name = file.Name, Path = file.FullName
             });
         }
     }
 }
예제 #15
0
        /// <summary>
        /// When overridden in a derived class, executes the task.
        /// </summary>
        /// <returns>
        /// true if the task successfully executed; otherwise, false.
        /// </returns>
        public override bool Execute()
        {
            try {
                if (Directory.Exists(IntermediatePath))
                {
                    foreach (var file in new DirectoryInfo(IntermediatePath).GetFiles("*.*", SearchOption.AllDirectories))
                    {
                        file.IsReadOnly = false;
                    }

                    Directory.Delete(IntermediatePath, recursive: true);
                }

                var list  = new List <ITaskItem>();
                var files = ImmutableHashSet.Create <string>(XmlFiles.Select(x => Path.GetFileName(x.ItemSpec)).ToArray());
                foreach (var xmlFile in XmlFiles)
                {
                    var xmlFileInfo = new FileInfo(xmlFile.ItemSpec);
                    var item        = ModifyAndGetNewItem(xmlFileInfo.FullName, xmlFile.GetMetadata("OutputSubPath"), out var newDirectory);
                    list.Add(item);


                    foreach (var extraFile in xmlFileInfo.Directory.GetFiles("*.*", SearchOption.AllDirectories))
                    {
                        if (extraFile.Extension == xmlFileInfo.Extension && files.Contains(extraFile.Name))
                        {
                            ModifyExtraXmlFile(newDirectory, extraFile.FullName);
                        }
                        else
                        {
                            CopyExtraFile(newDirectory, xmlFileInfo.Directory.FullName, extraFile.FullName);
                        }
                    }
                }

                NewXmlFiles = list.ToArray();
            }
            catch (Exception ex) {
                Log.LogErrorFromException(ex);
                return(false);
            }

            Log.LogMessage($"XmlUpdate Wrote: '{Value}'");
            return(true);
        }
예제 #16
0
        /// <summary>
        /// 下载文件列表
        /// </summary>
        protected void DownloadFiles()
        {
            try
            {
                string serverUrl = _appUpdate.LocalVersion.ServerUrl;
                serverUrl += serverUrl.EndsWith("/") ? "" : "/";
                string localDir = _appUpdate.LocalFileDir;
                localDir += localDir.EndsWith("\\") ? "" : "\\";
                foreach (Version v in _appUpdate.ServerVersions)
                {
                    string localconfigpath = localDir;
                    localconfigpath += v.ValueVersion + "\\Config.xml";
                    XmlFiles         xmlconfigfile = new XmlFiles(localconfigpath);
                    XmlNodeList      filenodes     = xmlconfigfile.GetNodeList("//File");
                    List <FileModel> fileList      = new List <FileModel>();
                    foreach (XmlNode node in filenodes)
                    {
                        FileModel model = new FileModel();
                        model.FileName     = Path.GetFileName(node.Attributes["Name"].Value);
                        model.FileUri      = serverUrl + v.ValueVersion + "/" + node.Attributes["Name"].Value;
                        model.TempPath     = localDir + v.ValueVersion + "\\" + node.Attributes["Name"].Value.Replace("/", "\\");
                        model.FileVersion  = v.StrVersion;
                        model.VersionValue = v.ValueVersion;
                        fileList.Add(model);
                    }

                    DownloadFiles(v, fileList);

                    string localVersionDir = localDir;
                    localVersionDir += localVersionDir.EndsWith("\\") ? v.ValueVersion.ToString() : "\\" + v.ValueVersion;
                    if (CheckMainAppIsRun())
                    {
                        KillMainApp();
                    }
                    CopyFile(localVersionDir, Application.StartupPath);
                    UpdateLocalXml(v.StrVersion, v.ValueVersion.ToString());
                }

                _appUpdate.StartMainAppExe(_appUpdate.LocalVersion.EntryPoint);
            }
            catch (Exception ex)
            {
                LogHelper.WriteException(ex);
            }
        }
예제 #17
0
        public static bool IsNeedUpdate()
        {
            bool result = false;

            try
            {
                string   FileName = Application.StartupPath + "\\UpdateList.xml";
                XmlFiles xdoc     = new XmlFiles(FileName);
                string   version  = xdoc.GetNodeValue("AutoUpdate/Application/Version");
                result = systemMg.IsNeedUpdate(Models.SqlHelper.Session._SystemId, version);
            }
            catch (Exception ex)
            {
                clsPublic.ShowMessage(ex.Message);
                result = false;
            }
            return(result);
        }
예제 #18
0
 public GetTokenReturn()
 {
     if (File.Exists(xmlFileName))
     {
         xmlFile       = new XmlFiles(xmlFileName);
         id            = xmlFile.FindNode("GetTokenReturn/id").InnerText;
         access_token  = xmlFile.FindNode("GetTokenReturn/access_token").InnerText;
         issued_at     = xmlFile.FindNode("GetTokenReturn/issued_at").InnerText;
         token_type    = xmlFile.FindNode("GetTokenReturn/token_type").InnerText;
         refresh_token = xmlFile.FindNode("GetTokenReturn/refresh_token").InnerText;
     }
     else
     {
         //Directory.CreateDirectory("XmlModel");
         //FileStream NewText = File.Create(xmlFileName);
         //NewText.Close();
         //Directory.CreateDirectory(xmlFileName);
         File.Create(xmlFileName);
         //xmlFile = new XmlFiles(xmlFileName);
     }
 }
예제 #19
0
 public override void LoadData(object data)
 {
     ClearData();
     foreach (var resView in ((ResourcesWorkspaceViewModel)data).Resources)
     {
         switch (resView.Resource.ResourceType)
         {
         // TRN~ abu_dhabi.erp is JPK file
         case "ActorSceneData":
         case "AISplineData":
         case "AIBrakeSettings":
         case "CrowdAnimation":
         case "CrowdConfig":
         case "CrowdLODs":
         case "CrowdPalette":
         case "CrowdPrpPalette":
         case "ECA~":
         case "FFBD":
         case "IBLConfig":
         case "PPRP":
         case "PracticeTA":
         case "RainfallData":
         case "Sequence":
         case "SkidmarksData":
         case "Spline":
         case "SURF":
         case "TimeOfDayConfig":
         case "TM":
         case "TrackInfoData":
         case "TrackSpace":
         case "TS":
         case "VCMPD":
         case "VTF":
             XmlFiles.Add(new ErpXmlFileViewModel((ErpResourceViewModel)resView));
             break;
         }
     }
     DisplayName = "XML Files " + xmlFiles.Count;
 }
 public override void LoadData(object data)
 {
     ClearData();
     foreach (var resView in ((ResourcesWorkspaceViewModel)data).Resources)
     {
         var resource = resView.Resource;
         foreach (var fragment in resource.Fragments)
         {
             try
             {
                 using var ds = fragment.GetDecompressDataStream(true);
                 if (XmlFile.IsXmlFile(ds))
                 {
                     XmlFiles.Add(new ErpXmlFileViewModel(resView, fragment));
                 }
             }
             catch
             {
                 // TODO: log
             }
         }
     }
     DisplayName = "XML Files " + xmlFiles.Count;
 }
예제 #21
0
        /*----------clear the listed files in the Selected Files listbox-----------*/

        private void ClearSelectedFiles(object sender, RoutedEventArgs e)
        {
            SelectedFiles.Items.Clear();
            XmlFiles.Clear();
        }
예제 #22
0
        public void LoadTypesMembers(Type t, bool forceReload)
        {
            if (!forceReload && t.Members.Count > 0)
            {
                return;
            }

            FileInfo typeXmlFile = XmlFiles.Find(
                file => file.Name.Remove(file.Name.LastIndexOf(file.Extension)) == t.ID);

            if (typeXmlFile == null || !typeXmlFile.Exists)
            {
                return;
            }

            XmlDocument typeDoc = new XmlDocument();

            typeDoc.Load(typeXmlFile.FullName);

            t.Description = typeDoc.SelectSingleNode("/doxygen/compounddef/detaileddescription").InnerXml.Replace("preformatted", "pre");

            XmlNodeList baseTypes = typeDoc.SelectNodes("/doxygen/compounddef/basecompoundref");

            if (baseTypes != null)
            {
                foreach (XmlNode baseType in baseTypes)
                {
                    t.BaseTypes.Add(baseType.Attributes["refid"].Value);
                }
            }

            XmlNodeList members = typeDoc.SelectNodes("/doxygen/compounddef/sectiondef/memberdef");

            if (members == null)
            {
                return;
            }

            foreach (XmlNode member in members)
            {
                string kind = member.Attributes["kind"].Value;
                string name = GetElementInnerText(member, "name");
                string args = GetElementInnerText(member, "argsstring").Replace("(", "").Replace(")", "").Trim();

                List <Parameter> parameters = new List <Parameter>();

                if (!string.IsNullOrEmpty(args) && kind == "function")
                {
                    string[] argsSplits = args.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string arg in argsSplits)
                    {
                        string[]  argParts = arg.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        Parameter p        = new Parameter {
                            Type = argParts[0].Trim(), Name = argParts[1].Trim()
                        };
                        parameters.Add(p);
                    }
                }

                if (kind == "function" && name == t.Name)
                {
                    kind = "ctor";
                }

                Member m = CreateNewMember(kind);

                if (parameters.Count > 0)
                {
                    ((Method)m).Parameters = parameters;
                }

                m.ID             = member.Attributes["id"].Value;
                m.FullName       = string.Format("{0}.{1}", t.FullName, name);
                m.Name           = name;
                m.Kind           = kind;
                m.Description    = GetElementInnerXml(member, "detaileddescription").Replace("preformatted", "pre");
                m.AccessModifier = member.Attributes["prot"].Value;
                m.Parent         = t;
                m.ReturnType     = GetElementInnerText(member, "type");
                if (m.ReturnType.EndsWith("."))
                {
                    m.ReturnType += m.Name;
                }
                t.Members.Add(m);
            }
        }
예제 #23
0
파일: AppUpdater.cs 프로젝트: chrgu000/DEMO
        /// <summary>
        /// 检查更新文件
        /// </summary>
        /// <param name="serverXmlFile"></param>
        /// <param name="localXmlFile"></param>
        /// <param name="updateFileList"></param>
        /// <returns></returns>
        public int CheckForUpdate()
        {
            string localXmlFile = Application.StartupPath + "\\UpdateList.xml";

            if (!File.Exists(localXmlFile))
            {
                return(-1);
            }

            XmlFiles updaterXmlFiles = new XmlFiles(localXmlFile);


            string tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";

            this.UpdaterUrl = updaterXmlFiles.GetNodeValue("//Url") + "/UpdateList.xml";
            this.DownAutoUpdateFile(tempUpdatePath);

            string serverXmlFile = tempUpdatePath + "\\UpdateList.xml";

            if (!File.Exists(serverXmlFile))
            {
                return(-1);
            }

            XmlFiles serverXmlFiles = new XmlFiles(serverXmlFile);
            XmlFiles localXmlFiles  = new XmlFiles(localXmlFile);

            XmlNodeList newNodeList = serverXmlFiles.GetNodeList("AutoUpdater/Files");
            XmlNodeList oldNodeList = localXmlFiles.GetNodeList("AutoUpdater/Files");

            int k = 0;

            for (int i = 0; i < newNodeList.Count; i++)
            {
                string[] fileList = new string[3];

                string newFileName = newNodeList.Item(i).Attributes["Name"].Value.Trim();
                string newVer      = newNodeList.Item(i).Attributes["Ver"].Value.Trim();

                ArrayList oldFileAl = new ArrayList();
                for (int j = 0; j < oldNodeList.Count; j++)
                {
                    string oldFileName = oldNodeList.Item(j).Attributes["Name"].Value.Trim();
                    string oldVer      = oldNodeList.Item(j).Attributes["Ver"].Value.Trim();

                    oldFileAl.Add(oldFileName);
                    oldFileAl.Add(oldVer);
                }
                int pos = oldFileAl.IndexOf(newFileName);
                if (pos == -1)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }
                else if (pos > -1 && newVer.CompareTo(oldFileAl[pos + 1].ToString()) > 0)
                {
                    fileList[0] = newFileName;
                    fileList[1] = newVer;
                    k++;
                }
            }
            return(k);
        }
예제 #24
0
파일: UpdateForm.cs 프로젝트: qwdingyu/C-
        private void UpdateForm_Load(object sender, EventArgs e)
        {
            string localXmlFile = string.Empty;

            //商业版与免费版区分
            if (Settings.Default.AuthorityUrl.Equals(@"\Template\Authority.XML"))
            {
                localXmlFile = Utils.installPath + "\\UpdateList_Ent.xml";
            }
            else
            {
                localXmlFile = Utils.installPath + "\\UpdateList.xml";
            }
            string serverXmlFile = string.Empty;

            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                MessageBox.Show("配置文件出错!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取服务器地址
            AppUpdater appUpdater = new AppUpdater();

            try
            {
                updateUrl = updaterXmlFiles.GetNodeValue("//Url");
                //商业版与免费版区分
                if (Settings.Default.AuthorityUrl.Equals(@"\Template\Authority.XML"))
                {
                    appUpdater.UpdaterUrl = updateUrl + "/UpdateList_Ent.xml";
                }
                else
                {
                    appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("获取服务器地址失败,失败原因为:" + ex.Message);
                this.Close();
                return;
            }


            //与服务器连接,下载更新配置文件
            try
            {
                string strTime = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff");
                //tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + strTime + "\\";
                tempUpdatePath = String.Format("{0}\\TempUpdate\\_{1}_{2}\\", Directory.GetCurrentDirectory(), updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value, strTime);
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                MessageBox.Show("与服务器连接失败,操作超时!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
                return;
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            try
            {
                //商业版与免费版区分
                if (Settings.Default.AuthorityUrl.Equals(@"\Template\Authority.XML"))
                {
                    serverXmlFile = tempUpdatePath + "\\UpdateList_Ent.xml";
                }
                else
                {
                    serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
                }
                if (!File.Exists(serverXmlFile))
                {
                    return;
                }

                availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
                if (availableUpdate > 0)
                {
                    for (int i = 0; i < htUpdateFile.Count; i++)
                    {
                        string[] fileArray = (string[])htUpdateFile[i];
                        lvUpdateList.Items.Add(new ListViewItem(fileArray));
                    }
                }
                else
                {
                    System.IO.Directory.Delete(tempUpdatePath, true);
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("更新文件列表更新失败,失败原因为:" + ex.Message);
            }
        }
예제 #25
0
        private void FrmUpdate_Load(object sender, System.EventArgs e)
        {
            string currentDirectory =Environment.CurrentDirectory ;
            if(!AppConst.GetConfig())
            {
                MessageBox.Show("配置文件读取失败!请确定配置文件放在"+currentDirectory+"该目录下");
                return;
            }
            panel2.Visible = false;
            btnFinish.Visible = false;

            string localXmlFile = currentDirectory + "\\UpdateList.xml";
            string serverXmlFile = string.Empty;

            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile );
            }
            catch
            {
                MessageBox.Show("配置文件出错!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
                this.Close();
                return;
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();
            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml" + url_postfix;

            //与服务器连接,下载更新配置文件
            try
            {
                //临时更新文件目录
                tempUpdatePath = currentDirectory+"\\"+AppConst.TempFilePath;
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                MessageBox.Show("与服务器连接失败,操作超时!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
                this.Close();
                return;

            }

            //获取更新文件列表
            htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if(!File.Exists(serverXmlFile))
            {
                return;
            }

            availableUpdate = appUpdater.CheckForUpdate(serverXmlFile,localXmlFile,out htUpdateFile);
            if (availableUpdate > 0)
            {
                for(int i=0;i<htUpdateFile.Count;i++)
                {
                    string [] fileArray =(string []) htUpdateFile[i];
                    lvUpdateList.Items.Add(new ListViewItem(fileArray));
                }
            }
        }
예제 #26
0
        public bool IsUpdate()
        {
            string   updateUrl       = string.Empty;
            string   tempUpdatePath  = string.Empty;
            XmlFiles updaterXmlFiles = null;
            int      availableUpdate = 0;

            string localXmlFile  = AppDomain.CurrentDomain.BaseDirectory + "UpdateList.xml";
            string serverXmlFile = string.Empty;

            if (!File.Exists(localXmlFile))
            {
                MessageBox.Show("配置文件不存在!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            try
            {
                //从本地读取更新配置文件信息
                updaterXmlFiles = new XmlFiles(localXmlFile);
            }
            catch
            {
                MessageBox.Show("配置文件出错!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
                //this.Close();
                return(false);
            }
            //获取服务器地址
            updateUrl = updaterXmlFiles.GetNodeValue("//Url");

            AppUpdater appUpdater = new AppUpdater();

            appUpdater.UpdaterUrl = updateUrl + "/UpdateList.xml";

            //与服务器连接,下载更新配置文件
            try
            {
                tempUpdatePath = Environment.GetEnvironmentVariable("Temp") + "\\" + "_" + updaterXmlFiles.FindNode("//Application").Attributes["applicationId"].Value + "_" + "y" + "_" + "x" + "_" + "m" + "_" + "\\";
                appUpdater.DownAutoUpdateFile(tempUpdatePath);
            }
            catch
            {
                MessageBox.Show("与更新服务器连接失败,操作超时!", "程序更新提示", MessageBoxButton.OK, MessageBoxImage.Information);
                //this.Close();
                return(false);
            }

            //获取更新文件列表
            Hashtable htUpdateFile = new Hashtable();

            serverXmlFile = tempUpdatePath + "\\UpdateList.xml";
            if (!File.Exists(serverXmlFile))
            {
                return(false);
            }
            try
            {
                availableUpdate = appUpdater.CheckForUpdate(serverXmlFile, localXmlFile, out htUpdateFile);
            }
            catch
            {
                MessageBox.Show("服务器配置文件格式错误", "程序更新提示", MessageBoxButton.OK, MessageBoxImage.Information);
                return(false);
            }
            if (availableUpdate > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }