//Click Save Button protected void btnSave_Click(object sender, EventArgs e) { try { var entity = GetSaveEntity(); List <CRMUser> UList = new List <CRMUser>(); if (DDCLUser.SelectedValuesToString() != "") { string[] arr = DDCLUser.SelectedValuesToString().Split(','); foreach (var ID in arr) { var p = new CRMUser(); p.UserID = long.Parse(ID); UList.Add(p); } } entity = svr.Save(entity, UList); hidID.Value = entity.ACTID.ToString(); this.ShowSaveOK(); btnBack_Click(null, null); } catch (Exception ex) { this.ShowMessage(ex.Message); } }
public ActionResult Reset(ForgotPasswordModel m) { if (ModelState.IsValid) { try { UserManager <CRMUser> userManger = new UserManager <CRMUser>(new UserStore <CRMUser>()); CRMUser user = userManger.GetUser(m.EmailAddress); if (user == null) { ModelState.AddModelError("UD", "Email Address does not exist in our database"); ViewBag.Success = "Email Address does not exist in our database"; } else { ModelState.AddModelError("UD", "Dear " + user.FirstName + user.LastName + ", please click on reset link sent to your email id."); ViewBag.Success = "Dear " + user.FirstName + user.LastName + ", please click on reset link sent to your email id."; return(View("SuccessMessage")); } } catch (Exception ex) { ModelState.AddModelError("UD", ex.Message); } } return(View(m)); }
//Click Save Button protected void btnSave_Click(object sender, EventArgs e) { try { var entity = GetSaveEntity(); List<CRMUser> UList = new List<CRMUser>(); if (DDCLUser.SelectedValuesToString() != "") { string[] arr = DDCLUser.SelectedValuesToString().Split(','); foreach (var ID in arr) { var p = new CRMUser(); p.UserID = long.Parse(ID); UList.Add(p); } } entity = svr.Save(entity,UList); hidID.Value = entity.ACTID.ToString(); this.ShowSaveOK(); btnBack_Click(null, null); } catch (Exception ex) { this.ShowMessage(ex.Message); } }
private ExecutionMessage[] LoadRolesAndPrivileges(CRMUser user) { var Msgs = new ExecutionMessageCollection(); try { DataSet Roles = null; new SecurityDataAdapter(_ConnectionString) .LoadRolesAndPrivileges(out Roles, user.UserID); // Load RoleNames user.RoleList = new System.Collections.ArrayList(); foreach (DataRow row in Roles.Tables[0].Rows) { user.RoleList.Add(row["RoleName"].ToString()); } // Load Privilege Names user.PrivilegeList = new System.Collections.ArrayList(); foreach (DataRow row in Roles.Tables[1].Rows) { user.PrivilegeList.Add(row["PrivilegeName"].ToString()); } } catch (Exception ex) { Msgs.Add(new ErrorMessage(ex.FormatMessage("LoadApplicationUsers"))); } return(Msgs.ToArray()); }
public ActionResult MyProfile() { UserProfileViewModel myProfile = new UserProfileViewModel(); //get user profile inromation from database if user is logged in if (Session["UID"] != null) { var id = Session["UID"]; //get information from db long UID = Convert.ToInt64(id); UserBiz getUser = new UserBiz(); CRMUser crmUser = new CRMUser(); crmUser = getUser.GetUserProfile(UID); myProfile.CompanyName = crmUser.CompanyName; myProfile.Password = crmUser.Password; myProfile.Username = crmUser.Username; myProfile.FirstName = crmUser.FirstName; myProfile.LastName = crmUser.LastName; return(View(myProfile)); } else { return(RedirectToAction("Login")); } }
/// <summary> /// Converts the contact into the user. /// </summary> /// <param name="contact">The contact.</param> /// <returns>The user.</returns> public CRMUser Convert(Entity contact) { Assert.ArgumentNotNull(contact, "contact"); var user = new CRMUser( (string)contact[Configuration.Settings.UniqueKeyProperty], (Guid)contact["contactid"], contact.Contains("emailaddress1") ? (string)contact["emailaddress1"] : String.Empty, null, contact.Contains("description") ? (string)contact["description"] : String.Empty, true, false, contact.Contains("createdon") ? ((DateTime)contact["createdon"]).ToLocalTime() : DateTime.MinValue, DateTime.Now, contact.Contains("lastusedincampaign") ? ((DateTime)contact["lastusedincampaign"]).ToLocalTime() : DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); foreach (var attribute in contact.Attributes) { if (attribute.Value is DateTime) { user.SetPropertyValue(attribute.Key, ((DateTime)attribute.Value).ToLocalTime()); } else { user.SetPropertyValue(attribute.Key, attribute.Value); } } return(user); }
public ActionResult Register(UserRegisterVM u) { try { ///creating company UserBiz userBiz = new UserBiz(); /// creating user CRMUser user = new CRMUser(); user.Password = u.Password; user.Username = u.EmailId; user.CompanyName = u.CompanyName; user.CompanyId = 0; string guid = userBiz.RegisterUser(user); //string CurrentURL = Request.Url.AbsoluteUri; string Msg = "Dear Customer,<br/><br/> Thank you for Registring with us<br/>" + "Plese Click below link for Activation<br/><br/>" + "<a href='http://*****:*****@gmail.com", "Company Registration", Msg, true); ViewBag.Message = "Succefully Registered"; return(View("RegisterSuccess")); } catch (Exception Ex) { ModelState.AddModelError("VE", Ex.Message); return(View(u)); } }
private CRMUser GetSaveEntity() { var entity = new CRMUser(); if (string.IsNullOrEmpty(hidID.Value.Trim()) == false) { entity.UserID = int.Parse(hidID.Value.Trim()); } if (string.IsNullOrEmpty(txtUserName.Text.Trim()) == false) { entity.UserName = txtUserName.Text.Trim(); } if (string.IsNullOrEmpty(txtUserFullName.Text.Trim()) == false) { entity.UserFullName = txtUserFullName.Text.Trim(); } if (string.IsNullOrEmpty(txtPassword.Text.Trim()) == false) { entity.Password = txtPassword.Text.Trim(); } if (string.IsNullOrEmpty(txtMobile.Text.Trim()) == false) { entity.Mobile = txtMobile.Text.Trim(); } if (string.IsNullOrEmpty(txtIsActive.Text.Trim()) == false) { entity.IsActive = Boolean.Parse(txtIsActive.Text.Trim()); } if (string.IsNullOrEmpty(txtEmail.Text.Trim()) == false) { entity.Email = txtEmail.Text.Trim(); } if (string.IsNullOrEmpty(txtBossID.Text.Trim()) == false) { entity.BossID = int.Parse(txtBossID.Text.Trim()); } if (string.IsNullOrEmpty(txtSYSID.Text.Trim()) == false) { entity.SYSID = int.Parse(txtSYSID.Text.Trim()); } if (string.IsNullOrEmpty(txtCDate.Text.Trim()) == false) { entity.CDate = DateTime.Parse(txtCDate.Text.Trim()); } if (string.IsNullOrEmpty(txtCUser.Text.Trim()) == false) { entity.CUser = int.Parse(txtCUserID.Value.Trim()); } if (string.IsNullOrEmpty(txtDept.Text.Trim()) == false) { entity.DepID = int.Parse(txtDept.SelectedValue.Trim()); } entity.ModifyDate = DateTime.Now; entity.ModifyUser = base.LoginUserID; return(entity); }
public override object GetPropertyValue(CRMUser user, string propertyName) { var value = base.GetPropertyValue(user, propertyName); var propertyType = this.GetPropertyType(propertyName); if (propertyType == SupportedTypes.Picklist) { OptionSetValue optionSet = value as OptionSetValue; var picklistAttribute = this.CacheService.MetadataCache[propertyName] as PicklistContactAttribute; if (optionSet != null && picklistAttribute != null) { value = picklistAttribute.Options.FirstOrDefault(p => p.Value == optionSet.Value).Key; } } if (propertyType == SupportedTypes.CrmMoney) { Money money = value as Money; if (money != null) { value = money.Value.ToString("f2"); } } if (propertyType == SupportedTypes.CrmBoolean) { bool boolean = (bool)value; value = boolean ? "1" : "0"; } return(value); }
public bool Authenticate(UserCreateModel user) { CRMUser crmUser = uow.UserRepository.GetUserByLoginId(user.LoginId); string passwordHash = Encryptor.GenerateHash(user.Password + crmUser.PasswordSalt); return(crmUser.PasswordHash == passwordHash); }
/// <summary> /// Leveraging the base components in BusinessPrincipalController, logon the /// current user and fill the User info (ie, name and email). /// </summary> /// <param name="user">EXSUser with UserName not null</param> public void Logon(ref CRMUser user) { // Nothing working, out aha here... if (user.UserName.IsEmpty()) { throw new Exception("Invalid UserName, must be specified to login."); } var Identity = new UserIdentity() { UserName = user.UserName }; var Ctrl = new BusinessPrincipalController(this._ConnectionString); Ctrl.LoginFull(ref Identity); if (Identity == null) { throw new Exception(string.Format("Invalid User, '{0}' not found in Enterprise database on {1}.", user.UserName, ConnectionManager.RegistrationServerName)); } user.UserID = Identity.UserID; user.UserName = Identity.UserName; user.Lastname = Identity.Lastname; user.Firstname = Identity.Firstname; user.Email = Identity.Email; user.Roles = Identity.Roles; this.LoadRolesAndPrivileges(user); }
public void RegisterUser(UserCreateModel model) { //Generating hash for password string salt = Encryptor.GetSaltString(); string password = model.Password + salt; string hashPassword = Encryptor.GenerateHash(password); CRMUser user = AutoMapper.Mapper.Map <UserCreateModel, CRMUser>(model); uow.UserRepository.Add(user); uow.SaveChanges(); }
public void Remove(UserViewModel model) { CRMUser user = uow.UserRepository.GetUserByUID(model.UID); if (user == null) { throw new Exception("user not found"); } else { uow.UserRepository.Delete(user); } uow.SaveChanges(); }
public string RegisterUser(CRMUser user) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMContext"].ConnectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("spRegisterUser", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Username", user.Username); cmd.Parameters.AddWithValue("@Password", user.Password); cmd.Parameters.AddWithValue("@CompanyName", user.CompanyName); SqlParameter prmGuid = cmd.Parameters.Add("@Guid", SqlDbType.UniqueIdentifier); prmGuid.Direction = ParameterDirection.Output; cmd.ExecuteNonQuery(); return(Convert.ToString(prmGuid.Value)); } }
public ActionResult MyProfile(UserProfileViewModel profile) { CRMUser userProfile = new CRMUser(); //var id = Session["UID"]; userProfile.UID = Convert.ToInt64(Session["UID"]); userProfile.FirstName = profile.FirstName; userProfile.LastName = profile.LastName; userProfile.CompanyName = profile.CompanyName; userProfile.Password = profile.Password; userProfile.Username = profile.Username; //userProfile.UserType = profile.UserType; UserBiz userprofilebiz = new UserBiz(); userprofilebiz.UpdateUserProfile(userProfile); ModelState.AddModelError("UPD", "Your Profile is Successfully Updated"); return(View()); }
public void UpdateUserProfile(CRMUser userProfile) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMContext"].ConnectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("spUpdateUserProfile", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UID", SqlDbType.BigInt).Value = userProfile.UID; cmd.Parameters.Add("@FirstName", SqlDbType.VarChar).Value = userProfile.FirstName; cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = userProfile.Password; cmd.Parameters.Add("@Lastname", SqlDbType.VarChar).Value = userProfile.LastName; cmd.Parameters.Add("@UserName", SqlDbType.VarChar).Value = userProfile.Username; cmd.Parameters.Add("@CompanyName", SqlDbType.VarChar).Value = userProfile.CompanyName; //cmd.Parameters.Add("@DateModifed", SqlDbType.DateTime).Value = DateTime.Now; //cmd.Parameters.Add("@UserType", SqlDbType.Bit).Value = userProfile.UserType; //cmd.Parameters.Add("@Status", SqlDbType.Int).Value = userProfile.Status; cmd.ExecuteNonQuery(); } }
//---------------保存CRMActionComments--------------------------- public CRMUser Save(CRMUser entity) { if (this.dataCtx.Connection != null) { if (this.dataCtx.Connection.State == ConnectionState.Closed) { this.dataCtx.Connection.Open(); } } DbTransaction tran = this.dataCtx.Connection.BeginTransaction(); dataCtx.Transaction = tran; try { var qry = from t in CRMUsers where t.UserID == entity.UserID select t; var obj = qry.SingleOrDefault(); if (obj != null) { this.CopyEntity(obj, entity); } else { this.CRMUsers.InsertOnSubmit(entity); } this.dataCtx.SubmitChanges(); tran.Commit(); return(entity); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { dataCtx.Connection.Close(); } }
public ActionResult Register(CompanyCreateModel m) { try { Company client = new Company(); client.Name = m.Name; // client.TicketStartNumber = Convert.ToInt32(m.TicketStartNumber); CRMUser user = new CRMUser() { Username = m.EmailId, Password = m.Password }; CompanyManager <Company> clientManager = new CompanyManager <Company>(new CompanyStore <Company>()); clientManager.CreateClient <CRMUser>(client, user); return(View("RegisterSuccess")); } catch (Exception ex) { ModelState.AddModelError("CC", ex.Message); return(View(m)); } }
public CRMUser GetUserProfile(long id) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMContext"].ConnectionString)) { con.Open(); SqlCommand cmd = new SqlCommand("spGetUserProfilebyId", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@UID", SqlDbType.BigInt).Value = id; SqlDataReader dr = cmd.ExecuteReader(); CRMUser crmUser = null; if (dr.Read()) { crmUser = new CRMUser(); crmUser.CompanyName = Convert.ToString(dr["CompanyName"]); crmUser.Username = Convert.ToString(dr["UserName"]); crmUser.Password = Convert.ToString(dr["Password"]); crmUser.FirstName = Convert.ToString(dr["FirstName"]); crmUser.LastName = Convert.ToString(dr["LastName"]); } return(crmUser); } }
/// <summary> /// Initializes a new instance of the <see cref="CrmMembershipProviderTest"/> class. /// </summary> public CrmMembershipProviderTest() { var cacheService = Substitute.For <ICacheService>(); this.userRepository = Substitute.For <UserRepositoryBase>(cacheService); this.profileRepository = Substitute.For <ProfileRepositoryBase>(this.userRepository, cacheService); this.userRepositoryFactory = Substitute.For <IUserRepositoryFactory>(); this.userRepositoryFactory.GetRepository(Arg.Any <ConfigurationSettings>()).Returns(this.userRepository); this.profileRepositoryFactory = Substitute.For <IProfileRepositoryFactory>(); this.profileRepositoryFactory.GetRepository(Arg.Any <ConfigurationSettings>()).Returns(this.profileRepository); var config = new NameValueCollection(); config.Add("name", "crm"); config.Add("applicationName", "CRM security provider"); config.Add("readOnly", "false"); config.Add("connectionStringName", "CRMConnString"); this.crmMembershipProvider = new CRMMembershipProvider(this.userRepositoryFactory, this.profileRepositoryFactory); this.crmMembershipProvider.Initialize(config["name"], config); this.user = new CRMUser( "*****@*****.**", Guid.NewGuid(), "*****@*****.**", null, String.Empty, true, false, DateTime.Now, DateTime.Now, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); }
/// <summary> /// Leveraging the base components in BusinessPrincipalController, logon the /// current user and fill the User info (ie, name and email). /// </summary> /// <param name="user">EXSUser with UserName not null</param> public void LogonWithApplications(ref CRMUser user) { this.Logon(ref user); }
/// <summary> /// Gets the property value. /// </summary> /// <param name="user">The user.</param> /// <param name="propertyName">Name of the property.</param> /// <returns></returns> public virtual object GetPropertyValue(CRMUser user, string propertyName) { return(user.GetPropertyValue(propertyName)); }
/// <summary> /// Converts the contact into the user. /// </summary> /// <param name="contact">The contact.</param> /// <returns>The user.</returns> public CRMUser Convert(DynamicEntity contact) { Assert.ArgumentNotNull(contact, "contact"); var nameProperty = (StringProperty)contact.Properties.ByName(Configuration.Settings.UniqueKeyProperty); var keyProperty = (KeyProperty)contact.Properties.ByName("contactid"); var emailProperty = contact.Properties.ByName("emailaddress1") as StringProperty; emailProperty = emailProperty ?? new StringProperty { Name = "emailaddress1", Value = String.Empty }; var descriptionProperty = contact.Properties.ByName("description") as StringProperty; descriptionProperty = descriptionProperty ?? new StringProperty { Name = "description", Value = String.Empty }; var createdProperty = contact.Properties.ByName("createdon") as CrmDateTimeProperty; createdProperty = createdProperty ?? new CrmDateTimeProperty { Name = "createdon", Value = new CrmDateTime { Value = DateTime.MinValue.ToString() } }; var lastActivityDateProperty = contact.Properties.ByName("lastusedincampaign") as CrmDateTimeProperty; lastActivityDateProperty = lastActivityDateProperty ?? new CrmDateTimeProperty { Name = "lastusedincampaign", Value = new CrmDateTime { Value = DateTime.MinValue.ToString() } }; var user = new CRMUser( nameProperty.Value, keyProperty.Value.Value, emailProperty.Value, null, descriptionProperty.Value, true, false, DateTime.Parse(createdProperty.Value.Value), DateTime.Now, DateTime.Parse(lastActivityDateProperty.Value.Value), DateTime.MinValue, DateTime.MinValue); var propertyToValueConverter = new PropertyToValueConverterV4(); foreach (var property in contact.Properties) { user.SetPropertyValue(property.Name, propertyToValueConverter.Convert(property)); } return(user); }
/// <summary> /// Initializes a new instance of the <see cref="CRMMembershipUser"/> class. /// </summary> /// <param name="providerName">The provider name.</param> /// <param name="user">The user.</param> public CRMMembershipUser(string providerName, CRMUser user) : base(providerName, user.Name, user.ID, user.Email, user.PasswordQuestion, user.Description, user.IsApproved, user.IsLockedOut, user.CreatedDate, user.LastLoginDate, user.LastActivityDate, user.LastPasswordChangedDate, user.LastLockoutDate) { }
public CRMUser CRMGetUser(CRMUser crmUser) { CRMFunctions function = new CRMFunctions(crmUser.Config); return(function.CRMGetUser(crmUser)); }
public override CRMUser CreateUser(string userName, string email, Guid providerUserKey) { Assert.ArgumentNotNullOrEmpty(userName, "userName"); Assert.ArgumentNotNullOrEmpty(email, "email"); const string CreateUserKey = "createUser"; ConditionalLog.Info(string.Format("CreateUser({0}, {1}, {2}). Started.", userName, email, providerUserKey), this, TimerAction.Start, CreateUserKey); var contact = new Entity { LogicalName = "contact" }; if (Configuration.Settings.UniqueKeyProperty != "fullname") { contact[Configuration.Settings.UniqueKeyProperty] = userName; } else { var nameParts = new List <string>(userName.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); contact["firstname"] = nameParts[0]; if (nameParts.Count > 1) { contact["lastname"] = string.Join(" ", nameParts.GetRange(1, nameParts.Count - 1).ToArray()); } } if ((email != null) && (Configuration.Settings.UniqueKeyProperty != "emailaddress1")) { contact["emailaddress1"] = email; } if (providerUserKey != Guid.Empty) { contact["contactid"] = providerUserKey; } CRMUser user = null; try { providerUserKey = this.organizationServiceCache.GetOrganizationService().Create(contact); ConditionalLog.Info(string.Format("CreateUser({0}, {1}, {2}). User has been created in CRM.", userName, email, providerUserKey), this, TimerAction.Tick, CreateUserKey); user = new CRMUser( userName, providerUserKey, email, null, string.Empty, true, false, DateTime.Now, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); this.CacheService.UserCache.Add(user); } catch (Exception e) { ConditionalLog.Error(string.Format("Couldn't create user {0} in CRM.", userName), e, this); } ConditionalLog.Info(string.Format("CreateUser({0}, {1}, {2}). Finished.", userName, email, providerUserKey), this, TimerAction.Stop, CreateUserKey); return(user); }
public override CRMUser CreateUser(string userName, string email, Guid providerUserKey) { Assert.ArgumentNotNullOrEmpty(userName, "userName"); Assert.ArgumentNotNullOrEmpty(email, "email"); const string CreateUserKey = "createUser"; ConditionalLog.Info(String.Format("CreateUser({0}, {1}, {2}). Started.", userName, email, providerUserKey), this, TimerAction.Start, CreateUserKey); var properties = new List <Property>(); if (Configuration.Settings.UniqueKeyProperty != "fullname") { properties.Add(new StringProperty { Name = Configuration.Settings.UniqueKeyProperty, Value = userName }); } else { var nameParts = new List <string>(userName.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); properties.Add(new StringProperty { Name = "firstname", Value = nameParts[0] }); if (nameParts.Count > 1) { properties.Add(new StringProperty { Name = "lastname", Value = String.Join(" ", nameParts.GetRange(1, nameParts.Count - 1).ToArray()) }); } } if ((email != null) && (Configuration.Settings.UniqueKeyProperty != "emailaddress1")) { properties.Add(new StringProperty { Name = "emailaddress1", Value = email }); } if (providerUserKey != Guid.Empty) { properties.Add(new KeyProperty { Name = "contactid", Value = new Key { Value = providerUserKey } }); } var contact = new DynamicEntity(); contact.Name = EntityName.contact.ToString(); contact.Properties = properties.ToArray(); CRMUser user = null; try { providerUserKey = this.CrmService.Create(contact); ConditionalLog.Info(String.Format("CreateUser({0}, {1}, {2}). User has been created in CRM.", userName, email, providerUserKey), this, TimerAction.Tick, CreateUserKey); user = new CRMUser( userName, providerUserKey, email, null, String.Empty, true, false, DateTime.Now, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue, DateTime.MinValue); this.CacheService.UserCache.Add(user); } catch (Exception e) { ConditionalLog.Error(String.Format("Couldn't create user {0} in CRM.", userName), e, this); } ConditionalLog.Info(String.Format("CreateUser({0}, {1}, {2}). Finished.", userName, email, providerUserKey), this, TimerAction.Stop, CreateUserKey); return(user); }
public CRMUser Save(CRMUser entity, IList <CRMRole> RoleList) { if (this.dataCtx.Connection != null) { if (this.dataCtx.Connection.State == ConnectionState.Closed) { this.dataCtx.Connection.Open(); } } DbTransaction tran = this.dataCtx.Connection.BeginTransaction(); dataCtx.Transaction = tran; try { var qry = from t in CRMUsers where t.UserID == entity.UserID select t; var obj = qry.SingleOrDefault(); //encrypt password,如果没输入password,不更改数据库password if (string.IsNullOrEmpty(entity.Password)) { if (obj != null) { entity.Password = obj.Password; } } else { entity.Password = this.Encypt(entity.UserName, entity.Password); } if (obj != null) { this.CopyEntity(obj, entity); } else { this.CRMUsers.InsertOnSubmit(entity); } this.dataCtx.SubmitChanges(); //delete Role relationship with User var qryDel = from t in CRMUserRoles where t.UserID == entity.UserID select t; foreach (var item in qryDel.ToList()) { this.CRMUserRoles.DeleteOnSubmit(item); } //add new foreach (var role in RoleList) { var p = new CRMUserRole(); p.UserID = entity.UserID; p.RoleID = role.RoleID; this.CRMUserRoles.InsertOnSubmit(p); } this.dataCtx.SubmitChanges(); tran.Commit(); return(entity); } catch (Exception ex) { tran.Rollback(); throw ex; } finally { dataCtx.Connection.Close(); } }
//---------------����CRMActionComments--------------------------- public CRMUser Save(CRMUser entity) { if (this.dataCtx.Connection != null) if (this.dataCtx.Connection.State == ConnectionState.Closed) this.dataCtx.Connection.Open(); DbTransaction tran = this.dataCtx.Connection.BeginTransaction(); dataCtx.Transaction = tran; try { var qry = from t in CRMUsers where t.UserID == entity.UserID select t; var obj = qry.SingleOrDefault(); if (obj != null) this.CopyEntity(obj, entity); else this.CRMUsers.InsertOnSubmit(entity); this.dataCtx.SubmitChanges(); tran.Commit(); return entity; } catch (Exception ex) { tran.Rollback(); throw ex; } finally { dataCtx.Connection.Close(); } }
public string RegisterUser(CRMUser user) { UserDB userDB = new UserDB(); return(userDB.RegisterUser(user)); }
public CRMUser Save(CRMUser entity, IList<CRMRole> RoleList) { if (this.dataCtx.Connection != null) if (this.dataCtx.Connection.State == ConnectionState.Closed) this.dataCtx.Connection.Open(); DbTransaction tran = this.dataCtx.Connection.BeginTransaction(); dataCtx.Transaction = tran; try { var qry = from t in CRMUsers where t.UserID == entity.UserID select t; var obj = qry.SingleOrDefault(); //encrypt password,���û����password�����������ݿ�password if (string.IsNullOrEmpty(entity.Password)) { if (obj != null) { entity.Password = obj.Password; } } else { entity.Password = this.Encypt(entity.UserName, entity.Password); } if (obj != null) this.CopyEntity(obj, entity); else this.CRMUsers.InsertOnSubmit(entity); this.dataCtx.SubmitChanges(); //delete Role relationship with User var qryDel = from t in CRMUserRoles where t.UserID == entity.UserID select t; foreach (var item in qryDel.ToList()) { this.CRMUserRoles.DeleteOnSubmit(item); } //add new foreach (var role in RoleList) { var p = new CRMUserRole(); p.UserID = entity.UserID; p.RoleID = role.RoleID; this.CRMUserRoles.InsertOnSubmit(p); } this.dataCtx.SubmitChanges(); tran.Commit(); return entity; } catch (Exception ex) { tran.Rollback(); throw ex; } finally { dataCtx.Connection.Close(); } }
private void GetCRMUser(ref ServiceObject so) { SourceCode.SmartObjects.Services.ServiceSDK.Objects.Method meth = so.Methods[0]; CRMUser user = new CRMUser(); user.Config = crmconfig; try { user.UserFQN = NotNull(so.Properties["UserFQN"].Value); CRMUser response = CRMFunctions.CRMGetUser(user); so.Properties.InitResultTable(); for (int c = 0; c < meth.ReturnProperties.Count; c += 1) { Property prop = so.Properties[meth.ReturnProperties[c]]; prop = SetCRMUserProperties(prop, response); } so.Properties.BindPropertiesToResultTable(); } catch (Exception ex) { throw; } }
private Property SetCRMUserProperties(Property prop, CRMUser task) { if (task != null) { switch (prop.Name.ToLower()) { case "userfqn": prop.Value = task.UserFQN; break; case "userid": prop.Value = task.UserId; break; } } return prop; }
public void UpdateUserProfile(CRMUser userProfile) { UserDB userProfiledb = new UserDB(); userProfiledb.UpdateUserProfile(userProfile); }
private CRMUser GetSaveEntity() { var entity = new CRMUser(); if (string.IsNullOrEmpty(txtUserID.Text.Trim()) == false) entity.UserID = int.Parse(txtUserID.Text.Trim()); if (string.IsNullOrEmpty(txtUserName.Text.Trim()) == false) entity.UserName = txtUserName.Text.Trim(); if (string.IsNullOrEmpty(txtUserFullName.Text.Trim()) == false) entity.UserFullName = txtUserFullName.Text.Trim(); if (string.IsNullOrEmpty(txtPassword.Text.Trim()) == false) entity.Password = txtPassword.Text.Trim(); if (string.IsNullOrEmpty(txtMobile.Text.Trim()) == false) entity.Mobile = txtMobile.Text.Trim(); entity.IsActive = true; if (string.IsNullOrEmpty(txtEmail.Text.Trim()) == false) entity.Email = txtEmail.Text.Trim(); if (string.IsNullOrEmpty(txtBossID.Text.Trim()) == false) entity.BossID = int.Parse(txtBossID.Text.Trim()); if (string.IsNullOrEmpty(txtSYSID.Text.Trim()) == false) entity.SYSID = int.Parse(txtSYSID.Text.Trim()); if (string.IsNullOrEmpty(txtCDate.Text.Trim()) == false) entity.CDate = DateTime.Parse(txtCDate.Text.Trim()); if (string.IsNullOrEmpty(txtCUser.Text.Trim()) == false) entity.CUser = int.Parse(txtCUserID.Value.Trim()); if (string.IsNullOrEmpty(txtDept.Text.Trim()) == false) entity.DepID = int.Parse(txtDept.SelectedValue.Trim()); entity.ModifyDate = DateTime.Now; entity.ModifyUser = base.LoginUserID; return entity; }