protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       eventId    = Convert.ToInt32(coll.Get("eId"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId   = Convert.ToInt32(coll.Get("aId"));
        string agentName = coll.Get("aName");
        string mode      = string.Empty;

        if (coll.Get("mode") != "" && coll.Get("mode") != null)
        {
            mode = coll.Get("mode");
        }
        int planType   = Convert.ToInt32(coll.Get("ptype"));
        int pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + " ";
        }

        if (!IsPostBack)
        {
            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            EventIdHiddenField.Value    = eventId.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            ModeHiddenField.Value       = mode;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            try
            {
                // Get the schedule event entry details and display.
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo schedule =
                    scheduleService.GetEventEntry(eventId, id);

                EventNumberLabel.Text = schedule.Events[0].EventNumber.ToString();
                EventDateLabel.Text   = schedule.Events[0].EventDate.ToString("MM/dd/yyyy");
                FarmLabel.Text        = schedule.FarmName;
                MailingPlanLabel.Text = schedule.Plan.Title;
                StartDateLabel.Text   = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text     = schedule.EndDate.ToString("MM/dd/yyyy");
                PlotLabel.Text        = schedule.Events[0].Entries[0].PlotName;

                // Get the design details for the event entry.
                ScheduleService.DesignInfo design =
                    scheduleService.GetDesign(eventId);

                int    index         = design.LowResolutionFile.LastIndexOf(".");
                string pageImagePath = ConfigurationManager.AppSettings["ApprovedDesignRoot"] +
                                       "\\ExtractedPages\\" +
                                       design.LowResolutionFile.Substring(0, index) +
                                       "_Page.jpg";

                if (!File.Exists(pageImagePath))
                {
                    pageImagePath = ConfigurationManager.AppSettings["ApprovedDesignRoot"] +
                                    "\\ExtractedPages\\dummy_page.jpg";

                    ErrorMessageLabel.Text    = "The preview message is not available. Please try again after some time or contact your administrator.";
                    ErrorMessageLabel.Visible = true;
                }

                float      zoomFactor;
                RectangleF messageRectangleActual;
                Util.CalculateMessageActual(design.MessageRectangle, design.Size,
                                            pageImagePath, out zoomFactor, out messageRectangleActual);

                pageImagePath = pageImagePath.Substring(pageImagePath.IndexOf("\\Members\\ApprovedDesignPages"));
                pageImagePath = pageImagePath.Replace("\\", "/");

                DesignImage.ImageUrl = "~" + pageImagePath;

                DesignTextLayer.Style.Add("left", messageRectangleActual.X.ToString() + "px");
                DesignTextLayer.Style.Add("top", messageRectangleActual.Y.ToString() + "px");
                DesignTextLayer.Style.Add("width", messageRectangleActual.Width.ToString() + "px");
                DesignTextLayer.Style.Add("height", messageRectangleActual.Height.ToString() + "px");
                DesignTextLayer.Style.Add("clip", "rect(0px " + messageRectangleActual.Width.ToString() + "px " + messageRectangleActual.Height.ToString() + "px 0px)");

                DesignText.Style.Add("zoom", zoomFactor.ToString());
                if (Session["MessagePreviewType"].ToString() == "text")
                {
                    DesignText.InnerHtml = Session["MessagePreviewText"].ToString();
                }
                else
                {
                    MessageImage.ImageUrl = Session["MessagePreviewText"].ToString();
                    MessageImage.Visible  = true;
                }

                if (!ClientScript.IsStartupScriptRegistered(this.GetType(), "Startup"))
                {
                    String scriptString = "<script language=JavaScript>";
                    scriptString += "var ctrlPrefix = 'ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_';";
                    scriptString += "var left = document.getElementById(ctrlPrefix + 'DesignImageLayer').offsetLeft;";
                    scriptString += "var top = document.getElementById(ctrlPrefix + 'DesignImageLayer').offsetTop;";
                    scriptString += "var leftOffset = document.getElementById(ctrlPrefix + 'DesignTextLayer').offsetLeft;";
                    scriptString += "var topOffset = document.getElementById(ctrlPrefix + 'DesignTextLayer').offsetTop;";
                    scriptString += "document.getElementById(ctrlPrefix + 'DesignTextLayer').style.left = left + leftOffset;";
                    scriptString += "document.getElementById(ctrlPrefix + 'DesignTextLayer').style.top = top + topOffset;";
                    scriptString += "</script>";

                    ClientScript.RegisterStartupScript(this.GetType(), "Startup", scriptString);
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
Beispiel #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       eventId    = Convert.ToInt32(coll.Get("eId"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId   = Convert.ToInt32(coll.Get("aId"));
        string agentName = coll.Get("aName");
        string mode      = string.Empty;

        if (coll.Get("mode") != "" && coll.Get("mode") != null)
        {
            mode = coll.Get("mode");
        }
        int planType   = Convert.ToInt32(coll.Get("ptype"));
        int pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        if (!IsPostBack)
        {
            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            EventIdHiddenField.Value    = eventId.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            ModeHiddenField.Value       = mode;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            // Get the schedule event entry details and display.
            try
            {
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo schedule =
                    scheduleService.GetEventEntry(eventId, id);

                EventNumberLabel.Text   = schedule.Events[0].EventNumber.ToString();
                EventDateLabel.Text     = schedule.Events[0].EventDate.ToString("MM/dd/yyyy");
                FarmIdHiddenField.Value = schedule.FarmId.ToString();
                FarmLabel.Text          = schedule.FarmName;
                MailingPlanLabel.Text   = schedule.Plan.Title;
                StartDateLabel.Text     = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text       = schedule.EndDate.ToString("MM/dd/yyyy");

                PlotLabel.Text = schedule.Events[0].Entries[0].PlotName;
                PrevMessageIdHiddenField.Value =
                    schedule.Events[0].Entries[0].Message.MessageId.ToString();

                if (coll.Get("fm") != "" && coll.Get("fm") != null && coll.Get("fm") == "pmp")
                {
                    if (Session["MessagePreviewTextId"].ToString().Length >= 6)
                    {
                        MessageTypeDropDownList.SelectedValue =
                            Session["MessagePreviewTypeId"].ToString();
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                        MessageDropDownList.SelectedValue =
                            Session["MessagePreviewTextId"].ToString();
                        MessageDropDownList_Changed(MessageDropDownList, new EventArgs());
                    }
                    else
                    {
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                    }
                }
                else
                {
                    if (schedule.Events[0].Entries[0].Message.MessageId != 0)
                    {
                        if (schedule.Events[0].Entries[0].Message.MessageType ==
                            ScheduleService.MessageType.Standard)
                        {
                            MessageTypeDropDownList.SelectedValue = "1";
                        }
                        else
                        {
                            MessageTypeDropDownList.SelectedValue = "2";
                        }
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                        MessageDropDownList.SelectedValue =
                            schedule.Events[0].Entries[0].Message.MessageId.ToString();
                        MessageDropDownList_Changed(MessageDropDownList, new EventArgs());
                    }
                    else
                    {
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                    }
                }

                if (mode == "view")
                {
                    MessageTypeDropDownList.Enabled = false;
                    MessageDropDownList.Enabled     = false;
                    SaveButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id        = Convert.ToInt32(coll.Get("id"));
        EventType eventType = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        else
        {
            if (coll.Get("ptype") != "" && coll.Get("ptype") != null)
            {
                if (Convert.ToInt32(coll.Get("ptype")) == 1)
                {
                    eventType = EventType.Past;
                }
            }
        }
        int    agentId    = Convert.ToInt32(coll.Get("aId"));
        string agentName  = coll.Get("aName");
        int    planType   = Convert.ToInt32(coll.Get("ptype"));
        int    pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        // Set the screen elements based on the type of events that are displayed.
        string queryString = "?id=" + id.ToString() +
                             "&aId=" + agentId.ToString() +
                             "&aName=" + agentName +
                             "&et=" + (Convert.ToInt32(eventType) == 0 ? "1" : "0") +
                             "&ptype=" + planType.ToString() +
                             "&pg=" + pageNumber.ToString();

        if (eventType == EventType.Future)
        {
            SetHyperLink(FutureEventsHyperLink, "");
            SetHyperLink(PastEventsHyperLink, "~/Members/ViewEvents.aspx" + queryString);
        }
        else
        {
            SetHyperLink(PastEventsHyperLink, "");
            SetHyperLink(FutureEventsHyperLink, "~/Members/ViewEvents.aspx" + queryString);
        }

        LegendTitleLabel.Text = "List of " + eventType.ToString() + " Events";

        if (!IsPostBack)
        {
            // Get the logged in account information.
            RegistrationService.LoginInfo loginInfo =
                (RegistrationService.LoginInfo)Session["loginInfo"];

            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            // Get the schedule details and display.
            try
            {
                ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo    schedule        = scheduleService.GetEvents(id);

                FarmLabel.Text        = schedule.FarmName;
                MailingPlanLabel.Text = schedule.Plan.Title;
                StartDateLabel.Text   = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text     = schedule.EndDate.ToString("MM/dd/yyyy");

                IList <ScheduleService.ScheduleEventInfo> events =
                    new List <ScheduleService.ScheduleEventInfo>();

                foreach (ScheduleService.ScheduleEventInfo eve in schedule.Events)
                {
                    if (eventType == EventType.Future)
                    {
                        if (eve.EventDate >= DateTime.Today)
                        {
                            events.Add(eve);
                        }
                    }
                    else
                    {
                        if (eve.EventDate < DateTime.Today)
                        {
                            events.Add(eve);
                        }
                    }
                }

                if (eventType == EventType.Future)
                {
                    FutureEventsDataGrid.Visible    = true;
                    FutureEventsDataGrid.DataSource = events;
                    FutureEventsDataGrid.DataBind();
                    PastEventsDataGrid.Visible = false;
                }
                else
                {
                    PastEventsDataGrid.Visible    = true;
                    PastEventsDataGrid.DataSource = events;
                    PastEventsDataGrid.DataBind();
                    FutureEventsDataGrid.Visible = false;
                }

                if (events.Count == 0)
                {
                    NoRecordsTable.Visible = true;
                }
                else
                {
                    NoRecordsTable.Visible = false;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
Beispiel #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId    = Convert.ToInt32(coll.Get("aId"));
        string agentName  = coll.Get("aName");
        int    planType   = Convert.ToInt32(coll.Get("ptype"));
        int    pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        if (!IsPostBack)
        {
            // Get the logged in account information.
            RegistrationService.LoginInfo loginInfo =
                (RegistrationService.LoginInfo)Session["loginInfo"];

            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            try
            {
                // Get the schedule event details and display.
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo schedule =
                    scheduleService.GetEventEntries(id);

                EventNumberLabel.Text = schedule.Events[0].EventNumber.ToString();
                EventDateLabel.Text   = schedule.Events[0].EventDate.ToString("MM/dd/yyyy");
                FarmLabel.Text        = schedule.FarmName;
                MailingPlanLabel.Text = schedule.Plan.Title;
                StartDateLabel.Text   = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text     = schedule.EndDate.ToString("MM/dd/yyyy");
                string designFile = schedule.Events[0].DesignFile;
                DesignHyperLink.Text        = designFile.Substring(designFile.IndexOf("_") + 1);
                DesignHyperLink.NavigateUrl = "~/Members/UserData/" +
                                              AgentIdHiddenField.Value + "/" + designFile;
                DesignHyperLink.Target = "_blank";
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Completed)
                {
                    StatusLabel.Text = schedule.Events[0].Status.Name +
                                       " on " + schedule.Events[0].CompletedOn.ToString("MM/dd/yyyy hh:mm tt");
                }
                else
                {
                    StatusLabel.Text = schedule.Events[0].Status.Name;
                }
                ProductTypeHiddenField.Value           = schedule.Events[0].ProductType.Name;
                ProductTypeLabel.Text                  = schedule.Events[0].ProductType.Name;
                PostalTariffDropDownList.SelectedValue = schedule.Events[0].PostalTariff;
                if (schedule.Events[0].Status.LookupId != (int)ScheduleEventStatus.Scheduled)
                {
                    PostalTariffDropDownList.Enabled = false;
                }
                if (schedule.Events[0].OrderValue == 0)
                {
                    TotalChargesPanel.Visible = false;
                }
                else
                {
                    TotalChargesPanel.Visible = true;
                    TotalChargesLabel.Text    = schedule.Events[0].OrderValue.ToString("####.#0");

                    if (schedule.Events[0].RefundAmount == 0)
                    {
                        RefundAmountPanel.Visible = false;
                    }
                    else
                    {
                        RefundAmountPanel.Visible = true;
                        RefundAmountLabel.Text    = schedule.Events[0].RefundAmount.ToString("####.#0");
                    }
                }

                // Set the notes panel based on the status of the event and role of the user.
                if ((schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Scheduled) &&
                    (loginInfo.Role != RegistrationService.UserRole.Agent))
                {
                    NotesReadOnlyPanel.Visible  = false;
                    NotesReadWritePanel.Visible = true;
                    NotesTextBox.Text           = schedule.Events[0].Notes;
                }
                else
                {
                    NotesReadWritePanel.Visible = false;
                    NotesReadOnlyPanel.Visible  = true;
                    NotesLabel.Text             = schedule.Events[0].Notes;
                }

                // Display plot's information.
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Scheduled)
                {
                    PastEventDetailsDataGrid.Visible      = false;
                    FutureEventDetailsDataGrid.Visible    = true;
                    FutureEventDetailsDataGrid.DataSource = schedule.Events[0].Entries;
                    FutureEventDetailsDataGrid.DataBind();
                }
                else
                {
                    FutureEventDetailsDataGrid.Visible  = false;
                    PastEventDetailsDataGrid.Visible    = true;
                    PastEventDetailsDataGrid.DataSource = schedule.Events[0].Entries;
                    PastEventDetailsDataGrid.DataBind();
                }

                if (schedule.Events[0].Entries.Length == 0)
                {
                    NoRecordsTable.Visible = true;
                }
                else
                {
                    NoRecordsTable.Visible = false;
                }

                // Set the printer remarks panel based on the status of the event and role of
                // the user.
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.InProgress)
                {
                    if (loginInfo.Role == RegistrationService.UserRole.Printer)
                    {
                        PrinterRemarksPanel.Visible = true;
                    }
                    else
                    {
                        PrinterRemarksPanel.Visible = false;
                    }
                }
                else if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Completed)
                {
                    PrinterRemarksPanel.Visible   = true;
                    PrinterRemarksRWPanel.Visible = false;
                    PrinterRemarksROPanel.Visible = true;

                    // Display Data.
                    string file = schedule.Events[0].MailingListFile;
                    MailingListFileHyperLink.Text        = file.Substring(file.IndexOf("_") + 1);
                    MailingListFileHyperLink.NavigateUrl = "~/Members/MailingLists/" + file;
                    MailingListFileHyperLink.Target      = "_blank";
                    MailingCountLabel.Text = schedule.Events[0].MailingCount.ToString();
                    RemarksLabel.Text      = schedule.Events[0].Remarks;

                    if (schedule.Events[0].RefundAmount == 0)
                    {
                        ExceptionReportedPanel.Visible = false;
                    }
                    else
                    {
                        ExceptionReportedPanel.Visible = true;

                        if (schedule.Events[0].ExceptionReported)
                        {
                            ExceptionReportedImage.ImageUrl = "~/Images/tick.gif";
                        }
                        else
                        {
                            ExceptionReportedImage.ImageUrl = "~/Images/cross.gif";
                        }
                    }
                }
                else
                {
                    PrinterRemarksPanel.Visible = false;
                }

                // Set the action buttons based on the role and status.
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Scheduled)
                {
                    if (loginInfo.Role == RegistrationService.UserRole.Agent)
                    {
                        ReadWriteButtonsPanel.Visible = true;
                    }
                    else
                    {
                        CancelEventButtonsPanel.Visible = true;
                    }
                }
                else if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.InProgress)
                {
                    if (loginInfo.Role == RegistrationService.UserRole.Printer)
                    {
                        CompleteEventButtonsPanel.Visible = true;
                    }
                    else
                    {
                        ReadOnlyButtonsPanel.Visible = true;
                    }
                }
                else
                {
                    ReadOnlyButtonsPanel.Visible = true;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }