/// <summary> /// Determines which Select is the proper one, then adds the table to it. Also adds to Query Tables collection if needed. Optionally errors if no relationship exists between existing tables and the new one. /// </summary> /// <param name="charIndex"></param> /// <param name="fmt"></param> /// <param name="errorOnMissingRelationship"></param> /// <returns></returns> public string AddTable(int charIndex, ITable fmt, bool errorOnMissingRelationship, bool errorOnMultipleRelationships, Join joinToUse) { var stmt = GetStatement(charIndex); if (stmt == null) { stmt = new Select(null, DataConnectionSpec, LanguageID, errorOnMissingRelationship, errorOnMultipleRelationships); Selects.Add(stmt); } var tbl = stmt.AddTable(fmt, errorOnMissingRelationship, errorOnMultipleRelationships, joinToUse); if (GetTable(Toolkit.Coalesce(tbl.AliasName, tbl.TableName) as string) == null) { this.Tables.Add(tbl); } if (stmt == Selects[0]) { foreach (var fm in stmt.Fields) { if (GetField(fm.DataviewFieldName) == null) { this.Fields.Add(fm); } } } return(Regenerate(errorOnMissingRelationship, errorOnMultipleRelationships)); }
/// <summary> /// Add a record to the email table that is to be sent at the given datetime. Optionally launch and/or wake monitoring thread to immediately process it. /// </summary> /// <param name="from"></param> /// <param name="to"></param> /// <param name="cc"></param> /// <param name="bcc"></param> /// <param name="replyTo"></param> /// <param name="subject"></param> /// <param name="body"></param> /// <param name="isHtml"></param> /// <param name="toBeSentDate"></param> /// <param name="attachmentVirtualFilePaths"></param> /// <param name="cooperatorID"></param> /// <param name="fromTableName"></param> /// <param name="fromTableID"></param> /// <param name="sendImmediately"></param> public static void QueueEmail(string from, string to, string cc, string bcc, string replyTo, string subject, string body, bool isHtml, DateTime toBeSentDate, string[] attachmentVirtualFilePaths, int cooperatorID, string fromTableName, int fromTableRowID, bool sendImmediately) { using (var dm = DataManager.Create()) { var emailID = dm.Write(@" insert into email (id_type, id_number, email_from, email_to, email_cc, email_bcc, email_reply_to, subject, body, is_html, to_be_sent_date, retry_count, created_date, created_by, owned_date, owned_by) values (:id_type, :id_number, :email_from, :email_to, :email_cc, :email_bcc, :email_reply_to, :subject, :body, :is_html, :to_be_sent_date, :retry_count, :created_date, :created_by, :owned_date, :owned_by) ", true, "email_id", new DataParameters( ":id_type", fromTableName, DbType.String, ":id_number", (fromTableRowID < 0 ? null : (int?)fromTableRowID), DbType.Int32, ":email_from", from, DbType.String, ":email_to", to, DbType.String, ":email_cc", cc, DbType.String, ":email_bcc", bcc, DbType.String, ":email_reply_to", Toolkit.Coalesce(replyTo, from) as string, DbType.String, ":subject", subject, DbType.String, ":body", body, DbType.String, ":is_html", isHtml ? "Y" : "N", DbType.String, ":to_be_sent_date", toBeSentDate.ToUniversalTime(), DbType.DateTime2, ":retry_count", 0, DbType.Int32, ":created_date", DateTime.UtcNow, DbType.DateTime2, ":created_by", cooperatorID, DbType.Int32, ":owned_date", DateTime.UtcNow, DbType.DateTime2, ":owned_by", cooperatorID, DbType.Int32 )); // also queue up associated attachments, if any if (attachmentVirtualFilePaths != null && attachmentVirtualFilePaths.Length > 0) { foreach (var vpath in attachmentVirtualFilePaths) { dm.Write(@" insert into email_attach (email_id, virtual_path, is_web_visible, created_date, created_by, owned_date, owned_by) values (:email_id, :virtual_path, :is_web_visible, :created_date, :created_by, :owned_date, :owned_by) ", new DataParameters( ":email_id", emailID, DbType.Int32, ":virtual_path", vpath, DbType.String, ":is_web_visible", "Y", DbType.String, ":created_date", DateTime.UtcNow, DbType.DateTime2, ":created_by", cooperatorID, DbType.Int32, ":owned_date", DateTime.UtcNow, DbType.DateTime2, ":owned_by", cooperatorID, DbType.Int32 )); } } } if (sendImmediately) { SendQueuedEmailNow(); } }
//internal static Field FromXPathNavigator(XPathNavigator nav) { // Field ret = new Field(); // ret.Name = nav.GetAttribute("Name", ""); // ret.IsPrimaryKey = Toolkit.ToBoolean(nav.GetAttribute("IsPrimaryKey", ""), false); // ret.StoredInIndex = Toolkit.ToBoolean(nav.GetAttribute("StoredInIndex", ""), false); // ret.Searchable = Toolkit.ToBoolean(nav.GetAttribute("Searchable", ""), false); // ret.Format = nav.GetAttribute("Format", ""); // ret.Ordinal = Toolkit.ToInt32(nav.GetAttribute("Ordinal", ""), 0); // ret.DataType = Type.GetType(nav.GetAttribute("Type", "")); // ret.IsBoolean = Toolkit.ToBoolean(nav.GetAttribute("IsBoolean", ""), false); // ret.TrueValue = nav.GetAttribute("TrueValue", ""); // ret.IsCreatedDate = Toolkit.ToBoolean(nav.GetAttribute("IsCreatedDate", ""), false); // ret.IsModifiedDate = Toolkit.ToBoolean(nav.GetAttribute("IsModifiedDate", ""), false); // ret.ForeignKeyTable = nav.GetAttribute("ForeignKeyTable", ""); // ret.ForeignKeyField = nav.GetAttribute("ForeignKeyField", ""); // ret.Calculation = nav.GetAttribute("Calculation", "") + ""; // XPathNodeIterator it = nav.SelectChildren("Field", ""); // while(it.MoveNext()){ // ret.SubFields.Add(Field.FromXPathNavigator(it.Current)); // } // return ret; //} internal static Field FromXmlNode(XmlNode nd, Field dbField) { //if (dbField == null) { // return FromXPathNavigator(nav); //} Field ret = new Field(); ret.Name = Toolkit.GetAttValue(nd, "Name", ""); if (String.IsNullOrEmpty(ret.Name)) { ret.Name = dbField.Name; } ret.IsPrimaryKey = Toolkit.ToBoolean(Toolkit.GetAttValue(nd, "IsPrimaryKey", ""), dbField.IsPrimaryKey); ret.StoredInIndex = Toolkit.ToBoolean(Toolkit.GetAttValue(nd, "StoredInIndex", ""), dbField.StoredInIndex); ret.Searchable = Toolkit.ToBoolean(Toolkit.GetAttValue(nd, "Searchable", ""), dbField.Searchable); ret.Format = Toolkit.Coalesce(Toolkit.GetAttValue(nd, "Format", ""), dbField.Format) as string; // Ordinal is the only thing that we completely ignore from the global config file and dbField always wins out on. ret.Ordinal = dbField.Ordinal; string typeName = Toolkit.GetAttValue(nd, "Type", ""); if (String.IsNullOrEmpty(typeName)) { ret.DataType = dbField.DataType; } else { ret.DataType = Type.GetType(typeName); } ret.IsBoolean = Toolkit.ToBoolean(Toolkit.GetAttValue(nd, "IsBoolean", ""), dbField.IsBoolean); ret.TrueValue = Toolkit.GetAttValue(nd, "TrueValue", ""); if (String.IsNullOrEmpty(ret.TrueValue)) { ret.TrueValue = dbField.TrueValue; } //ret.IsCreatedDate = Toolkit.ToBoolean(nav.GetAttribute("IsCreatedDate", ""), dbField.IsCreatedDate); //ret.IsModifiedDate = Toolkit.ToBoolean(nav.GetAttribute("IsModifiedDate", ""), dbField.IsModifiedDate); ret.ForeignKeyTable = Toolkit.GetAttValue(nd, "ForeignKeyTable", ""); ret.ForeignKeyField = Toolkit.GetAttValue(nd, "ForeignKeyField", ""); ret.Calculation = Toolkit.GetAttValue(nd, "Calculation", ""); var children = nd.SelectNodes("Field"); foreach (XmlNode child in children) { ret.SubFields.Add(Field.FromXmlNode(child, dbField)); } return(ret); }
protected void rptFields_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.DataItem != null) { var dr = (e.Item.DataItem as DataRowView).Row; (e.Item.FindControl("hidFieldResultID") as HiddenField).Value = dr["feedback_result_field_id"].ToString(); (e.Item.FindControl("hidFieldFormID") as HiddenField).Value = dr["fff_id"].ToString(); var title = dr["title"].ToString(); var lblTitle = e.Item.FindControl("lblTitle") as Label; lblTitle.Text = title; var desc = dr["description"].ToString(); var lblDesc = e.Item.FindControl("lblDescription") as Label; lblDesc.Text = desc; var hidField = e.Item.FindControl("hidFieldType") as HiddenField; var hidLookup = e.Item.FindControl("hidLookupID") as HiddenField; var txtField = e.Item.FindControl("txtField") as TextBox; var calField = e.Item.FindControl("calField") as Calendar; var btnField = e.Item.FindControl("btnField") as Button; var ddlField = e.Item.FindControl("ddlField") as DropDownList; var chkField = e.Item.FindControl("chkField") as CheckBox; var revFieldInteger = e.Item.FindControl("revFieldInteger") as RegularExpressionValidator; var revFieldDecimal = e.Item.FindControl("revFieldDecimal") as RegularExpressionValidator; var reqField = e.Item.FindControl("reqField") as RequiredFieldValidator; var lblRequired = e.Item.FindControl("lblRequired") as Label; var litField = e.Item.FindControl("litField") as Literal; reqField.Text = lblTitle.Text + " is required"; reqField.ErrorMessage = lblTitle.Text + " is required"; if (_hasBeenSubmitted) { txtField.Enabled = false; calField.Enabled = false; btnField.Enabled = false; ddlField.Enabled = false; chkField.Enabled = false; } var defaultValue = dr["default_value"].ToString(); var actualValue = dr["string_value"].ToString(); txtField.Visible = false; calField.Visible = false; btnField.Visible = false; ddlField.Visible = false; chkField.Visible = false; litField.Visible = false; var guiHint = dr["gui_hint"].ToString(); var groupName = dr["group_name"].ToString(); var lookupDataview = dr["foreign_key_dataview_name"].ToString(); var isrequired = dr["is_required"].ToString().ToUpper() == "Y"; var isreadonly = dr["is_readonly"].ToString().ToUpper() == "Y" || _hasBeenSubmitted; var type = dr["field_type_code"].ToString(); switch (guiHint.ToUpper()) { case "DATE_CONTROL": calField.Visible = true; hidField.Value = "CALENDAR"; calField.SelectedDate = Toolkit.ToDateTime(defaultValue, DateTime.UtcNow); if (isrequired) { reqField.ControlToValidate = calField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { txtField.ReadOnly = true; txtField.Enabled = false; } break; case "LARGE_SINGLE_SELECT_CONTROL": hidField.Value = "LOOKUP"; txtField.Visible = true; txtField.ReadOnly = true; txtField.Width = 500; btnField.Visible = true; btnField.Text = "..."; btnField.CommandName = "lookup"; btnField.CommandArgument = lookupDataview; var id = Toolkit.ToInt32(Toolkit.Coalesce(actualValue, defaultValue), -1); hidLookup.Value = id.ToString(); txtField.Text = getLookupText(lookupDataview, id); if (isrequired) { reqField.ControlToValidate = txtField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { btnField.Enabled = false; } // remember given lookupDataview so we can present them with a popup to choose from break; case "SMALL_SINGLE_SELECT_CONTROL": hidField.Value = "DROPDOWN"; ddlField.Visible = true; // using given group name, find list of items to display Master.FillCodeGroupDropDown(ddlField, groupName, _sd); // select appropriate item ddlField.SelectedIndex = ddlField.Items.IndexOf(ddlField.Items.FindByValue(Toolkit.Coalesce(actualValue, defaultValue) as string)); if (isrequired) { reqField.ControlToValidate = ddlField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { ddlField.Enabled = false; } break; case "INTEGER_CONTROL": hidField.Value = "TEXT"; txtField.Visible = true; txtField.Text = actualValue; revFieldInteger.Enabled = true; revFieldInteger.ControlToValidate = txtField.ID; revFieldInteger.Visible = true; if (isrequired) { reqField.ControlToValidate = txtField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { txtField.ReadOnly = true; txtField.Enabled = false; } break; case "DECIMAL_CONTROL": hidField.Value = "TEXT"; txtField.Visible = true; txtField.Text = actualValue; revFieldDecimal.Enabled = true; revFieldDecimal.ControlToValidate = txtField.ID; revFieldDecimal.Visible = true; if (isrequired) { reqField.ControlToValidate = txtField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { txtField.ReadOnly = true; txtField.Enabled = false; } break; case "BOOLEAN_CONTROL": hidField.Value = "BOOL"; chkField.Visible = true; chkField.Checked = Toolkit.Coalesce(actualValue, defaultValue) as string == "Y"; chkField.Text = lblDesc.Text; lblDesc.Visible = false; if (isrequired) { reqField.ControlToValidate = chkField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { chkField.Enabled = false; } break; case "LONGTEXT_CONTROL": hidField.Value = "TEXT"; txtField.Visible = true; txtField.Text = actualValue; txtField.TextMode = TextBoxMode.MultiLine; txtField.Rows = 6; txtField.Columns = 60; if (isrequired) { reqField.ControlToValidate = txtField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { txtField.ReadOnly = true; txtField.Enabled = false; } break; case "LITERAL_CONTROL": hidField.Value = "LITERAL"; litField.Text = "<p>" + defaultValue + "</p>"; litField.Visible = true; break; case "HR_CONTROL": hidField.Value = "LITERAL"; lblTitle.Visible = false; litField.Text = "<hr />"; litField.Visible = true; break; case "H1_CONTROL": hidField.Value = "LITERAL"; lblTitle.Visible = false; litField.Text = "<h1>" + defaultValue + "</h2>"; litField.Visible = true; break; case "H2_CONTROL": hidField.Value = "LITERAL"; lblTitle.Visible = false; litField.Text = "<h2>" + defaultValue + "</h2>"; litField.Visible = true; break; case "BR_CONTROL": hidField.Value = "LITERAL"; lblTitle.Visible = false; litField.Text = "<br />"; litField.Visible = true; break; case "TEXT_CONTROL": default: hidField.Value = "TEXT"; txtField.Visible = true; txtField.Text = actualValue; if (isrequired) { reqField.ControlToValidate = txtField.ID; reqField.Enabled = true; reqField.Visible = true; lblRequired.Visible = true; } if (isreadonly) { txtField.ReadOnly = true; txtField.Enabled = false; } break; } } }
public override void RefreshData() { Sync(true, delegate() { lvDataviews.Items.Clear(); foreach (string file in ImportFiles) { if (File.Exists(file)) { DataSet ds = null; var bin = new BinaryFormatter(); using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) { ds = bin.Deserialize(fs) as DataSet; } AdminProxy.UpconvertDataviewForImport(ds); foreach (DataRow dr in ds.Tables["sys_dataview"].Rows) { var lvi = new ListViewItem(dr["dataview_name"].ToString()); lvi.Checked = chkSelectAll.Checked; lvi.SubItems.Add(((DateTime)Toolkit.Coalesce(dr["modified_date"], dr["created_date"])).ToLocalTime().ToString()); if (dr.Table.Columns.Contains("category_code")) { lvi.SubItems.Add(dr["category_code"].ToString()); } else { lvi.SubItems.Add(""); } if (dr.Table.Columns.Contains("database_area_code")) { lvi.SubItems.Add(dr["database_area_code"].ToString()); } else { lvi.SubItems.Add(""); } var langRows = ds.Tables["sys_dataview_lang"].Select("sys_dataview_id = " + dr["sys_dataview_id"] + " and sys_lang_id = " + (AdminProxy == null ? 1 : AdminProxy.LanguageID)); if (langRows.Length > 0) { if (langRows[0].Table.Columns.Contains("title")) { lvi.SubItems.Add(langRows[0]["title"].ToString()); } else { lvi.SubItems.Add(""); } if (langRows[0].Table.Columns.Contains("description")) { lvi.SubItems.Add(langRows[0]["description"].ToString()); } else { lvi.SubItems.Add(""); } } lvi.Tag = ds; lvDataviews.Items.Add(lvi); } //count++; //proxy.ImportDataViewDefinitions(ds, dvNames); // } // } //} } } var allEngines = ("" + Toolkit.GetRegSetting(mdiParent.HIVE, "DataviewShowAllEngines", "false")).ToLower() == "true"; chkOracle.Checked = chkOracle.Visible = allEngines; chkPostgreSQL.Checked = chkPostgreSQL.Visible = allEngines; chkSQLServer.Checked = chkSQLServer.Visible = allEngines; chkMySQL.Checked = chkMySQL.Visible = allEngines; var engine = AdminProxy.Connection.DatabaseEngineProviderName.ToLower(); switch (engine) { case "sqlserver": chkSQLServer.Checked = chkSQLServer.Visible = true; break; case "mysql": chkMySQL.Checked = chkMySQL.Visible = true; break; case "postgresql": chkPostgreSQL.Checked = chkPostgreSQL.Visible = true; break; case "oracle": chkOracle.Checked = chkOracle.Visible = true; break; } }); }
protected void btnSave_Click(object sender, EventArgs e) { using (var sd = UserManager.GetSecureData(false)) { var id = (int)ViewState["reportID"]; var programID = (int)ViewState["programID"]; var dt = sd.GetData("web_feedback_reports", ":cooperatorid=" + sd.CooperatorID + ";:feedbackreportid=;:feedbackid=" + programID, 0, 0).Tables["web_feedback_reports"]; var drs = dt.Select("feedback_report_id = " + id); if (drs.Length == 0) { var dr = dt.NewRow(); dr["feedback_id"] = programID; dr["feedback_report_id"] = -1; dr["feedback_form_id"] = Toolkit.Coalesce(Toolkit.ToInt32(ddlForms.SelectedValue, null), DBNull.Value); dr["title"] = txtTitle.Text; dr["is_observation_data"] = chkIsObservationData.Checked ? "Y" : "N"; dr["is_web_visible"] = ddlYesNo.SelectedValue; dr["due_interval"] = Toolkit.ToInt32(ddlDue.SelectedValue, 0); dr["interval_length_code"] = ddlInterval.SelectedValue; dr["interval_type_code"] = ddlStartDate.SelectedValue; if (ddlStartDate.SelectedValue.ToString() == "CUSTOMDATE") { dr["custom_due_date"] = Toolkit.Coalesce(Toolkit.ToDateTime(txtCustomDate.Text, null), DBNull.Value); } else { dr["custom_due_date"] = DBNull.Value; } dr["is_notified_initially"] = chkSendInitialEmail.Checked ? "Y" : "N"; dr["is_notified_30days_prior"] = chkSend30DayNotice.Checked ? "Y" : "N"; dr["is_notified_15days_prior"] = chkSend15DayNotice.Checked ? "Y" : "N"; dr["initial_email_text"] = txtInitialEmail.Text; dr["prior15_email_text"] = txt15DayEmail.Text; dr["prior30_email_text"] = txt30DayEmail.Text; dr["initial_email_subject"] = txtInitialEmailSubject.Text; dr["prior15_email_subject"] = txt15DayEmailSubject.Text; dr["prior30_email_subject"] = txt30DayEmailSubject.Text; if (dt.Rows.Count == 0) { dr["sort_order"] = Toolkit.ToInt32(dt.Rows[dt.Rows.Count - 1]["sort_order"], 0); } else { dr["sort_order"] = 0; } dt.Rows.Add(dr); sd.SaveData(dt.DataSet, true, null); } else { var dr = drs[0]; dr["feedback_id"] = programID; dr["feedback_form_id"] = Toolkit.Coalesce(Toolkit.ToInt32(ddlForms.SelectedValue, null), DBNull.Value); dr["title"] = txtTitle.Text; dr["is_observation_data"] = chkIsObservationData.Checked ? "Y" : "N"; dr["is_web_visible"] = ddlYesNo.SelectedValue; dr["due_interval"] = Toolkit.ToInt32(ddlDue.SelectedValue, 0); dr["interval_length_code"] = ddlInterval.SelectedValue; dr["interval_type_code"] = ddlStartDate.SelectedValue; if (ddlStartDate.SelectedValue.ToString() == "CUSTOMDATE") { dr["custom_due_date"] = Toolkit.ToDateTime(txtCustomDate.Text, null); } else { dr["custom_due_date"] = DBNull.Value; } dr["is_notified_initially"] = chkSendInitialEmail.Checked ? "Y" : "N"; dr["is_notified_30days_prior"] = chkSend30DayNotice.Checked ? "Y" : "N"; dr["is_notified_15days_prior"] = chkSend15DayNotice.Checked ? "Y" : "N"; dr["initial_email_text"] = txtInitialEmail.Text; dr["prior15_email_text"] = txt15DayEmail.Text; dr["prior30_email_text"] = txt30DayEmail.Text; dr["initial_email_subject"] = txtInitialEmailSubject.Text; dr["prior15_email_subject"] = txt15DayEmailSubject.Text; dr["prior30_email_subject"] = txt30DayEmailSubject.Text; sd.SaveData(dt.DataSet, true, null); } Master.ShowMessage("Your changes have been saved."); bindData(id, false); } }
private void process() { try { // Debug.WriteLine("processing email queue, thread=" + Thread.CurrentThread.ManagedThreadId); // query the database, see what all there is to do using (var dm = DataManager.Create()) { var systemCooperatorID = getSystemCooperatorID(dm); var maxRetryCount = Toolkit.GetSetting("EmailMaxRetryCount", 5); var delayRetryOnFail = Toolkit.GetSetting("EmailRetryDelayInSeconds", 1200); var dt = dm.Read(@" select * from email where sent_date is null and to_be_sent_date < :now and retry_count < :maxretry ", new DataParameters(":now", DateTime.UtcNow, DbType.DateTime2, ":maxretry", maxRetryCount, DbType.Int32)); // pull the email info from the database foreach (DataRow dr in dt.Rows) { var email = new Email(); email.Id = Toolkit.ToInt32(dr["email_id"], -1); email.To = dr["email_to"].ToString(); email.From = dr["email_from"].ToString(); email.CC = dr["email_cc"].ToString(); email.BCC = dr["email_bcc"].ToString(); email.Subject = dr["subject"].ToString(); email.Body = dr["body"].ToString(); email.Format = dr["is_html"].ToString().ToUpper() == "Y" ? EmailFormat.Html : EmailFormat.Text; email.ReplyTo = Toolkit.Coalesce(dr["email_reply_to"].ToString(), email.From) as string; var retries = Toolkit.ToInt32(dr["retry_count"], 0); try { // add any attachments... var dtAttach = dm.Read(@" select * from email_attach where email_id = :emailid ", new DataParameters(":emailid", Toolkit.ToInt32("email_id", -1), DbType.Int32)); foreach (DataRow drAttach in dtAttach.Rows) { var vpath = drAttach["virtual_file_path"].ToString(); if (!String.IsNullOrEmpty(vpath)) { var physpath = Toolkit.ResolveFilePath(vpath, false); if (File.Exists(physpath)) { var attach = new Attachment(physpath); email.Attachments.Add(attach); } else { throw new FileNotFoundException("Could not attach file '" + physpath + "' to emailID = " + dr["email_id"] + " because it could not be found."); } } } // try to send it email.Send(); // we get here, email was sent successfully. dm.Write(@" update email set sent_date = :now1, modified_date = :now2, modified_by = :coop1 where email_id = :emailid ", new DataParameters( ":now1", DateTime.UtcNow, DbType.DateTime2, ":now2", DateTime.UtcNow, DbType.DateTime2, ":coop1", systemCooperatorID, DbType.Int32, ":emailid", Toolkit.ToInt32("email_id", -1), DbType.Int32)); } catch (Exception ex) { // we get here, send email failed, log it and continue. retries++; dm.Write(@" update email set retry_count = :retries, last_retry_error_message = :errormsg, last_retry_date = :now1, to_be_sent_date = :later1, modified_date = :now2, modified_by = :coop1 where email_id = :emailid ", new DataParameters( ":retries", retries, DbType.Int32, ":errormsg", ex.Message, DbType.String, ":now1", DateTime.UtcNow, DbType.DateTime2, ":later1", DateTime.UtcNow.AddSeconds(delayRetryOnFail), DbType.DateTime2, ":now2", DateTime.UtcNow, DbType.DateTime2, ":coop1", systemCooperatorID, DbType.Int32, ":emailid", email.Id, DbType.Int32)); } } } } catch (Exception ex2) { // eat all errors so email thread doesn't die off Logger.LogText(ex2); } }
private static void init(DataConnectionSpec dcs) { if (_dtResources_a == null) { _dtResources_a = new DataTable(); _dtResources_a.Columns.Add("ietf_tag", typeof(string)); _dtResources_a.Columns.Add("app_name", typeof(string)); _dtResources_a.Columns.Add("form_name", typeof(string)); _dtResources_a.Columns.Add("resource_name", typeof(string)); _dtResources_a.Columns.Add("value_member", typeof(string)); _dtResources_a.Columns.Add("display_member", typeof(string)); _dtResources_a.Columns.Add("description", typeof(string)); _dtResources_a.Columns.Add("sort_order", typeof(int)); } if (dcs != null && !_loadedFromDatabase) { try { using (var dm = DataManager.Create(dcs)) { var dt = dm.Read(@" select ar.app_name, ar.form_name, ar.app_resource_name, ar.description, ar.display_member, ar.value_member, ar.sort_order, sl.ietf_tag from app_resource ar left join sys_lang sl on ar.sys_lang_id = sl.sys_lang_id "); foreach (DataRow dr in dt.Rows) { _dtResources_a.Rows.Add(Toolkit.Coalesce(dr["ietf_tag"].ToString(), "en-US"), dr["app_name"], dr["form_name"], dr["app_resource_name"], dr["value_member"], dr["display_member"], dr["description"], dr["sort_order"]); } _loadedFromDatabase = true; } } catch { // eat all errors loading resources. } } if (!_loadedFromFile) { var path = Toolkit.ResolveFilePath("./resources.xml", false); if (File.Exists(path)) { XPathNavigator nav = new XPathDocument(path).CreateNavigator(); var apps = nav.Select("/apps/app"); while (apps.MoveNext()) { var app = apps.Current; var appName = app.GetAttribute("Name", ""); var forms = app.Select("form"); while (forms.MoveNext()) { var form = forms.Current; var formName = form.GetAttribute("Name", ""); var resources = form.Select("resource"); while (resources.MoveNext()) { var resource = resources.Current; var resourceName = resource.GetAttribute("Name", ""); var sortOrder = Toolkit.ToInt32(resource.GetAttribute("SortOrder", ""), 0); var languages = resource.Select("language"); while (languages.MoveNext()) { var lang = languages.Current; var langName = lang.GetAttribute("Name", ""); var value = lang.GetAttribute("ValueMember", ""); var display = lang.GetAttribute("DisplayMember", ""); var description = lang.GetAttribute("Description", ""); _dtResources_a.Rows.Add(langName, appName, formName, resourceName, value, display, description, sortOrder); } } } } _loadedFromFile = true; } } }