Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        void Populate(Int64 catId)
        {
            AWAPI_Data.Data.awEmailTemplate t = _emailTempLib.Get(catId);

            _id.Text           = t.emailTemplateId.ToString();
            _title.Text        = t.title;
            _description.Text  = t.description;
            _emailFrom.Text    = t.emailFrom;
            _emailSubject.Text = t.emailSubject;
            _emailBody.Text    = t.emailBody;

            ShowHildeControls(true);
        }
Exemplo n.º 3
0
        void Save()
        {
            long id = 0;

            AWAPI_Data.Data.awEmailTemplate t = new AWAPI_Data.Data.awEmailTemplate();

            try
            {
                t.title        = _title.Text;
                t.description  = _description.Text;
                t.emailFrom    = _emailFrom.Text;
                t.emailSubject = _emailSubject.Text;
                t.emailBody    = _emailBody.Text;
                t.siteId       = App_Code.SessionInfo.CurrentSite.siteId;
                t.userId       = App_Code.SessionInfo.CurrentUser.userId;

                //update current
                if (_id.Text == "")
                {
                    id       = _emailTempLib.Add(t.siteId, t.userId.Value, t.title, t.description, t.emailFrom, t.emailSubject, t.emailBody);
                    _id.Text = id.ToString();
                }
                else
                {
                    id = Convert.ToInt64(_id.Text);
                    _emailTempLib.Update(id, t.userId.Value, t.title, t.description, t.emailFrom, t.emailSubject, t.emailBody);
                }

                ShowHildeControls(true);
                PopulateList();
                App_Code.Misc.WriteMessage(_msg, "Email template has been saved.");
            }
            catch (Exception ex)
            {
                _msg.Text = ex.Message;
                App_Code.Misc.WriteMessage(App_Code.Misc.MessageType.ERROR, _msg, ex.Message);
            }
        }