//public void Notify(View view, int action, string by, OldNewValue[] oldNewValues, string pk, DataRow prevRow) //{ // try // { // if (string.IsNullOrEmpty(view.HistoryNotifyList)) // return; // string host = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["host"]); // int port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["port"]); // string username = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["username"]); // string password = Convert.ToString(System.Configuration.ConfigurationSettings.AppSettings["password"]); // string[][] distributionLists = GetDistributionLists(view.HistoryNotifyList); // string[] to = distributionLists[0]; // string[] cc = distributionLists[1]; // string message = string.Empty; // string userFullName = Map.Database.GetUserFullName(by); // string usernameAndFullName = userFullName + " (" + by + ") "; // message += "The following changes were made:<br>View: {0}<br>User: {1}<br>Time: {2}<br>Action {3}<br>Primary Key Value: {4}<br>{5}: {6}<br>"; // bool displayValueChanged = false; // string oldNewValuesMessage = GetOldNewValues(view, oldNewValues, out displayValueChanged); // if (!string.IsNullOrEmpty(oldNewValuesMessage)) // { // message += oldNewValuesMessage; // string displayValue = null; // if (prevRow == null || displayValueChanged) // { // if (string.IsNullOrEmpty(pk)) // { // displayValue = string.Empty; // } // else // { // DataRow row = view.GetDataRow(pk); // if (row == null) // { // displayValue = string.Empty; // } // else // { // displayValue = view.GetDisplayValue(row); // if (displayValue == null) // displayValue = string.Empty; // } // } // } // else // { // displayValue = view.GetDisplayValue(prevRow); // } // message = string.Format(message, view.DisplayName, usernameAndFullName, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), GetAction(action), pk, view.DisplayField.DisplayName, displayValue); // Durados.Cms.DataAccess.Email.Send(host, false, port, username, password, false, to, cc, null, GetSubject(view), message, GetFrom(view), null, null); // } // } // catch( Exception ex) // { // Map.Logger.Log("Workflow.HistoryNotifier", "Notify", null, ex, 1,""); // } //} public void Notify(View view, int action, string by, OldNewValue[] oldNewValues, string pk, DataRow prevRow, object controller, Dictionary <string, object> values, string siteWithoutQueryString, string mainSiteWithoutQueryString) { try { if (string.IsNullOrEmpty(view.HistoryNotifyList)) { return; } string host = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["host"]); int port = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["port"]); string username = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["username"]); string password = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["password"]); string[][] distributionLists = GetDistributionLists(view.HistoryNotifyList, (Database)view.Database); string[] to = distributionLists[0]; string[] cc = distributionLists[1]; bool displayValueChanged = false; string oldNewValuesMessage = GetOldNewValues(view, oldNewValues, out displayValueChanged); Durados.Web.Mvc.Controllers.CrmController crmController = (Durados.Web.Mvc.Controllers.CrmController)controller; if (!string.IsNullOrEmpty(oldNewValuesMessage)) { string message = string.Empty; string subject = string.Empty; message += "<html dir=\"ltr\"><head><style><!--"; string css = ".tableCss {margin-top:5px; border:solid 1px #9ca3ad;} .tdCss, .tdCssalt, .oldVal, .oldValalt {padding: 0px 5px 0px 5px; vertical-align: top; color: #000000; border-bottom:solid 1px #e8eaec; padding-top:2px; padding-bottom:5px; background: #f8f8f9;} .tdCssalt{ background: #CEE3F6;} .oldVal{ text-decoration: line-through;} .oldValalt{ background: #CEE3F6; text-decoration: line-through;}"; message += css; message += "--></style></head><body>"; if (!string.IsNullOrEmpty(view.NotifySubjectKey) && !string.IsNullOrEmpty(view.NotifySubjectKey)) { string[] s = base.GetSubjectAndMessage(crmController, view.NotifySubjectKey, view.NotifyMessageKey, view, values, pk, siteWithoutQueryString, mainSiteWithoutQueryString); subject = s[0]; message += s[1]; } else { message += GetMessage(view, action, by, pk, prevRow, crmController, values, siteWithoutQueryString, mainSiteWithoutQueryString); subject = GetSubject(view, action, by, pk, prevRow, crmController, values, siteWithoutQueryString, mainSiteWithoutQueryString); } message += oldNewValuesMessage; message += "</body></html>"; Durados.Cms.DataAccess.Email.Send(host, view.Database.UseSmtpDefaultCredentials, port, username, password, false, to, cc, null, subject, message, GetFrom(view), null, null, ((Durados.Web.Mvc.Controllers.CrmController)controller).DontSend, view.Database.Logger); } } catch (Exception ex) { ((Database)view.Database).Map.Logger.Log("Workflow.HistoryNotifier", "Notify", null, ex, 1, ""); } }
protected virtual string GetSubject(View view, int action, string by, string pk, DataRow prevRow, Durados.Web.Mvc.Controllers.CrmController controller, Dictionary <string, object> values, string siteWithoutQueryString, string mainSiteWithoutQueryString) { if (string.IsNullOrEmpty(view.NotifySubjectKey)) { return("Changes at " + view.Database.SiteInfo.GetTitle() + " " + view.DisplayName); } else { return(base.GetMessage(controller, view.NotifySubjectKey, view, values, pk, siteWithoutQueryString, mainSiteWithoutQueryString)); } }
private string GetMessage(View view, int action, string by, string pk, DataRow prevRow, Durados.Web.Mvc.Controllers.CrmController controller, Dictionary <string, object> values, string siteWithoutQueryString, string mainSiteWithoutQueryString) { if (string.IsNullOrEmpty(view.NotifyMessageKey)) { string message = string.Empty; string userFullName = controller.Map.Database.GetUserFullName(by); string usernameAndFullName = userFullName + " (" + by + ") "; message += "The following changes were made:<br>View: {0}<br>User: {1}<br>Time: {2}<br>Action {3}<br>Primary Key Value: {4}<br>{5}: {6}<br>"; bool displayValueChanged = false; string displayValue = null; if (prevRow == null || displayValueChanged) { if (string.IsNullOrEmpty(pk)) { displayValue = string.Empty; } else { DataRow row = view.GetDataRow(pk); if (row == null) { displayValue = string.Empty; } else { displayValue = view.GetDisplayValue(row); if (displayValue == null) { displayValue = string.Empty; } } } } else { displayValue = view.GetDisplayValue(prevRow); } message = string.Format(message, view.DisplayName, usernameAndFullName, DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(), GetAction(action), pk, view.DisplayField.DisplayName, displayValue); return(message); } else { return(base.GetMessage(controller, view.NotifyMessageKey, view, values, pk, siteWithoutQueryString, mainSiteWithoutQueryString)); } }