示例#1
0
        void bkgBugLastUpdated_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            string bugLastUpdated = null;

            ArrayList al = e.Argument as ArrayList;

            int bugNo = int.Parse(al[0].ToString());

            try
            {
                worker.ReportProgress(0); // start thread.

                worker.ReportProgress(10);

                IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId);

                bugLastUpdated = bugInterface.GetBugLastUpdated(bugNo);

                worker.ReportProgress(60);

                e.Result = bugLastUpdated;

                worker.ReportProgress(100);  //completed
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "bkgBugDetails_DoWork", LoggingCategory.Exception);

                worker.ReportProgress(100);  //completed

                throw;
            }
        }
示例#2
0
        private void btnAddAttachment_Click(object sender, EventArgs e)
        {
            try
            {
                bool isValid = CheckConditions();

                if (isValid == true)
                {
                    this.Cursor = Cursors.WaitCursor;

                    string contentType = Utils.GetFileContentType(txtFile.Text);

                    this.NewAttachment = new Attachment(_bugID, txtFile.Text, txtDescription.Text, contentType, txtComment.Text);

                    System.IO.FileInfo fileInfo = new System.IO.FileInfo(txtFile.Text);

                    this.NewAttachment.Size = fileInfo.Length;

                    if (_postWhenAdding == true)
                    {
                        string errorMessage = string.Empty;
                        // post attachment
                        IBugBSI bugProvider = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId);

                        bugProvider.PostAttachment(this.NewAttachment, out errorMessage);

                        if (!String.IsNullOrEmpty(errorMessage))
                        {
                            string strMessage = string.Format(Messages.ErrPostFile, txtFile.Text);

                            MessageBox.Show(this, strMessage + Environment.NewLine + errorMessage, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);

                            this.NewAttachment = null;
                        }
                        else
                        {
                            this.Close();
                        }
                    }
                    else
                    {
                        // no code here.
                        this.Close();
                    }
                }
            }

            catch (Exception ex)
            {
                MyLogger.Write(ex, "btnAddAttachment_Click", LoggingCategory.Exception);

                this.NewAttachment = null;

                MessageBox.Show(this, ex.Message, Messages.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally {
                this.Cursor = Cursors.Default;
            }
        }
示例#3
0
        void bkgSearch_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            worker.ReportProgress(0); // start thread.

            IBugBSI bugProvider = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(_userID);

            worker.ReportProgress(60);  //intermediate state

            List <BSI.BusinessEntities.Bug> bugsFound = bugProvider.SearchBugs(_searchParam);

            worker.ReportProgress(100);  //completed

            e.Result = bugsFound;
        }
示例#4
0
        private void bkgBugDetails_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            Bug bugDetail           = null;

            ArrayList al = e.Argument as ArrayList;

            int bugNo = int.Parse(al[0].ToString());

            bool useCachedBugIfExits = bool.Parse(al[1].ToString());

            try
            {
                worker.ReportProgress(0); // start thread.
                worker.ReportProgress(10);

                // check if bug was previously loaded
                if (bugToUpdate == null || !useCachedBugIfExits)
                {
                    IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId);

                    bugDetail = bugInterface.GetBug(bugNo);

                    bugDetail.Id = bugNo;
                }
                else
                {
                    bugDetail = bugToUpdate;
                }

                worker.ReportProgress(60);

                e.Result = bugDetail;

                worker.ReportProgress(100);  //completed
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "bkgBugDetails_DoWork", LoggingCategory.Exception);

                worker.ReportProgress(100);  //completed

                throw;
            }
        }
示例#5
0
        private void bkgBugUpdate_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                worker.ReportProgress(0); // start thread.
                worker.ReportProgress(10);

                IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId);

                worker.ReportProgress(60);  //intermediate state

                string errorMessage = string.Empty;

                string result = bugInterface.UpdateBug(bugToUpdate, out errorMessage);

                ArrayList al = new ArrayList();

                al.Add(errorMessage);

                al.Add(result);

                e.Result = al;

                worker.ReportProgress(100);  //completed
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "bkgBugUpdate_DoWork", LoggingCategory.Exception);

                worker.ReportProgress(100);  //completed

                throw;
            }
        }
示例#6
0
        void bkgAddBug_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            try
            {
                worker.ReportProgress(0); // start thread.
                worker.ReportProgress(10);

                IBugBSI bugInterface = (IBugBSI)BLControllerFactory.GetRegisteredConcreteFactory(this.connectionId);

                worker.ReportProgress(60);  //intermediate state

                string strResult = bugInterface.AddBug(addedBug);

                if (addedBug.Attachments.Count > 0)
                {
                    // get bug ID

                    Regex addBug = new Regex(@"(?<bug_number>[(0-9)]+) was added to the database", RegexOptions.IgnoreCase);

                    Match match = addBug.Match(strResult);

                    int bugNo = 0;

                    if (match.Success == true)
                    {
                        bugNo = int.Parse(match.Groups["bug_number"].ToString());
                    }


                    string strAtt = string.Empty;

                    string errorMessage = string.Empty;

                    // get version for current connection
                    MyZillaSettingsDataSet _appSettings = MyZillaSettingsDataSet.GetInstance();

                    string version = _appSettings.GetConnectionById(this.connectionId).Version;

                    int versionINT = int.Parse(version.Substring(0, version.IndexOf(".")));

                    switch (versionINT)
                    {
                    case 2:
                        foreach (Attachment att in addedBug.Attachments)
                        {
                            att.BugId = bugNo;

                            bugInterface.PostAttachment(att, out errorMessage);

                            if (!String.IsNullOrEmpty(errorMessage))
                            {
                                strAtt = string.Format(Messages.ErrPostFile, att.FileName);

                                strResult += Environment.NewLine + strAtt + " [" + errorMessage + "]";
                            }
                        }

                        break;

                    case 3:
                        break;
                    }
                }


                e.Result = strResult;

                worker.ReportProgress(100);  //completed
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "bkgAddBug_DoWork", LoggingCategory.Exception);

                worker.ReportProgress(100);  //completed

                throw;
            }
        }