private void BckGrWork_DoWork(object sender, DoWorkEventArgs e) { ProgressStruc ToSend = new ProgressStruc(); BckGrWork.ReportProgress(0, SetProgressStruc(ToSend, "Total", "I will Create the link", 1)); Branch.PostBranch(CmBxSubPrjText, CmBxSubPkgText, CmbxCurSubPrjText, TxtPkgDestText); BckGrWork.ReportProgress(1, SetProgressStruc(ToSend, "Total", "Link created", 1)); if (MessageBox.Show(string.Format("Done! Do you want to imediatly branch also all files of {0} in {1}", CmBxSubPrjText + ":" + CmBxSubPkgText, CmbxCurSubPrjText + ":" + TxtPkgDestText), "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { BckGrWork.ReportProgress(1, SetProgressStruc(ToSend, "Total", "Get the list of file(s)", 3)); string PkgSourceDir = VarGlobal.MonoOBSFrameworkTmpDir + CmBxSubPkgText + Path.DirectorySeparatorChar.ToString(); if (!Directory.Exists(PkgSourceDir)) { Directory.CreateDirectory(PkgSourceDir); } StringBuilder Result = GetSourceProjectPackage.GetFileList(CmBxSubPrjText, CmBxSubPkgText); List <string> FsLs = ReadXml.GetAllFirstAttrValue(Result.ToString(), "directory", "name"); BckGrWork.ReportProgress(2, SetProgressStruc(ToSend, "Total", "Find " + FsLs.Count + " file(s)", 3)); int Cnt = 1; if (FsLs.Count > 0) { List <string> CurItem = new List <string>(); foreach (string item in FsLs) { BckGrWork.ReportProgress(Cnt, SetProgressStruc(ToSend, "Cur" , string.Format("Download file {0} {1}/{2}", item, Cnt, FsLs.Count), FsLs.Count)); Cnt += 1; CurItem.Clear(); CurItem.Add(item); SourceProjectPackageFile.GetSourceProjectPackageFiles( CmBxSubPrjText, CmBxSubPkgText, CurItem, PkgSourceDir, 4096); BckGrWork.ReportProgress(Cnt, SetProgressStruc(ToSend, "Cur" , "File downloaded", FsLs.Count)); } Cnt = 1; foreach (string FsPathName in Directory.GetFiles(PkgSourceDir)) { BckGrWork.ReportProgress(Cnt, SetProgressStruc(ToSend, "Cur" , string.Format("Upload file {0} {1}/{2}", FsLs[Cnt], Cnt, FsLs.Count), FsLs.Count)); Cnt += 1; PutSourceProjectPackageFile.PutFile(CmbxCurSubPrjText, TxtPkgDestText, FsPathName); BckGrWork.ReportProgress(Cnt, SetProgressStruc(ToSend, "Cur" , "Uploaded !", FsLs.Count)); } } BckGrWork.ReportProgress(3, SetProgressStruc(ToSend, "Total", "Done !", 3)); } }
private void BtnBranch_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(CmBxSubPrj.Text) && !string.IsNullOrEmpty(CmBxSubPkg.Text) && !string.IsNullOrEmpty(CmbxCurSubPrj.Text) && !string.IsNullOrEmpty(TxtPkgDest.Text)) { if (!BckGrWork.IsBusy) { CmBxSubPrjText = CmBxSubPrj.Text; CmBxSubPkgText = CmBxSubPkg.Text; CmbxCurSubPrjText = CmbxCurSubPrj.Text; TxtPkgDestText = TxtPkgDest.Text; BtnBranch.Enabled = false; BckGrWork.RunWorkerAsync(); } } else { MessageBox.Show("All field must be filled!"); CancelClose = true; } }