예제 #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());
        }
예제 #2
0
        public string GetContent(Durados.Workflow.INotifier controller, string content, Durados.View view, Dictionary <string, object> nameValueDictionary, string pk, string siteWithoutQueryString, string mainSiteWithoutQueryString)
        {
            content = controller.HtmlDecode(content);


            string viewDisplayName = view.DisplayName;

            content = content.Replace("[MainAppPath]", mainSiteWithoutQueryString);
            content = content.Replace("[AppPath]", siteWithoutQueryString);
            content = content.Replace("{{MainAppPath}}", mainSiteWithoutQueryString);
            content = content.Replace("{{AppPath}}", siteWithoutQueryString);

            if (nameValueDictionary != null && content.Contains('[') && content.Contains(']'))
            {
                content = content.Replace(nameValueDictionary, controller.GetTableViewer(), view);
            }

            return(content);
        }
예제 #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);
        }