示例#1
0
        public Session()
        {
            UiInput            = new UiInput(this);
            HudUi              = new Hud(this);
            TargetUi           = new TargetUi(this);
            DsUtil             = new DSUtils(this);
            DsUtil2            = new DSUtils(this);
            StallReporter      = new StallReporter();
            InnerStallReporter = new StallReporter();
            Av                     = new RunAv(this);
            Api                    = new ApiBackend(this);
            ApiServer              = new ApiServer(this);
            Projectiles            = new Projectiles.Projectiles(this);
            AcqManager             = new AcquireManager(this);
            TerminalMon            = new TerminalMonitor(this);
            _cachedEwarPacket.Data = new List <EwarValues>(32);

            ProblemRep            = new ProblemReport(this);
            VisDirToleranceCosine = Math.Cos(MathHelper.ToRadians(VisDirToleranceAngle));
            AimDirToleranceCosine = Math.Cos(MathHelper.ToRadians(AimDirToleranceAngle));

            VoxelCaches[ulong.MaxValue] = new VoxelCache();

            HeatEmissives = CreateHeatEmissive();
            LoadVanillaData();

            for (int i = 0; i < AuthorSettings.Length; i++)
            {
                AuthorSettings[i] = -1;
            }
        }
 /// <summary>
 /// Saves the problemReport and adds a unique reference number in the <see cref="ProblemReport.ProblemReportId"/> property.
 /// </summary>
 /// <param name="problemReport">The problemReport.</param>
 public void SaveProblemReport(ProblemReport problemReport)
 {
     if (problemReport != null)
     {
         problemReport.ProblemReportId = 12345;
     }
 }
        /// <summary>
        /// Reads a problem problemReport.
        /// </summary>
        /// <param name="problemReportId">The problem problemReport id.</param>
        public ProblemReport ReadProblemReport(int problemReportId)
        {
            var report = new ProblemReport()
            {
                ProblemReportId = 12345,
                MessageHtml     = "We've noticed an urgent problem.",
                Page            = new Page()
                {
                    PageTitle = "Page title", PageUrl = new Uri("http://ww.example.org")
                },
                ReportDate = DateTime.Now.AddDays(-10),
                WebAuthorPermissionsGroupName = "Permissions group"
            };

            report.WebAuthors.Add(new WebAuthor()
            {
                Name = "John Smith", EmailAddress = "*****@*****.**", UserName = "******", WebAuthorId = 1
            });
            report.WebAuthors.Add(new WebAuthor()
            {
                Name = "Jane Smith", EmailAddress = "*****@*****.**", UserName = "******", WebAuthorId = 2
            });
            report.ProblemTypes.Add(new ProblemType()
            {
                Name = "Urgent problem"
            });
            return(report);
        }
示例#4
0
        public ProblemReport getOneReportByID(int problemID, MySqlConnection conn)
        {
            conn.Open();
            MySqlCommand cmd = new MySqlCommand("SELECT `problem_report`.`Problem_ID`, `problem_report`.`Photo`, `problem_report`.`Reason`, `problem_report`.`Order_ID`, `customer`.`Customer_Surname`, `customer`.`Customer_GivenName`, `customer`.`Regeion_Code`, `customer`.`Mobile_Phone_No`, " +
                                                "`problem_report`.`Report_date`, `problem_report`.`Return_date` FROM `problem_report`, `customer`, `order` " +
                                                "WHERE  `problem_report`.`Order_ID`=`order`.`Order_ID` AND `order`.`Customer_ID`=`customer`.`Customer_ID` AND `problem_report`.`Date_Deleted` IS NULL AND `problem_report`.`Problem_ID`=@problemID", conn);

            cmd.Parameters.AddWithValue("@problemID", problemID);
            cmd.Prepare();
            MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
            DataTable        dt      = new DataTable();

            adapter.Fill(dt);

            ProblemReport problemReport = new ProblemReport();

            foreach (DataRow item in dt.Rows)
            {
                problemReport.setProblemID(int.Parse(item["Problem_ID"].ToString()));
                problemReport.setPhoto(ImageConverter.byteArrayToImage((byte[])item["Photo"]));
                problemReport.setReason(item["Reason"].ToString());
                problemReport.setOrderID(((uint)item["Order_ID"]).ToString("0000000000"));
                problemReport.setCustSurname(item["Customer_Surname"].ToString());
                problemReport.setCustGivenName(item["Customer_GivenName"].ToString());
                problemReport.setCustRegeionCode((int)item["Regeion_Code"]);
                problemReport.setCustMobilePhoneNo((int)item["Mobile_Phone_No"]);
                problemReport.setReportDate(Convert.ToDateTime(item["Report_date"]));
                if (!Convert.IsDBNull(item["Return_date"]))
                {
                    problemReport.setReturnDate(Convert.ToDateTime(item["Return_date"]));
                }
            }
            conn.Close();
            return(problemReport);
        }
