protected void Page_Load(object sender, EventArgs e) { string uid = Request["uid"]; if (string.IsNullOrEmpty(uid)) { Response.Redirect("~/Public/default.aspx", true); } else { if (Security.CurrentUser != null && Security.IsUserInGroup(InternalSecureGroups.Administrator)) { divUserCheckedTrue.Visible = false; divUserCheckedFalse.Visible = false; } else { divAdminCheckedTrue.Visible = false; divAdminCheckedFalse.Visible = false; } if (SmtpBox.CommitTestEmail(new Guid(uid))) { labelCheckedFalse.Visible = false; divAdminCheckedFalse.Visible = false; divUserCheckedFalse.Visible = false; } else { labelCheckedTrue.Visible = false; divAdminCheckedTrue.Visible = false; divUserCheckedTrue.Visible = false; } } }
private void lbCheck_Click(object sender, EventArgs e) { if (_boxId > 0) { string message = String.Empty; try { SmtpBox.SendTestEmail(_boxId, LocRM.GetString("tLetterSubj"), LocRM.GetString("tLetterBody"), Mediachase.Ibn.Web.UI.CHelper.GetFullPath("/Public/CheckSMTPSettings.aspx")); } catch (Exception ex) { message = ex.Message; message = message.Replace("\r\n", "<br/>"); } lbCheck.Visible = false; if (String.IsNullOrEmpty(message)) { lblMessage.Text = String.Format(LocRM.GetString("tGuidWasSent"), Security.CurrentUser.Email); } else { lblMessage.Text = LocRM.GetString("tGuidWasNotSent") + "<br/><br/>" + message; } } }
private void dg_DeleteCommand(object source, DataGridCommandEventArgs e) { int sid = int.Parse(e.Item.Cells[0].Text); SmtpBox.Delete(sid); Response.Redirect("~/Admin/SMTPList.aspx", true); }
private void BindValues() { SmtpBox box = SmtpBox.Load(_boxId); txtTitle.Text = box.Name; txtServer.Text = box.Server; txtPort.Text = box.Port.ToString(); cbIsDefault.Checked = box.IsDefault; switch (box.SecureConnection) { case SecureConnectionType.None: rbSecurity.SelectedValue = "0"; break; case SecureConnectionType.Ssl: rbSecurity.SelectedValue = "1"; break; case SecureConnectionType.Tls: rbSecurity.SelectedValue = "2"; break; default: break; } cbAuthenticate.Checked = box.Authenticate; txtUser.Text = box.User; ViewState["Password"] = box.Password; }
private void BindList() { ddSmtpBoxes.DataSource = SmtpBox.List(); ddSmtpBoxes.DataTextField = "Name"; ddSmtpBoxes.DataValueField = "SmtpBoxId"; ddSmtpBoxes.DataBind(); ddSmtpBoxes.Items.Insert(0, new ListItem(LocRM2.GetString("tDefaultValue"), "-1")); }
private void btCheckSettings_Click(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } SecureConnectionType type = SecureConnectionType.None; switch (rbSecurity.SelectedValue) { case "0": type = SecureConnectionType.None; break; case "1": type = SecureConnectionType.Ssl; break; case "2": type = SecureConnectionType.Tls; break; default: break; } string password = txtPassword.Text.Trim(); if (String.IsNullOrEmpty(password) && ViewState["Password"] != null) { password = ViewState["Password"].ToString(); } SmtpSettingsResult result = SmtpBox.CheckSettings(txtServer.Text, int.Parse(txtPort.Text), type, cbAuthenticate.Checked, txtUser.Text, password); lbSettingsValid.Visible = true; if (result == SmtpSettingsResult.AllOk) { lbSettingsValid.ForeColor = Color.Blue; lbSettingsValid.Text = LocRM.GetString("tOK"); } else { lbSettingsValid.ForeColor = Color.Red; lbSettingsValid.Text = LocRM.GetString("tError"); } }
private void BindDG() { dgSets.Columns[1].HeaderText = LocRM.GetString("tTitle"); dgSets.Columns[2].HeaderText = LocRM.GetString("tServer"); dgSets.Columns[3].HeaderText = LocRM.GetString("tPort"); dgSets.Columns[4].HeaderText = LocRM.GetString("tUser"); dgSets.Columns[5].HeaderText = LocRM.GetString("tDefaultBox"); dgSets.DataSource = SmtpBox.List(); dgSets.DataBind(); foreach (DataGridItem dgi in dgSets.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("tWarningSmtpBox") + "')"); } } }
protected void Page_Load(object sender, System.EventArgs e) { this.imbSave.ServerClick += new EventHandler(imbSave_ServerClick); this.lbCheck.Click += new EventHandler(lbCheck_Click); this.btCheckSettings.Click += new EventHandler(btCheckSettings_Click); ApplyLocalization(); BindToolBar(); if (!Page.IsPostBack) { ViewState["IsInChecking"] = false.ToString(); BindTypes(); if (_boxId > 0) { BindValues(); } } if (_boxId > 0) { SmtpBox box = SmtpBox.Load(_boxId); if (box.Checked) { ViewState["IsInChecking"] = false.ToString(); lblMessage.Text = LocRM.GetString("tSetsAreCorrect"); lbCheck.ForeColor = Color.Green; lbCheck.Visible = true; } else { lblMessage.Text = LocRM.GetString("tNeedToCheck"); lbCheck.ForeColor = Color.Red; lbCheck.Visible = true; } } else { divCheck.Visible = false; rbSecurity.SelectedIndex = 0; txtPort.Text = "25"; } }
private void BindSavedValues() { using (IDataReader rdr = Mediachase.IBN.Business.User.GetUserInfoByLogin("Alert")) { if (rdr.Read()) { ViewState["UserId"] = rdr["UserId"]; tbFirstname.Text = rdr["FirstName"].ToString(); tbLastName.Text = rdr["LastName"].ToString(); tbEmail.Text = rdr["Email"].ToString(); } } SmtpBox box = OutgoingEmailServiceConfig.FindSmtpBox(OutgoingEmailServiceType.AlertService, false); if (box != null) { CommonHelper.SafeSelect(ddSmtpBoxes, box.SmtpBoxId.ToString()); } cbUseAS.Checked = PortalConfig.EnableAlerts; txtSubjectTemp.Text = PortalConfig.AlertSubjectFormat; cbUseIMServer.Checked = PortalConfig.UseIM; }
public override void Invoke() { // TODO: Remove Expired RemoveExpiredMessages(); //int maxDeliveryAttempts = 100; // TODO: Read From Config int maxMessagesPerConnection = 10; // Prepare temporary collection List <MailMessage> outputMessages = new List <MailMessage>(); List <OutgoingMessageQueueEntity> queueEntity = new List <OutgoingMessageQueueEntity>(); // Load Outgoing Message Queue Entity EntityObject[] elements = BusinessManager.List(OutgoingMessageQueueEntity.ClassName, OutgoingMessageUtil.CreateEmailDeliveryProviderFilters(), new SortingElement[] { SortingElement.Ascending(OutgoingMessageQueueEntity.FieldSource), SortingElement.Ascending(OutgoingMessageQueueEntity.FieldCreated) }); // Run Message Delivery Process for (int elementIndex = 0; elementIndex < elements.Length; elementIndex++) { // Read Element From Outgoing Message Queue OutgoingMessageQueueEntity element = (OutgoingMessageQueueEntity)elements[elementIndex]; // Load Email Message EmailEntity emailEntity = (EmailEntity)BusinessManager.Load(EmailEntity.ClassName, element.EmailId.Value); // Create Output Mail Message MailMessage outputMessage = CopyEmailEntityToMailMessage(emailEntity); // Add Output message to Output queue outputMessages.Add(outputMessage); queueEntity.Add(element); string currentSource = element.Source; string nextElementSource = (elementIndex < (elements.Length - 1)) ? ((OutgoingMessageQueueEntity)elements[elementIndex + 1]).Source : string.Empty; if (outputMessages.Count < maxMessagesPerConnection && currentSource == nextElementSource) { continue; } // Send Output queue try { // OZ [2010-03-03]: Check that SmtpServer is configured. Write To Outgoing log if (SmtpBox.TotalCount() == 0) { throw new SmtpNotConfiguredException(); } // Initialize Smtp Client SmtpClient smtpClient = Mediachase.IBN.Business.EMail.SmtpClientUtility.CreateSmtpClient(element.Source); // Send smtpClient.Send(outputMessages.ToArray()); // Process result ProcessSendResult(outputMessages, queueEntity); } catch (Exception ex) { ProcessException(outputMessages, queueEntity, ex); } // Clear Output queue outputMessages.Clear(); queueEntity.Clear(); } // }
protected void BindSettings() { if (PortalConfig.UseFullTextSearch.HasValue) { trFTSNotInstalled.Visible = false; trFTSNotEnabled.Visible = false; trFTSEnabled.Visible = true; if ((bool)PortalConfig.UseFullTextSearch) { ftsStat.Visible = true; try { FullTextSearchInfo info = FullTextSearch.GetInformation(); lbIndSize.Text = Util.CommonHelper.ByteSizeToStr(info.IndexSize * 1024 * 1024); lbStat.Text = info.PopulateStatus.ToString(); ftsInfoOK.Visible = true; ftsInfoFailed.Visible = false; } catch (Exception ex) { ftsInfoOK.Visible = false; ftsInfoFailed.Visible = true; lbFTSErrorMessage.Text = ex.Message; } } else { trFTSEnabled.Visible = false; ftsStat.Visible = false; trFTSNotEnabled.Visible = true; } } else { if (!FullTextSearch.IsInstalled()) { trFTSNotInstalled.Visible = true; trFTSNotEnabled.Visible = false; trFTSEnabled.Visible = false; } if (FullTextSearch.IsInstalled()) { trFTSNotInstalled.Visible = false; trFTSNotEnabled.Visible = true; trFTSEnabled.Visible = false; } } if (PortalConfig.UseWebDav.HasValue) { if ((bool)PortalConfig.UseWebDav) { trWDDisabled.Visible = false; trWDEnabled.Visible = true; } else { trWDDisabled.Visible = true; trWDEnabled.Visible = false; } } else { trWDDisabled.Visible = true; trWDEnabled.Visible = false; } SmtpBox box = OutgoingEmailServiceConfig.FindSmtpBox(OutgoingEmailServiceType.SendFile, false); if (box != null) { CommonHelper.SafeSelect(ddSmtpBoxes, box.SmtpBoxId.ToString()); } }
private void BindData() { ddSmtpBoxes.DataSource = SmtpBox.List(); ddSmtpBoxes.DataTextField = "Name"; ddSmtpBoxes.DataValueField = "SmtpBoxId"; ddSmtpBoxes.DataBind(); ddSmtpBoxes.Items.Insert(0, new ListItem(LocRM.GetString("tDefaultValue"), "-1")); if (BoxId > 0) { EMailRouterPop3Box box = EMailRouterPop3Box.Load(BoxId); if (box != null) { txtName.Text = box.Name; tbInternalEmail.Text = box.EMailAddress; tbServer.Text = box.Server; tbPort.Text = box.Port.ToString(); tbLogin.Text = box.Login; //tbPassword.Text = box.Pass; ViewState["Pop3Box_Password"] = box.Pass; ListItem li = null; switch (box.SecureConnectionType) { case Pop3SecureConnectionType.Ssl: li = rblSecureConnection.Items.FindByValue("SSL"); if (li != null) { li.Selected = true; } break; case Pop3SecureConnectionType.Tls: li = rblSecureConnection.Items.FindByValue("TLS"); if (li != null) { li.Selected = true; } break; default: li = rblSecureConnection.Items.FindByValue("Never"); if (li != null) { li.Selected = true; } break; } SmtpBox smtp = OutgoingEmailServiceConfig.FindSmtpBox(OutgoingEmailServiceType.HelpDeskEmailBox, BoxId, false); if (smtp != null) { CommonHelper.SafeSelect(ddSmtpBoxes, smtp.SmtpBoxId.ToString()); } } trConfirmPassword.Visible = false; rfvPassword.Enabled = false; } else { trConfirmPassword.Visible = true; rfvPassword.Enabled = true; } }
private void imbSave_ServerClick(object sender, EventArgs e) { Page.Validate(); if (!Page.IsValid) { return; } SmtpBox box; if (_boxId > 0) { box = SmtpBox.Load(_boxId); } else { box = SmtpBox.Initialize(); } box.Name = txtTitle.Text; box.Server = txtServer.Text; box.Port = int.Parse(txtPort.Text); switch (rbSecurity.SelectedValue) { case "0": box.SecureConnection = SecureConnectionType.None; break; case "1": box.SecureConnection = SecureConnectionType.Ssl; break; case "2": box.SecureConnection = SecureConnectionType.Tls; break; default: break; } box.Authenticate = cbAuthenticate.Checked; if (cbAuthenticate.Checked) { box.User = txtUser.Text; if (txtPassword.Text.Length > 0 || txtUser.Text.Length == 0) { box.Password = txtPassword.Text; } } //PortalConfig.SmtpSettings.IsChecked = false; //PortalConfig.SmtpSettings.CheckUid = Guid.NewGuid(); if (_boxId > 0) { SmtpBox.Update(box); } else { SmtpBox.Create(box); } if (cbIsDefault.Checked) { SmtpBox.SetDefault(box.SmtpBoxId); } Response.Redirect("~/Admin/SMTPList.aspx", true); }