public static bool SendEmailAsApproved(DesignService.DesignInfo design, string applicationPath, string url) { try { // Send email to the Agent. RegistrationService.RegistrationService registrationService = serviceLoader.GetRegistration(); RegistrationService.RegistrationInfo agent = registrationService.GetDetails(design.UserId); string templatePath = AppDomain.CurrentDomain.BaseDirectory + "HTMLTemplate\\Email_DesignApproved_Agent.html"; Hashtable variables = new Hashtable(); variables.Add("FIRST_NAME", agent.FirstName); variables.Add("LAST_NAME", agent.LastName); variables.Add("DESIGN_CATEGORY", design.Category.Name); variables.Add("DESIGN_INFO", BuildInformation(design, agent.UserId, url)); MailAddressCollection mailAddresses = new MailAddressCollection(); mailAddresses.Add(agent.Email); Mail.Send(templatePath, variables, mailAddresses, "MailingCycle Design Approved", applicationPath); // Send email to all the Admins. CommonService.CommonService commonService = serviceLoader.GetCommon(); IList <CommonService.RegistrationInfo> users = commonService.GetUsersByRole(CommonService.UserRole.Admin.ToString()); templatePath = AppDomain.CurrentDomain.BaseDirectory + "HTMLTemplate\\Email_DesignApproved_Admin.html"; variables = new Hashtable(); variables.Add("DESIGN_CATEGORY", design.Category.Name); variables.Add("FIRST_NAME", agent.FirstName); variables.Add("LAST_NAME", agent.LastName); variables.Add("DESIGN_INFO", BuildInformation(design, agent.UserId, url)); mailAddresses = new MailAddressCollection(); foreach (CommonService.RegistrationInfo user in users) { mailAddresses.Add(user.Email); } Mail.Send(templatePath, variables, mailAddresses, "MailingCycle Design Approved", applicationPath); } catch (Exception ex) { log.Error("Unknown Error", ex); return(false); } return(true); }
private static string BuildInformation(DesignService.DesignInfo design, int userId, string url) { StringBuilder designInfo = new StringBuilder(); string urlPrefix = url.Substring(0, url.IndexOf("Members")) + "Members/UserData/" + userId.ToString() + "/"; designInfo.Append("Type: " + design.Type.Name + "<br />"); designInfo.Append("Size: " + design.Size.Width.ToString() + " x " + design.Size.Height.ToString() + " inch." + "<br />"); if (design.Category.Name == "PowerKard") { designInfo.Append("Gender: " + design.Gender + "<br />"); designInfo.Append("Agent Name: " + design.OnDesignName + "<br />"); designInfo.Append("Justification: " + design.Justification.ToString() + "<br />"); if (design.Gutter != "") { designInfo.Append("Gutter: " + design.Gutter + "<br />"); } if (design.MessageRectangle.X > 0) { designInfo.Append("Message Location: " + design.MessageRectangle.X.ToString() + " x " + design.MessageRectangle.Y.ToString() + " inch." + "<br />"); } if (design.MessageRectangle.Width > 0) { designInfo.Append("Message Size: " + design.MessageRectangle.Width.ToString() + " x " + design.MessageRectangle.Height.ToString() + " inch." + "<br />"); } } designInfo.Append("Low-Resolution File: <a href=\"" + urlPrefix + design.LowResolutionFile + "\">" + design.LowResolutionFile.Substring(design.LowResolutionFile.IndexOf("_") + 1) + "</a><br />"); designInfo.Append("High-Resolution File: <a href=\"" + urlPrefix + design.HighResolutionFile + "\">" + design.HighResolutionFile.Substring(design.HighResolutionFile.IndexOf("_") + 1) + "</a><br />"); if (design.ExtraFile != "") { designInfo.Append("Additional File: <a href=\"" + urlPrefix + design.ExtraFile + "\">" + design.ExtraFile.Substring(design.ExtraFile.IndexOf("_") + 1) + "</a><br />"); } designInfo.Append("Notes: " + (design.Comments == "" ? "---" : design.Comments)); return(designInfo.ToString()); }
private bool Save(int statusId) { string approvedDesignRoot = ConfigurationManager.AppSettings["ApprovedDesignRoot"]; // Get the logged in account information. RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"]; // Get the upload location. string path = Server.MapPath("~/Members/UserData/" + AgentIdHiddenField.Value); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!ValidateFiles()) { return(false); } // Upload the files. string lowResolutionFile = LowResolutionFileHiddenField.Value; string highResolutionFile = HighResolutionFileHiddenField.Value; string additionalFile = AdditionalFileHiddenField.Value; try { Util.Design.UploadFiles(path, ref lowResolutionFile, ref highResolutionFile, ref additionalFile, Convert.ToInt32(IdHiddenField.Value), LowResolutionFileUpload, HighResolutionFileUpload, AdditionalFileUpload, ref RemoveAdditionalFileHiddenField); try { if (statusId == (int)DesignStatus.Approved) { if (StatusLabel.Text == "Submitted") { File.Copy(path + "\\" + lowResolutionFile, approvedDesignRoot + "\\" + lowResolutionFile, true); } } } catch (Exception ex) { log.Error("Unknown Error", ex); } } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to process the request. Please contact your administrator."; ErrorMessageLabel.Visible = true; log.Error("Unknown Error", ex); return(false); } // Save the data. try { string[] typeArgs = TypeDropDownList.SelectedValue.Split("|".ToCharArray()); decimal length = 0, width = 0; DesignService.DesignService designService = serviceLoader.GetDesign(); DesignService.DesignInfo design = new DesignService.DesignInfo(); // Design Details. design.DesignId = Convert.ToInt32(IdHiddenField.Value); design.UserId = Convert.ToInt32(AgentIdHiddenField.Value); DesignService.LookupInfo category = new DesignService.LookupInfo(); category.LookupId = (int)DesignCategory.PowerKard; category.Name = DesignCategory.PowerKard.ToString(); design.Category = category; DesignService.LookupInfo type = new DesignService.LookupInfo(); if (typeArgs[0] == DesignType.Standard.ToString().Substring(0, 1)) { type.LookupId = (int)DesignType.Standard; type.Name = DesignType.Standard.ToString(); length = Convert.ToDecimal(typeArgs[1]); width = Convert.ToDecimal(typeArgs[2]); } else { type.LookupId = (int)DesignType.Custom; type.Name = DesignType.Custom.ToString(); length = Convert.ToDecimal(LengthTextBox.Text); width = Convert.ToDecimal(WidthTextBox.Text); } design.Type = type; DesignService.SizeF size = new DesignService.SizeF(); size.Width = (float)length; size.Height = (float)width; design.Size = size; // Attributes. design.Gender = GenderDropDownList.SelectedValue; design.OnDesignName = AgentNameTextBox.Text; design.Justification = (DesignService.JustificationType)Convert.ToInt32(JustificationDropDownList.SelectedValue); design.Gutter = GutterDropDownList.SelectedValue; DesignService.RectangleF messageRectangle = new DesignService.RectangleF(); messageRectangle.X = MessageXTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageXTextBox.Text.Trim()) : 0; messageRectangle.Y = MessageYTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageYTextBox.Text.Trim()) : 0; messageRectangle.Width = MessageLengthTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageLengthTextBox.Text.Trim()) : 0; messageRectangle.Height = MessageWidthTextBox.Text.Trim() != "" ? (float)Convert.ToDecimal(MessageWidthTextBox.Text.Trim()) : 0; design.MessageRectangle = messageRectangle; // Upload Files. design.LowResolutionFile = lowResolutionFile; design.HighResolutionFile = highResolutionFile; design.ExtraFile = additionalFile; // Additional fields. DesignService.LookupInfo status = new DesignService.LookupInfo(); status.LookupId = statusId; design.Status = status; design.LastModifyBy = loginInfo.UserId; design.Comments = NotesTextBox.Text; if (statusId == (int)DesignStatus.Approved) { design.ApproveBy = loginInfo.UserId; } else { design.ApproveBy = 0; } designService.Update(loginInfo.UserId, design); try { if (statusId == (int)DesignStatus.Approved) { if (StatusLabel.Text == "Submitted") { Util.Design.SendEmailAsApproved(design, Request.ApplicationPath, Request.Url.ToString()); } } else if (statusId == (int)DesignStatus.Submitted) { if (design.UserId == design.LastModifyBy) { Util.Design.SendEmailAsSubmitted(design, Request.ApplicationPath, Request.Url.ToString()); } } } catch (Exception ex) { log.Error("Unknown Error", ex); } return(true); } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to process the request. Please contact your administrator."; ErrorMessageLabel.Visible = true; log.Error("Unknown Error", ex); return(false); } }
protected void Page_Load(object sender, EventArgs e) { // Get the query string values. NameValueCollection coll = Request.QueryString; int id = Convert.ToInt32(coll.Get("id")); string mode = coll.Get("mode"); string type = coll.Get("type"); decimal length = Convert.ToDecimal(coll.Get("length")); decimal width = Convert.ToDecimal(coll.Get("width")); int agentId = Convert.ToInt32(coll.Get("aId")); string agentName = coll.Get("aName"); // Change the title of the page. Page.Title = "Mailing Cycle " + mode + " PowerKard"; PageTitleLabel.Text = mode + " PowerKard"; if (mode == "Edit") { AddPageDescriptionPanel.Visible = false; EditPageDescriptionPanel.Visible = true; } else if (mode == "Review") { AddPageDescriptionPanel.Visible = false; ReviewPageDescriptionPanel.Visible = true; } else if (mode == "View") { AddPageDescriptionPanel.Visible = false; ViewPageDescriptionPanel.Visible = true; } if (agentName != "") { AgentNameLabel.Text = "Agent Name: " + agentName + " "; } ErrorMessageLabel.Visible = false; 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(); ModeHiddenField.Value = mode.ToString(); AgentIdHiddenField.Value = agentId.ToString(); AgentNameHiddenField.Value = agentName; // Set the controls based on the role. if (loginInfo.Role == RegistrationService.UserRole.Agent) { NotesRow.Visible = false; } // Set the design details section. TypeDropDownList.SelectedValue = type + "|" + (type == "S" ? length.ToString("####.####") : "0") + "|" + (type == "S" ? width.ToString("####.####") : "0"); LengthTextBox.Text = length.ToString("####.####"); WidthTextBox.Text = width.ToString("####.####"); if (type != "C") { LengthTextBox.Enabled = false; WidthTextBox.Enabled = false; } // Get the design details, if one exists. if (id != 0) { try { DesignService.DesignService designService = serviceLoader.GetDesign(); DesignService.DesignInfo design = designService.Get(id); // Display Data - Status. AgentIdHiddenField.Value = design.UserId.ToString(); StatusLabel.Text = design.Status.Name; UsedHiddenField.Value = design.Used.ToString(); // Display Data - Attributes. GenderDropDownList.SelectedValue = design.Gender; AgentNameTextBox.Text = design.OnDesignName; JustificationDropDownList.SelectedValue = ((int)design.Justification).ToString(); GutterDropDownList.SelectedValue = design.Gutter; MessageXTextBox.Text = design.MessageRectangle.X.ToString("####.####"); MessageYTextBox.Text = design.MessageRectangle.Y.ToString("####.####"); MessageLengthTextBox.Text = design.MessageRectangle.Width.ToString("####.####"); MessageWidthTextBox.Text = design.MessageRectangle.Height.ToString("####.####"); // Display Data - Upload Files. string path = Server.MapPath("~/Members/UserData/" + AgentIdHiddenField.Value) + "\\"; string lowResolutionFile, highResolutionFile, additionalFile = string.Empty; lowResolutionFile = design.LowResolutionFile; LowResolutionFileHyperLink.Text = lowResolutionFile.Substring(lowResolutionFile.IndexOf("_") + 1); LowResolutionFileHyperLink.NavigateUrl = "~/Members/UserData/" + AgentIdHiddenField.Value + "/" + lowResolutionFile; LowResolutionFileHyperLink.Target = "_blank"; FileInfo file = new FileInfo(path + lowResolutionFile); if (file.Exists) { LowResolutionFileSizeLabel.Text = Convert.ToInt32(file.Length / 1024).ToString() + " KB"; } else { LowResolutionFileSizeLabel.Text = "-"; } LowResolutionFileNotExistsPanel.Style.Value = "position: absolute; visibility: hidden;"; LowResolutionFileExistsPanel.Style.Value = "position: relative; visibility: visible;"; LowResolutionFileRequiredFieldValidator.Enabled = false; LowResolutionFileHiddenField.Value = lowResolutionFile; highResolutionFile = design.HighResolutionFile; HighResolutionFileHyperLink.Text = highResolutionFile.Substring(highResolutionFile.IndexOf("_") + 1); HighResolutionFileHyperLink.NavigateUrl = "~/Members/UserData/" + AgentIdHiddenField.Value + "/" + highResolutionFile; HighResolutionFileHyperLink.Target = "_blank"; file = new FileInfo(path + highResolutionFile); if (file.Exists) { HighResolutionFileSizeLabel.Text = Convert.ToInt32(file.Length / 1024).ToString() + " KB"; } else { HighResolutionFileSizeLabel.Text = "-"; } HighResolutionFileNotExistsPanel.Style.Value = "position: absolute; visibility: hidden;"; HighResolutionFileExistsPanel.Style.Value = "position: relative; visibility: visible;"; HighResolutionFileRequiredFieldValidator.Enabled = false; HighResolutionFileHiddenField.Value = highResolutionFile; if (design.ExtraFile != "") { additionalFile = design.ExtraFile; AdditionalFileHyperLink.Text = additionalFile.Substring(additionalFile.IndexOf("_") + 1); AdditionalFileHyperLink.NavigateUrl = "~/Members/UserData/" + AgentIdHiddenField.Value + "/" + additionalFile; AdditionalFileHyperLink.Target = "_blank"; file = new FileInfo(path + additionalFile); if (file.Exists) { AdditionalFileSizeLabel.Text = Convert.ToInt32(file.Length / 1024).ToString() + " KB"; } else { AdditionalFileSizeLabel.Text = "-"; } AdditionalFileNotExistsPanel.Style.Value = "position: absolute; visibility: hidden;"; AdditionalFileExistsPanel.Style.Value = "position: relative; visibility: visible;"; AdditionalFileHiddenField.Value = additionalFile; } // Display Data - History. HistoryTextBox.Text = design.History; if (mode == "View") { DisableDesignInformation(); NotesTextBox.Enabled = false; AgentButtonsPanel.Visible = false; ReadOnlyButtonsPanel.Visible = true; AgentButtonsHelpPanel.Visible = false; ReadOnlyButtonsHelpPanel.Visible = true; } else if (mode == "Review") { AgentButtonsPanel.Visible = false; ReviewButtonsPanel.Visible = true; MessageLocnManLabel.Visible = true; MessageSizeManLabel.Visible = true; MessageXTextBoxRequiredFieldValidator.Enabled = true; MessageYTextBoxRequiredFieldValidator.Enabled = true; MessageLengthTextBoxRequiredFieldValidator.Enabled = true; MessageWidthTextBoxRequiredFieldValidator.Enabled = true; AgentButtonsHelpPanel.Visible = false; ReviewButtonsHelpPanel.Visible = true; } else if (mode == "Edit") { if (StatusLabel.Text == "Uploaded") { if (loginInfo.Role != RegistrationService.UserRole.Agent) { AgentButtonsPanel.Visible = false; ReadWriteButtonsPanel.Visible = true; AgentButtonsHelpPanel.Visible = false; ReadWriteButtonsHelpPanel.Visible = true; } } else if (StatusLabel.Text == "Submitted") { DisableDesignInformation(); AgentButtonsPanel.Visible = false; ReadWriteButtonsPanel.Visible = true; AgentButtonsHelpPanel.Visible = false; ReadWriteButtonsHelpPanel.Visible = true; } else if (StatusLabel.Text == "Approved") { DisableDesignInformation(); AgentButtonsPanel.Visible = false; DeleteButtonsPanel.Visible = true; AgentButtonsHelpPanel.Visible = false; DeleteButtonsHelpPanel.Visible = true; // Check whether pages already extracted. int index = LowResolutionFileHiddenField.Value.LastIndexOf("."); string approvedDesignPage = ConfigurationManager.AppSettings["ApprovedDesignRoot"] + "\\ExtractedPages\\" + LowResolutionFileHiddenField.Value.Substring(0, index) + "_Page.jpg"; file = new FileInfo(approvedDesignPage); if (file.Exists) { ExtractPagesButton.Enabled = false; } else { ExtractPagesButton.Enabled = true; } } } } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to process the request. Please contact your administrator."; ErrorMessageLabel.Visible = true; log.Error("Unknown Error", ex); } } if (mode == "Add") { if (loginInfo.Role != RegistrationService.UserRole.Agent) { AgentButtonsPanel.Visible = false; ReadWriteButtonsPanel.Visible = true; AgentButtonsHelpPanel.Visible = false; ReadWriteButtonsHelpPanel.Visible = true; } } } }
/// <remarks/> public void UpdateAsync(int userId, DesignInfo design) { this.UpdateAsync(userId, design, null); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (IsPrinterRole) { DeleteFarmButton.Enabled = false; EditFarmButton.Enabled = false; FirmUpButton.Enabled = false; CreatePlotButton.Enabled = false; } int farmId = 0; if ((Request.QueryString["farmId"] != "") && (Request.QueryString["farmId"] != null)) { int.TryParse(Request.QueryString["farmId"], out farmId); } if (farmId == 0) { Response.Redirect("~/Members/FarmManagement.aspx"); } FarmIdHiddenField.Value = farmId.ToString(); try { // Get the common web service instance. ServiceAccess serviceLoader = ServiceAccess.GetInstance(); FarmService.FarmService farmService = serviceLoader.GetFarm(); int userId = farmService.GetUserIdForFarm(farmId); UserIdHiddenField.Value = userId.ToString(); if (!IsAgentRole) { ForAgentLiteral.Visible = true; RegistrationService.RegistrationService regservice = serviceLoader.GetRegistration(); RegistrationService.RegistrationInfo regInfo = regservice.GetDetails(userId); ForAgentLiteral.Text = "Selected Agent: " + regInfo.UserName + " / " + regInfo.FirstName + " " + regInfo.LastName + " "; ForAgentUserIdHiddenField.Value = userId.ToString(); } else { ForAgentLiteral.Visible = false; } FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId); FarmNameLabel.Text = farm.FarmName; MailingPlanLabel.Text = farm.MailingPlan.Title; CreateDateLabel.Text = farm.CreateDate.ToShortDateString(); if (farm.Firmup) { FirmupStatusLabel.Text = "Firmed Up"; } else { FirmupStatusLabel.Text = "Not Firmed Up"; } FarmContactCountLabel.Text = farm.ContactCount.ToString(); PlotCountLabel.Text = farm.PlotCount.ToString(); FillPlotGrid(farm.Plots, 0); // ***************** Firm Up ***************** \\ if (IsAgentRole) { // Set the firm up button visible to agent. FirmUpButtonPanel.Visible = true; // Get the mailing plan of the farm. int mailingPlanId = farm.MailingPlan.MailingPlanId; // Get the design details of the agent. DesignService.DesignService designService = serviceLoader.GetDesign(); DesignService.DesignInfo design = new DesignService.DesignInfo(); DesignService.DesignInfo brochure = new DesignService.DesignInfo(); RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"]; IList <DesignService.DesignInfo> designs = designService.GetList(loginInfo.UserId); foreach (DesignService.DesignInfo designInfo in designs) { if (designInfo.Category.Name == "PowerKard") { design = designInfo; } else { brochure = designInfo; } } // Get the credit card details of the logged in agent. RegistrationService.RegistrationService registrationService = serviceLoader.GetRegistration(); RegistrationService.CreditCardInfo creditCard = registrationService.GetCreditCard(loginInfo.UserId); bool isCreditCardValid = false; if (creditCard != null) { DateTime expirationDate = new DateTime(creditCard.ExpirationYear, creditCard.ExpirationMonth, 1); expirationDate = expirationDate.AddMonths(1); if (expirationDate > DateTime.Today) { isCreditCardValid = true; } } // Check whether the farm is ready for firm up. if (mailingPlanId == 0) { FirmUpStatusHiddenField.Value = "MP_REQ"; } else if (mailingPlanId == 100003) { // 8 x 8. if (design.Status.Name != "Approved") { FirmUpStatusHiddenField.Value = "DESIGN_REQ"; } } else { if (design.Status.Name != "Approved" || brochure.Status.Name != "Approved") { FirmUpStatusHiddenField.Value = "DESIGN_REQ"; } } if (!isCreditCardValid) { FirmUpStatusHiddenField.Value = "CC_INVALID"; } if (farm.Firmup) { FirmUpButton.Enabled = false; } } // ******************************************* \\ } catch (Exception ex) { log.Error("UNKNOWN ERROR:", ex); ErrorLiteral.Text = "Unknown Error Please contact Administrator:"; } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["loginInfo"] == null || Session["loginInfo"] == "") { Response.Redirect("../userLogin.aspx?Message=SessionExpired"); } RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"]; bool isAgent = (loginInfo.Role == RegistrationService.UserRole.Agent); ServiceAccess serviceLoader = ServiceAccess.GetInstance(); // ************Populate the Farm Data************ FarmService.FarmService farmService = serviceLoader.GetFarm(); int farmCount = 0; int plotCount = 0; long contactCount = 0; if (isAgent) { FarmService.FarmInfo[] farmInfo = farmService.GetFarmSummary(loginInfo.UserId); farmCount = farmInfo.Length; for (int i = 0; i < farmCount; i++) { plotCount = plotCount + farmInfo[i].PlotCount; contactCount = contactCount + farmInfo[i].ContactCount; } } else { farmCount = farmService.TotalActiveFarmCount(); plotCount = farmService.TotalActivePlotCount(); contactCount = farmService.TotalActiveContactCount(); } FarmPlotLabel.Text = farmCount.ToString() + " Farms / " + plotCount + " Plots"; ContactLabel.Text = contactCount.ToString() + " Contacts"; // ************Populate Messages Data************ MessageService messageService = serviceLoader.GetMessage(); StandardMessagesLabel.Text = messageService.GetStandardMessageList(isAgent, string.Empty, string.Empty).Length + " messages"; if (isAgent) { CustomMessagesLabel.Text = messageService.GetCustomMessageList(loginInfo.UserId).Length + " messages"; } else { CustomMessagesLabel.Text = messageService.GetCustomMessageList(0).Length + " messages"; } // ************Populate design Data************ DesignService.DesignService designService = serviceLoader.GetDesign(); if (isAgent) { IList <DesignService.DesignInfo> designs = designService.GetList(loginInfo.UserId); DesignService.DesignInfo design = new DesignService.DesignInfo(); DesignService.DesignInfo brochure = new DesignService.DesignInfo(); foreach (DesignService.DesignInfo designInfo in designs) { if (designInfo.Category.Name == "PowerKard") { design = designInfo; } else { brochure = designInfo; } } PowerKardStatusLabel.Text = design.Status.Name.ToString(); BrochureStatusLabel.Text = brochure.Status.Name.ToString(); } else { object[] designStatusArray; DataTable designStatusTable = new DataTable(); designStatusArray = designService.GetSummary(); designStatusTable = Util.GetDataTable(designStatusArray); if (designStatusTable != null) { PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[0][3] + " - " + designStatusTable.Rows[0][4] + ","; PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[1][3] + " - " + designStatusTable.Rows[1][4] + ","; PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[4][3] + " - " + designStatusTable.Rows[4][4] + ","; PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Substring(0, PowerKardStatusLabel.Text.Length - 1); PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Uploaded", "Upd"); PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Submitted", "Sub"); PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Approved", "App"); BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[5][3] + " - " + designStatusTable.Rows[5][4] + ","; BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[6][3] + " - " + designStatusTable.Rows[6][4] + ","; BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[9][3] + " - " + designStatusTable.Rows[9][4] + ","; BrochureStatusLabel.Text = BrochureStatusLabel.Text.Substring(0, BrochureStatusLabel.Text.Length - 1); BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Uploaded", "Upd"); BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Submitted", "Sub"); BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Approved", "App"); WelcomeHelpPanel.Visible = true; } } // ************Populate Inventory Data************ ProductService.ProductService productService = serviceLoader.GetProduct(); ProductService.ProductItemInfo[] productItemInfo; if (isAgent) { productItemInfo = productService.GetInventoryTotalCount(loginInfo.UserId); } else { productItemInfo = productService.GetInventoryTotalCount(0); } if (productItemInfo.Length < 1) { InventoryLabel.Text = "PowerKards:0<br>Brochures:0"; } InventoryRepeater.DataSource = productItemInfo; InventoryRepeater.DataBind(); // ************Populate Schedule Management Data************ ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule(); object[] SchedulePlansArray; DataTable SchedulePlansTable = new DataTable(); if (isAgent) { SchedulePlansArray = scheduleService.GetSummaryOfUser(loginInfo.UserId); } else { SchedulePlansArray = scheduleService.GetSummary(); } SchedulePlansTable = Util.GetDataTable(SchedulePlansArray); if (SchedulePlansTable != null) { ActivePlansLabel.Text = SchedulePlansTable.Rows[0][0].ToString() + ": " + SchedulePlansTable.Rows[0][1].ToString(); if (Convert.ToInt32(SchedulePlansTable.Rows[1][1].ToString()) > 0) { DelayedPlansLabel.Text = SchedulePlansTable.Rows[1][0].ToString() + ": " + SchedulePlansTable.Rows[1][1].ToString(); } } //********* Populate User Management Info ********** if (isAgent) { UserManagementPanel.Visible = false; } else { object[] usersArray; DataTable usersTable = new DataTable(); RegistrationService.RegistrationService registrationService = ServiceAccess.GetInstance().GetRegistration(); usersArray = registrationService.GetApprovalRequiredUsers(); usersTable = Util.GetDataTable(usersArray); RegistrationService.UserRole userRole; if (usersTable != null) { if (usersTable.Rows.Count < 1) { UsersLabel.Text = "No Users waiting for approval"; } else { for (int i = 0; i < usersTable.Rows.Count; i++) { userRole = (RegistrationService.UserRole)((Convert.ToInt32(usersTable.Rows[i][0].ToString()) - 1)); UsersLabel.Text = UsersLabel.Text + userRole.ToString() + " : " + usersTable.Rows[i][1].ToString() + "<br>"; } } } } }
private void DisplayDesigns(int agentId) { try { DesignService.DesignService designService = serviceLoader.GetDesign(); IList <DesignService.DesignInfo> designs = designService.GetListAll(agentId); DesignService.DesignInfo design = new DesignService.DesignInfo(); design.Category = new DesignService.LookupInfo(); design.Category.LookupId = 17; design.Category.Name = DesignCategory.PowerKard.ToString(); design.Status = new DesignService.LookupInfo(); design.Status.LookupId = 21; design.Status.Name = "Not Uploaded"; DesignService.DesignInfo brochure = new DesignService.DesignInfo(); brochure.Category = new DesignService.LookupInfo(); brochure.Category.LookupId = 18; brochure.Category.Name = DesignCategory.Brochure.ToString(); brochure.Status = new DesignService.LookupInfo(); brochure.Status.LookupId = 21; brochure.Status.Name = "Not Uploaded"; List <DesignService.DesignInfo> prevDesigns = new List <DesignService.DesignInfo>(); List <DesignService.DesignInfo> prevBrochures = new List <DesignService.DesignInfo>(); foreach (DesignService.DesignInfo designInfo in designs) { if (designInfo.Category.LookupId == (int)DesignCategory.PowerKard) { if (designInfo.Status.LookupId == (int)DesignStatus.Inactivated) { prevDesigns.Add(designInfo); } else { design = designInfo; } } else { if (designInfo.Status.LookupId == (int)DesignStatus.Inactivated) { prevBrochures.Add(designInfo); } else { brochure = designInfo; } } } SetControls(design, PowerKardLengthTextBox, PowerKardWidthTextBox, PowerkardHyperLink, PowerKardTypeDropDownList, PowerKardEditButton, PowerKardStatusLabel); SetControls(brochure, BrochureLengthTextBox, BrochureWidthTextBox, BrochureHyperLink, BrochureTypeDropDownList, BrochureEditButton, BrochureStatusLabel); DesignIdHiddenField.Value = design.DesignId.ToString(); BrochureIdHiddenField.Value = brochure.DesignId.ToString(); // Display previous designs. if (prevDesigns.Count > 0) { PreviousDesignsRow.Visible = true; ShowPreviousDesigns(prevDesigns, PreviousDesignsGridView, "EditDesign"); } else { PreviousDesignsRow.Visible = false; } if (prevBrochures.Count > 0) { PreviousBrochuresRow.Visible = true; ShowPreviousDesigns(prevBrochures, PreviousBrochuresGridView, "EditBrochure"); } else { PreviousBrochuresRow.Visible = false; } } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to process the request. Please contact your administrator."; ErrorMessageLabel.Visible = true; log.Error("Unknown Error", ex); } }
private void SetControls(DesignService.DesignInfo designInfo, TextBox lengthTextBox, TextBox widthTextBox, HyperLink hyperLink, DropDownList typeDropDownList, Button editButton, Label statusLabel) { if (designInfo.Status.LookupId == (int)DesignStatus.NotUploaded) { lengthTextBox.Enabled = false; widthTextBox.Enabled = false; } else { // Display the data. hyperLink.NavigateUrl = "~/Members/UserData/" + AgentIdHiddenField.Value + "/" + designInfo.LowResolutionFile; hyperLink.Target = "_blank"; typeDropDownList.SelectedValue = designInfo.Type.Name.Substring(0, 1) + "|" + (designInfo.Type.Name == "Standard" ? designInfo.Size.Width.ToString("####.####") : "0") + "|" + (designInfo.Type.Name == "Standard" ? designInfo.Size.Height.ToString("####.####") : "0"); typeDropDownList.Enabled = false; lengthTextBox.Text = designInfo.Size.Width.ToString("####.####"); lengthTextBox.Enabled = false; widthTextBox.Text = designInfo.Size.Height.ToString("####.####"); widthTextBox.Enabled = false; // Set the action button. if (designInfo.Status.Name == "Uploaded") { editButton.Text = "Edit " + designInfo.Category.Name; } else if (designInfo.Status.Name == "Hold") { editButton.Text = "View " + designInfo.Category.Name; } else { RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"]; if (loginInfo.Role == RegistrationService.UserRole.Agent) { editButton.Text = "View " + designInfo.Category.Name; } else if (loginInfo.Role == RegistrationService.UserRole.Printer) { if (designInfo.Status.Name == "Submitted") { editButton.Text = "Review " + designInfo.Category.Name; } else { editButton.Text = "Edit " + designInfo.Category.Name; } } else { editButton.Text = "Edit " + designInfo.Category.Name; } } } statusLabel.Text = designInfo.Status.Name; }