示例#1
0
        void PopulateEmailTemplates()
        {
            AWAPI_BusinessLibrary.library.EmailTemplateLib lib = new EmailTemplateLib();
            _emailTemplate.DataTextField  = "title";
            _emailTemplate.DataValueField = "emailTemplateId";
            _emailTemplate.DataSource     = lib.GetList(App_Code.SessionInfo.CurrentSite.siteId);
            _emailTemplate.DataBind();

            _emailTemplate.Items.Insert(0, new ListItem("-Select a template", ""));
            _emailTemplate.SelectedIndex = 0;
        }
示例#2
0
        private long SecureAdd(string accessKey, long siteId, string username, string firstName, string lastName,
                               string email, string password, string description, string link, string imageurl,
                               string gender, DateTime?birthday, string tel, string tel2, string address, string city,
                               string state, string postalCode, string country, string redirectUrlAfterConfirmationTask)
        {
            //CONFIRMATION EMAIL IS REQUIRED -------------------------------------------------------------
            AWAPI_Data.Data.awSite site = new AWAPI_BusinessLibrary.library.SiteLibrary().Get(siteId);
            if (site.userConfirmationEmailTemplateId == 0)
            {
                throw new Exception(ErrorLibrary.ErrorMessage(ErrorLibrary.USER.USER_CONFIRMATION_EMAIL_REQURED));
            }

            AWAPI_BusinessLibrary.library.EmailTemplateLib emailTemplateLib = new EmailTemplateLib();
            AWAPI_Data.Data.awEmailTemplate emailTemplate = emailTemplateLib.Get(site.userConfirmationEmailTemplateId);
            if (emailTemplate == null)
            {
                throw new Exception(ErrorLibrary.ErrorMessage(ErrorLibrary.USER.USER_CONFIRMATION_EMAIL_NOT_FOUND));
            }

            //ADD USER ------------------------------------------------------------------------------------
            long userId = _userLib.Add(username, firstName, lastName, email, password, description,
                                       false, false, link, imageurl, gender, birthday, tel, tel2, address,
                                       city, state, postalCode, country);

            if (userId <= 0)
            {
                return(0);
            }

            //ADD USER TO THE SITE ------------------------------------------------------------------------
            _userLib.AddUserToSite(siteId, userId, true);

            //ADD AN AUTOMATED CONFIRMATION TASK ----------------------------------------------------------
            AutomatedTaskLibrary taskLib = new AutomatedTaskLibrary();
            Guid enableUserTaskId        = Guid.NewGuid();

            taskLib.Add(siteId, 0, enableUserTaskId,
                        "Enable User", userId.ToString(),
                        false, "",
                        "AWAPI_BusinessLibrary.library.UserLibrary", "UpdateStatus", String.Format("int64:{0}|bool:{1}", userId, (bool)true),
                        redirectUrlAfterConfirmationTask);

            //SEND CONFIRMATION EMAIL ----------------------------------------------------------------------
            string confirmationLink = ConfigurationLibrary.Config.automatedTaskServiceUrl + "?taskid=" + enableUserTaskId.ToString();

            AWAPI_BusinessLibrary.library.EmailTemplateLib emailLib = new EmailTemplateLib();
            emailLib.Send(emailTemplate.emailTemplateId, email,
                          "firstname|" + firstName,
                          "lastname|" + lastName,
                          "confirmationlink|" + confirmationLink,
                          "date|" + DateTime.Now.ToString());

            return(userId);
        }