示例#5
0
        private void reportDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                ProblemReport pr = prda.getOneReportByID((int)reportDataGridView.Rows[e.RowIndex].Cells["problemIdColumn"].Value, conn);
                showReportDateLabel.Text     = pr.getReportDate().ToLongDateString();
                reasonComboBox.SelectedValue = pr.getReason();
                photoBox.Image = pr.getPhoto();

                showReportDateLabel.Enabled = false;
                reasonComboBox.Enabled      = false;
                reasonHintLabel.Enabled     = false;
                photoBox.Enabled            = false;
                browsePhotoButton.Enabled   = false;
                zoomPhotoButton.Enabled     = true;
                photoHintLabel.Enabled      = false;
                if (pr.getReturnDate() == null)
                {
                    naReturnDateCheckBox.Checked = true;
                    naReturnDateCheckBox.Enabled = true;
                    returnDateTime.Enabled       = false;
                }
                else
                {
                    naReturnDateCheckBox.Checked = false;
                    naReturnDateCheckBox.Enabled = false;
                    returnDateTime.Enabled       = false;
                }

                addButton.Enabled = false;
                recordReturnDateButton.Enabled = false;
            }
        }
        /// <summary>
        /// Saves the problemReport and adds a unique reference number in the <see cref="ProblemReport.ProblemReportId"/> property.
        /// </summary>
        /// <param name="problemReport">The problem report.</param>
        public void SaveProblemReport(ProblemReport problemReport)
        {
            if (problemReport == null)
            {
                throw new ArgumentNullException("problemReport");
            }

            CheckForConnectionString();

            using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["CmsSupport"].ConnectionString))
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    // Add problem report
                    var sqlParameters = new SqlParameter[6];
                    sqlParameters[0] = new SqlParameter("@problemReportId", SqlDbType.Int)
                    {
                        Direction = ParameterDirection.Output
                    };

                    sqlParameters[1] = new SqlParameter("@pageUrl", problemReport.Page.PageUrl.ToString());
                    sqlParameters[2] = new SqlParameter("@pageTitle", problemReport.Page.PageTitle);
                    sqlParameters[3] = new SqlParameter("@reportDate", problemReport.ReportDate);
                    sqlParameters[4] = new SqlParameter("@messageHtml", problemReport.MessageHtml);
                    sqlParameters[5] = new SqlParameter("@webAuthorPermissionsGroupName", problemReport.WebAuthorPermissionsGroupName);

                    SqlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "usp_WebAuthorProblemReport_Insert", sqlParameters);
                    problemReport.ProblemReportId = Int32.Parse(sqlParameters[0].Value.ToString(), CultureInfo.InvariantCulture);

                    // Add problem types to report
                    foreach (ProblemType problemType in problemReport.ProblemTypes)
                    {
                        SqlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "usp_WebAuthorProblemReport_InsertProblemType",
                                                  new SqlParameter("@problemReportId", problemReport.ProblemReportId),
                                                  new SqlParameter("@problemTypeId", problemType.ProblemTypeId));
                    }

                    // Add web authors to report
                    foreach (WebAuthor webAuthor in problemReport.WebAuthors)
                    {
                        SqlHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, "usp_WebAuthorProblemReport_InsertWebAuthor",
                                                  new SqlParameter("@problemReportId", problemReport.ProblemReportId),
                                                  new SqlParameter("@name", webAuthor.Name),
                                                  new SqlParameter("@username", webAuthor.UserName),
                                                  new SqlParameter("@emailAddress", webAuthor.EmailAddress));
                    }

                    trans.Commit();
                }
                catch (SqlException)
                {
                    trans.Rollback();
                    throw;
                }
            }
        }
