public async Task GenerateRandomDirectory() { try { DataBaseManager databaseManager = new DataBaseManager(); Employees = new ObservableCollection <Employee>(); Random rdn = new Random(); string[] photos = { //"http://www.femside.com/wp-content/uploads/2013/06/suit-woman.jpg", // "http://previews.123rf.com/images/phakimata/phakimata1103/phakimata110300023/9030612-Experienced-female-business-lawyer-in-suit-Beautiful-Senior-old-woman-with-arms-crossed-isolated--Stock-Photo.jpg", // "https://angrymiddleagewoman.files.wordpress.com/2011/12/woman-in-suit.jpg", "http://steezo.com/wp-content/uploads/2012/12/man-in-suit2.jpg", "http://attractmen.org/wp-content/uploads/2015/10/attractmen.org-libra-men.jpg", }; ImageClient client = new ImageClient(); for (int i = 0; i < 16; i++) { var name = "Nombre" + i; var photo = photos[rdn.Next(0, 2)]; var newEmployee = new Employee( name, await client.GetImage(photo), (JobPosition)rdn.Next(0, 4), name + "@mycompany.com" ); Employees.Add(newEmployee); await databaseManager.SaveValueAsync <Employee>(newEmployee); } }catch (Exception e) { } }
//- @SaveImage -// public static BlogImage GetImage(String blogImageGuid) { using (ImageClient imageClient = new ImageClient(MinimaConfiguration.ActiveImageServiceEndpoint)) { imageClient.ClientCredentials.UserName.UserName = MinimaConfiguration.DefaultServiceUserName; imageClient.ClientCredentials.UserName.Password = MinimaConfiguration.DefaultServicePassword; //+ return(imageClient.GetImage(blogImageGuid)); } }
//- @SaveImage -// public static BlogImage GetImage(String blogImageGuid) { using (ImageClient imageClient = new ImageClient(BlogSection.GetConfigSection().Service.Endpoint.Image)) { imageClient.ClientCredentials.UserName.UserName = BlogSection.GetConfigSection().Service.Authentication.DefaultUserName; imageClient.ClientCredentials.UserName.Password = BlogSection.GetConfigSection().Service.Authentication.DefaultPassword; //+ return(imageClient.GetImage(blogImageGuid)); } }
async Task ChangeState() { var state = _ropuClient.State; State = state.ToString(); switch (state) { case StateId.Start: case StateId.NoGroup: case StateId.Unregistered: PttColor = Gray; break; case StateId.Registered: case StateId.Deregistering: case StateId.StartingCall: PttColor = Blue; break; case StateId.InCallRequestingFloor: case StateId.InCallReleasingFloor: case StateId.InCallTransmitting: case StateId.InCallIdle: case StateId.InCallReceiving: PttColor = Green; break; default: throw new Exception("Unhandled Call State"); } Transmitting = state == StateId.InCallTransmitting; var callGroup = InCall(state) && _ropuClient.CallGroup.HasValue ? await _groupsClient.Get(_ropuClient.CallGroup.Value) : null; CallGroup = callGroup?.Name == null ? "" : callGroup.Name; CallGroupImage = callGroup?.Image; await SetupCircleText(state); var user = state == StateId.InCallReceiving ? (_ropuClient.Talker.HasValue ? await _usersClient.Get(_ropuClient.Talker.Value) : null) : null; Talker = user?.Name; if (user != null) { TalkerImage = await _imageClient.GetImage(user.ImageHash); } }