/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 9, Configuration.FieldSeparator), Id, RoleInstanceId?.ToDelimitedString(), ActionCode, RoleRol?.ToDelimitedString(), RolePerson?.ToDelimitedString(), RoleBeginDateTime.HasValue ? RoleBeginDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RoleEndDateTime.HasValue ? RoleEndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RoleDuration?.ToDelimitedString(), RoleActionReason?.ToDelimitedString() ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest rp = context.Request; string msg = string.Empty; try { Guid RoleID = new Guid(rp["roleID"]); string personID = rp["person"]; string[] personArray = personID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); List <BaseEntity> list = new List <BaseEntity>(); foreach (string item in personArray) { RolePerson rpi = new RolePerson(); rpi.ID = Guid.NewGuid(); rpi.PersonID = new Guid(item); rpi.RoleID = RoleID; list.Add(rpi); } RoleInfoManager manager = new RoleInfoManager(); manager.Save(list); context.Response.Write("{\"success\":\"true\"}"); } catch (Exception ex) { msg = ex.Message; } if (!string.IsNullOrEmpty(msg)) { byte[] bytes = Encoding.UTF8.GetBytes(msg.Replace("\r\n", "<br/>")); string encode = Convert.ToBase64String(bytes); context.Response.Write("{\"success\":\"false\",\"msg\":\"" + encode + "\"}"); } context.Response.End(); }
//Générateur de roles public List <RolePerson> GetRolePersons(List <Person> allPersons, List <Role> roles) { var rolePerson = new List <RolePerson>(); foreach (Role role in roles) { var personsWithThisRole = new List <Person>(); var numberOfPerson = _random.Next(0, 50); for (int i = 0; i < numberOfPerson; i++) { var check = 1; while (check == 1) { var indice = _random.Next(0, 50); var randPerson = allPersons[indice]; if ((personsWithThisRole.Exists(x => x.Id == randPerson.Id)) == false) { personsWithThisRole.Add(randPerson); check = 0; } } } foreach (Person person in personsWithThisRole) { var relation = new RolePerson { PersonId = person.Id, Person = person, RoleId = role.Id, Role = role }; rolePerson.Add(relation); } } return(rolePerson); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 15, Configuration.FieldSeparator), Id, RoleInstanceId?.ToDelimitedString(), ActionCode, RoleRol?.ToDelimitedString(), RolePerson != null ? string.Join(Configuration.FieldRepeatSeparator, RolePerson.Select(x => x.ToDelimitedString())) : null, RoleBeginDateTime.HasValue ? RoleBeginDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RoleEndDateTime.HasValue ? RoleEndDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null, RoleDuration?.ToDelimitedString(), RoleActionReason?.ToDelimitedString(), ProviderType != null ? string.Join(Configuration.FieldRepeatSeparator, ProviderType.Select(x => x.ToDelimitedString())) : null, OrganizationUnitType?.ToDelimitedString(), OfficeHomeAddressBirthplace != null ? string.Join(Configuration.FieldRepeatSeparator, OfficeHomeAddressBirthplace.Select(x => x.ToDelimitedString())) : null, Phone != null ? string.Join(Configuration.FieldRepeatSeparator, Phone.Select(x => x.ToDelimitedString())) : null, PersonsLocation?.ToDelimitedString(), Organization?.ToDelimitedString() ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }