ProgressStruc SetProgressStruc(ProgressStruc PrStruc, string ProgressChoice, string ProgressMessage, int ProgressTotal) { PrStruc.ProgressChoice = ProgressChoice; PrStruc.ProgressTotal = ProgressTotal; PrStruc.ProgressMessage = ProgressMessage; return(PrStruc); }
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 BckGrWork_ProgressChanged(object sender, ProgressChangedEventArgs e) { ProgressStruc ToGet = (ProgressStruc)e.UserState; switch (ToGet.ProgressChoice) { case "Total": LblTotal.Text = "Total : " + ToGet.ProgressMessage; PrBarTotal.Maximum = ToGet.ProgressTotal; PrBarTotal.Value = e.ProgressPercentage; break; case "Cur": LblCur.Text = "Current : " + ToGet.ProgressMessage; PrBarCur.Maximum = ToGet.ProgressTotal; PrBarCur.Value = e.ProgressPercentage; break; default: break; } }