public bool LsbDistinct() { try { var networkActivitities = new List <BsonDocument>(); if (SelectedUsers.Count < 11 || SelectedMachines.Count < 1) { return(false); } DbClient.ClearTestCollections(); SvcCtrl.StopService("ATACenter"); DbClient.SetCenterProfileForReplay(); Logger.Debug("Center profile set for replay"); networkActivitities.AddRange( SelectedUsers.Select( user => DocumentCreator.SimpleBindCreator(user, SelectedMachines[0], SelectedDomainControllers.FirstOrDefault(), DomainList.Single(_ => _.Id == user.Domain).Name , DomainList.Single(_ => _.Id == SelectedMachines[0].Domain).Name, SourceGateway))); DbClient.InsertBatch(networkActivitities); Logger.Debug("Done inserting Ldap activities"); SvcCtrl.StartService("ATACenter"); return(true); } catch (Exception distinctException) { Logger.Error(distinctException); return(false); } }
private IEnumerable <int> GetUsersToSearchFor() { var allUsersMarker = SelectedUsers.FirstOrDefault(x => x.IsAllUsers); // If allUsersMarker, get all users return(allUsersMarker != null ? Users.Where(x => !x.IsAllUsers).Select(x => x.UserId) : SelectedUsers.Select(x => x.UserId)); }
protected void Page_Load(object sender, EventArgs e) { //init advUserSelector var userSelector = new AdvancedUserSelector { ID = "advUserSelectorListView" + ObjId, IsLinkView = true, LinkText = CustomNamingPeople.Substitute <CRMCommonResource>("AddUser"), AdditionalFunction = "ASC.CRM.UserSelectorListView" + ObjId + ".pushUserIntoList" }; if (UserList != null && UserList.Count > 0) { userSelector.UserList = UserList; } if (DisabledUsers != null && DisabledUsers.Count > 0) { userSelector.DisabledUsers = DisabledUsers; } _phAdvUserSelector.Controls.Add(userSelector); var ids = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Key).ToArray() : new List <Guid>().ToArray(); var names = SelectedUsers != null && SelectedUsers.Count > 0 ? SelectedUsers.Select(i => i.Value).ToArray() : new List <string>().ToArray(); var key = Guid.NewGuid().ToString(); Page.ClientScript.RegisterClientScriptBlock(typeof(PrivatePanel), key, "SelectedUsers" + ObjId + " = " + JavaScriptSerializer.Serialize( new { IDs = ids, Names = names, PeopleImgSrc = PeopleImgSrc, DeleteImgSrc = DeleteImgSrc, DeleteImgTitle = CRMCommonResource.DeleteUser, CurrentUserID = SecurityContext.CurrentAccount.ID }) + "; ", true); }
public override void Create() { if (string.IsNullOrEmpty(Title)) { MessageBox.Show(AppResources.PleaseEnterGroupSubject, AppResources.Error, MessageBoxButton.OK); return; } var participants = new TLVector <TLInputUserBase>(); foreach (var item in SelectedUsers) { participants.Add(item.ToInputUser()); } if (participants.Count == 0) { MessageBox.Show(AppResources.PleaseChooseAtLeastOneParticipant, AppResources.Error, MessageBoxButton.OK); return; } var broadcastChat = new TLBroadcastChat { Id = TLInt.Random(), Photo = new TLChatPhotoEmpty(), Title = new TLString(Title), ParticipantIds = new TLVector <TLInt> { Items = SelectedUsers.Select(x => x.Id).ToList() } }; CacheService.SyncBroadcast(broadcastChat, result => { var broadcastPeer = new TLPeerBroadcast { Id = broadcastChat.Id }; var serviceMessage = new TLMessageService17 { FromId = new TLInt(StateService.CurrentUserId), ToId = broadcastPeer, Status = MessageStatus.Confirmed, Out = new TLBool { Value = true }, Date = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now), //IsAnimated = true, RandomId = TLLong.Random(), Action = new TLMessageActionChatCreate { Title = broadcastChat.Title, Users = broadcastChat.ParticipantIds } }; serviceMessage.SetUnread(new TLBool(false)); CacheService.SyncMessage(serviceMessage, message => { StateService.With = broadcastChat; StateService.RemoveBackEntry = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); }); }); }
public override void Create() { if (IsWorking) { return; } if (_newChannel == null) { return; } var participants = new TLVector <TLInputUserBase>(); foreach (var item in SelectedUsers) { participants.Add(item.ToInputUser()); } participants.Add(new TLInputUserContact { UserId = new TLInt(StateService.CurrentUserId) }); if (participants.Count == 0) { MessageBox.Show(AppResources.PleaseChooseAtLeastOneParticipant, AppResources.Error, MessageBoxButton.OK); return; } _newChannel.ParticipantIds = new TLVector <TLInt> { Items = SelectedUsers.Select(x => x.Id).ToList() }; #if LAYER_40 IsWorking = true; MTProtoService.InviteToChannelAsync(_newChannel.ToInputChannel(), participants, result => Execute.BeginOnUIThread(() => { IsWorking = false; StateService.With = _newChannel; StateService.RemoveBackEntries = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); }), error => Execute.BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("channels.inviteToChannel error " + error); })); #else CacheService.SyncBroadcast(_newChannel, result => { var broadcastPeer = new TLPeerBroadcast { Id = _newChannel.Id }; var serviceMessage = new TLMessageService17 { FromId = new TLInt(StateService.CurrentUserId), ToId = broadcastPeer, Status = MessageStatus.Confirmed, Out = TLBool.True, Date = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now), //IsAnimated = true, RandomId = TLLong.Random(), Action = new TLMessageActionChannelCreate { Title = _newChannel.Title, } }; serviceMessage.SetUnread(TLBool.False); CacheService.SyncMessage(serviceMessage, broadcastPeer, message => { if (_newChannel.Photo is TLChatPhoto) { var serviceMessage2 = new TLMessageService17 { FromId = new TLInt(StateService.CurrentUserId), ToId = broadcastPeer, Status = MessageStatus.Confirmed, Out = TLBool.True, Date = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now), //IsAnimated = true, RandomId = TLLong.Random(), Action = new TLMessageActionChatEditPhoto { Photo = _newChannel.Photo, } }; serviceMessage2.SetUnread(TLBool.False); CacheService.SyncMessage(serviceMessage2, broadcastPeer, message2 => { StateService.With = _newChannel; StateService.RemoveBackEntries = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); }); return; } StateService.With = _newChannel; StateService.RemoveBackEntries = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); }); }); #endif }
public override void Create() { if (IsWorking) { return; } if (_newChannel == null) { return; } var participants = new TLVector <TLInputUserBase>(); foreach (var item in SelectedUsers) { participants.Add(item.ToInputUser()); } participants.Add(new TLInputUser { UserId = new TLInt(StateService.CurrentUserId), AccessHash = new TLLong(0) }); if (participants.Count == 0) { MessageBox.Show(AppResources.PleaseChooseAtLeastOneParticipant, AppResources.Error, MessageBoxButton.OK); return; } _newChannel.ParticipantIds = new TLVector <TLInt> { Items = SelectedUsers.Select(x => x.Id).ToList() }; IsWorking = true; MTProtoService.InviteToChannelAsync(_newChannel.ToInputChannel(), participants, result => Execute.BeginOnUIThread(() => { IsWorking = false; StateService.With = _newChannel; StateService.RemoveBackEntries = true; NavigationService.UriFor <DialogDetailsViewModel>().Navigate(); }), error => Execute.BeginOnUIThread(() => { if (error.TypeEquals(ErrorType.PEER_FLOOD)) { //MessageBox.Show(AppResources.PeerFloodAddContact, AppResources.Error, MessageBoxButton.OK); ShellViewModel.ShowCustomMessageBox(AppResources.PeerFloodAddContact, AppResources.Error, AppResources.MoreInfo.ToLowerInvariant(), AppResources.Ok.ToLowerInvariant(), result => { if (result == CustomMessageBoxResult.RightButton) { TelegramViewBase.NavigateToUsername(MTProtoService, Constants.SpambotUsername, null, null, null); } }); } else if (error.TypeEquals(ErrorType.USERS_TOO_MUCH)) { MessageBox.Show(AppResources.UsersTooMuch, AppResources.Error, MessageBoxButton.OK); } else if (error.TypeEquals(ErrorType.USER_CHANNELS_TOO_MUCH)) { MessageBox.Show(AppResources.UserChannelsTooMuch, AppResources.Error, MessageBoxButton.OK); } else if (error.TypeEquals(ErrorType.BOTS_TOO_MUCH)) { MessageBox.Show(AppResources.BotsTooMuch, AppResources.Error, MessageBoxButton.OK); } else if (error.TypeEquals(ErrorType.USER_NOT_MUTUAL_CONTACT)) { MessageBox.Show(AppResources.UserNotMutualContact, AppResources.Error, MessageBoxButton.OK); } IsWorking = false; Execute.ShowDebugMessage("channels.inviteToChannel error " + error); })); }