コード例 #1
0
        private async Task SetUserTemplate(EmailTemplateTypes EmailType)
        {
            Template = await _DbContext.EmailTemplates
                       .FirstOrDefaultAsync(et => et.TemplateType.Equals(EmailType)).ConfigureAwait(false);

            if (Template == null)
            {
                throw new Exception("Email Template cannot be found.");
            }

            Template.PrepareHtml(_WebEnv.WebRootPath);
            Template.SetServerClasses();
        }
コード例 #2
0
ファイル: EmailInserts.cs プロジェクト: rocketeerbkw/DNA
        /// <summary>
        /// This metho gets all the Email Inserts for a given site or mod class
        /// </summary>
        /// <param name="readerCreator">A data reader creator to create procedure calls</param>
        /// <param name="insertType">The type of inserts to get, modclass or site</param>
        /// <param name="typeID">The ID of the modclass or site to get</param>
        /// <returns>An EmailInserts object that holds a list of all the email inserts for the requested object</returns>
        public static EmailInserts GetEmailInserts(IDnaDataReaderCreator readerCreator, EmailTemplateTypes insertType, int typeID)
        {
            // Create a new EmailInserts object and initialise the collection
            EmailInserts emailInserts = new EmailInserts();
            emailInserts.EmailInsertList = new Collection<EmailInsert>();

            // Work out which type of inserts we're trying to get
            string procName = "getemailinsertsbyclass";
            string paramName = "ModClassID";
            if (insertType == EmailTemplateTypes.SiteTemplates)
            {
                procName = "getemailinsertsbysite2";
                paramName = "siteid";
            }
            else if (insertType == EmailTemplateTypes.AllTemplates)
            {
                typeID = -1;
            }

            // Go through all the results creating the inserts and adding them to the list
            using (IDnaDataReader reader = readerCreator.CreateDnaDataReader(procName))
            {
                reader.AddParameter(paramName, typeID);
                reader.Execute();
                
                while (reader.HasRows && reader.Read())
                {
                    EmailInsert insert = new EmailInsert();
                    insert.ID = reader.GetInt32("EmailInsertID");
                    insert.Name = reader.GetString("InsertName");
                    insert.DisplayName = reader.GetString("DisplayName");
                    insert.Group = reader.GetString("InsertGroup");
                    if (!reader.IsDBNull("SiteID"))
                    {
                        insert.SiteID = reader.GetInt32("SiteID");
                    }
                    insert.DefaultText = reader.GetString("DefaultText");
                    insert.InsertText = reader.GetString("InsertText");
                    insert.ClassID = reader.GetInt32("ModClassID");

                    emailInserts.EmailInsertList.Add(insert);
                }
            }

            // Return the new object
            return emailInserts;
        }
コード例 #3
0
ファイル: EmailTemplate.cs プロジェクト: rocketeerbkw/DNA
        /// <summary>
        /// This method gets all the Email Templates for a given type
        /// </summary>
        /// <param name="readerCreator">A data reader creator to create procedures</param>
        /// <param name="templateType">The type of templates to get</param>
        /// <param name="typeID">The ID of the template type</param>
        /// <returns>An Email Templates object that contains a collection of all the requested email templates</returns>
        public static EmailTemplates GetEmailTemplates(IDnaDataReaderCreator readerCreator, EmailTemplateTypes templateType, int typeID)
        {
            // Create a new email templates object and intialise the collection
            EmailTemplates emailTemplates = new EmailTemplates();
            emailTemplates.EmailTemplatesList = new Collection<EmailTemplate>();

            // Work out which procedure and params we need to call for the requested type
            string emailTemplateProc = "getemailtemplatesbymodclassid";
            string typeIDName = "modclassid";
            if (templateType == EmailTemplateTypes.SiteTemplates)
            {
                emailTemplateProc = "getemailtemplatesbysiteid";
                typeIDName = "siteid";
            }
            else if (templateType == EmailTemplateTypes.AllTemplates)
            {
                typeID = -1;
            }

            // Go through all the results creating and adding the templates to the list
            using (IDnaDataReader reader = readerCreator.CreateDnaDataReader(emailTemplateProc))
            {
                reader.AddParameter(typeIDName, typeID);
                reader.Execute();
                while (reader.HasRows && reader.Read())
                {
                    EmailTemplate emailTemplate = new EmailTemplate()
                    {
                        ModClassID = reader.GetInt32("ModClassID"),
                        AutoFormat = reader.IsDBNull("AutoFormat") ? 0 : reader.GetBoolean("AutoFormat") ? 1 : 0,
                        EmailTemplateID = reader.GetInt32("EmailTemplateID"),
                        Name = reader.GetString("Name"),
                        Subject = reader.GetString("Subject"),
                        Body = reader.GetString("Body")
                    };

                    emailTemplates.EmailTemplatesList.Add(emailTemplate);
                }
            }

            // Return the new Email template object
            return emailTemplates;
        }
