private void FillStandardMessages() { try { ServiceAccess serviceLoader = ServiceAccess.GetInstance(); MessageService msgService = serviceLoader.GetMessage(); int userId = 0; LoginInfo regInfo = (LoginInfo)Session["loginInfo"]; if (IsAgentRole) { userId = regInfo.UserId; } else { userId = Convert.ToInt32(Request.QueryString["userId"]); } DesignService designService = ServiceAccess.GetInstance().GetDesign(); DesignInfo[] designs = designService.GetList(userId); string gender = string.Empty; string onDesignName = string.Empty; bool isDesignAvl = true; if (designs != null) { foreach (DesignInfo designInfo in designs) { if (designInfo != null && designInfo.DesignId > 0) { DesignInfo allDesignInfo = designService.Get(designInfo.DesignId); if (allDesignInfo.Status.Name.ToLower() != "approved") { isDesignAvl = false; } else if (allDesignInfo.Gender != string.Empty && allDesignInfo.OnDesignName != string.Empty) { gender = allDesignInfo.Gender; onDesignName = allDesignInfo.OnDesignName; break; } } else { isDesignAvl = false; } } } if (isDesignAvl) { MessageInfo[] messageInfo = msgService.GetStandardMessageList(regInfo.Role == UserRole.Agent, gender, onDesignName); StandardMessagesDropDownList.DataSource = messageInfo; ViewState["DataSource"] = StandardMessagesDropDownList.DataSource; StandardMessagesDropDownList.DataTextField = "ShortDesc"; StandardMessagesDropDownList.DataValueField = "MessageId"; StandardMessagesDropDownList.DataBind(); } else { StandardMessagesDropDownList.Enabled = false; } StandardMessagesDropDownList.Items.Insert(0, new ListItem("<Select a standard message>", "0")); } catch (Exception ex) { ErrorLiteral.Text = "Unable to load standard messages."; ErrorLiteral.Visible = true; log.Error("Unknown error", ex); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if ((IsFromModifyPage && Request.QueryString["MessageId"] == null && Session["SelectedMessage"] == null)) { RedirectPage(); } FillStatusDropDown(); LoginInfo regInfo = (LoginInfo)Session["loginInfo"]; int userId = regInfo.UserId; string path = Server.MapPath("~/Members/UserData/" + userId.ToString() + "/Images/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] files = dirInfo.GetFiles(); ExistingImagesGridview.DataSource = files; ExistingImagesGridview.DataBind(); if (IsFromModifyPage) { TitleLabel.Text = "Modify Standard Message"; SubTitleLabel.Text = "Please modify standard message details in the below form"; MessageInfo dataSource = (MessageInfo)Session["SelectedMessage"]; if (Session["SelectedMessage"] == null) { MessageService msgService = ServiceAccess.GetInstance().GetMessage(); userId = regInfo.UserId; DesignService designService = ServiceAccess.GetInstance().GetDesign(); DesignInfo[] designs = designService.GetList(regInfo.UserId); string gender = string.Empty; string onDesignName = string.Empty; foreach (DesignInfo designInfo in designs) { DesignInfo allDesignInfo = designService.Get(designInfo.DesignId); if (allDesignInfo.Gender != string.Empty && allDesignInfo.OnDesignName != string.Empty) { gender = allDesignInfo.Gender; onDesignName = allDesignInfo.OnDesignName; break; } } MessageInfo[] messageInfo = msgService.GetStandardMessageList(false, gender, onDesignName); foreach (MessageInfo msgInfo in messageInfo) { if (msgInfo.MessageId == Convert.ToInt32(Request.QueryString["MessageId"])) { dataSource = msgInfo; break; } } } MessageIdPanel.Visible = true; MessageIdLabel.Text = dataSource.MessageId.ToString(); foreach (ListItem listItem in StatusDropDownList.Items) { if (listItem.Text == dataSource.Status.ToString()) { listItem.Selected = true; break; } } ShortDescText.Text = dataSource.ShortDesc; HTMLEditTextBox.Text = dataSource.MessageText; DefaultMessageCheckBox.Checked = dataSource.IsDefaultMessage; if (dataSource.UsageCount > 0) { StatusDropDownList.Enabled = false; } if (dataSource.IsDefaultMessage) { DefaultMessageCheckBox.Enabled = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Session["SelectedMessage"] = null; ServiceAccess serviceLoader = ServiceAccess.GetInstance(); RegistrationService.LoginInfo regInfo = (RegistrationService.LoginInfo)Session["loginInfo"]; if (regInfo.Role != RegistrationService.UserRole.Agent) { AgentsPanel.Visible = true; AgentRFValidator.ControlToValidate = "ListOfAgentsWebUserControl1"; AgentRFValidator.Enabled = true; try { ListOfAgentsWebUserControl1.AutoPostBack = false; ListOfAgentsWebUserControl1.FillDropDown(); } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to load the agents list"; ErrorMessageLabel.Visible = true; log.Error("Unknown error", ex); } } MessageService messageService = serviceLoader.GetMessage(); bool isAgent = (regInfo.Role == RegistrationService.UserRole.Agent); try { DesignService designService = ServiceAccess.GetInstance().GetDesign(); MessageInfo[] dataSource = null; string gender = string.Empty; string onDesignName = string.Empty; if (isAgent) { DesignInfo[] designs = designService.GetList(regInfo.UserId); if (designs != null) { foreach (DesignInfo designInfo in designs) { if (designInfo != null && designInfo.DesignId > 0 && designInfo.Status.Name.ToLower() == "approved") { DesignInfo allDesignInfo = designService.Get(designInfo.DesignId); if (allDesignInfo.Gender != string.Empty && allDesignInfo.OnDesignName != string.Empty) { gender = allDesignInfo.Gender; onDesignName = allDesignInfo.OnDesignName; break; } } } } } dataSource = messageService.GetStandardMessageList(isAgent, gender, onDesignName); if (dataSource == null || dataSource.Length == 0) { NoRecordsTable.Visible = true; } else { NoRecordsTable.Visible = false; MessageDataGrid.DataSource = dataSource; ViewState["dataSource"] = MessageDataGrid.DataSource; MessageDataGrid.DataBind(); } } catch (Exception ex) { ErrorMessageLabel.Text = "Unable to load the messages"; ErrorMessageLabel.Visible = true; log.Error("Unknown error", ex); } if (!IsAgentRole) { MessageDataGrid.Columns[0].Visible = true; AgentRFValidator.Enabled = true; AddStdMessagePanel.Visible = true; } else { MessageDataGrid.Columns[0].Visible = false; } } }