/// <summary> /// /// </summary> /// <param name="profile"></param> /// <param name="status"></param> /// <param name="rejectedReason"></param> public static void SendAuthenticateResult(OrganizationProfile profile, Passports.AttestationStatus status, string rejectedReason = null) { var message = new Message(); if (status == Passports.AttestationStatus.Passed) { message.Subject = "身份认证成功通知"; message.Content = "你好,你的身份认证已经通过审核。"; } else if (status == Passports.AttestationStatus.Rejected) { message.Subject = "身份认证失败通知"; message.Content = string.Format("你好,你的身份认证失败,失败原因:{0};请上传相关资料重新认证。" , rejectedReason); } else { return; } message.ToPassportId = profile.PassportId; message.MessageType = Message.TextType; message.ToProfileType = ProfileType.OrganizationProfile; message.FromPassportId = Message.SystemNotificationPassportId; message.SentTime = DateTime.Now; Message.AddNewMessage(message); }
public static async Task <OrganizationProfile> GetOrganizationProfile() { OrganizationProfile obj = new OrganizationProfile(); try { string url = ServiceConfigrations.BaseUrl1 + ServiceConfigrations.GetOrganizationProfile; var userinfo = await HttpRequest.GetRequest(url); var serviceResult = JsonConvert.DeserializeObject <OrganizationProfile>(userinfo.Result); if (serviceResult != null) { obj = serviceResult; return(obj); } else { return(obj); } } catch (Exception ex) { return(obj); } }
private IEnumerable <PatchCommandData> Establish(UserProfile user, ManagerOf managerOf, OrganizationProfile organization, HasManager hasManager) { const string patchScript = "var _this = this;" + "function addRelation(clrType, relation, thisArg) {" + " relation['$type'] = clrType; " + " (thisArg || _this).Relations.push(relation);" + "}" + "addRelation(args.relationClrType, args.relation);"; yield return(new PatchCommandData(user.Id, null, new PatchRequest { Script = patchScript, Values = new Dictionary <string, object> { { "relation", managerOf }, { "relationClrType", ClrType(managerOf.GetType()) } } }, null)); yield return(new PatchCommandData(organization.Id, null, new PatchRequest { Script = patchScript, Values = new Dictionary <string, object> { { "relation", hasManager }, { "relationClrType", ClrType(hasManager.GetType()) } } }, null)); }
public AutoMapperFixture() { var myProfile = new OrganizationProfile(); var configuration = new MapperConfiguration(cfg => cfg.AddProfile(myProfile)); Instance = new Mapper(configuration); }
/// <summary> /// Updates the organization profile.</summary> /// <param name="entity">The updated organization profile.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> /// <returns>The updated organization profile.</returns> public async Task <OrganizationProfile> UpdateAsync(OrganizationProfile entity, CancellationToken cancellationToken = default) { return(await Partner.ServiceClient.PutAsync <OrganizationProfile, OrganizationProfile>( new Uri( $"/{PartnerService.Instance.ApiVersion}/{PartnerService.Instance.Configuration.Apis.GetOrganizationProfile.Path}", UriKind.Relative), entity, cancellationToken).ConfigureAwait(false)); }
public AccountEntity ChangeCurrentToOrganizationProfile(OrganizationProfile newProfile) { var passport = MvcContext.Current.UserPassport; MemberShip.OpenOrganizationService(passport, newProfile); AccountAuthentication.SyncIMAccount(passport); return(new AccountEntity(MvcContext.Current.ClientAccount, passport)); }
private static TreeNode ToTreeNode(OrganizationProfile child) { Contract.Requires(child != null); Contract.Ensures(Contract.Result <TreeNode>() != null); return(new TreeNode(child.DisplayName, child.RecordId.ToString()) { PopulateOnDemand = child.HasChildren, }); }
public void ChangeProfileTest() { var entity = new OrganizationProfile(); TestHelper.FillRndProperties(entity, "Id"); entity.Avatar = null; var responseResult = WebApiClient.HttpPost(ApiEnvironment.Consultant_ChangeProfile_Endpoint, entity); Assert.AreEqual(HttpStatusCode.OK, responseResult.StatusCode); Assert.IsNotNullOrEmpty(responseResult.Content); Assert.IsTrue(responseResult.Content.ConvertEntity <bool>()); }
public bool ChangeProfile([FromBody] OrganizationProfile entity) { if (entity == null) { return(false); } var profile = (OrganizationProfile)MvcContext.Current.UserPassport.Profile; var syncIMAccount = false == string.IsNullOrEmpty(entity.RealName) && profile.RealName != entity.RealName; profile.FillPropertiesFromEntity(entity, true); profile.PassportId = MvcContext.Current.PassportId; var saved = profile.Save(); if (saved && syncIMAccount) { AccountAuthentication.SyncIMAccount(MvcContext.Current.UserPassport); } return(saved); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { Scheduler.RunTask(async() => { if (ShouldProcess("Updates the partner's organization profile")) { IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false); OrganizationProfile profile = await partner.Profiles.OrganizationProfile.GetAsync(CancellationToken).ConfigureAwait(false); profile.CompanyName = UpdateValue(CompanyName, profile.CompanyName); profile.Email = UpdateValue(Email, profile.Email); profile.Language = UpdateValue(Language, profile.Language); profile.Culture = UpdateValue(Culture, profile.Culture); profile.DefaultAddress.AddressLine1 = UpdateValue(AddressLine1, profile.DefaultAddress.AddressLine1); profile.DefaultAddress.AddressLine2 = UpdateValue(AddressLine2, profile.DefaultAddress.AddressLine2); profile.DefaultAddress.City = UpdateValue(City, profile.DefaultAddress.City); profile.DefaultAddress.Country = UpdateValue(Country, profile.DefaultAddress.Country); profile.DefaultAddress.PostalCode = UpdateValue(PostalCode, profile.DefaultAddress.PostalCode); profile.DefaultAddress.State = UpdateValue(State, profile.DefaultAddress.State); profile.DefaultAddress.FirstName = UpdateValue(FirstName, profile.DefaultAddress.FirstName); profile.DefaultAddress.LastName = UpdateValue(LastName, profile.DefaultAddress.LastName); profile.DefaultAddress.PhoneNumber = UpdateValue(PhoneNumber, profile.DefaultAddress.PhoneNumber); if (!DisableValidation.ToBool()) { IValidator <Address> validator = new AddressValidator(partner); if (!await validator.IsValidAsync(profile.DefaultAddress, CancellationToken).ConfigureAwait(false)) { throw new PSInvalidOperationException("The specified address is invalid. Please verify the address and try again."); } } profile = await partner.Profiles.OrganizationProfile.UpdateAsync(profile, CancellationToken).ConfigureAwait(false); WriteObject(new PSOrganizationProfile(profile)); } }, true); }
public AccountEntity OpenOrganizationService([FromBody] OrganizationProfile entity) { var passport = MvcContext.Current.UserPassport; if (null == entity) { entity = new OrganizationProfile(); entity.PassportId = passport.PassportId; entity.RealName = passport.Profile.Nickname; } var success = MemberShip.OpenOrganizationService(passport, entity); AccountEntity result = null; if (success) { AccountAuthentication.SyncIMAccount(passport); result = new AccountEntity(MvcContext.Current.ClientAccount, passport); } return(result); }
public void ApplyAuthenticationTest() { var entity = new OrganizationProfile(); entity.Identity = TestHelper.GetRndString(); entity.AuthenticationImages = new string[TestHelper.GetRndNumber(1, 4)]; for (var i = 0; i < entity.AuthenticationImages.Length; i++) { entity.AuthenticationImages[i] = TestHelper.GetTestImageStream(); } var responseResult = WebApiClient.HttpPost(ApiEnvironment.Consultant_ApplyAuthentication_Endpoint, entity); Assert.AreEqual(HttpStatusCode.OK, responseResult.StatusCode); Assert.IsNotNullOrEmpty(responseResult.Content); var images = responseResult.Content.ConvertEntity <string[]>(); Assert.IsNotNull(images); Assert.AreEqual(images.Length, entity.AuthenticationImages.Length); }
public IEnumerable <ScriptedPatchCommandData> Establish(UserProfile user, ManagerOf managerOf, OrganizationProfile organization, HasManager hasManager) { const string patchScript = "var _this = this;" + "function addRelation(clrType, relation, thisArg) {" + " (thisArg || _this).Relations.push(_.extend({ '$type': clrType }, relation));" + "}" + "addRelation(relationClrType, relation);"; yield return(new ScriptedPatchCommandData { Key = user.Id, Patch = new ScriptedPatchRequest { Script = patchScript, Values = new Dictionary <string, object> { { "relation", managerOf }, { "relationClrType", ClrType(managerOf.GetType()) } } } }); yield return(new ScriptedPatchCommandData { Key = organization.Id, Patch = new ScriptedPatchRequest { Script = patchScript, Values = new Dictionary <string, object> { { "relation", hasManager }, { "relationClrType", ClrType(hasManager.GetType()) } } } }); }
static void CreateSiteGroup(OrganizationProfile parentProfile, IEnumerable<string> accountNames, SPSite site) { var groupName = parentProfile.DisplayName + parentProfile.RecordId; site.RootWeb.SiteGroups.Add(groupName, site.Owner, null, null); var group = site.RootWeb.SiteGroups.GetByName(groupName); foreach (var accountName in accountNames) { group.AddUser(accountName, null, null, null); } }
/// <summary> /// Initializes a new instance of the <see cref="PSOrganizationProfile" /> class. /// </summary> /// <param name="profile">The base organization profile for this instance.</param> public PSOrganizationProfile(OrganizationProfile profile) { this.CopyFrom(profile); }
internal ManagerOf(OrganizationProfile organization) : base(organization) { }
static OrganizationProfile CreateOrganization(string displayName, long id, OrganizationProfile parentProfile, ProfileSubtype subtype, OrganizationProfileManager manager, SPSite site) { OrganizationProfile profile = manager.CreateOrganizationProfile(subtype, parentProfile); profile.DisplayName = displayName; using (var db = new CMSMIPEntities()) { IEnumerable<string> accountNames = db.CMS_SA_USER_INFO_V.Where(u => u.所属部门ID == id).Select(u => u.SP账号); foreach (var accountName in accountNames) { profile.AddMember(accountName, OrganizationMembershipType.Member); } profile.Commit(); CreateSiteGroup(profile, accountNames, site); var subOrganizations = db.CMS_BA_IN_DEPT_INFO_V.Where(o => o.组织机构上级ID == id); foreach (var subOrganization in subOrganizations) { CreateOrganization(subOrganization.组织机构名称, subOrganization.机构ID, profile, subtype, manager, site); } return profile; } Console.WriteLine(displayName + id); }