Exemplo n.º 1
0
        public ActionResult ReportArea(ReportArea reportArea)
        {
            if (ModelState.IsValid)
            {
                if (!CurrentUser.AccessibleAreaIds.Contains(reportArea.AreaId))
                {
                    throw new HttpException(403, "Forbidden");
                }
                reportArea.Summary = HttpUtility.HtmlDecode(reportArea.Summary);
                var savedReportArea = reportArea.Id == 0 ? _reportAreaManager.Create(reportArea) : _reportAreaManager.Update(reportArea);

                if (savedReportArea != null)
                {
                    this.SetNotificationMessage(NotificationType.Success, "Report area saved successfully.");

                    // Notify listeners
                    var reportEditLink = Url.Action("Edit", "Reports", new { year = reportArea.ReportDate.Year, month = reportArea.ReportDate.Month });
                    _webhookManager.ReportingAreaUpdated(CompanyId, CurrentUser, reportArea, reportEditLink);
                }

                return(RedirectToAction("Edit", new { year = reportArea.ReportDate.Year, month = reportArea.ReportDate.Month }));
            }

            return(View(reportArea));
        }
Exemplo n.º 2
0
        private void NotifyReportingAreaUpdated(LiteUser currentUser, ReportArea reportArea, IEnumerable <Webhook> webhooks, string url)
        {
            var payload = new WebhookPayload {
                Text = string.Format("{0} updated a Reporting Area", currentUser.DisplayName)
            };

            payload.Attachments.Add(new WebhookPayloadAttachment
            {
                Title = string.Format("{0}, {1}", reportArea.AreaName, reportArea.ReportDate.ToString("MMMM \\'yy")),
                Text  = string.Format("{0}\n<{1}{2}|Go to Report>", reportArea.Summary, ConfigUtil.BaseAppUrl, url)
            });

            PostMessages(webhooks, payload);
        }
Exemplo n.º 3
0
        public void ReportingAreaUpdated(int companyId, LiteUser currentUser, ReportArea reportArea, string reportUrl)
        {
            var webhooks = _webhookRepository.GetList(new { CompanyId = companyId, EventReportingAreaUpdated = true });

            Task.Run(() => NotifyReportingAreaUpdated(currentUser, reportArea, webhooks, reportUrl));
        }
Exemplo n.º 4
0
 private void SetEnable(ReportArea reportArea, bool isEnable)
 {
     switch (reportArea)
     {
         case ReportArea.Header:
             btHeaderUp.Enabled = isEnable;
             btHeaderDown.Enabled = isEnable;
             break;
         case ReportArea.DetailColumns:
             btFieldUp.Enabled = isEnable;
             btFieldDown.Enabled = isEnable;
             break;
         case ReportArea.DetailGroupColumns:
             btGroupColumnUp.Enabled = isEnable;
             btGroupColumnDown.Enabled = isEnable;
             break;
         case ReportArea.Footer:
             btFooterUp.Enabled = isEnable;
             btFooterDown.Enabled = isEnable;
             break;
     }
 }
Exemplo n.º 5
0
        private void RefreshListBox(ReportArea reportArea)
        {
            #region Variable Definition
            ReportItem tempItem = null;
            int selectedIndex = -1;
            #endregion

            switch (reportArea)
            {
                case ReportArea.Header:
                    selectedIndex = lbxHeaderItems.SelectedIndex;
                    tempItem = ((ReportItem)lbxHeaderItems.SelectedItem).Copy();
                    lbxHeaderItems.Items.Insert(selectedIndex + 1, tempItem);
                    lbxHeaderItems.Items.RemoveAt(selectedIndex);
                    lbxHeaderItems.SelectedIndex = selectedIndex;
                    break;
                case ReportArea.Footer:
                    selectedIndex = lbxFooterItems.SelectedIndex;
                    tempItem = ((ReportItem)lbxFooterItems.SelectedItem).Copy();
                    lbxFooterItems.Items.Insert(selectedIndex + 1, tempItem);
                    lbxFooterItems.Items.RemoveAt(selectedIndex);
                    lbxFooterItems.SelectedIndex = selectedIndex;
                    break;
            }
        }