Inheritance: System.Configuration.SettingsBase
 public WebProfile(System.Web.Profile.ProfileBase profileBase)
 {
   
     
     this._profileBase = profileBase;
    
 }
        private static Collection <string> SetProfile(HttpContext context, IDictionary <string, object> values)
        {
            // return collection of successfully saved settings.
            Collection <string> failedSettings = new Collection <string>();

            if (values == null || values.Count == 0)
            {
                // no values were given, so we're done, and there are no failures.
                return(failedSettings);
            }

            ProfileBase profile = context.Profile;
            Dictionary <string, object> allowedSet = ApplicationServiceHelper.ProfileAllowedSet;

            // Note that profile may be null, and allowedSet may be null.
            // Even though no properties will be saved in these cases, we still iterate over the given values to be set,
            // because we must build up the failed collection anyway.
            bool profileDirty = false;

            foreach (KeyValuePair <string, object> entry in values)
            {
                string propertyName = entry.Key;
                if (profile != null && allowedSet != null && allowedSet.ContainsKey(propertyName))
                {
                    SettingsProperty settingProperty = ProfileBase.Properties[propertyName];

                    if (settingProperty != null && !settingProperty.IsReadOnly &&
                        (!profile.IsAnonymous || (bool)settingProperty.Attributes["AllowAnonymous"]))
                    {
                        Type   propertyType = settingProperty.PropertyType;
                        object convertedValue;
                        if (ObjectConverter.TryConvertObjectToType(entry.Value, propertyType, JavaScriptSerializer, out convertedValue))
                        {
                            profile[propertyName] = convertedValue;
                            profileDirty          = true;
                            // setting successfully saved.
                            // short circuit the foreach so only failed cases fall through.
                            continue;
                        }
                    }
                }

                // Failed cases fall through to here. Possible failure reasons:
                // 1. type couldn't be converted for some reason (TryConvert returns false)
                // 2. the property doesnt exist (settingProperty == null)
                // 3. the property is read only (settingProperty.IsReadOnly)
                // 4. the current user is anonymous and the setting doesn't allow anonymous access
                // 5. profile for this user is null (profile == null)
                // 6. no properties are allowed for setting (allowedSet is null)
                // 7. *this* property is not allowed for setting (allowedSet.Contains returns false)
                failedSettings.Add(propertyName);
            }

            if (profileDirty)
            {
                profile.Save();
            }

            return(failedSettings);
        }
Beispiel #3
0
 public static ProfileBase Create(string username, bool isAuthenticated)
 {
     if (!ProfileManager.Enabled)
     {
         throw new ProviderException(System.Web.SR.GetString("Profile_not_enabled"));
     }
     InitializeStatic();
     if (s_SingletonInstance != null)
     {
         return(s_SingletonInstance);
     }
     if (s_Properties.Count == 0)
     {
         lock (s_InitializeLock)
         {
             if (s_SingletonInstance == null)
             {
                 s_SingletonInstance = new DefaultProfile();
             }
             return(s_SingletonInstance);
         }
     }
     HttpRuntime.CheckAspNetHostingPermission(AspNetHostingPermissionLevel.Low, "Feature_not_supported_at_this_level");
     return(CreateMyInstance(username, isAuthenticated));
 }
Beispiel #4
0
        void OnLeave(object o, EventArgs eventArgs)
        {
            if (!ProfileManager.Enabled)
            {
                return;
            }

            if (!app.Context.ProfileInitialized)
            {
                return;
            }

            if (ProfileManager.AutomaticSaveEnabled)
            {
                profile = app.Context.Profile;

                if (profile == null)
                {
                    return;
                }

                ProfileAutoSaveEventHandler eh = events [profileAutoSavingEvent] as ProfileAutoSaveEventHandler;
                if (eh != null)
                {
                    ProfileAutoSaveEventArgs args = new ProfileAutoSaveEventArgs(app.Context);
                    eh(this, args);
                    if (!args.ContinueWithProfileAutoSave)
                    {
                        return;
                    }
                }
                profile.Save();
            }
        }
Beispiel #5
0
 protected void Page_PreInit(object sender, EventArgs e)
 {
     System.Web.Profile.ProfileBase perfil =
         new System.Web.Profile.ProfileBase();
     perfil = HttpContext.Current.Profile;
     Theme  =
         perfil.GetPropertyValue("temaPredeterminado").ToString();
 }
