コード例 #1
0
        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));
            }
        }
コード例 #2
0
        private void SetFsList(StringBuilder XmlFsList)
        {
            try
            {
                // InvokeRequired required compares the thread ID of the
                // calling thread to the thread ID of the creating thread.
                // If these threads are different, it returns true.
                if (listViewPckg.InvokeRequired)
                {
                    SetFsListCallback d = new SetFsListCallback(SetFsList);
                    listViewPckg.Invoke(d, XmlFsList);
                }
                else
                {
                    //if(!VarGlobal.LessVerbose)Console.WriteLine(XmlFsList.ToString());
                    List <string> Result = ReadXml.GetAllFirstAttrValue(XmlFsList.ToString(), "binarylist", "filename");
                    listViewPckg.Items.Clear();
                    if (Result.Count > 0)
                    {
                        foreach (string item in Result)
                        {
                            if (backgroundWorkerBuildStatus.CancellationPending == true)
                            {
                                break;
                            }
                            Dictionary <string, string> SubResult = ReadXml.GetAllAttrValue(XmlFsList.ToString(), "binarylist", "filename", item);
                            string name      = string.Empty;
                            int    Size      = 0;
                            string FinalSize = string.Empty;
                            string Time      = string.Empty;

                            foreach (string KeyName in SubResult.Keys)
                            {
                                switch (KeyName)
                                {
                                case "filename":
                                    name = SubResult[KeyName];
                                    break;

                                case "size":
                                    Size       = Convert.ToInt32(SubResult[KeyName]);
                                    FsByteSize = Size;
                                    FinalSize  = Size.ToString() + " Byte";
                                    if (Size >= 1024)
                                    {
                                        FinalSize = (Size / 1024).ToString() + " Kb";
                                    }
                                    if (Size >= (1024 * 1024))
                                    {
                                        FinalSize = (Size / 1024 / 1024).ToString() + " Mo";
                                    }
                                    break;

                                case "mtime":
                                    try
                                    {
                                        DateTime Dt2 = Convert.ToDateTime("1970-01-01T01:00:00+01:00");
                                        Time = Dt2.AddSeconds(Convert.ToInt64(SubResult[KeyName])).ToString();
                                    }
                                    catch (ArgumentOutOfRangeException)
                                    {
                                        // fileCreationTime is not valid, so re-throw the exception.
                                        throw;
                                    }
                                    break;

                                default:
                                    break;
                                }
                            }
                            ListViewItem ToAdd = new ListViewItem(name);
                            ToAdd.SubItems.AddRange(new string[] { FinalSize, Time });
                            ToAdd.Tag = FsByteSize;
                            listViewPckg.Items.Add(ToAdd);
                        }
                    }
                    _OperationStatusEnd = true;
                    //FIXME : Yet another mono bug, it don't show the last item when there is an scrollbar
                    listViewPckg.Items.Add(string.Empty);
                }
            }
            catch (Exception Ex)
            {
                if (!VarGlobal.LessVerbose)
                {
                    Console.WriteLine(Ex.Message + Environment.NewLine + Ex.StackTrace);
                }
            }
        }
コード例 #3
0
        private void SetListFsPkg(StringBuilder XmlListFsPkg)
        {
            // InvokeRequired required compares the thread ID of the
            // calling thread to the thread ID of the creating thread.
            // If these threads are different, it returns true.
            if (TbCtrlFsList.InvokeRequired)
            {
                SetListFsPkgCallback d = new SetListFsPkgCallback(SetListFsPkg);
                TbCtrlFsList.Invoke(d, XmlListFsPkg);
            }
            else
            {
                //if(!VarGlobal.LessVerbose)Console.WriteLine(XmlListFsPkg.ToString());
                List <string> Result = ReadXml.GetAllFirstAttrValue(XmlListFsPkg.ToString(), "directory", "name");
                if (Result.Count > 0)
                {
                    PanelFsList.Controls.Clear();

                    foreach (string item in Result)
                    {
                        if (backgroundWorkerAddFs.CancellationPending == true)
                        {
                            break;
                        }
                        Dictionary <string, string> SubResult = ReadXml.GetAllAttrValue(XmlListFsPkg.ToString(), "directory", "name", item);
                        string name = string.Empty;
                        int    Size = 0;
                        long   Time = 0;
                        foreach (string KeyName in SubResult.Keys)
                        {
                            switch (KeyName)
                            {
                            case "name":
                                name = SubResult[KeyName];
                                break;

                            case "size":
                                Size = Convert.ToInt32(SubResult[KeyName]);
                                break;

                            case "mtime":
                                Time = Convert.ToInt64(SubResult[KeyName]);
                                break;

                            default:
                                break;
                            }
                        }
                        PkgFiles TheCtrl = new PkgFiles(Package, name, Size, Time);
                        TheCtrl.Dock = DockStyle.Top;
                        PanelFsList.Controls.Add(TheCtrl);
                    }

                    //Mono have a damed bug who don't show ToolStrip2 since we rezise the control
                    this.Height = this.Height + 1;
                    this.Height = this.Height - 1;
                }

                VarGlobal.NetEvManager.DoSomething("List of files Done");
                if (FromBtn == false && backgroundWorkerBuildStatus.IsBusy == false)
                {
                    backgroundWorkerBuildStatus.RunWorkerAsync();
                }
            }
        }