コード例 #4
0
        /// <summary>
        /// This method creates or updates email inserts
        /// </summary>
        /// <param name="actionObjectName">The name of the email insert to create/update</param>
        /// <param name="siteID">The siteid the insert belongs to</param>
        /// <param name="modClassID">The modclass the insert belongs to</param>
        /// <param name="eTemplateType">The type of view to add the insert to</param>
        /// <param name="action">The current action</param>
        private void CreateUpdateEmailInsert(ref string actionObjectName, int siteID, int modClassID, ref EmailTemplateTypes eTemplateType, ref string action)
        {
            string insertGroup = InputContext.GetParamStringOrEmpty("InsertGroup", "Get the group for the insert");
            string newInsertGroup = InputContext.GetParamStringOrEmpty("NewInsertGroup", "Get the name of the new insert group");
            string classInsertText = InputContext.GetParamStringOrEmpty("ClassInsertText", "The class insert text");
            string siteInsertText = InputContext.GetParamStringOrEmpty("SiteINsertText", "The site insert text");
            string duplicateIntoClass = InputContext.GetParamStringOrEmpty("DuplicateToClass", "Duplicate insert to modclass");
            string insertDescription = InputContext.GetParamStringOrEmpty("reasonDescription", "The insert description");
            string state = InputContext.GetParamStringOrEmpty("state", "The current state");

            actionObjectName = StringUtils.EscapeAllXml(actionObjectName);
            insertGroup = StringUtils.EscapeAllXml(insertGroup);
            newInsertGroup = StringUtils.EscapeAllXml(newInsertGroup);
            classInsertText = StringUtils.EscapeAllXml(classInsertText);
            siteInsertText = StringUtils.EscapeAllXml(siteInsertText);

            if (insertDescription.Length == 0)
            {
                throw new Exception("No description given for insert!");
            }

            string group = insertGroup;
            if (insertGroup.Length == 0)
            {
                group = newInsertGroup;
            }

            if (group.Length > 0)
            {
                if (duplicateIntoClass == "on")
                {
                    if (modClassID == 0)
                    {
                        throw new Exception("No mod class ID given to update!");
                    }

                    if (classInsertText.Length > 0)
                    {
                        if (state == "create")
                        {
                            EmailInserts.CreateModClassEmailInsert(AppContext.ReaderCreator, modClassID, actionObjectName, group, classInsertText, insertDescription);
                        }
                        else
                        {
                            EmailInserts.UpdateModClassEmailInsert(AppContext.ReaderCreator, modClassID, actionObjectName, group, classInsertText, insertDescription);
                        }
                    }
                    else
                    {
                        throw new Exception("No mod class specific insert provided");
                    }
                    action = "default";
                    eTemplateType = EmailTemplateTypes.ClassTemplates;
                }
                else
                {
                    if (siteID == 0)
                    {
                        throw new Exception("No site ID given to update!");
                    }

                    if (siteInsertText.Length > 0)
                    {
                        if (state == "create")
                        {
                            EmailInserts.CreateSiteEmailInsert(AppContext.ReaderCreator, siteID, actionObjectName, group, siteInsertText, insertDescription);
                        }
                        else
                        {
                            EmailInserts.UpdateSiteEmailInsert(AppContext.ReaderCreator, siteID, actionObjectName, group, siteInsertText, insertDescription);
                        }
                    }
                    else
                    {
                        throw new Exception("No site specific insert provided");
                    }
                }
            }
            else
            {
                throw new Exception("No insert groupname provided");
            }

            _actionProcessed = true;
        }
コード例 #5
0
        /// <summary>
        /// Updates the page view params after an action has been processed
        /// </summary>
        /// <param name="nextAction">The next action to be preformed</param>
        /// <param name="selectedTemplateType">The current selected template</param>
        /// <param name="selectedInsert">The current select insert</param>
        /// <param name="viewModeObject">The view mode object</param>
        /// <param name="viewModeObjectID">The view mode object ID</param>
        /// <param name="actionObjectName">The object name the action was performed on</param>
        /// <param name="actionObjectTypeID">The id of the object that the action was performed</param>
        /// <param name="siteID">The site id used</param>
        /// <param name="modClassID">The mod class id used</param>
        /// <param name="eTemplateType">The current type of template being viewed</param>
        /// <param name="action">The new action</param>
        private void UpdatePageViewForProcessedAction(ref string nextAction, ref string selectedTemplateType, ref string selectedInsert, ref string viewModeObject, ref int viewModeObjectID, ref string actionObjectName, ref int actionObjectTypeID, int siteID, int modClassID, ref EmailTemplateTypes eTemplateType, ref string action)
        {
            if (siteID > 0)
            {
                viewModeObject = "site";
                viewModeObjectID = siteID;
                eTemplateType = EmailTemplateTypes.SiteTemplates;
            }
            else
            {
                viewModeObject = "class";
                viewModeObjectID = modClassID;
                eTemplateType = EmailTemplateTypes.ClassTemplates;
            }

            if (InputContext.DoesParamExist("insertsaveandcreatenew", "save insert template and create a new one"))
            {
                action = "createinsert";
                nextAction = "createinsert";
            }
            else if (InputContext.DoesParamExist("saveandcreatenew", "Save the email tmeplate and return to the home page"))
            {
                action = "createnewemail";
                nextAction = "createnewemail";
            }
            else
            {
                action = "";
                nextAction = "default";
            }

            actionObjectName = "";
            actionObjectTypeID = 0;
            selectedInsert = "";
            selectedTemplateType = "";
        }