Beispiel #6
0
 public void Init(ProfileBase parent, string myName)
 {
     if (this._Parent == null)
     {
         this._Parent = parent;
         this._MyName = myName + ".";
     }
 }
 /// <summary>
 /// this is used to update the user credential info   //swaraj on 18 feb 2010
 /// </summary>
 public void update()
 {
     try
     {
         //update membership information of user
         objMembershipUser = Membership.GetUser(User.Identity.Name);
         objMembershipUser.Email = txtEmail.Text;
         Membership.UpdateUser(objMembershipUser);
         if (!User.IsInRole("user"))
         {
             //update profile information of user
             objProfileBase = ProfileBase.Create(User.Identity.Name, true);
             objProfileBase.SetPropertyValue("FName", txtFirstname.Text);
             objProfileBase.SetPropertyValue("LName", txtLastname.Text);
             objProfileBase.SetPropertyValue("MobilePhone", txtMobilePhone.Text);
             objProfileBase.SetPropertyValue("Fax", txtFax.Text);
             objProfileBase.SetPropertyValue("Address", txtAddress.Text);
             objProfileBase.SetPropertyValue("ModifiedBy", User.Identity.Name);
             objProfileBase.SetPropertyValue("PostalCode", txtPostalCode.Text);
             objProfileBase.SetPropertyValue("State", txtState.Text);
             objProfileBase.SetPropertyValue("Country", txtCountry.Text);
             objProfileBase.SetPropertyValue("Fax", txtFax.Text);
             objProfileBase.SetPropertyValue("WorkPhone", txtWorkPhone.Text);
             objProfileBase.SetPropertyValue("HomePhone", txtHomePhone.Text);
             objProfileBase.Save();
         }
         else
         {
             UserInfoPrimaryKey objUserInfoPrimaryKey = new UserInfoPrimaryKey(objMembershipUser.ProviderUserKey.ToString());
             userInfo = UserInfo.SelectOne(objUserInfoPrimaryKey, ConnectionString);
             userInfo.UserName = txtUsername.Text;
             userInfo.FirstName = txtFirstname.Text;
             userInfo.LastName = txtLastname.Text;
             userInfo.Address1 = txtAddress.Text;
             userInfo.WorkPhone = txtWorkPhone.Text;
             userInfo.CellPhone = txtMobilePhone.Text;
             userInfo.State = txtState.Text;
             userInfo.Country = txtCountry.Text;
             userInfo.PostalCode = txtPostalCode.Text;
             userInfo.EmailAddress = txtEmail.Text;
             userInfo.Fax = txtFax.Text;
             userInfo.HomePhone = txtHomePhone.Text;
             UserInfos objUserInfos = UserInfo.SelectByField("UserId", objMembershipUser.ProviderUserKey.ToString(), ConnectionString);
             if (objUserInfos.Count > 0)
             {
                 userInfo.ListTab = objUserInfos[0].ListTab;
                 userInfo.CampaignTab = objUserInfos[0].CampaignTab;
                 userInfo.AdvancedTab = objUserInfos[0].AdvancedTab;
                 userInfo.ReportsTab = objUserInfos[0].ReportsTab;
             }
             userInfo.UpdateUserDetails();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 protected void Save_Click(object sender, EventArgs e)
 {
     objProfileBase = ProfileBase.Create(User.Identity.Name);
     //insert profile information of user
     objProfileBase.SetPropertyValue("PriceRate", txtPrice.Text);
     objProfileBase.SetPropertyValue("Discount", txtDiscount.Text);
     objProfileBase.SetPropertyValue("Tax", txtTax.Text);
     objProfileBase.Save();
     lblMsg.Style.Add("Color","green");
     lblMsg.Text = "Price Rate Settings Updated Successfully.";
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Username = User.Identity.Name;
     Master.ParentModulelbl.Text = "Bounce Settings";
     objProfileBase = ProfileBase.Create(Username, true);
     if (!IsPostBack)
     {
         lblMsg.Text = string.Empty;
         txtHardbounce.Text = objProfileBase.GetPropertyValue("HBounce").ToString();
         txtSoftbounce.Text = objProfileBase.GetPropertyValue("SBounce").ToString();
     }
 }
        private static Dictionary <string, object> GetProfile(HttpContext context, IEnumerable <string> properties)
        {
            ProfileBase profile = context.Profile;

            if (profile == null)
            {
                return(null);
            }

            Dictionary <string, object> allowedGet = ApplicationServiceHelper.ProfileAllowedGet;

            if (allowedGet == null || allowedGet.Count == 0)
            {
                // there are no readable properties
                return(new Dictionary <string, object>(0));
            }

            Dictionary <string, object> dictionary = null;

            if (properties == null)
            {
                // initialize capacity to the exact number we will fill: the number of readAccessProperties
                dictionary = new Dictionary <string, object>(allowedGet.Count, StringComparer.OrdinalIgnoreCase);

                // Returns all profile properties defined in configuration when given properties array is null
                string propertyName;
                foreach (KeyValuePair <string, object> entry in allowedGet)
                {
                    // note: dont enumerate over _allowedGet.Keys since it unecessarily creates a keys collection object
                    propertyName = entry.Key;
                    dictionary.Add(propertyName, profile[propertyName]);
                }
            }
            else
            {
                // initialize capacity to the largest possible number of properties we may return.
                dictionary = new Dictionary <string, object>(allowedGet.Count, StringComparer.OrdinalIgnoreCase);

                // Returns the specified profile properties (if empty array, no properties returned)
                foreach (string propertyName in properties)
                {
                    if (allowedGet.ContainsKey(propertyName))
                    {
                        dictionary.Add(propertyName, profile[propertyName]);
                    }
                }
            }

            return(dictionary);
        }
Beispiel #11
0
        public static void UpdateDatabaseConnectionString(ProfileBase profile, HttpRequest request)
        {
            if (request != null)
            {
                //VolunteerTracker.Document.RootPath = request.PhysicalApplicationPath + "App_Data";
                //VolunteerTracker.ExpenseList.RootPath = request.PhysicalApplicationPath + "App_Data";
            }

            string databaseFileName = ConfigurationManager.AppSettings["DatabaseFileName"];
            string databaseName = ConfigurationManager.AppSettings["DatabaseName"];
            string databaseUserName = ConfigurationManager.AppSettings["DatabaseUserName"];
            string databasePassword = ConfigurationManager.AppSettings["DatabasePassword"];
            string databaseConnector = ConfigurationManager.AppSettings["DatabaseConnector"];
              			if (databaseConnector.ToLower() == "postgresql")
            {
                VolunteerTracker.DatabaseAccess.SetDatabaseType(new VolunteerTracker.PSQL());
            }
            if (databaseConnector.ToLower() == "sqlite")
            {
                VolunteerTracker.DatabaseAccess.SetDatabaseType(new VolunteerTracker.SQLite());
            }

            VolunteerTracker.Database.SetConnectionString(VolunteerTracker.Database.CreateConnectionString(databaseFileName, databaseName, databaseUserName, databasePassword));
            if (profile.IsAnonymous)
            {
                VolunteerTracker.Database.SetUserId(VolunteerTracker.AccessControlList.ROOT_USERID);
                return;
            }
            MembershipUser mu = Membership.GetUser(profile.UserName);
            VolunteerTracker.Database.SetUserId(VolunteerTracker.AccessControlList.ROOT_USERID);
            bool userExists = false;
            System.Collections.Generic.List<VolunteerTracker.User> users = VolunteerTracker.User.Find<VolunteerTracker.User>();
            foreach (VolunteerTracker.User user in users)
            {
                if(user.Email.Trim().ToLower() == mu.Email.Trim().ToLower())
                {
                    VolunteerTracker.User pmUser = new VolunteerTracker.User(mu.Email);
                    VolunteerTracker.Database.SetUserId(pmUser.Id);
                    userExists = true;
                    break;
                }
            }
            if (!userExists)
            {
                VolunteerTracker.User user = new VolunteerTracker.User(mu.Email);
                user.Save();
                VolunteerTracker.Database.SetUserId(user.Id);
            }
            //
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Request.QueryString["Username"] != null)
                {
                    //update existing user

                    //update membership information of user
                    objMembershipUser = Membership.GetUser(User.Identity.Name);
                    objMembershipUser.Email = txtEmail.Text;
                    Membership.UpdateUser(objMembershipUser);

                    objProfileBase = ProfileBase.Create(Request.QueryString["Username"].ToString(), true);
                    //update profile information of user
                    objProfileBase.SetPropertyValue("FName", txtFirstname.Text);
                    objProfileBase.SetPropertyValue("LName", txtLastname.Text);
                    objProfileBase.SetPropertyValue("MobilePhone", txtMobilePhone.Text);
                    objProfileBase.SetPropertyValue("Fax", txtFax.Text);
                    objProfileBase.SetPropertyValue("Address", txtAddress.Text);
                    objProfileBase.SetPropertyValue("ModifiedBy", User.Identity.Name);
                    objProfileBase.Save();
                }
                else
                {
                    //create a new user

                    //insert membership information of user .
                    MembershipCreateStatus objMembershipCreateStatus;
                    MembershipUser objMembershipUser = Membership.CreateUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtSecurityQuestion.Text, txtSecurityAnswer.Text, chkStatus.Checked, out objMembershipCreateStatus);

                    //if user succesfully created than add profile information.
                    if (objMembershipUser != null)
                    {
                        objProfileBase = ProfileBase.Create(txtUsername.Text, true);
                        //insert profile information of user
                        objProfileBase.SetPropertyValue("FName", txtFirstname.Text);
                        objProfileBase.SetPropertyValue("LName", txtLastname.Text);
                        objProfileBase.SetPropertyValue("MobilePhone", txtMobilePhone.Text);
                        objProfileBase.SetPropertyValue("Fax", txtFax.Text);
                        objProfileBase.SetPropertyValue("Address", txtAddress.Text);
                        objProfileBase.SetPropertyValue("ModifiedBy", User.Identity.Name);
                        objProfileBase.Save();
                    }

                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Beispiel #13
0
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        // Private static functions and properties
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        static private ProfileBase CreateMyInstance(string username, bool isAuthenticated)
        {
            Type t;

            if (HostingEnvironment.IsHosted)
            {
                t = BuildManager.GetProfileType();
            }
            else
            {
                t = InheritsFromType;
            }
            ProfileBase hbc = (ProfileBase)Activator.CreateInstance(t);

            hbc.Initialize(username, isAuthenticated);
            return(hbc);
        }
Beispiel #14
0
        public static ProfileBase Create(string username, bool isAuthenticated)
        {
            ProfileBase profile     = null;
            Type        profileType = ProfileParser.GetProfileCommonType(HttpContext.Current);

            if (profileType != null)
            {
                profile = (ProfileBase)Activator.CreateInstance(profileType);
            }
            else
            {
                profile = (ProfileBase) new DefaultProfile();
            }

            profile.Initialize(username, isAuthenticated);
            return(profile);
        }
Beispiel #15
0
        private static ProfileBase CreateMyInstance(string username, bool isAuthenticated)
        {
            Type profileType;

            if (HostingEnvironment.IsHosted)
            {
                profileType = BuildManager.GetProfileType();
            }
            else
            {
                profileType = InheritsFromType;
            }
            ProfileBase base2 = (ProfileBase)Activator.CreateInstance(profileType);

            base2.Initialize(username, isAuthenticated);
            return(base2);
        }
        public static string RenderFullMemberName(string username)
        {
            ProfileBase profile = new ProfileBase();
            profile.Initialize(username,true);

            object profilePropertyValue = profile.GetPropertyValue("FullName");
            string outputValue = username;

            if(profilePropertyValue != null)
            {
                if(!String.IsNullOrEmpty(profilePropertyValue.ToString()))
                {
                    outputValue = profilePropertyValue.ToString();
                }
            }

            return outputValue;
        }
        protected void btnCreateClient_Click(object sender, EventArgs e)
        {
            try
            {
                //create a new user

                //insert membership information of user .
                MembershipCreateStatus objMembershipCreateStatus;
                MembershipUser objMembershipUser = Membership.CreateUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtSecurityQuestion.Text, txtSecurityAnswer.Text, chkStatus.Checked, out objMembershipCreateStatus);
                //Insert role information of user.
                Roles.AddUserToRole(txtUsername.Text, "client");

                //if user succesfully created than add profile information.
                if (objMembershipUser != null)
                {
                    objProfileBase = ProfileBase.Create(txtUsername.Text, true);
                    //insert profile information of user
                    objProfileBase.SetPropertyValue("FName", txtFirstname.Text);
                    objProfileBase.SetPropertyValue("LName", txtLastname.Text);
                    objProfileBase.SetPropertyValue("PostalCode", txtPostalCode.Text);
                    objProfileBase.SetPropertyValue("State", txtState.Text);
                    objProfileBase.SetPropertyValue("Country", txtCountry.Text);
                    objProfileBase.SetPropertyValue("HomePhone", txtHomePhone.Text);
                    objProfileBase.SetPropertyValue("WorkPhone", txtWorkPhone.Text);
                    objProfileBase.SetPropertyValue("MobilePhone", txtMobilePhone.Text);
                    objProfileBase.SetPropertyValue("Fax", txtFax.Text);
                    objProfileBase.SetPropertyValue("Address", txtAddress.Text);
                    objProfileBase.SetPropertyValue("CreatedBy", User.Identity.Name);
                    objProfileBase.SetPropertyValue("DBPassword", txtDBPassword.Text);
                    objProfileBase.SetPropertyValue("DBServerName", txtDBServerName.Text);
                    objProfileBase.SetPropertyValue("DBUserID", txtDBUserID.Text);
                    objProfileBase.SetPropertyValue("DBName", txtDBName.Text);
                    objProfileBase.Save();

                }

                divCreateClent.InnerHtml = "Successfully created " + txtUsername.Text + " client";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ParentModulelbl.Text = "PriceRate Settings";

            ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["sqlConstr"].ConnectionString;
            try
            {
                if (!IsPostBack)
                {
                    objProfileBase = ProfileBase.Create(User.Identity.Name);
                    txtPrice.Text = objProfileBase.GetPropertyValue("PriceRate").ToString();
                    txtDiscount.Text = objProfileBase.GetPropertyValue("Discount").ToString();
                    txtTax.Text = objProfileBase.GetPropertyValue("Tax").ToString();
                }
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #19
0
        private void LoadUserProfile(string username)
        {
             profile = ProfileBase.Create(username);
            this.FirstName = profile["FirstName"] as string;
            this.MiddleName = profile["MiddleName"] as string;
            this.LastName = profile["LastName"] as string;
            this.Prefix = profile["Prefix"] as string;
            this.Suffix = profile["Suffix"] as string;
            string dobStr = Convert.ToString(profile["DateOfBirth"]);
            if(dobStr.Length>0)
                this.DOB = DateTime.Parse(dobStr);
            this.WorkPhone = profile["WorkPhone"] as string;
            this.HomePhone = profile["HomePhone"] as string;
            this.CellPhone = profile["CellPhone"] as string;
            this.ShippingAddress.AddressLine1 = profile["ShippingAddress1"] as string;
            this.ShippingAddress.AddressLine2 = profile["ShippingAddress2"] as string;
            this.ShippingAddress.City = profile["ShippingCity"] as string;
            this.ShippingAddress.State = profile["ShippingState"] as string;
            this.ShippingAddress.Country = profile["ShippingCountry"] as string;
            this.ShippingAddress.ZipCode = profile["ShippingZipCode"] as string;
            this.BillingAddress.AddressLine1 = profile["BillingAddress1"] as string;
            this.BillingAddress.AddressLine2 = profile["BillingAddress2"] as string;
            this.BillingAddress.City = profile["BillingCity"] as string;
            this.BillingAddress.State = profile["BillingState"] as string;
            this.BillingAddress.Country = profile["BillingCountry"] as string;
            this.BillingAddress.ZipCode = profile["BillingZipCode"] as string;
            this.LanguageCode = profile["LanguageCode"] as string;
            this.Timezone = profile["Timezone"] as string;
            this.Sex = Convert.ToBoolean(Convert.ToInt16(profile["Sex"]));
            this.TimezoneOffset = (Nullable<double>)profile["TimezoneOffset"];

            if ((profile["InitialOfferID"] != null))
                this.InitialOfferID = (Guid)(profile["InitialOfferID"]);
            else
                this.InitialOfferID = new Guid();

            this.Browser = profile["Browser"] as string;
            this.IPAddress = profile["IPAddress"] as string;
        }
Beispiel #20
0
 //public override RestaurantModel ToRestaurantModel(RestaurantBasicData restaurantData, bool withMenu = true, string lang = DefaultLang)
 //{
 //    return restaurantData.ToRestaurantModel(withMenu, lang);
 //}
 public UserProfileModel ToUserProfileModel(ProfileBase profileBase)
 {
     UserProfileModel userProf = null;
     if (profileBase != null)
     {
         userProf = new UserProfileModel()
         {
             UserName = profileBase.UserName,
             UserType = profileBase.GetUserType()
         };
         if (!string.IsNullOrEmpty(userProf.UserName))
         {
             var userRoles = Roles.GetRolesForUser(userProf.UserName);
             userProf.UserRole = userRoles != null && userRoles.Length > 0 ? userRoles[0] : "";
         }
         var userData = profileBase.GetUserData();
         if (userData != null && userData.BaseInsulinCalcProfile != null)
         {
             userProf.InsulinCalcProfile = ToUserBaseInsulinCalcProfileModel(userData.BaseInsulinCalcProfile);
         }
     }
     return userProf;
 }
		public void SetProfile(ProfileBase val)
		{
		}
        private void SendNewsletter(object data)
        {
            object[] parameters = (object[])data;

            // get parameters from the data object passed in
            Newsletter newsletter = (Newsletter)parameters[0];
            TheBeerHouseDataContext dc = (TheBeerHouseDataContext)parameters[1];

            MembershipUserCollection membershipUserCollection = Membership.GetAllUsers();
            ProfileBase profileBase = new ProfileBase();
            NewslettersElement config = Configuration.TheBeerHouseSection.Current.Newsletters;

            // create the message
            MailMessage mailMessage = new MailMessage();
            mailMessage.Body = newsletter.HtmlBody;
            mailMessage.From = new MailAddress(config.FromEmail, config.FromDisplayName);
            mailMessage.Subject = newsletter.Subject;

            // add members to the BCC
            foreach (MembershipUser membershipUser in membershipUserCollection)
            {
                profileBase = ProfileBase.Create(membershipUser.UserName);
                if (profileBase.GetPropertyValue("Subscription").ToString() != "None")
                    mailMessage.Bcc.Add(membershipUser.Email);
            }

            // send the e-mail
            SmtpClient smtpClient = new SmtpClient();
            try
            {
                smtpClient.Send(mailMessage);
                newsletter.Status = "Sent";
                newsletter.DateSent = DateTime.Now;
                dc.SubmitChanges();
            }
            catch (Exception ex)
            {
                newsletter.Status = "Failed: " + ex.Message;
                dc.SubmitChanges();
            }
        }
 public void Init(ProfileBase parent, string myName)
 {
 }
        private ProfileBase SaveToProfile(Contact contact,ProfileBase profile)
        {
            profile.SetPropertyValue("customer_title",contact.Title);
            profile.SetPropertyValue("customer_first_name", contact.FirstName);
            profile.SetPropertyValue("customer_last_name",contact.LastName);
            profile.SetPropertyValue("customer_address_1",contact.Address1);
            profile.SetPropertyValue("customer_address_2", contact.Address2);
            profile.SetPropertyValue("customer_address_3", contact.Address3);
            profile.SetPropertyValue("customer_town",contact.Town);
            profile.SetPropertyValue("customer_county",contact.County);
            profile.SetPropertyValue("customer_country", contact.Country);
            profile.SetPropertyValue("customer_postcode",contact.Postcode);

            profile.SetPropertyValue("customer_mobile",contact.Mobile);
            profile.SetPropertyValue("customer_telephone",contact.Telephone);
            profile.SetPropertyValue("customer_separate_delivery_address", contact.SeparateDeliveryAddress);
            profile.SetPropertyValue("customer_delivery_address1",contact.DeliveryAddress1);
            profile.SetPropertyValue("customer_delivery_address2", contact.DeliveryAddress2);
            profile.SetPropertyValue("customer_delivery_address3", contact.DeliveryAddress3);
            profile.SetPropertyValue("customer_delivery_town", contact.DeliveryTown);
            profile.SetPropertyValue("customer_delivery_county", contact.DeliveryCounty);
            profile.SetPropertyValue("customer_delivery_postcode", contact.DeliveryPostcode);
            profile.SetPropertyValue("customer_delivery_country",contact.DeliveryCountry);
            profile.SetPropertyValue("care_contact_number", contact.ExternalContactNumber.ToString());
            profile.SetPropertyValue("care_address_number", contact.ExternalAddressNumber.ToString());
            profile.Save();

            //TODO: what to do with updating email addresses?
            try
            {

                //having to update membership in this convoluted way because of Umbraco bug
                //see http://umbraco.codeplex.com/workitem/30789

                var updateMember = Membership.GetUser(contact.UserName);
                var m = new umbraco.cms.businesslogic.member.Member((int)updateMember.ProviderUserKey);
                m.LoginName = contact.Email;
                m.Email = contact.Email;
                m.Save();
                FormsAuthentication.SetAuthCookie(contact.Email, true);

             }
            catch (Exception e)
            {
                string err=e.ToString();
            }
            return profile;
        }
        public static ConfigurationModel Initialize(ProfileBase profile)
        {
            ConfigurationModel model = new ConfigurationModel();
            model.PhoneNumber = (string)profile.GetPropertyValue("PhoneNumber");

            model.ReplyToMailbox = (bool)profile.GetPropertyValue("ReplyToMailbox");
            model.SmtpServerName = (string)profile.GetPropertyValue("SmtpServerName");
            model.SmtpServerPort = (int?)profile.GetPropertyValue("SmtpServerPort");
            model.SmtpUserName = (string)profile.GetPropertyValue("SmtpUserName");
            model.SmtpPassword = (string)profile.GetPropertyValue("SmtpPassword");
            model.UseSmtpSsl = (bool)profile.GetPropertyValue("UseSmtpSsl");

            model.AccountSid = (string)profile.GetPropertyValue("AccountSid");
            model.AuthToken = (string)profile.GetPropertyValue("AuthToken");

            return model;
        }
 public void Init(ProfileBase parent, string myName)
 {
 }
 public WebProfile() {
     this._profileBase = new System.Web.Profile.ProfileBase();
 }
        protected void lbtnNext_Click(object sender, EventArgs e)
        {
            mvAuthorize.ActiveViewIndex = mvAuthorize.ActiveViewIndex + 1;
            if (mvAuthorize.ActiveViewIndex == 1)
            {

                objProfileBase = ProfileBase.Create(User.Identity.Name, true);

                objMembershipUser = Membership.GetUser(User.Identity.Name);
                txtaddress.Text = objProfileBase.GetPropertyValue("Address").ToString(); ;
                txtfirstname.Text = objProfileBase.GetPropertyValue("FName").ToString(); ;
                txtlastname.Text = objProfileBase.GetPropertyValue("LName").ToString(); ;
                txtemail.Text = objMembershipUser.Email;
                txtstate.Text = objProfileBase.GetPropertyValue("State").ToString();
                txtphone.Text = objProfileBase.GetPropertyValue("WorkPhone").ToString();
                txtzip.Text = objProfileBase.GetPropertyValue("PostalCode").ToString();
                lblAmount.Text = "$"+amount.ToString();
            }
        }
 public WebProfile(System.Web.Profile.ProfileBase profileBase)
 {
     this._profileBase = profileBase;
 }
Beispiel #30
0
 public ProfileModel(string username)
 {
     profile = ProfileBase.Create(username);
 }
Beispiel #31
0
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        static private void InitializeStatic()
        {
            if (!ProfileManager.Enabled || s_Initialized)
            {
                if (s_InitializeException != null)
                {
                    throw s_InitializeException;
                }
                return;
            }
            lock (s_InitializeLock) {
                if (s_Initialized)
                {
                    if (s_InitializeException != null)
                    {
                        throw s_InitializeException;
                    }
                    return;
                }

                try {
                    ProfileSection config       = MTConfigUtil.GetProfileAppConfig();
                    bool           fAnonEnabled = (HostingEnvironment.IsHosted ? AnonymousIdentificationModule.Enabled : true);
                    Type           baseType     = ProfileBase.InheritsFromType;
                    bool           hasLowTrust  = HttpRuntime.HasAspNetHostingPermission(AspNetHostingPermissionLevel.Low);

                    s_Properties = new SettingsPropertyCollection();

                    // Step 0: Add all dynamic profile properties set programatically during PreAppStart
                    ProfileBase.AddPropertySettingsFromConfig(baseType, fAnonEnabled, hasLowTrust, ProfileManager.DynamicProfileProperties, null);

                    //////////////////////////////////////////////////////////////////////
                    // Step 1: Add Properties from the base class (if not ProfileBase)
                    if (baseType != typeof(ProfileBase))
                    {
                        //////////////////////////////////////////////////////////////////////
                        // Step 2: Construct a hashtable containing a list of all the property-names in the ProfileBase type
                        PropertyInfo[]      baseProps      = typeof(ProfileBase).GetProperties();
                        NameValueCollection baseProperties = new NameValueCollection(baseProps.Length);
                        foreach (PropertyInfo baseProp in baseProps)
                        {
                            baseProperties.Add(baseProp.Name, String.Empty);
                        }

                        //////////////////////////////////////////////////////////////////////
                        // Step 3: For each property in the derived class, add it to the s_Properties class.
                        PropertyInfo[] props = baseType.GetProperties();
                        foreach (PropertyInfo prop in props)
                        {
                            if (baseProperties[prop.Name] == null)   //not in the base class

                            {
                                ProfileProvider     prov           = hasLowTrust ? ProfileManager.Provider : null;
                                bool                readOnly       = false;
                                SettingsSerializeAs serializeAs    = SettingsSerializeAs.ProviderSpecific;
                                string              defaultValue   = String.Empty;
                                bool                allowAnonymous = false;
                                string              customData     = null;

                                //////////////////////////////////////////////////////////////////////
                                // Step 4: For the property, get the attributes
                                Attribute[] attribs = Attribute.GetCustomAttributes(prop, true);

                                foreach (Attribute attrib in attribs)
                                {
                                    if (attrib is SettingsSerializeAsAttribute)
                                    {
                                        serializeAs = ((SettingsSerializeAsAttribute)attrib).SerializeAs;
                                    }
                                    else if (attrib is SettingsAllowAnonymousAttribute)
                                    {
                                        allowAnonymous = ((SettingsAllowAnonymousAttribute)attrib).Allow;
                                        if (!fAnonEnabled && allowAnonymous)
                                        {
                                            throw new ConfigurationErrorsException(SR.GetString(SR.Annoymous_id_module_not_enabled, prop.Name), config.ElementInformation.Properties["inherits"].Source, config.ElementInformation.Properties["inherits"].LineNumber);
                                        }
                                    }
                                    else if (attrib is System.ComponentModel.ReadOnlyAttribute)
                                    {
                                        readOnly = ((System.ComponentModel.ReadOnlyAttribute)attrib).IsReadOnly;
                                    }
                                    else if (attrib is DefaultSettingValueAttribute)
                                    {
                                        defaultValue = ((DefaultSettingValueAttribute)attrib).Value;
                                    }
                                    else if (attrib is CustomProviderDataAttribute)
                                    {
                                        customData = ((CustomProviderDataAttribute)attrib).CustomProviderData;
                                    }
                                    else if (hasLowTrust && attrib is ProfileProviderAttribute)
                                    {
                                        prov = ProfileManager.Providers[((ProfileProviderAttribute)attrib).ProviderName];
                                        if (prov == null)
                                        {
                                            throw new ConfigurationErrorsException(SR.GetString(SR.Profile_provider_not_found, ((ProfileProviderAttribute)attrib).ProviderName), config.ElementInformation.Properties["inherits"].Source, config.ElementInformation.Properties["inherits"].LineNumber);
                                        }
                                    }
                                }
                                //////////////////////////////////////////////////////////////////////
                                // Step 5: Add the property to the s_Properties
                                SettingsAttributeDictionary settings = new SettingsAttributeDictionary();
                                settings.Add("AllowAnonymous", allowAnonymous);
                                if (!string.IsNullOrEmpty(customData))
                                {
                                    settings.Add("CustomProviderData", customData);
                                }
                                SettingsProperty sp = new SettingsProperty(prop.Name, prop.PropertyType, prov, readOnly, defaultValue, serializeAs, settings, false, true);
                                s_Properties.Add(sp);
                            }
                        }
                    }

                    //////////////////////////////////////////////////////////////////////
                    //////////////////////////////////////////////////////////////////////
                    // Step 6: Add all properties from config
                    if (config.PropertySettings != null)
                    {
                        AddPropertySettingsFromConfig(baseType, fAnonEnabled, hasLowTrust, config.PropertySettings, null);
                        foreach (ProfileGroupSettings pgs in config.PropertySettings.GroupSettings)
                        {
                            AddPropertySettingsFromConfig(baseType, fAnonEnabled, hasLowTrust, pgs.PropertySettings, pgs.Name);
                        }
                    }
                }
                catch (Exception e) {
                    if (s_InitializeException == null)
                    {
                        s_InitializeException = e;
                    }
                }
                // If there are no properties, create an empty collection.
                if (s_Properties == null)
                {
                    s_Properties = new SettingsPropertyCollection();
                }
                // Make the properties collection read-only
                s_Properties.SetReadOnly();
                s_Initialized = true;
            }

            // Throw an exception if there was an exception during initialization
            if (s_InitializeException != null)
            {
                throw s_InitializeException;
            }
        }
        private void fillUserDetails()
        {
            try
            {
                //fill user information from membership
                objMembershipUser = Membership.GetUser(User.Identity.Name);
                lblUsername.Text = User.Identity.Name;
                lblEmail.Text = objMembershipUser.Email;
                lblMsg.Text = string.Empty;

                if (!User.IsInRole("user"))
                {
                    //fill user information from profile
                    objProfileBase = ProfileBase.Create(User.Identity.Name, true);
                    lblFirstname.Text = objProfileBase.GetPropertyValue("FName").ToString();
                    lblLastname.Text = objProfileBase.GetPropertyValue("LName").ToString();
                    lblPhone.Text = objProfileBase.GetPropertyValue("MobilePhone").ToString();
                    lblFax.Text = objProfileBase.GetPropertyValue("Fax").ToString();
                    ttAddress.Text = objProfileBase.GetPropertyValue("Address").ToString();
                    lbState.Text = objProfileBase.GetPropertyValue("State").ToString();
                    lblCountry.Text = objProfileBase.GetPropertyValue("Country").ToString();
                    lblPostalcode.Text = objProfileBase.GetPropertyValue("PostalCode").ToString();
                    lblHomePhone.Text = objProfileBase.GetPropertyValue("HomePhone").ToString();
                    lblWorkPhone.Text = objProfileBase.GetPropertyValue("WorkPhone").ToString();
                    //fill user information from profile in Update div
                    txtUsername.Text = User.Identity.Name;
                    txtEmail.Text = objMembershipUser.Email;
                    txtFirstname.Text = objProfileBase.GetPropertyValue("FName").ToString();
                    txtLastname.Text = objProfileBase.GetPropertyValue("LName").ToString();
                    txtMobilePhone.Text = objProfileBase.GetPropertyValue("MobilePhone").ToString();
                    txtFax.Text = objProfileBase.GetPropertyValue("Fax").ToString();
                    txtAddress.Text = objProfileBase.GetPropertyValue("Address").ToString();
                    txtState.Text = objProfileBase.GetPropertyValue("State").ToString();
                    txtCountry.Text = objProfileBase.GetPropertyValue("Country").ToString();
                    txtPostalCode.Text = objProfileBase.GetPropertyValue("PostalCode").ToString();
                    txtHomePhone.Text = objProfileBase.GetPropertyValue("HomePhone").ToString();
                    txtWorkPhone.Text = objProfileBase.GetPropertyValue("WorkPhone").ToString();
                }
                else
                {
                    txtUsername.Text = User.Identity.Name;
                    txtEmail.Text = objMembershipUser.Email;
                    //Written by Swaroop Feb 15,2012
                    UserInfos objUserInfos = UserInfo.SelectByField("UserId", objMembershipUser.ProviderUserKey.ToString(), ConnectionString);
                    if (objUserInfos.Count > 0)
                    {
                        //fill user information from profile
                        lblFirstname.Text = objUserInfos[0].FirstName;
                        lblLastname.Text = objUserInfos[0].LastName;
                        lblPhone.Text = objUserInfos[0].CellPhone;
                        lblFax.Text = objUserInfos[0].Fax;
                        ttAddress.Text = objUserInfos[0].Address1;
                        lbState.Text = objUserInfos[0].State;
                        lblCountry.Text = objUserInfos[0].Country;
                        lblPostalcode.Text = objUserInfos[0].PostalCode;
                        lblHomePhone.Text = objUserInfos[0].HomePhone;
                        lblWorkPhone.Text = objUserInfos[0].WorkPhone;

                        //fill user information from profile in Update div
                        txtUsername.Text = User.Identity.Name;
                        txtEmail.Text = objMembershipUser.Email;
                        txtFirstname.Text = objUserInfos[0].FirstName;
                        txtLastname.Text = objUserInfos[0].LastName;
                        txtMobilePhone.Text = objUserInfos[0].CellPhone;
                        txtFax.Text = objUserInfos[0].Fax;
                        txtAddress.Text = objUserInfos[0].Address1;
                        txtState.Text = objUserInfos[0].State;
                        txtCountry.Text = objUserInfos[0].Country;
                        txtPostalCode.Text = objUserInfos[0].PostalCode;
                        txtHomePhone.Text = objUserInfos[0].HomePhone;
                        txtWorkPhone.Text = objUserInfos[0].WorkPhone;
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
        }
Beispiel #33
0
 public void Load(string username)
 {
     _profile = ProfileBase.Create(username);
 }
 public WebProfile()
 {
     this._profileBase = new System.Web.Profile.ProfileBase();
 }
Beispiel #35
0
 public void Load(string username, bool anon)
 {
     _profile = ProfileBase.Create(username, anon);
 }
		public void SetProfile(ProfileBase val)
		{
			_profile = val;
		}
Beispiel #37
0
 public UserProfile(string username)
 {
     _profile = ProfileBase.Create(username);
 }
Beispiel #38
0
 /// <summary>
 /// Sets the <see cref="System.Web.Profile.ProfileBase" /> object for the current user profile.
 /// </summary>
 /// <param name="profile">The profile.</param>
 public void SetProfile(ProfileBase profile)
 {
     this.profile = profile;
 }
Beispiel #39
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.ParentModulelbl.Text = "Campaign Summary";
            ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
            scriptManager.RegisterPostBackControl(this.lbtnDownload);

            Session["AdvCampId"] = null;
            Session["AdvCampName"] = null;
            if (Request.QueryString["Client"] != null && Session["AdvanceTabCon"] == null)
            {
                userName = Request.QueryString["Client"].ToString();
                Session["ClientName"] = userName.ToString();
                objProfileBase = ProfileBase.Create(userName, true);
                string dbName = objProfileBase.GetPropertyValue("DBName").ToString();
                string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();
                Connectionstring = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True", dbServerName, dbName, dbUserID, dbPassword);
                Session["AdvanceTabCon"] = Connectionstring;

                //userName = "******";// Request.QueryString["Client"].ToString(); //
                //Session["ClientName"] = userName.ToString();
                //objProfileBase = ProfileBase.Create(userName, true);
                //string dbName = "amm_Latest";// objProfileBase.GetPropertyValue("DBName").ToString();
                //string dbUserID = objProfileBase.GetPropertyValue("DBUserID").ToString();
                //string dbPassword = objProfileBase.GetPropertyValue("DBPassword").ToString();
                //string dbServerName = objProfileBase.GetPropertyValue("DBServerName").ToString();
                //Connectionstring = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};Pooling=True", dbServerName, dbName, dbUserID, dbPassword);
                //Session["AdvanceTabCon"] = Connectionstring;
            }
            Master.ClientName.Text = (Session["ClientName"] != null) ? Session["ClientName"].ToString() : userName;
            if (Session["AdvanceTabCon"] != null)
            {
                Connectionstring = Session["AdvanceTabCon"].ToString();
            }
            if (!IsPostBack)
            {
                if (Connectionstring != string.Empty)
                    bindGrid("", 0);
            }
        }
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////
        private static SettingsPropertyValue GetPropertyValue(ProfileBase pb, string name) {
            SettingsProperty prop = ProfileBase.Properties[name];
            if (prop == null) {
                return null;
            }

            SettingsPropertyValue p = pb.PropertyValues[name];
            if (p == null) {
                // not fetched from provider
                pb.GetPropertyValue(name); // to force a fetch from the provider
                p = pb.PropertyValues[name];
                if (p == null) {
                    return null;
                }
            }
            return p;
        }
 /// <summary>
 /// Users can only be invoked internally.
 /// </summary>
 /// <param name="mu"></param>
 internal ASPNetMembershipGraffitiUser(MembershipUser mu)
 {
     _mu = mu;
     _pb = ProfileBase.Create(_mu.UserName);
 }
        private Contact LoadFromProfile(ProfileBase profile)
        {
            Contact contact = new Contact();
            if (profile.UserName == null)
            {
                contact.Status = false;
            }
            else
            {
                contact.UserName = profile.UserName;
                contact.Title = (string)profile.GetPropertyValue("customer_title");
                contact.Address1 = (string)profile.GetPropertyValue("customer_address_1");
                contact.Address2 = (string)profile.GetPropertyValue("customer_address_2");
                contact.Address3 = (string)profile.GetPropertyValue("customer_address_3");
                contact.Town = (string)profile.GetPropertyValue("customer_town");
                contact.County = (string)profile.GetPropertyValue("customer_county");
                contact.Country = (string)profile.GetPropertyValue("customer_country");
                if (contact.Country == "United Kingdom") contact.Country = "UK";
                if (contact.Country.Length > 5) contact.Country = "";
                contact.Postcode = (string)profile.GetPropertyValue("customer_postcode");
                contact.FirstName = (string)profile.GetPropertyValue("customer_first_name");
                contact.LastName = (string)profile.GetPropertyValue("customer_last_name");
                contact.Email = Membership.GetUser(profile.UserName).Email;
                contact.Mobile = (string)profile.GetPropertyValue("customer_mobile");
                contact.Telephone = (string)profile.GetPropertyValue("customer_telephone");
                contact.SeparateDeliveryAddress = (profile.GetPropertyValue("customer_separate_delivery_address").ToString() == "1");
                contact.DeliveryAddress1 = (string)profile.GetPropertyValue("customer_delivery_address1");
                contact.DeliveryAddress2 = (string)profile.GetPropertyValue("customer_delivery_address2");
                contact.DeliveryAddress3 = (string)profile.GetPropertyValue("customer_delivery_address3");
                contact.DeliveryTown = (string)profile.GetPropertyValue("customer_delivery_town");
                contact.DeliveryCounty = (string)profile.GetPropertyValue("customer_delivery_county");
                contact.DeliveryPostcode = (string)profile.GetPropertyValue("customer_delivery_postcode");
                contact.DeliveryCountry = (string)profile.GetPropertyValue("customer_delivery_country");
                if (contact.DeliveryCountry == "United Kingdom") contact.DeliveryCountry = "UK";
                if (contact.DeliveryCountry.Length > 5) contact.DeliveryCountry = "";
                int externalContactNumber = 0;
                int.TryParse(profile.GetPropertyValue("care_contact_number").ToString(), out externalContactNumber);
                int externalAddressNumber = 0;
                int.TryParse(profile.GetPropertyValue("care_address_number").ToString(), out externalAddressNumber);
                contact.ExternalContactNumber = externalContactNumber;
                contact.ExternalAddressNumber = externalAddressNumber;
                contact.Status = true;

                //get the contact id
                //var getMember = Membership.GetUser(contact.UserName);
                //var m = new umbraco.cms.businesslogic.member.Member((int)getMember.ProviderUserKey);
                //contact.ContactId = m.Id;
            }
            return contact;
        }
 /// <summary>
 /// 获取用户ProfileItem
 /// </summary>
 private string GetUserProfileItem(ProfileBase objProfile, string key, string defaultvalue = "")
 {
     string value = objProfile.GetPropertyValue(key).ToString();
     return string.IsNullOrEmpty(value) ? defaultvalue : value;
 }
Beispiel #44
0
		public void Init (ProfileBase parent, string myName)
		{
			_parent = parent;
			_name = myName;
		}