private void GetFiles(string filePath, ScanMode mode) { try { foreach (string str in System.IO.Directory.GetFiles(filePath)) { System.IO.FileInfo fi = new System.IO.FileInfo(str); if (!this.itemsList.Contains(fi.Extension.ToUpper())) { continue; } if (mode == ScanMode.AnalyseDirectoryStructure) { this.analyseFileCount += 1; UpdateFiles?.Invoke(this.analyseFileCount.ToString()); } else { this.scanFileCount += 1; UpdateFiles?.Invoke(this.scanFileCount + " of " + this.analyseFileCount); UpdateProgress?.Invoke(Convert.ToInt32((this.scanFileCount / (double)this.analyseFileCount) * 100)); ScanFile(str); } } } catch (UnauthorizedAccessException ex) { } }
// ---------------------------------------------------------------------------------------------------- public void CheckAndUpdate(Action onUpdated) { UpdateFiles updateFiles = new UpdateFiles(); updateFiles.onUpdated = onUpdated; //先加载本地的索引 也可以进行自检生成数据后 在和服务器上的索引进行对比 updateFiles.tempLocalInfo = new AssetRecordsInfo(); LoadFile localLoad = updateFiles.tempLocalInfo.GetLoadFile(LoadBehaviour.ContentLoadFromLoacal_WWW, (localLoaded) => { if (isOffLine) { SetUpdateFiles(updateFiles); } else { updateFiles.tempServerInfo = new AssetRecordsInfo(); updateFiles.tempServerLoad = updateFiles.tempServerInfo.GetLoadFile(LoadBehaviour.ContentLoadFromServer_WWW, (serverLoaded) => { SetUpdateFiles(updateFiles); }); LoadFileController.Instance.Load(updateFiles.tempServerLoad); } }); LoadFileController.Instance.Load(localLoad); }
private void SetMainManifest(UpdateFiles updateFiles) { AssetRecordsInfo info = AssetsManager.Instance.RecordsInfo; AssetRecord record = info.GetAssetRecord(RuntimeAssetType.MANIFEST, info.mainManifestFileName); if (record != null) { LoadFile loadFile = record.GetLoadFile(LoadBehaviour.ContentLoadFromLoacal_LoadBundleFile, false, (obj) => { AssetBundle bundle = obj as AssetBundle; AssetsManager.Instance.ABManifest = bundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); }, (loaded) => { //string[] testArray = mainManifest.GetAllAssetBundles(); //var it = testArray.GetEnumerator(); //while (it.MoveNext()) //{ // Debug.Log(it.Current); //} AssetsManager.Instance.IsInitialized = true; Debug.Log("资源以及配置加载完毕!"); if (updateFiles.onUpdated != null) { updateFiles.onUpdated(); } }); LoadFileController.Instance.Load(loadFile); } }
private StringBuilder AddToLog(UpdateFiles fileStruct, string comment) { StringBuilder sb = new StringBuilder(); sb.AppendLine($"<Italic>Устаревший файл:</Italic> <Bold>{fileStruct.Name}</Bold>"); if (!string.IsNullOrEmpty(fileStruct.Comment)) { sb.AppendLine($"<Italic>Последние изменения:</Italic> {comment}"); } sb.AppendLine($"<Bold>Ссылка на новую версию файла:</Bold> {fileStruct.URL}

"); return(sb); }
public async void GetFiles() { HttpClient HttpClient = new HttpClient(); var Request = await HttpClient.GetAsync($"https://launchwares.com/storage/updates/{Utils.UpdateToken}/files.json"); var Response = Request.Content.ReadAsStringAsync().Result; if (Response == null || Response == "") { MessageBox.Show($"{Application.Current.Resources["application.noupdate"]}", $"{Application.Current.Resources["application.title"]}", MessageBoxButton.OK, MessageBoxImage.Warning); Environment.Exit(0); } FilesWillDownload = JsonConvert.DeserializeObject <UpdateFiles>(Response); Download(); }
private void DownloadingOrCheckingFiles(UpdateFiles updateFiles, Action onAllLoaded) { monitor.State = ProgressState.DOWNLOAD; LoadFiles(updateFiles.downloadList, LoadBehaviour.DownloadFile_ResumeBrokenTransfer_HttpWebRequest, isCacheBundleOnDownloading, () => { if (isLoadCheckedFile) { monitor.State = ProgressState.CHECK; LoadFiles(updateFiles.checkedList, LoadBehaviour.ContentLoadFromLoacal_WWW, isCacheBundleOnCheckingLocalFile, onAllLoaded); } else { onAllLoaded(); } }); }
private UpdateFiles GenerateUpdateFiles(string xmlFilePath) { var updateFiles = new UpdateFiles { OfficeEdition = OfficeEdition.Office64Bit }; if (xmlFilePath.Contains("32")) { updateFiles.OfficeEdition = OfficeEdition.Office32Bit; } var xmlDoc = new XmlDocument(); xmlDoc.Load(xmlFilePath); var baseUrlNodes = xmlDoc.SelectNodes("/UpdateFiles/baseURL"); foreach (XmlNode baseUrlNode in baseUrlNodes) { var branch = baseUrlNode.GetAttributeValue("branch"); var url = baseUrlNode.GetAttributeValue("URL"); updateFiles.BaseURL.Add(new baseURL() { Branch = branch, URL = url }); } var fileNodes = xmlDoc.SelectNodes("/UpdateFiles/File"); foreach (XmlNode fileNode in fileNodes) { var name = fileNode.GetAttributeValue("name"); var rename = fileNode.GetAttributeValue("rename"); var relativePath = fileNode.GetAttributeValue("relativePath"); var language = Convert.ToInt32(fileNode.GetAttributeValue("language")); updateFiles.Files.Add(new Model.File() { Name = name, Rename = rename, RelativePath = relativePath, Language = language }); } return(updateFiles); }
private void SetAssetRecordsInfo(UpdateFiles updateFiles) { if (isAllFilesExist && updateFiles.tempServerInfo.Version != 0) { AssetsManager.Instance.RecordsInfo = updateFiles.tempServerInfo; //写入本地索引文件 if (updateFiles.isOverwriteLocalAssetRecordsInfo && updateFiles.tempServerLoad != null) { FileHelper.SaveToFile(updateFiles.tempServerLoad, updateFiles.tempServerInfo.WriteByBinaryWriter); } } else { AssetsManager.Instance.RecordsInfo = updateFiles.tempLocalInfo; } }
// ---------------------------------------------------------------------------------------------------- public void ExecuteUpdate(UpdateFiles updateFiles) { //清空本地资源 ClearAllAssetFiles(); DownloadingOrCheckingFiles(updateFiles, () => { LoadFileController.Instance.ClearHttpWebRequestQueue(); MoveFromTempToLocal(updateFiles.downloadList); DeleteRedundancyFiles(updateFiles.redundancyQueue, () => { updateFiles.downloadList.Clear(); updateFiles.checkedList.Clear(); SetAssetRecordsInfo(updateFiles); SetMainManifest(updateFiles); }); }); }
/// <summary> /// 检查当前版本是否需要更新, /// 如果需要更新返回 /// </summary> /// <param name="pVersion"></param> public string CheckUpdate() { string file = System.AppDomain.CurrentDomain.BaseDirectory + "application.ini"; IniFileHelper ifh = new IniFileHelper(file); bool update = bool.Parse(ifh.IniReadValue("application", "update", "false")); string updateFileUrl = ""; if (update) { string pVersion = ifh.IniReadValue("application", "version", "0.0.0"); string update_server = ifh.IniReadValue("application", "update_server", ""); //1、发起http请求,获取当前的最新版本的版本号码及下载地址 string versionFile = HttpGet(update_server); UpdateFiles files = JsonConvert.DeserializeObject <UpdateFiles>(versionFile); //ID为1的为系统主程序,其他为系统的插件,例如自动更新插件、控制台日志插件、诊间结算插件等,系统支持最小模块运行。即不加载任何插件运行 if (files != null) { foreach (UpdateFile uf in files.Filelist) { if (uf.Id == "1" && pVersion != uf.Version) { try { System.Diagnostics.Process.Start(Global.gAppPath + @"plugins\\updater\\Updater.exe", string.Format("{0} {1} {2} {3}", update_server.Replace("version.json", uf.File), Global.gAppPath, "ScWebBrowser.exe", uf.Version)); } catch (Exception ex) { Global.ShowWarning(ex.Message); } System.Environment.Exit(0); } } } } return(updateFileUrl); }
public async Task DownloadBranch(DownloadBranchProperties properties, CancellationToken token = new CancellationToken()) { var fd = new FileDownloader(); if (properties.Languages == null) { properties.Languages = new List <string>() { "en-us" } } ; if (_updateFiles == null) { for (var t = 1; t <= 20; t++) { try { _updateFiles = await DownloadCabAsync(); break; } catch (Exception ex) { } await Task.Delay(1000, token); } } var selectUpdateFile = new UpdateFiles(); if (properties.OfficeEdition == OfficeEdition.Office32Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); } else if (properties.OfficeEdition == OfficeEdition.Office64Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); } else if (properties.OfficeEdition == OfficeEdition.Both) { var selectUpdateFile32 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); var selectUpdateFile64 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); selectUpdateFile32.Files.AddRange(selectUpdateFile64.Files); selectUpdateFile = selectUpdateFile32; } if (selectUpdateFile == null) { throw (new Exception("Cannot Find Office Files")); } var branch = selectUpdateFile.BaseURL.FirstOrDefault(b => b.Branch.ToLower() == properties.BranchName.ToLower()); var version = properties.Version; if (string.IsNullOrEmpty(properties.Version)) { version = await GetLatestVersionAsync(branch, properties.OfficeEdition); if (VersionDetected != null) { VersionDetected(this, new Events.BuildVersion() { Version = version }); } } var allFiles = new List <Model.File>(); foreach (var language in properties.Languages) { var langCode = language.GetLanguageNumber(); var langfiles = selectUpdateFile.Files.Where(f => f.Language == 0 || f.Language == langCode); foreach (var file in langfiles) { file.Name = Regex.Replace(file.Name, "%version%", version, RegexOptions.IgnoreCase); file.RelativePath = Regex.Replace(file.RelativePath, "%version%", version, RegexOptions.IgnoreCase); file.RemoteUrl = branch.URL + @"/" + file.RelativePath + file.Name; file.FileSize = await fd.GetFileSizeAsync(file.RemoteUrl); allFiles.Add(file); if (token.IsCancellationRequested) { return; } } } allFiles = allFiles.Distinct().ToList(); fd = new FileDownloader(); foreach (var file in allFiles) { file.LocalFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; } double downloadedSize = 0; double totalSize = allFiles.Where(f => !f.Exists).Sum(f => f.FileSize); foreach (var file in allFiles) { var localFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; fd.DownloadFileProgress += (sender, progress) => { if (DownloadFileProgress == null) { return; } if (progress.PercentageComplete == 100.0) { return; } double bytesIn = downloadedSize + progress.BytesRecieved; double percentage = bytesIn / totalSize * 100; if (percentage > 100) { percentage = 100; } DownloadFileProgress(this, new Events.DownloadFileProgress() { BytesRecieved = (long)(downloadedSize + progress.BytesRecieved), PercentageComplete = Math.Truncate(percentage), TotalBytesToRecieve = (long)totalSize }); }; if (file.Exists) { continue; } await fd.DownloadAsync(file.RemoteUrl, localFilePath, token); downloadedSize += file.FileSize; if (token.IsCancellationRequested) { return; } } foreach (var file in allFiles) { var localFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; if (string.IsNullOrEmpty(file.Rename)) { continue; } var fInfo = new FileInfo(localFilePath); File.Copy(localFilePath, fInfo.Directory.FullName + @"\" + file.Rename, true); } double percentageEnd = downloadedSize / totalSize * 100; if (percentageEnd == 99.0) { percentageEnd = 100; } if (DownloadFileProgress != null) { DownloadFileProgress(this, new Events.DownloadFileProgress() { BytesRecieved = (long)(downloadedSize), PercentageComplete = Math.Truncate(percentageEnd), TotalBytesToRecieve = (long)totalSize }); } if (DownloadFileComplete != null) { DownloadFileComplete(this, new Events.DownloadFileProgress() { BytesRecieved = (long)(downloadedSize), PercentageComplete = Math.Truncate(percentageEnd), TotalBytesToRecieve = (long)totalSize }); } }
public Form1() { InitializeComponent(); this.updateFiles = new UpdateFiles(); }
public async Task <bool> ValidateSourceFiles(DownloadBranchProperties properties, CancellationToken token = new CancellationToken()) { var fd = new FileDownloader(); if (properties.Languages == null) { properties.Languages = new List <string>() { "en-us" } } ; if (_updateFiles == null) { for (var t = 1; t <= 20; t++) { try { _updateFiles = await DownloadCabAsync(); break; } catch (Exception ex) { } await Task.Delay(1000, token); } } var selectUpdateFile = new UpdateFiles(); if (properties.OfficeEdition == OfficeEdition.Office32Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); } else if (properties.OfficeEdition == OfficeEdition.Office64Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); } else if (properties.OfficeEdition == OfficeEdition.Both) { var selectUpdateFile32 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); var selectUpdateFile64 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); selectUpdateFile32.Files.AddRange(selectUpdateFile64.Files); selectUpdateFile = selectUpdateFile32; } if (selectUpdateFile == null) { throw (new Exception("Cannot Find Office Files")); } var branch = selectUpdateFile.BaseURL.FirstOrDefault(b => b.Branch.ToLower() == properties.BranchName.ToLower()); var version = properties.Version; if (string.IsNullOrEmpty(properties.Version)) { version = await GetLatestVersionAsync(branch, properties.OfficeEdition); } var allFiles = new List <Model.File>(); foreach (var language in properties.Languages) { var langCode = language.GetLanguageNumber(); var langfiles = selectUpdateFile.Files.Where(f => f.Language == 0 || f.Language == langCode); foreach (var file in langfiles) { file.Name = Regex.Replace(file.Name, "%version%", version, RegexOptions.IgnoreCase); file.RelativePath = Regex.Replace(file.RelativePath, "%version%", version, RegexOptions.IgnoreCase); file.RemoteUrl = branch.URL + @"/" + file.RelativePath + file.Name; file.FileSize = await fd.GetFileSizeAsync(file.RemoteUrl); allFiles.Add(file); } } allFiles = allFiles.Distinct().ToList(); foreach (var file in allFiles) { file.LocalFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; } foreach (var file in allFiles) { var localFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; if (!File.Exists(localFilePath)) { return(false); } } return(true); }
private void SetUpdateFiles(UpdateFiles updateFiles) { if (updateFiles.tempServerInfo.Version != 0) { if (updateFiles.tempLocalInfo.Version != 0) { Debug.Log("1. 本地端与网络端索引文件均已发现,开始进行对比更新!!!"); //对比进行更新 updateFiles.isOverwriteLocalAssetRecordsInfo = !updateFiles.tempLocalInfo.Version.Equals(updateFiles.tempServerInfo.Version) || !updateFiles.tempLocalInfo.LastModifyTime.Equals(updateFiles.tempServerInfo.LastModifyTime); if (updateFiles.isOverwriteLocalAssetRecordsInfo) { Debug.Log("1.1 需要更新~~~~~~"); FileHelper.ActionOnTraversePackingRecordType((type) => { Dictionary <string, AssetRecord> localRecords = updateFiles.tempLocalInfo.GetRecordsDic(type); Dictionary <string, AssetRecord> serverRecords = updateFiles.tempServerInfo.GetRecordsDic(type); updateFiles.SetUpdateByComparingRecords(localRecords, serverRecords, isComparingLocalFile); }); } else { Debug.Log("1.2 不需要更新~~~~~~"); } isClearAll = false; } else { Debug.Log("2. 只发现了网络端的索引文件,进行完全更新"); // 全部更新 更新前情况本地资源文件夹 updateFiles.isOverwriteLocalAssetRecordsInfo = true; updateFiles.tempServerInfo.ActionOnTraverseRecordsDic((kvp) => { updateFiles.SetUpdateByAssetRecord(false, kvp.Value, isComparingLocalFile); }); isClearAll = true; } } else { if (updateFiles.tempLocalInfo.Version != 0) { Debug.Log("3. 只发现了本地端的索引文件,与本地文件映射进行检测"); updateFiles.isOverwriteLocalAssetRecordsInfo = false; updateFiles.tempLocalInfo.ActionOnTraverseRecordsDic((kvp) => { updateFiles.SetUpdateByAssetRecord(true, kvp.Value, isComparingLocalFile); }); isClearAll = false; // 索引文件与本地文件不能一一对应 if (updateFiles.downloadList.Count > 0) { Debug.Log("3.1 索引文件与本地文件不一致,无法开始体验"); // 严重警告界面 或断线重连界面 return; } } else { updateFiles.isOverwriteLocalAssetRecordsInfo = false; Debug.Log("4. 网络端与本地端均未找到索引文件,无法开始体验"); //UIManager.Instance.SetVisible(UIName.UISceneHint, true); //UISceneHint.Instance.ShowNetworkConnectHint(); // 严重警告界面 或断线重连界面 return; } } //updateFiles.PrintInfo(); ExecuteUpdate(updateFiles); }
private UpdateFiles GenerateUpdateFiles(string xmlFilePath) { var updateFiles = new UpdateFiles { OfficeEdition = OfficeEdition.Office64Bit }; if (xmlFilePath.Contains("32")) { updateFiles.OfficeEdition = OfficeEdition.Office32Bit; } var xmlDoc = new XmlDocument(); xmlDoc.Load(xmlFilePath); var baseUrlNodes = xmlDoc.SelectNodes("/UpdateFiles/baseURL"); foreach (XmlNode baseUrlNode in baseUrlNodes) { var branch = baseUrlNode.GetAttributeValue("branch"); var url = baseUrlNode.GetAttributeValue("URL"); updateFiles.BaseURL.Add(new baseURL() { Branch = branch, URL = url }); } var fileNodes = xmlDoc.SelectNodes("/UpdateFiles/File"); foreach (XmlNode fileNode in fileNodes) { var name = fileNode.GetAttributeValue("name"); var rename = fileNode.GetAttributeValue("rename"); var relativePath = fileNode.GetAttributeValue("relativePath"); var language = Convert.ToInt32(fileNode.GetAttributeValue("language")); updateFiles.Files.Add(new Model.File() { Name = name, Rename = rename, RelativePath = relativePath, Language = language }); } return updateFiles; }
public async Task DownloadBranch(DownloadBranchProperties properties, CancellationToken token = new CancellationToken()) { var fd = new FileDownloader(); if (properties.Languages == null) properties.Languages = new List<string>() { "en-us" }; if (_updateFiles == null) { for (var t = 1; t <= 20; t++) { try { _updateFiles = await DownloadCabAsync(); break; } catch (Exception ex) { } await Task.Delay(1000, token); } } var selectUpdateFile = new UpdateFiles(); if (properties.OfficeEdition == OfficeEdition.Office32Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); } else if (properties.OfficeEdition == OfficeEdition.Office64Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); } else if (properties.OfficeEdition == OfficeEdition.Both) { var selectUpdateFile32 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); var selectUpdateFile64 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); selectUpdateFile32.Files.AddRange(selectUpdateFile64.Files); selectUpdateFile = selectUpdateFile32; } if (selectUpdateFile == null) throw (new Exception("Cannot Find Office Files")); var branch = selectUpdateFile.BaseURL.FirstOrDefault(b => b.Branch.ToLower() == properties.BranchName.ToLower()); var version = properties.Version; if (string.IsNullOrEmpty(properties.Version)) { version = await GetLatestVersionAsync(branch, properties.OfficeEdition); if (VersionDetected != null) { VersionDetected(this, new Events.BuildVersion() { Version = version }); } } var allFiles = new List<Model.File>(); foreach (var language in properties.Languages) { var langCode = language.GetLanguageNumber(); var langfiles = selectUpdateFile.Files.Where(f => f.Language == 0 || f.Language == langCode); foreach (var file in langfiles) { file.Name = Regex.Replace(file.Name, "%version%", version, RegexOptions.IgnoreCase); file.RelativePath = Regex.Replace(file.RelativePath, "%version%", version, RegexOptions.IgnoreCase); file.RemoteUrl = branch.URL + @"/" + file.RelativePath + file.Name; file.FileSize = await fd.GetFileSizeAsync(file.RemoteUrl); allFiles.Add(file); if (token.IsCancellationRequested) { return; } } } allFiles = allFiles.Distinct().ToList(); fd = new FileDownloader(); foreach (var file in allFiles) { file.LocalFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; } double downloadedSize = 0; double totalSize = allFiles.Where(f => !f.Exists).Sum(f => f.FileSize); foreach (var file in allFiles) { var localFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; fd.DownloadFileProgress += (sender, progress) => { if (DownloadFileProgress == null) return; if (progress.PercentageComplete == 100.0) return; double bytesIn = downloadedSize + progress.BytesRecieved; double percentage = bytesIn / totalSize * 100; if (percentage > 100) { percentage = 100; } DownloadFileProgress(this, new Events.DownloadFileProgress() { BytesRecieved = (long)(downloadedSize + progress.BytesRecieved), PercentageComplete = Math.Truncate(percentage), TotalBytesToRecieve = (long)totalSize }); }; if (file.Exists) { continue; } await fd.DownloadAsync(file.RemoteUrl, localFilePath, token); downloadedSize += file.FileSize; if (token.IsCancellationRequested) { return; } } foreach (var file in allFiles) { var localFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; if (string.IsNullOrEmpty(file.Rename)) continue; var fInfo = new FileInfo(localFilePath); File.Copy(localFilePath, fInfo.Directory.FullName + @"\" + file.Rename, true); } double percentageEnd = downloadedSize / totalSize * 100; if (percentageEnd == 99.0) percentageEnd = 100; if (DownloadFileProgress != null) { DownloadFileProgress(this, new Events.DownloadFileProgress() { BytesRecieved = (long) (downloadedSize), PercentageComplete = Math.Truncate(percentageEnd), TotalBytesToRecieve = (long) totalSize }); } if (DownloadFileComplete != null) { DownloadFileComplete(this, new Events.DownloadFileProgress() { BytesRecieved = (long) (downloadedSize), PercentageComplete = Math.Truncate(percentageEnd), TotalBytesToRecieve = (long) totalSize }); } }
public async Task<bool> ValidateSourceFiles(DownloadBranchProperties properties, CancellationToken token = new CancellationToken()) { var fd = new FileDownloader(); if (properties.Languages == null) properties.Languages = new List<string>() { "en-us" }; if (_updateFiles == null) { for (var t = 1; t <= 20; t++) { try { _updateFiles = await DownloadCabAsync(); break; } catch (Exception ex) { } await Task.Delay(1000, token); } } var selectUpdateFile = new UpdateFiles(); if (properties.OfficeEdition == OfficeEdition.Office32Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); } else if (properties.OfficeEdition == OfficeEdition.Office64Bit) { selectUpdateFile = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); } else if (properties.OfficeEdition == OfficeEdition.Both) { var selectUpdateFile32 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office32Bit); var selectUpdateFile64 = _updateFiles.FirstOrDefault(u => u.OfficeEdition == OfficeEdition.Office64Bit); selectUpdateFile32.Files.AddRange(selectUpdateFile64.Files); selectUpdateFile = selectUpdateFile32; } if (selectUpdateFile == null) throw (new Exception("Cannot Find Office Files")); var branch = selectUpdateFile.BaseURL.FirstOrDefault(b => b.Branch.ToLower() == properties.BranchName.ToLower()); var version = properties.Version; if (string.IsNullOrEmpty(properties.Version)) { version = await GetLatestVersionAsync(branch, properties.OfficeEdition); } var allFiles = new List<Model.File>(); foreach (var language in properties.Languages) { var langCode = language.GetLanguageNumber(); var langfiles = selectUpdateFile.Files.Where(f => f.Language == 0 || f.Language == langCode); foreach (var file in langfiles) { file.Name = Regex.Replace(file.Name, "%version%", version, RegexOptions.IgnoreCase); file.RelativePath = Regex.Replace(file.RelativePath, "%version%", version, RegexOptions.IgnoreCase); file.RemoteUrl = branch.URL + @"/" + file.RelativePath + file.Name; file.FileSize = await fd.GetFileSizeAsync(file.RemoteUrl); allFiles.Add(file); } } allFiles = allFiles.Distinct().ToList(); foreach (var file in allFiles) { file.LocalFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; } foreach (var file in allFiles) { var localFilePath = properties.TargetDirectory + file.RelativePath.Replace("/", "\\") + file.Name; if (!File.Exists(localFilePath)) { return false; } } return true; }