public void WhenIProcessTheFile() { ImageMemoryStream.Seek(0, SeekOrigin.Begin); const string classifierConfigFile = "svm_config.xml"; //Arrange var handler = new ImageRatingHandler { Parameters = new WorkItemBase.WorkItemParameters { RuntimeData = new Dictionary <string, string> { { "ExhibitId", ExhibitId.ToString(CultureInfo.InvariantCulture) }, { "FileId", FileId.ToString(CultureInfo.InvariantCulture) }, { "FileCategoryId", CategoryId.ToString(CultureInfo.InvariantCulture) }, { "ClassifierConfigFile", Path.GetFullPath(classifierConfigFile) } } }, WorkItemDataStream = ImageMemoryStream }; //Act using (new Performance("ImageRating")) { HandlerOutcome = handler.Execute(); } }
public void CreateOrAppend(FileId id, System.IO.Stream stream) { _OssClient.AppendObject(new AppendObjectRequest(_BucketName, id.ToString()) { Content = stream }); }
/// <nodoc/> public string ToString(bool verbose) { return(verbose ? $"Path: {FullFilePath}{Environment.NewLine}" + $"{string.Join(Environment.NewLine, DebugEntries.Select(a => $" BlobId:{a.BlobIdentifier} - ClientKey:{a.ClientKey} - InfoLevel:{a.InformationLevel}"))}" : FileId.ToString(m_file)); }
public Stream GetFile(FileId id) { try { var obj = _OssClient.GetObject(_BucketName, id.ToString()); if (!obj.Metadata.UserMetadata.ContainsKey("Expires") || String.IsNullOrWhiteSpace(obj.Metadata.UserMetadata["Expires"])) { return(obj.Content); } var expirationTime = obj.Metadata.UserMetadata["Expires"].To <DateTime>(); if (expirationTime > DateTime.Now) { return(obj.Content); } else { Delete(id); return(null); } } catch (ServiceException ex) { if (ex.ErrorCode == "NoSuchKey") { return(null); } else { throw new Exception("aliyun error:" + ex.ErrorCode + ";message:" + ex.ToString()); } } }
public void TestValidFileId(int pathId, int rewriteCount) { var file = new FileArtifact(new AbsolutePath(pathId), rewriteCount); var file2 = FileId.Parse(FileId.ToString(file)); XAssert.AreEqual(file, file2); }
private MaterializeFileCommand ReceiveMaterializeFileCmdAndCheckItMatchesFileId(string operationPayload, string expectedFileId) { var cmd = global::BuildXL.Ipc.ExternalApi.Commands.Command.Deserialize(operationPayload); XAssert.AreEqual(typeof(MaterializeFileCommand), cmd.GetType()); var materializeFileCmd = (MaterializeFileCommand)cmd; XAssert.AreEqual(expectedFileId, FileId.ToString(materializeFileCmd.File)); return(materializeFileCmd); }
/// <summary> /// This is used only for testing, particulary <code>Client.GetSealedDirectoryContent</code> /// </summary> internal async Task <IIpcResult> AddDirectoryAsync(string directoryPath, string directoryId, string dropDirectoryPath, bool enableChunkDedup, Client apiClient) { Contract.Requires(!string.IsNullOrEmpty(directoryPath)); Contract.Requires(!string.IsNullOrEmpty(directoryId)); Contract.Requires(dropDirectoryPath != null); if (apiClient == null) { return(new IpcResult( IpcResultStatus.ExecutionError, "ApiClient is not initialized")); } DirectoryArtifact directoryArtifact = DirectoryId.Parse(directoryId); var maybeResult = await apiClient.GetSealedDirectoryContent(directoryArtifact, directoryPath); if (!maybeResult.Succeeded) { return(new IpcResult( IpcResultStatus.GenericError, "could not get the directory content from BuildXL server:" + maybeResult.Failure.Describe())); } List <SealedDirectoryFile> directoryContent = maybeResult.Result; var addFileTasks = directoryContent.Select( file => { var remoteFileName = Inv( "{0}/{1}", dropDirectoryPath, // we need to convert '\' into '/' because this path would be a part of a drop url GetRelativePath(directoryPath, file.FileName).Replace('\\', '/')); var dropItem = new DropItemForBuildXLFile( apiClient, file.FileName, FileId.ToString(file.Artifact), enableChunkDedup, file.ContentInfo, remoteFileName); return(AddFileAsync(dropItem)); }).ToArray(); var ipcResults = await BuildXL.Utilities.Tasks.TaskUtilities.SafeWhenAll(addFileTasks); return(IpcResult.Merge(ipcResults)); }
public override void OnActionExecuted(ActionExecutedContext filterContext) { if (IsValid() && IdeaId != 0 && filterContext.HttpContext.User is UserPrincipal) { UserPrincipal user = filterContext.HttpContext.User as UserPrincipal; AuditDataObject audit = new AuditDataObject { IdeaId = IdeaId, LoginUserId = user.Id, AuditTypeKey = auditType.ToString(), Description = auditType == AuditType.FILE_DOWNLOAD ? FileId.ToString() : null }; ProcessFactory.GetAuditProcess().Insert(audit); } }
public override byte[] Serialize() { using (var stream = new MemoryStream()) { stream.WriteASCII(StringValueAttribute.Get(MessageType)); stream.WriteASCII(' '); stream.WriteASCII(VersionM.ToString("D")); stream.WriteASCII('.'); stream.WriteASCII(VersionN.ToString("D")); stream.WriteASCII(' '); stream.WriteASCII(FileId.ToString()); stream.WriteASCII(' '); stream.WriteASCII(ChunkNo.ToString("D")); stream.WriteASCII("\r\n\r\n"); return(stream.ToArray()); } }
/// <summary> /// Gets the location formatted as a string. /// </summary> /// <returns>The string format of the location.</returns> public override string ToString() { if (string.IsNullOrEmpty(ExtraInformation)) { return(String.Format(CultureInfo.CurrentCulture, "{0}_{1}_{2}_{3}_{4}", SiteId.ToString(), WebId.ToString(), FileId.ToString(), Convert.ToString(VersionId, CultureInfo.InvariantCulture), Convert.ToString(Timestamp.Ticks, CultureInfo.InvariantCulture))); } else { return(String.Format(CultureInfo.CurrentCulture, "{0}_{1}_{2}_{3}_{4}_{5}", SiteId.ToString(), WebId.ToString(), FileId.ToString(), Convert.ToString(VersionId, CultureInfo.InvariantCulture), Convert.ToString(Timestamp.Ticks, CultureInfo.InvariantCulture), ExtraInformation)); } }
public JsonResult SaveFile() { HttpPostedFileBase file = Request.Files[0]; int FileId; using (Conector.Comon common = new Conector.Comon()) { FileId = common.SaveFile(Path.GetExtension(file.FileName)); MemoryStream target = new MemoryStream(); file.InputStream.CopyTo(target); byte[] data = target.ToArray(); global::System.IO.File.WriteAllBytes(Path.Combine(PathContent, FileId.ToString()), data); } return(Json(new SaveFileResponse() { Id = FileId })); }
/// <summary> /// Funkcija upisuje u FileSystem.bin datoteku podatke o kreiranom fajlu u vidu jednog zapisa u MFT tabeli /// MFT = Master File Table /// Prepisuje prvu liniju binarne datoteke, zapim upisuje novi zapis, potom prepisuje ostatak sadrzaja datoteke /// </summary> /// <returns>Funkcija vraca true/false u zavisnosti od toga da li je bilo moguće upisati podatke u datoteku</returns> internal bool WriteToMFT() { byte[] content = File.ReadAllBytes("FileSystem.bin"); string mftRecord = "file~" + FileId.ToString() + "~" + FileName + "~" + FilePath + "~" + DateCreated.ToString() + "~" + InitialSize.ToString() + "~" + NumberOfBlocks.ToString(); if (content.Length + mftRecord.Length + 1 > FileSystem.freeSpace) { Console.WriteLine("Greska - nije moguce dodati datoteku jer je memorija fajl sistema popunjena."); return(false); } BinaryWriter writer1 = new BinaryWriter(new FileStream("FileSystem.bin", FileMode.Truncate)); for (int i = 0; i < 51; i++) { writer1.Write(content[i]); } writer1.Close(); StreamWriter writer2 = new StreamWriter(new FileStream("FileSystem.bin", FileMode.Append)); writer2.Write(mftRecord + '\n'); writer2.Close(); BinaryWriter writer3 = new BinaryWriter(new FileStream("FileSystem.bin", FileMode.Append)); for (int i = 51; i < content.Length; i++) { writer3.Write(content[i]); } writer3.Close(); return(true); }
public bool RemoveAllChunkPeer(FileId fileId) { List <ChunkPeer> toRemove; lock (_sync) { toRemove = _chunkPeers.Where(pair => pair.Key.Chunk.StartsWith(fileId.ToString())) .Select(pair => pair.Key).ToList(); } var any = false; foreach (var key in toRemove) { any = true; lock (_sync) { _chunkPeers.Remove(key); } } return(any); }
public void WhenIProcessTheFile() { //Arrange var handler = new ImageScalingHandler { Parameters = new WorkItemBase.WorkItemParameters { RuntimeData = new Dictionary <string, string> { { "ExhibitId", ExhibitId.ToString(CultureInfo.InvariantCulture) }, { "FileId", FileId.ToString(CultureInfo.InvariantCulture) }, { "FileCategoryId", CategoryId.ToString(CultureInfo.InvariantCulture) }, } }, WorkItemDataStream = ImageMemoryStream }; //Act using (new Performance("ImageScaling")) { HandlerOutcome = handler.Execute(); } }
/// <summary> /// OnPreRender handler. /// </summary> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); _lblFolder.Text = Utilities.GetLocalizedString("Folder"); _lblFile.Text = Utilities.GetLocalizedString("File"); _lblFolder.CssClass = LabelCssClass; _lblFile.CssClass = LabelCssClass; string fileName = null; string folderPath = null; if (!String.IsNullOrEmpty(FilePath)) { fileName = FilePath.Substring(FilePath.LastIndexOf("/") + 1); { folderPath = String.IsNullOrEmpty(fileName) ? FilePath : FilePath.Replace(fileName, String.Empty); } } else { fileName = FilePath; folderPath = String.Empty; } if (_cboFolders.Items.FindItemByValue(folderPath) != null) { _cboFolders.SelectedIndex = -1; { _cboFolders.Items.FindItemByValue(folderPath).Selected = true; } } LoadFiles(); _pnlFolder.Visible = (_cboFolders.Items.Count > 1 && ShowFolders); if (_cboFiles.Items.FindItemByText(fileName) != null) { _cboFiles.Items.FindItemByText(fileName).Selected = true; } if (_cboFiles.SelectedItem == null || String.IsNullOrEmpty(_cboFiles.SelectedItem.Value)) { FileId = -1; } else { FileId = Int32.Parse(_cboFiles.SelectedItem.Value); } _hfFileId.Value = FileId.ToString(); switch (Mode) { case FileControlMode.Normal: { _pnlFile.Visible = true; _pnlUpload.Visible = false; _pnlRightDiv.Visible = true; { ShowImage(); // show file selector preview } if ((FolderPermissionController.HasFolderPermission(PortalId, _cboFolders.SelectedItem.Value, "ADD")) && ShowUpload) { ShowButton(_cmdUpload, "Upload"); } break; } case FileControlMode.UploadFile: { ShowButton(_cmdSave, "Save"); ShowButton(_cmdCancel, "Cancel"); { _pnlFile.Visible = false; _pnlRightDiv.Visible = false; _pnlUpload.Visible = true; } RadAjaxPanel panel = (Parent as RadAjaxPanel); { panel.ClientEvents.OnRequestStart = @"utils.postback"; } break; } } }
public static bool WriteBFiles(int DayDate, string DestinationFolder) { if (DestinationFolder == null) { return(false); } int FileId; CRecordSet Data_Line = new CRecordSet(Connection1); CRecordSet Data_Header = new CRecordSet(Connection2); string DebitAcc, CreditAcc , CmdText = "exec pMega_OpenGate_Export;2 @TaskCode = 'ErcGate' " + ", @Date=" + DayDate.ToString() + ", @SeansNum=" + BFileNum.ToString() + ", @FileName=''"; if (Data_Header.Open(CmdText)) { while (Data_Header.Read()) { FileId = CCommon.CInt32(Data_Header["FileId"]); if (Data_Line.Open("exec dbo.pMega_OpenGate_Export;3 @FileId=" + FileId.ToString())) { if (BFile.Create(DestinationFolder + "\\" + Data_Header["FileName"].Trim(), CAbc.CHARSET_DOS)) { BFile.Head[CSepAFileInfo.H_EMPTYSTR] = ""; // char[100] // Пеpвые 100 - пpобелы BFile.Head[CSepAFileInfo.H_CRLF1] = CAbc.CRLF; // char[ 2]; // Символ концец строки BFile.Head[CSepAFileInfo.H_FILENAME] = Data_Header["FileName"].Trim(); // char[ 12]; // Наименование файла BFile.Head[CSepAFileInfo.H_DATE] = Now_Date_Str; // char[ 6]; // Дата создания файла BFile.Head[CSepAFileInfo.H_TIME] = Now_Time_Str; // char[ 4]; // Дата создания файла BFile.Head[CSepAFileInfo.H_STRCOUNT] = Data_Header["TotalLines"].Trim(); // char[ 6]; // Количество ИС в файле BFile.Head[CSepAFileInfo.H_TOTALDEBET] = "0"; // char[ 16]; // Сумма дебета по файлу BFile.Head[CSepAFileInfo.H_TOTALCREDIT] = Data_Header["TotalCents"].Trim(); // char[ 16]; // Сумма кpедита по файлу BFile.Head[CSepAFileInfo.H_DES] = Md5.GetHash(BFile.GetHeader().Substring(102, 60)); // char[ 64]; // ЕЦП BFile.Head[CSepAFileInfo.H_DES_ID] = "UIAB00"; // char[ 6]; // ID ключа ЕЦП BFile.Head[CSepAFileInfo.H_DES_OF_HEADER] = ""; // char[ 64]; // ЕЦП заголовка BFile.Head[CSepAFileInfo.H_CRLF2] = CAbc.CRLF; // char[ 2]; // Символ конец строки if (!BFile.WriteHeader()) { Data_Header.Close(); Data_Line.Close(); BFile.Close(); return(false); } while (Data_Line.Read()) { DebitAcc = Data_Line["DebitAcc"].Trim(); CreditAcc = Data_Line["CreditAcc"].Trim(); BFile.Line[CSepAFileInfo.L_DEBITMFO] = Data_Line["DebitMfo"].Trim(); // char[ 9]; // Дебет-МФО BFile.Line[CSepAFileInfo.L_DEBITACC] = DebitAcc; // char[ 14]; // Дебет-счет BFile.Line[CSepAFileInfo.L_DEBITACC_EXT] = (DebitAcc.Length > 14 ? DebitAcc : ""); // char[ 20]; // Расширенный Дебет-счет BFile.Line[CSepAFileInfo.L_DEBITIBAN] = Data_Line["DebitIBAN"].Trim(); // char[ 34]; // Дебет-IBAN BFile.Line[CSepAFileInfo.L_OKPO1] = Data_Line["DebitState"].Trim(); // char[ 14]; // Идент.код клиента А BFile.Line[CSepAFileInfo.L_DEBITNAME] = Data_Line["DebitName"].Trim().Replace("?", "i"); // char[ 38]; // Наименование дебет-счета BFile.Line[CSepAFileInfo.L_CREDITMFO] = Data_Line["CreditMfo"].Trim(); // char[ 9]; // Кредит-МФО BFile.Line[CSepAFileInfo.L_CREDITACC] = CreditAcc; // char[ 14]; // Кредит счет BFile.Line[CSepAFileInfo.L_CREDITACC_EXT] = (CreditAcc.Length > 14 ? CreditAcc : ""); // char[ 20]; // Расширенный Кредит счет BFile.Line[CSepAFileInfo.L_OKPO2] = Data_Line["CreditState"].Trim(); // char[ 14]; // Идент.код клиента Б BFile.Line[CSepAFileInfo.L_CREDITIBAN] = Data_Line["CreditIBAN"].Trim(); // char[ 34]; // Кредит-IBAN BFile.Line[CSepAFileInfo.L_CREDITNAME] = Data_Line["CreditName"].Trim().Replace("?", "i"); // char[ 38]; // Наименование кредит-счета BFile.Line[CSepAFileInfo.L_FLAG] = "1"; // char[ 1]; // Флаг `дебет/кредит` BFile.Line[CSepAFileInfo.L_SUMA] = Data_Line["Cents"].Trim(); // char[ 16]; // Сумма в копейках BFile.Line[CSepAFileInfo.L_DTYPE] = "6"; // char[ 2]; // Вид документа BFile.Line[CSepAFileInfo.L_NDOC] = Data_Line["Code"].Trim(); // char[ 10]; // Номер документа BFile.Line[CSepAFileInfo.L_CURRENCY] = Data_Line["CurrencyId"].Trim(); // char[ 3]; // Валюта BFile.Line[CSepAFileInfo.L_DATE1] = CCommon.DtoC(CCommon.CInt32(Data_Line["DayDate"].Trim())).Substring(2, 6); // char[ 6]; Дата платежа BFile.Line[CSepAFileInfo.L_DATE2] = CCommon.DtoC(CCommon.CInt32(Data_Line["OrgDate"].Trim())).Substring(2, 6); // char[ 6]; Дата пуступления документа BFile.Line[CSepAFileInfo.L_PURPOSE] = Data_Line["Purpose"].Trim().Replace("?", "i"); // char[160]; // Назначение платежа BFile.Line[CSepAFileInfo.L_SYMBOL] = Data_Line["Ctrls"].Trim(); // char[ 3]; // Кассовый символ BFile.Line[CSepAFileInfo.L_ID] = Data_Line["TransferId"].Trim(); // char[ 9]; // Идентификатор документа BFile.Line[CSepAFileInfo.L_DES] = Md5.GetHash(BFile.GetFullLine().Substring(0, 444)); // char[ 64]; // ЕЦП BFile.Line[CSepAFileInfo.L_CRLF] = CAbc.CRLF; // char[ 2]; // Символ `конец строки` if (!BFile.WriteLine()) { Data_Header.Close(); Data_Line.Close(); BFile.Close(); return(false); } } } BFile.Close(); } } Data_Line.Close(); } Data_Header.Close(); return(true); }
/// <nodoc/> public override string ToString() => FileId.ToString(m_file);
public void Delete(FileId id) { _OssClient.DeleteObject(_BucketName, id.ToString()); }
public bool Exists(FileId id) { return(_OssClient.DoesObjectExist(_BucketName, id.ToString())); }
string GetFilePath(FileId fileId) { return(string.IsNullOrWhiteSpace(Name) ? fileId.ToString() : string.Format("{0}/{1}", Name, fileId.ToString())); }
public void Copy(FileId sourceId, FileId destId) { _OssClient.CopyObject(new CopyObjectRequest(_BucketName, sourceId.ToString(), _BucketName, destId.ToString())); }
public void CreateOrUpdate(FileId id, System.IO.Stream stream) { _OssClient.PutObject(_BucketName, id.ToString(), stream); }
protected override string GetFileName(ZiPatchConfig.PlatformId platform) => $"{base.GetFileName(platform)}.index{(FileId == 0 ? string.Empty : FileId.ToString())}";
protected void btnUpload_Click() { this.WfId = Convert.ToInt32((string)Request.QueryString["wfid"]); this.FileNo = GetFileNo(WfId); if (dllFileType.SelectedItem.ToString() == "Invoice") { if (CheckInput()) { return; } } if (dllFileType.SelectedItem.ToString() == "Other") { if (txtDesc.Text.Trim() == "") { lblmsg.Text = "Description is required for document type of 'Other'"; } this.descRow.Style.Add("display", ""); } if (this.FileUpload.PostedFile.FileName.Trim().Equals("")) { lblmsg.Text = "Please select 'Choose Files' before clicking Upload Files."; lblmsg.Visible = true; return; } int lastPos = FileUpload.PostedFile.FileName.Trim().LastIndexOf(@"."); string suffix = FileUpload.PostedFile.FileName.Trim().Substring(lastPos); if (suffix.ToLower() == ".pdf" || suffix.ToLower() == ".jpg" || suffix.ToLower() == ".jpeg") { lblmsg.Text = ""; } else { lblmsg.Text = "Please upload only PDF or images"; lblmsg.Visible = true; return; } if (lblmsg.Text == "") { HttpFileCollection uploadedFiles = Request.Files; string errorList = ""; DataAccess dba = new DataAccess(); for (int i = 0; i < uploadedFiles.Count; i++) { HttpPostedFile file = uploadedFiles[i]; try { if (file.ContentLength > 0) { if (!file.FileName.Trim().Equals("")) { string descriptor = this.txtDesc.Text; if (descriptor == "") { descriptor = this.dllFileType.SelectedItem.ToString(); } int ftyp = Convert.ToInt32(this.dllFileType.SelectedValue); errorList += this.ProcessFile(ftyp, descriptor, file); } } } catch (Exception Ex) { //Span1.Text += "Error: <br>" + Ex.Message; } } if (errorList == "") { if (uploadedFiles.Count > 1) { string strDBfilePath = dba.dxGetSPString("wfGetFilesRootPath"); string File; string filePath; filePath = strDBfilePath; if (WfId > 0) { filePath += WfId + @"\"; } for (int i = 1; i < uploadedFiles.Count; i++) { HttpPostedFile file = uploadedFiles[i]; string File1 = filePath + SetFileName(file); File = filePath + SetFileName(uploadedFiles[0]); MergeFile(File, File1); int filekeyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + SetFileName(file) + "'"); if (filekeyId > 0) { SmartflowLite.UploadDoc doc = new SmartflowLite.UploadDoc(filekeyId); string message = ""; int delCount = doc.DeleteFile(ref message); } } File = filePath + SetFileName(uploadedFiles[0]); System.IO.File.Delete(File.Replace(".pdf", ".jpg")); } HttpPostedFile firstfile = uploadedFiles[0]; string fileonly = firstfile.FileName.Trim().Substring(firstfile.FileName.Trim().LastIndexOf("\\") + 1); int OAid = dba.dxGetIntData("select projmanagerid from claimvalues where wfid=" + this.WfId.ToString() + " and subprocessid=" + SubProcessId.ToString()); if (dllFileType.SelectedItem.ToString() == "Inspection Report/Estimate") { createGeneralTask(OAid); } if (dllFileType.SelectedItem.ToString() == "Customer Authorization (Emergency)") { Smartflow.BLL.Claim.PreliminaryReportsf pr = new Smartflow.BLL.Claim.PreliminaryReportsf(9999); pr.CreateTasks(WfId, SubProcessId, 22435, userID); int KeyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'"); dba.dxExecuteNonQuery("update wfdet set sindexid=" + KeyId + " where actionid=22436 and wfid=" + this.WfId.ToString() + " and subprocessid=" + SubProcessId.ToString()); } if (dllFileType.SelectedItem.ToString().Contains("Scope Document")) { Smartflow.BLL.Claim.PreliminaryReportsf pr = new Smartflow.BLL.Claim.PreliminaryReportsf(9999); if (dllFileType.SelectedItem.ToString().Contains("Emergency")) { pr.CreateTasks(WfId, 1, 22395, userID); } else { pr.CreateTasks(WfId, 2, 22395, userID); } } int keyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'"); if (keyId < 0) { lastPos = fileonly.LastIndexOf(@"."); suffix = fileonly.Substring(lastPos); fileonly = fileonly.Replace(suffix, ".pdf"); keyId = dba.dxGetIntData("select top 1 keyId from StrFilesDet where wfid=" + this.WfId + " and filename = '" + fileonly + "'"); } //this.FileId = keyId; dba.dxExecuteNonQuery("update StrFilesDet set refId=" + this.schId + " where keyId=" + FileId.ToString()); if (dllFileType.SelectedItem.ToString().Contains("Invoice")) { dba.dxExecuteNonQuery("update StrFilesDet set FileId=20, Comments='AP Invoice' where keyId=" + FileId.ToString()); Save(); } string myStringVariable = "File upload and conversion succesfull"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true); //Response.Redirect("Claims.aspx"); } else { lblmsg.Text = errorList; } } }
/// <nodoc/> public override string ToString() { return(FileId.ToString(m_file)); }
private void InitializePatchingProcess() { Invoke((MethodInvoker) delegate() { lblStatus.Text = "Status: Gathering patching information..."; }); DirectoryInfo directory = new DirectoryInfo(_serverDirectory); List <FileInfo> files = new List <FileInfo>(); FileInfo[] muoFiles = directory.GetFiles("*.muo"); FileInfo[] uopFiles = directory.GetFiles("*.uop"); FileInfo[] mulFiles = directory.GetFiles("verdata.mul"); List <FileInfo> patchFiles = new List <FileInfo>(); patchFiles.AddRange(muoFiles); patchFiles.AddRange(uopFiles); patchFiles.AddRange(mulFiles); List <Patch> patches = new List <Patch>(); for (int i = 0; i < patchFiles.Count; i++) { PatchReader reader = new PatchReader( File.OpenRead(patchFiles[i].FullName), PatchReader.ExtensionToPatchFileType(patchFiles[i].FullName)); patches.AddRange(reader.ReadPatches()); reader.Close(); } for (int i = 0; i < muoFiles.Length; i++) { muoFiles[i].Delete(); } for (int i = 0; i < uopFiles.Length; i++) { uopFiles[i].Delete(); } for (int i = 0; i < mulFiles.Length; i++) { mulFiles[i].Delete(); } if (patches.Count <= 0) { Complete(); return; } Dictionary <int, List <Patch> > typedPatchTable = new Dictionary <int, List <Patch> >(); for (int i = 0; i < patches.Count; i++) { if (!typedPatchTable.ContainsKey(patches[i].FileId)) { typedPatchTable.Add(patches[i].FileId, new List <Patch>()); } typedPatchTable[patches[i].FileId].Add(patches[i]); } Invoke((MethodInvoker) delegate() { lvDownloads.Items.Clear(); columnHeader1.Text = "Mul File"; columnHeader2.Text = "Total"; columnHeader3.Text = "Completed"; columnHeader4.Text = "Progress"; columnHeader7.Text = "Status"; }); List <int> keys = new List <int>(typedPatchTable.Keys); _patchCount = keys.Count; for (int i = 0; i < keys.Count; i++) { int key = keys[i]; patches = typedPatchTable[keys[i]]; if (patches.Count > 0) { FileId id = (FileId)i; PatchingTask task = new PatchingTask(patches.ToArray(), _serverDirectory, id.ToString().Replace('_', '.')); task.ProgressUpdate += new EventHandler <ProgressUpdateEventArgs>(OnPatchingProgressUpdate); task.ProgressCompleted += new EventHandler <ProgressCompletedEventArgs>(OnPatchingProgressCompleted); ListViewItem item = new ListViewItem(new string[5]); Invoke((MethodInvoker) delegate() { lvDownloads.Items.Add(item); UpdatePatchingStatus(task, item, 0, 100, 0, "Patching Queued"); }); _patchTable.Add(task, item); _patchManager.Queue(task); } } _patchManager.Begin(); }