Esempio n. 1
0
        protected string[] GetEmailsFromParameter(Durados.Workflow.INotifier controller, string parameter, Durados.View view, Dictionary <string, object> values, DataRow prevRow, string pk, string connectionString, string currentUserId, string currentUsername, string currentUserRole)
        {
            //// replace the tokens in the parameter
            if (!string.IsNullOrEmpty(pk) && ((parameter.Contains('[') && parameter.Contains(']')) || (parameter.Contains(Database.DictionaryPrefix) && parameter.Contains(Database.DictionaryPostfix)) || parameter.Contains('$')))
            {
                if (nameValueDictionary.Count == 0 && prevRow != null)
                {
                    controller.LoadValues(nameValueDictionary, prevRow, (Durados.Web.Mvc.View)view, null, (Durados.Web.Mvc.View)view, view.DisplayName + ".", "[", "]", dicFields, view.Name + ".");
                }

                parameter = parameter.ReplaceAllTokens(view, values, pk, currentUserId, currentUsername, currentUserRole, prevRow);
                parameter = parameter.Replace(nameValueDictionary, controller.GetTableViewer(), view);
                parameter = parameter.Replace(dicFields.ToDictionary(k => k.Key, v => ((Durados.Workflow.DictionaryField)v.Value).Value), controller.GetTableViewer(), view);
            }

            parameter = parameter.Replace(values, controller.GetTableViewer(), view);

            string[] parameters = parameter.Split(';');
            Dictionary <string, string> emails = new Dictionary <string, string>();

            if (parameters != null)
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    string param = parameters[i];
                    string email = GetEmail(param, view, values, prevRow, pk, connectionString);
                    if (!string.IsNullOrEmpty(email) && !emails.ContainsKey(email))
                    {
                        emails.Add(email, email);
                    }
                }
            }

            return(emails.Values.ToArray());
        }
Esempio n. 2
0
        public string[] GetSubjectAndMessage(Durados.Workflow.INotifier controller, string subjectKey, string messageKey, Durados.View view, Dictionary <string, object> values, string pk, string siteWithoutQueryString, string mainSiteWithoutQueryString)
        {
            string messageContent = GetContent(controller, messageKey);
            string subjectContent = GetContent(controller, subjectKey);

            string[] s = new string[2] {
                subjectKey, messageKey
            };
            if (messageContent == null && subjectContent == null)
            {
                return(s);
            }

            Dictionary <string, object> nameValueDictionary = new Dictionary <string, object>();
            Dictionary <string, Durados.Workflow.DictionaryField> dicFields = new Dictionary <string, Durados.Workflow.DictionaryField>();

            string viewDisplayName = view.DisplayName;

            if (!string.IsNullOrEmpty(pk) && ((messageContent.Contains('[') && messageContent.Contains(']')) || (subjectContent.Contains('[') && subjectContent.Contains(']'))))
            {
                DataRow row = view.GetDataRow(pk);

                controller.LoadValues(nameValueDictionary, row, (Durados.Web.Mvc.View)view, null, (Durados.Web.Mvc.View)view, viewDisplayName + ".", "[", "]", dicFields, view.Name + ".");
            }

            else
            {
                return(s);
            }

            if (messageContent != null && messageContent.Contains('[') && messageContent.Contains(']'))
            {
                s[1] = GetContent(controller, messageContent, view, nameValueDictionary, pk, siteWithoutQueryString, mainSiteWithoutQueryString);
            }

            if (subjectContent != null && subjectContent.Contains('[') && subjectContent.Contains(']'))
            {
                s[0] = GetContent(controller, subjectContent, view, nameValueDictionary, pk, siteWithoutQueryString, mainSiteWithoutQueryString);
            }

            return(s);
        }
Esempio n. 3
0
        public string GetMessage(Durados.Workflow.INotifier controller, string messageKey, Durados.View view, Dictionary <string, object> values, string pk, string siteWithoutQueryString, string mainSiteWithoutQueryString)
        {
            string content = GetContent(controller, messageKey);

            if (content == null)
            {
                return(messageKey);
            }

            content = controller.HtmlDecode(content);


            string viewDisplayName = view.DisplayName;

            if (Maps.MultiTenancy)
            {
                content = content.Replace("[AppPath]", ((Database)view.Database).Map.Url);
                content = content.Replace("[MainAppPath]", mainSiteWithoutQueryString);
                content = content.Replace("{{AppPath}}", ((Database)view.Database).Map.Url);
                content = content.Replace("{{MainAppPath}}", mainSiteWithoutQueryString);
            }
            else
            {
                content = content.Replace("[AppPath]", siteWithoutQueryString);
                content = content.Replace("{{AppPath}}", siteWithoutQueryString);
            }
            content = content.Replace("[Product]", ((Database)view.Database).Map.AppName);
            content = content.Replace("{{AppName}}", ((Database)view.Database).Map.AppName);

            if (!string.IsNullOrEmpty(pk) && (content.Contains('[') && content.Contains(']') || content.Contains(Database.DictionaryPrefix) && content.Contains(Database.DictionaryPostfix)))
            {
                DataRow row = view.GetDataRow(pk);

                if (nameValueDictionary.Count == 0)
                {
                    controller.LoadValues(nameValueDictionary, row, (Durados.Web.Mvc.View)view, null, (Durados.Web.Mvc.View)view, viewDisplayName + ".", "[", "]", dicFields, view.Name + ".");
                }

                content = content.Replace(nameValueDictionary, controller.GetTableViewer(), view);
                content = content.Replace(dicFields.ToDictionary(k => k.Key, v => ((Durados.Workflow.DictionaryField)v.Value).Value), controller.GetTableViewer(), view);
                try
                {
                    content = content.Replace(values, controller.GetTableViewer(), view);
                }
                catch { }

                if (content.Contains("[User.First Name]"))
                {
                    if (row.Table.Columns.Contains("FirstName"))
                    {
                        if (!row.IsNull("FirstName"))
                        {
                            content = content.Replace("[User.First Name]", row["FirstName"].ToString());
                        }
                    }
                }
            }
            else
            {
                content = content.Replace(values, controller.GetTableViewer(), view);
            }
            return(content);
        }