示例#7
0
 private void AddWebAuthorsToProblem(ProblemReport problem, IContentManagementProvider cms)
 {
     problem.WebAuthorPermissionsGroupName = cms.ReadPermissionsGroupNameForPage(problem.Page.PageUrl);
     if (!String.IsNullOrEmpty(problem.WebAuthorPermissionsGroupName))
     {
         problem.WebAuthors.AddRange(cms.ReadWebAuthorsInGroup(problem.WebAuthorPermissionsGroupName));
     }
 }
示例#8
0
        public bool SaveAndPublish(string pageUrl, int[] problemTypes, string message)
        {
            if (String.IsNullOrEmpty(pageUrl))
            {
                throw new ArgumentNullException("pageUrl");
            }
            if (problemTypes == null || problemTypes.Length == 0)
            {
                throw new ArgumentNullException("problemTypes");
            }
            if (String.IsNullOrEmpty(message))
            {
                throw new ArgumentNullException("message");
            }

            var problem = new ProblemReport();

            IContentManagementProvider cms = new UmbracoContentManagementSystem();

            problem.Page        = cms.ReadMetadataForPage(new Uri(pageUrl));
            problem.ReportDate  = DateTime.Now;
            problem.MessageHtml = message;

            AddWebAuthorsToProblem(problem, cms);

            if (problem.WebAuthors.Count > 0)
            {
                IWebAuthorMonitoringRepository repo = new SqlServerRepository();
                var problemTypesFromRepo            = repo.ReadProblemTypes();
                AddProblemTypesToProblem(problem, problemTypes, problemTypesFromRepo);

                // Check problem type was recognised
                if (problem.ProblemTypes.Count == 0)
                {
                    throw new ArgumentException("problemTypes");
                }

                CreateHtmlMessage(problem);

                repo.SaveProblemReport(problem);

                IEnumerable <IReportListener> listeners = new[] { String.IsNullOrEmpty(ConfigurationManager.AppSettings["Escc.WebAuthorMonitoring.TestEmailListenerAddress"]) ? new EmailListener() : new TestEmailListener() };
                foreach (var listener in listeners)
                {
                    listener.ReportPublished(problem);
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#9
0
 private static void AddProblemTypesToProblem(ProblemReport problem, IEnumerable <int> problemTypes, IList <ProblemType> problemTypesFromRepo)
 {
     foreach (int problemTypeId in problemTypes)
     {
         foreach (ProblemType problemType in problemTypesFromRepo)
         {
             if (problemTypeId == problemType.ProblemTypeId)
             {
                 problem.ProblemTypes.Add(problemType);
                 break;
             }
         }
     }
 }
示例#10
0
        public int update(ProblemReport problemReport, MySqlConnection conn)
        {
            conn.Open();
            MySqlCommand cmd = new MySqlCommand("UPDATE `problem_report` SET `Photo`=@photo,`Reason`=@reason,`Order_ID`=@orderID,`Report_date`=@reportDate,`Return_date`=@returnDate WHERE `Problem_ID`=@problemID", conn);

            cmd.Parameters.AddWithValue("@problemID", problemReport.getProblemID());
            cmd.Parameters.AddWithValue("@photo", ImageConverter.imageToByteArray(problemReport.getPhoto()));
            cmd.Parameters.AddWithValue("@reason", problemReport.getReason());
            cmd.Parameters.AddWithValue("@orderID", problemReport.getOrderID());
            cmd.Parameters.AddWithValue("@reportDate", problemReport.getReportDate().ToString("yyyy-MM-dd HH:mm:ss"));
            cmd.Parameters.AddWithValue("@returnDate", (problemReport.getReturnDate() != null) ? problemReport.getReturnDate().Value.ToString("yyyy-MM-dd HH:mm:ss") : null);
            cmd.Prepare();
            int i = cmd.ExecuteNonQuery();

            conn.Close();
            return(i);
        }
示例#11
0
        public int insert(ProblemReport problemReport, MySqlConnection conn)
        {
            conn.Open();
            MySqlCommand cmd = new MySqlCommand("INSERT INTO `problem_report`(`Photo`, `Reason`, `Order_ID`, `Report_date`, `Return_date`) " +
                                                "VALUES(@photo, @reason, @orderID, @reportDate, @returnDate)", conn);

            cmd.Parameters.AddWithValue("@photo", ImageConverter.imageToByteArray(problemReport.getPhoto()));
            cmd.Parameters.AddWithValue("@reason", problemReport.getReason());
            cmd.Parameters.AddWithValue("@orderID", problemReport.getOrderID());
            cmd.Parameters.AddWithValue("@reportDate", problemReport.getReportDate().ToString("yyyy-MM-dd HH:mm:ss"));
            cmd.Parameters.AddWithValue("@returnDate", (problemReport.getReturnDate() != null) ? problemReport.getReturnDate().Value.ToString("yyyy-MM-dd HH:mm:ss") : null);
            cmd.Prepare();
            int i = cmd.ExecuteNonQuery();

            problemReport.setProblemID((int.Parse(cmd.LastInsertedId.ToString())));
            conn.Close();
            return(i);
        }
示例#12
0
        private void recordReturnDateButton_Click(object sender, EventArgs e)
        {
            if (!naReturnDateCheckBox.Checked)
            {
                if (MessageBox.Show(rs.GetString("askRecordReturnDateDialogbox"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ProblemReport pr = prda.getOneReportByID((int)reportDataGridView.Rows[reportDataGridView.CurrentCell.RowIndex].Cells["problemIdColumn"].Value, conn);
                    pr.setReturnDate(returnDateTime.Value);
                    naReturnDateCheckBox.Checked = false;
                    naReturnDateCheckBox.Enabled = false;
                    returnDateTime.Enabled       = false;

                    recordReturnDateButton.Enabled = false;

                    prda.update(pr, conn);

                    MessageBox.Show(rs.GetString("recordReturnDateSuccessMsg"));
                }
            }
        }
示例#13
0
 private static void OnWorkerReportsProblem(object sender, ProblemReport e)
 {
     routeDescriptionBox.Text = Translations.GetInterfaceString("packages_creation_failure_error") + Environment.NewLine;
     if (e.Exception is UnauthorizedAccessException && currentOperation != PackageOperation.Creating)
     {
         //User attempted to install in a directory which requires UAC access
         routeDescriptionBox.Text += e.Exception.Message + Environment.NewLine + Environment.NewLine + Translations.GetInterfaceString("errors_security_checkaccess");
         if (Program.CurrentHost.Platform == HostPlatform.MicrosoftWindows)
         {
             routeDescriptionBox.Text += Environment.NewLine + Environment.NewLine + Translations.GetInterfaceString("errors_security_badlocation");
         }
     }
     else
     {
         //Non-localised string as this is a specific error message
         routeDescriptionBox.Text += e.Exception + @"\r\n \r\n encountered whilst processing the following file: \r\n\r\n" +
                                     e.CurrentFile + @" at " + e.Progress + @"% completion.";
         //Create crash dump file
         CrashHandler.LogCrash(e.Exception + Environment.StackTrace);
     }
 }
示例#14
0
        private void CreateHtmlMessage(ProblemReport problem)
        {
            var html = new StringBuilder();

            html.Append("<p>This message is about <a href=\"").Append(HttpUtility.HtmlAttributeEncode(problem.Page.PageUrl.ToString())).Append("\">").Append(HttpUtility.HtmlEncode(problem.Page.PageTitle)).Append("</a>.</p>");
            if (problem.ProblemTypes.Count > 1)
            {
                html.Append("<ul>");
                foreach (ProblemType problemType in problem.ProblemTypes)
                {
                    html.Append("<li>").Append(HttpUtility.HtmlEncode(problemType.Name)).Append("</li>");
                }
                html.Append("</ul>");
            }
            else
            {
                html.Append(problem.ProblemTypes[0].DefaultText);
            }
            html.Append(problem.MessageHtml);

            problem.MessageHtml = html.ToString();
        }
示例#15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var skinnable = Master as BaseMasterPage;

            if (skinnable != null)
            {
                skinnable.Skin = new CustomerFocusSkin(ViewSelector.CurrentViewIs(MasterPageFile));
            }

            var reportId = GetReportIdFromQueryString();

            if (reportId == -1)
            {
                return;
            }

            _problem = _repo.ReadProblemReport(reportId);

            this.subject.InnerText    = _problem.SubjectLine();
            this.reportDate.InnerText = _problem.ReportDate.ToBritishDateWithDay();
            this.messageHtml.Text     = _problem.MessageHtml;

            DisplayWebAuthors();
        }
示例#16
0
        private void addButton_Click(object sender, EventArgs e)
        {
            bool error = false;

            if (string.IsNullOrWhiteSpace(reasonComboBox.Text))
            {
                reasonHintLabel.ForeColor = Color.Red;
                error = true;
            }
            else
            {
                reasonHintLabel.ForeColor = SystemColors.ControlText;
            }

            if (photoBox.Image == null)
            {
                photoHintLabel.ForeColor = Color.Red;
                error = true;
            }
            else
            {
                photoHintLabel.ForeColor = SystemColors.ControlText;
            }

            if (!error)
            {
                if (MessageBox.Show((!naReturnDateCheckBox.Checked) ? rs.GetString("askAddReportDialogbox") : rs.GetString("askAddReportExceptReturnDateDialogbox"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ProblemReport pr = new ProblemReport();
                    pr.setOrderID(orderDetail.getOrderID());

                    pr.setReportDate(DateTime.Now);
                    showReportDateLabel.Enabled = false;

                    pr.setReason(reasonComboBox.SelectedValue.ToString());
                    reasonComboBox.Enabled  = false;
                    reasonHintLabel.Enabled = false;

                    pr.setPhoto(photoBox.Image);
                    photoBox.Enabled          = false;
                    browsePhotoButton.Enabled = false;
                    photoHintLabel.Enabled    = false;

                    if (!naReturnDateCheckBox.Checked)
                    {
                        pr.setReturnDate(returnDateTime.Value);
                        naReturnDateCheckBox.Checked   = false;
                        naReturnDateCheckBox.Enabled   = false;
                        returnDateTime.Enabled         = false;
                        recordReturnDateButton.Enabled = false;
                    }

                    addButton.Enabled = false;
                    int i = prda.insert(pr, conn);

                    MessageBox.Show(rs.GetString("addNewReportSuccessMsg"));

                    reportDataGridView.Rows.Add(pr.getProblemID(), pr.getReportDate().ToLongDateString() + ", " + pr.getReportDate().ToLongTimeString());

                    reportDataGridView.ClearSelection();
                    foreach (DataGridViewRow row in reportDataGridView.Rows)
                    {
                        if ((pr.getProblemID().ToString()).Equals(row.Cells["problemIdColumn"].Value.ToString()))
                        {
                            row.Selected = true;
                            reportDataGridView.FirstDisplayedScrollingRowIndex = row.Index;
                        }
                    }
                }
            }
        }