Exemple #1
0
        public async Task <LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user)
        {
            FacebookUserInfo facebookUser = GetFacebookUserInfo(account.Token);

            if (!Validate(facebookUser, account.FacebookUserId, account.Email))
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = "Access is denied"
                });
            }

            LoginResult result = FacebookSignIn.SignIn(account.FacebookUserId, account.Email, account.OfficeId, facebookUser.Name, account.Token, user.Browser,
                                                       user.IpAddress, account.Culture);

            if (result.Status)
            {
                if (!Registration.HasAccount(account.Email))
                {
                    string       template     = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-3rd-party.html";
                    WelcomeEmail welcomeEmail = new WelcomeEmail(facebookUser, template, ProviderName);
                    await welcomeEmail.SendAsync();
                }
            }
            return(result);
        }
Exemple #2
0
 public User(RemoteUser user)
 {
     Email    = user.email;
     FullName = user.fullname;
     Username = user.name;
     Url      = user.url;
 }
Exemple #3
0
        public static async Task <bool> ChangePasswordAsync(AppUser current, ChangePassword model,
                                                            RemoteUser user)
        {
            int userId = current.UserId;

            if (userId <= 0)
            {
                await Task.Delay(5000).ConfigureAwait(false);

                return(false);
            }

            if (model.Password != model.ConfirmPassword)
            {
                return(false);
            }

            string email      = current.Email;
            var    frapidUser = await Users.GetAsync(current.Tenant, email).ConfigureAwait(false);

            bool oldPasswordIsValid = PasswordManager.ValidateBcrypt(model.OldPassword, frapidUser.Password);

            if (!oldPasswordIsValid)
            {
                await Task.Delay(2000).ConfigureAwait(false);

                return(false);
            }

            string newPassword = PasswordManager.GetHashedPassword(model.Password);
            await Users.ChangePasswordAsync(current.Tenant, userId, newPassword, user).ConfigureAwait(false);

            return(true);
        }
Exemple #4
0
        public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user)
        {
            bool validationResult = Task.Run(() => this.ValidateAsync(account.Token)).GetAwaiter().GetResult();

            if (!validationResult)
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = Resources.AccessIsDenied
                });
            }

            var gUser = new GoogleUserInfo
            {
                Email = account.Email,
                Name  = account.Name
            };

            var result = await GoogleSignIn.SignInAsync(this.Tenant, account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture).ConfigureAwait(false);

            if (result.Status)
            {
                if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false))
                {
                    string template     = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html";
                    var    welcomeEmail = new WelcomeEmail(gUser, template, ProviderName);
                    await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false);
                }
            }

            return(result);
        }
        /// <summary>creates the new task in the system</summary>
        private void createNewTask()
        {
            try
            {
                string taskName = this.taskName.Text;
                int    taskStatus = 1, taskType = 1;

                //create new task and set its properties
                RemoteTask newTask = new RemoteTask();
                newTask.ProjectId         = SpiraContext.ProjectId;
                newTask.Name              = taskName;
                newTask.TaskStatusId      = taskStatus;
                newTask.TaskTypeId        = taskType;
                newTask.CompletionPercent = 0;
                newTask.CreationDate      = DateTime.UtcNow;

                //create a client object
                Spira_ImportExport s = new Spira_ImportExport(SpiraContext.BaseUri.ToString(), SpiraContext.Login, SpiraContext.Password);
                s.Connect();
                s.Client.Connection_Authenticate2(SpiraContext.Login, SpiraContext.Password, "Visual Studio");
                s.Client.Connection_ConnectToProject(SpiraContext.ProjectId);

                //get the user ID of the user
                RemoteUser user   = s.Client.User_RetrieveByUserName(SpiraContext.Login, false);
                int        userId = (int)user.UserId;
                newTask.OwnerId = userId;

                s.Client.Task_Create(newTask);
                cntlSpiraExplorer.refresh();
            }
            catch (Exception e)
            {
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemple #6
0
        public static async Task <bool> SignUp(Registration model, RemoteUser user)
        {
            if (model.Password != model.ConfirmPassword)
            {
                throw new PasswordConfirmException("Passwords do not match.");
            }

            if (model.Email != model.ConfirmEmail)
            {
                throw new PasswordConfirmException("Emails do not match.");
            }

            model.Browser   = user.Browser;
            model.IpAddress = user.IpAddress;

            var registration = model.Adapt <DTO.Registration>();

            registration.Password = PasswordManager.GetHashedPassword(model.Password);

            string registrationId = Registrations.Register(registration).ToString();

            if (string.IsNullOrWhiteSpace(registrationId))
            {
                return(false);
            }

            var email = new SignUpEmail(registration, registrationId);
            await email.SendAsync();

            return(true);
        }
        public static async Task <bool> ChangePassword(ChangePassword model, RemoteUser user)
        {
            int userId = AppUsers.GetCurrent().UserId;

            if (userId <= 0)
            {
                await Task.Delay(5000);

                return(false);
            }

            if (model.Password != model.ConfirmPassword)
            {
                return(false);
            }

            string email      = AppUsers.GetCurrent().Email;
            var    frapidUser = Users.Get(email);

            bool oldPasswordIsValid = PasswordManager.ValidateBcrypt(model.OldPassword, frapidUser.Password);

            if (!oldPasswordIsValid)
            {
                await Task.Delay(2000);

                return(false);
            }

            string newPassword = PasswordManager.GetHashedPassword(model.Password);

            Users.ChangePassword(userId, newPassword, user);
            return(true);
        }
Exemple #8
0
 // Sends a message to the specified user.
 public void SendMessage(RemoteUser toUser, string message)
 {
     var encrypt = EncryptionService.Encrypt(message, toUser);
     writer.Write("msg");
     writer.Write(toUser.PublicKey);
     writer.WriteLenBytes(encrypt);
 }
        public async Task <LoginResult> AuthenticateAsync(GoogleAccount account, RemoteUser user)
        {
            bool validationResult = Task.Run(() => ValidateAsync(account.Token)).Result;

            if (!validationResult)
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = "Access is denied"
                });
            }

            var gUser = new GoogleUserInfo
            {
                Email = account.Email,
                Name  = account.Name
            };
            var result = GoogleSignIn.SignIn(account.Email, account.OfficeId, account.Name, account.Token, user.Browser, user.IpAddress, account.Culture);

            if (result.Status)
            {
                if (!Registrations.HasAccount(account.Email))
                {
                    string template     = "~/Catalogs/{catalog}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html";
                    var    welcomeEmail = new WelcomeEmail(gUser, template, ProviderName);
                    await welcomeEmail.SendAsync();
                }
            }

            return(result);
        }
Exemple #10
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            PopulateCurrentSessionData();

            AppHub = MsmqMessageHub.Create()
                     .WithConfiguration(new MsmqHubConfiguration
            {
                RemoteQueuePath = @"FormatName:DIRECT=OS:BDRISCOLL-PC2\private$\AppHub"
            });

            AppHub.Connect().Wait();

            AppHub.Channel("Users").AddReceiver("Add", (userData) =>
            {
                return(Task.Factory.StartNew(async() =>
                {
                    RemoteUser user = userData as RemoteUser;
                    if (user != null)
                    {
                        RemoteUser existing = Session.Current.AllUsers.FirstOrDefault(u => u.Id == user.Id);
                        if (existing != null)
                        {
                            await App.Current.Dispatcher.InvokeAsync(() => Session.Current.AllUsers.Remove(existing));
                        }

                        await App.Current.Dispatcher.InvokeAsync(() => Session.Current.AllUsers.Add(user));
                    }
                }));
            }, channelReceiverId);

            App.AppHub.Channel("Users").AddReceiver("Remove", (userData) =>
            {
                return(Task.Factory.StartNew(async() =>
                {
                    RemoteUser user = userData as RemoteUser;
                    if (user != null)
                    {
                        RemoteUser existing = Session.Current.AllUsers.FirstOrDefault(u => u.Id == user.Id);
                        if (existing != null)
                        {
                            await App.Current.Dispatcher.InvokeAsync(() => Session.Current.AllUsers.Remove(existing));
                        }
                    }
                }));
            }, channelReceiverId);

            App.AppHub.Channel("Content").AddReceiver("Update", (contentData) =>
            {
                return(Task.Factory.StartNew(() =>
                {
                    string content = contentData as string;
                    Session.Current.Content = content ?? string.Empty;
                }));
            }, channelReceiverId);

            Session.Current.PropertyChanged      += Session_PropertyChanged;
            Session.Current.User.PropertyChanged += User_PropertyChanged;
        }
Exemple #11
0
        public async Task <LoginResult> AuthenticateAsync(FacebookAccount account, RemoteUser user)
        {
            var facebookUser = this.GetFacebookUserInfo(account.Token);

            if (!this.Validate(facebookUser, account.FacebookUserId, account.Email))
            {
                return(new LoginResult
                {
                    Status = false,
                    Message = Resources.AccessIsDenied
                });
            }

            var result =
                await
                FacebookSignIn.SignInAsync(this.Tenant, account.FacebookUserId, account.Email, account.OfficeId, facebookUser.Name, account.Token, user.Browser, user.IpAddress, account.Culture)
                .ConfigureAwait(false);

            if (result.Status)
            {
                if (!await Registrations.HasAccountAsync(this.Tenant, account.Email).ConfigureAwait(false))
                {
                    string template     = "~/Tenants/{tenant}/Areas/Frapid.Account/EmailTemplates/welcome-email-other.html";
                    var    welcomeEmail = new WelcomeEmail(facebookUser, template, this.ProviderName);
                    await welcomeEmail.SendAsync(this.Tenant).ConfigureAwait(false);
                }
            }
            return(result);
        }
        private void ExecuteUserInfoResultCommand(RemoteUser remoteUser)
        {
            lbl_Mail.Text     = $@"Email: {remoteUser.Mail}";
            lbl_UserName.Text = $@"User Name: {remoteUser.ProfileName}";
            lbl_Rank.Text     = $@"Rank: {remoteUser.Rank}";
            //
            comboBox1.Items.Clear();
            if (remoteUser.AllowedCiv.Count > 0)
            {
                foreach (var civ in remoteUser.AllowedCiv)
                {
                    var strCiv = Enum.GetName(typeof(Civilization), civ);
                    if (string.IsNullOrEmpty(strCiv))
                    {
                        strCiv = "Unknow";
                    }
                    comboBox1.Items.Add(strCiv);
                }
            }
            else
            {
                comboBox1.Items.Add("None");
            }

            comboBox1.SelectedIndex = 0;
        }
Exemple #13
0
        private void PopulateCurrentSessionData()
        {
            using (ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"))
            {
                IDatabase db = redis.GetDatabase();

                ObservableCollection <RemoteUser> remoteUsers = new ObservableCollection <RemoteUser>(Session.Current.AllUsers.AsEnumerable());

                RedisValue[] serializedUserData = db.SetMembers("AllUsers");
                foreach (string serializedUser in serializedUserData)
                {
                    RemoteUser user     = JsonConvert.DeserializeObject <RemoteUser>(serializedUser);
                    RemoteUser existing = remoteUsers.FirstOrDefault(u => u.Id == user.Id);

                    if (existing != null)
                    {
                        remoteUsers.Remove(existing);
                    }

                    remoteUsers.Add(user);
                }

                App.Current.Dispatcher.Invoke(() => { Session.Current.AllUsers = remoteUsers; });

                string content = db.StringGet("Content");

                Session.Current.Content = content;
            }
        }
        /**
         * Cuando se recibe el usuario (sin informacion solo sus identificaciones)
         **/
        protected override void OnUserReceived(RemoteUser remoteUser)
        {
            base.OnUserReceived(remoteUser);

            //Exsitia un usuario creado con id de facebook temporal?
            KuberaUser kUser = localData.getCurrentData().getUserById(currentUser.facebookId);

            if (kUser != null)
            {
                //Le asignamos su id de verdad
                kUser._id = currentUser.id;
            }

            localData.changeCurrentuser(currentUser.id);

            //En caso de que se creo un nuevo usuario se le asigna su facebookId
            if (localData.currentUser.facebookId != currentUser.facebookId)
            {
                localData.currentUser.facebookId = currentUser.facebookId;
                localData.saveLocalData(false);
            }

            if (remoteUser.newlyCreated)
            {
                if (_mustShowDebugInfo)
                {
                    Debug.Log("Creating remote user.");
                }

                KuberaAnalytics.GetInstance().registerFaceBookLogin();
                if (!localData.currentUser.remoteLifesGranted)
                {
                    if (_mustShowDebugInfo)
                    {
                        Debug.Log("Granted Lifes: " + freeLifesAfterSignIn.ToString());
                    }

                    localData.giveUserLifes(freeLifesAfterSignIn);
                    localData.currentUser.isDirty = localData.currentUser.updateremoteLifesGranted(true) || localData.currentUser.isDirty;
                }

                //Hacemos un update normal del usuario
                //updateData(localData.getUserDirtyData());

                isGettingData = true;
                server.getUserData(currentUser.id, localData.currentUser.remoteDataVersion, true);
            }
            else
            {
                if (_mustShowDebugInfo)
                {
                    Debug.Log("Getting data from remote user.");
                }

                isGettingData = true;
                //Nos traemos los datos de este usuario
                server.getUserData(currentUser.id, localData.currentUser.remoteDataVersion, true);
            }
        }
Exemple #15
0
 private void HandleVoiceTranslatedPacket(Command command, RemoteUser remoteUser)
 {
     if (remoteUser.IsInCallWith == null)
     {
         return;
     }
     remoteUser.IsInCallWith.Peer.SendCommand(command);
 }
        public void SetRemoteUserTest()
        {
            RunTest(() =>
            {
                var remoteUserName     = "******";
                var remoteUserPassword = "******";
                var originalRemoteUser = new RemoteUser()
                {
                    Username = remoteUserName, Password = remoteUserPassword, UseDerivedPassword = true
                };

                var assertRemoteUser = new Action(() =>
                {
                    var remoteUser = GetRemoteUser();

                    bool flag = false;
                    var msg   = string.Empty;
                    if (null == remoteUser)
                    {
                        msg = "The DUT returned empty remote user";
                    }
                    else if (remoteUser.Username != originalRemoteUser.Username)
                    {
                        msg = string.Format("Received remote user has unexpected Username '{0}'. Expected: '{1}'", remoteUser.Username, originalRemoteUser.Username);
                    }
                    else if (null != remoteUser.Password)
                    {
                        msg = "Received remote user has non-empty 'Password' field";
                    }
                    else if (remoteUser.UseDerivedPassword != originalRemoteUser.UseDerivedPassword)
                    {
                        msg = string.Format("Received remote user has unexpected UseDerivedPassword flag value '{0}'. Expected: '{1}'", remoteUser.UseDerivedPassword, originalRemoteUser.UseDerivedPassword);
                    }
                    else
                    {
                        flag = true;
                    }

                    Assert(flag, msg, "Validating received response to GetRemoteUser command");
                });

                SetRemoteUser(originalRemoteUser);
                assertRemoteUser();

                originalRemoteUser = new RemoteUser()
                {
                    Username = remoteUserName, Password = remoteUserPassword, UseDerivedPassword = false
                };
                SetRemoteUser(originalRemoteUser);
                assertRemoteUser();

                SetRemoteUser(null);

                Assert(null == GetRemoteUser(),
                       "The DUT returned non-empty remote",
                       "Validating received response to GetRemoteUser command");
            });
        }
Exemple #17
0
        public void deleteUser(RemoteUser rUser)
        {//Remove user from the local table
            this.connect();
            SqlCeCommand cmd = this.conn.CreateCommand();

            cmd.CommandText = "delete from " + TABLE_NAME + "  where username='******' and system='" + rUser.getSystemName() + "'";
            cmd.ExecuteNonQuery();
            this.disconnect();
        }
Exemple #18
0
        public ActionResult ResetEmailSent()
        {
            if (RemoteUser.IsListedInSpamDatabase(this.Tenant))
            {
                return(this.View(this.GetRazorView <AreaRegistration>("ListedInSpamDatabase.cshtml", this.Tenant)));
            }

            return(this.View(this.GetRazorView <AreaRegistration>("Reset/ResetEmailSent.cshtml", this.Tenant)));
        }
 public void deleteUser(RemoteUser rUser)
 {
     //Remove user from the local table
     this.connect();
     SqlCeCommand cmd = this.conn.CreateCommand();
     cmd.CommandText = "delete from " + TABLE_NAME + "  where username='******' and system='" + rUser.getSystemName() + "'";
     cmd.ExecuteNonQuery();
     this.disconnect();
 }
Exemple #20
0
        protected RemoteUser GetRemoteUser()
        {
            RemoteUser r = null;

            RunStep(() => r = Client.GetRemoteUser(), "Get Remote User");
            DoRequestDelay();

            return(r);
        }
Exemple #21
0
        public ActionResult Success()
        {
            if (RemoteUser.IsListedInSpamDatabase(this.Tenant))
            {
                return(this.View(this.GetRazorView <AreaRegistration>("ListedInSpamDatabase.cshtml", this.Tenant)));
            }

            return(this.View(this.GetRazorView <AreaRegistration>("ChangePassword/Success.cshtml", this.Tenant)));
        }
Exemple #22
0
        public void updateStatus(RemoteUser rUser)
        {//Set status
            this.connect();
            SqlCeCommand cmd = this.conn.CreateCommand();

            cmd.CommandText = "update " + TABLE_NAME + " set status='" + rUser.getStatus() + "'  where username='******' and system='" + rUser.getSystemName() + "'";
            cmd.ExecuteNonQuery();
            this.disconnect();
        }
Exemple #23
0
        public ActionResult Index()
        {
            if (RemoteUser.IsListedInSpamDatabase(this.Tenant))
            {
                return(this.View(this.GetRazorView <AreaRegistration>("ListedInSpamDatabase.cshtml", this.Tenant)));
            }

            return(this.View(this.GetRazorView <AreaRegistration>("Reset/Index.cshtml", this.Tenant), new Reset()));
        }
 public void addUser(RemoteUser rUser)
 {
     //add new user
     this.connect();
     SqlCeCommand cmd = this.conn.CreateCommand();
     DateTime currentTime = DateTime.Now;
     cmd.CommandText = "insert into " + TABLE_NAME + "(system,username,password,modified_date,status) values('" + rUser.getSystemName() + "','" + rUser.getUsername() + "','" + rUser.getPassword() + "','" + currentTime.ToString() + "','" + rUser.getStatus() + "')";
     cmd.ExecuteNonQuery();
     this.disconnect();
 }
Exemple #25
0
        public void addUser(RemoteUser rUser)
        {//add new user
            this.connect();
            SqlCeCommand cmd         = this.conn.CreateCommand();
            DateTime     currentTime = DateTime.Now;

            cmd.CommandText = "insert into " + TABLE_NAME + "(system,username,password,modified_date,status) values('" + rUser.getSystemName() + "','" + rUser.getUsername() + "','" + rUser.getPassword() + "','" + currentTime.ToString() + "','" + rUser.getStatus() + "')";
            cmd.ExecuteNonQuery();
            this.disconnect();
        }
Exemple #26
0
        public void updatePassword(RemoteUser rUser)
        {//change user password
            this.connect();
            SqlCeCommand cmd         = this.conn.CreateCommand();
            DateTime     currentTime = DateTime.Now;

            cmd.CommandText = "update " + TABLE_NAME + " set password='******',status='',modified_date='" + currentTime.ToString() + "' where username='******' and system='" + rUser.getSystemName() + "'";
            cmd.ExecuteNonQuery();
            this.disconnect();
        }
Exemple #27
0
        private void HandleEndCall(Command command, RemoteUser remoteUser)
        {
            if (remoteUser.IsInCallWith == null)
            {
                return;
            }

            var cmd = _commandBuilder.Create(CommandName.EndCall, string.Empty);

            remoteUser.IsInCallWith.Peer.SendCommand(cmd);
        }
Exemple #28
0
        public void SetCredentials(string id, string token)
        {
            currentUser    = new RemoteUser();
            currentUser.id = id;

            ((ShopikaProvider)server).userId = id;
            ((ShopikaProvider)server).token  = token;

            //Cambio de usuario
            server.stopAndRemoveCurrentRequests();
        }
Exemple #29
0
        private async void HandleDial(Command command, RemoteUser remoteUser)
        {
            var callerNumber = _commandBuilder.GetUnderlyingObject <string>(command);
            var opponent     = _connectionsManager.FindRemoteUserByNumber(callerNumber);

            var dialResult = new DialResult();

            if (opponent == null)
            {
                var opponentUser = _usersRepository.GetByNumber(callerNumber);
                if (opponentUser != null)
                {
                    _pushSender.SendVoipPush(opponentUser.PushUri, remoteUser.User.Number, remoteUser.User.Number);
                    var resultCommand = await _connectionsManager.PostWaiter(opponentUser.UserId, CommandName.IncomingCall);

                    var answerType = _commandBuilder.GetUnderlyingObject <AnswerResultType>(resultCommand);
                    if (answerType == AnswerResultType.Answered)
                    {
                        dialResult.Result       = DialResultType.Answered;
                        opponent.IsInCallWith   = remoteUser;
                        remoteUser.IsInCallWith = opponent;
                    }
                    else
                    {
                        dialResult.Result = DialResultType.Declined;
                    }
                }
                else
                {
                    dialResult.Result = DialResultType.NotFound;
                }
            }
            else
            {
                var incomingCallCommand = _commandBuilder.Create(CommandName.IncomingCall, callerNumber);
                var resultCommand       = await opponent.Peer.SendCommandAndWaitAnswer(incomingCallCommand);

                var answerType = _commandBuilder.GetUnderlyingObject <AnswerResultType>(resultCommand);
                if (answerType == AnswerResultType.Answered)
                {
                    dialResult.Result       = DialResultType.Answered;
                    opponent.IsInCallWith   = remoteUser;
                    remoteUser.IsInCallWith = opponent;
                }
                else
                {
                    dialResult.Result = DialResultType.Declined;
                }
            }
            _commandBuilder.ChangeUnderlyingObject(command, dialResult);
            remoteUser.Peer.SendCommand(command);
        }
        private void _resource_OnReceived(object sender, PeerCommandEventArgs e)
        {
            try
            {
                lock (_activeConnections)
                {
                    var command = _serializer.Deserialize(e.Data);
                    if (!string.IsNullOrEmpty(command.UserId))
                    {
                        lock (_responceWaiters)
                        {
                            TaskCompletionSource <Command> taskSource;
                            if (_responceWaiters.TryGetValue(new Tuple <string, CommandName>(command.UserId, command.Name),
                                                             out taskSource))
                            {
                                taskSource.TrySetResult(command);
                            }
                        }
                    }

                    var        user = _userRepository.GetById(command.UserId);
                    RemoteUser remoteUser;
                    if (user != null)
                    {
                        var existedConnection = _activeConnections.FirstOrDefault(i => i.User.Equals(user));
                        if (existedConnection != null)
                        {
                            existedConnection.Peer = e.Peer;
                            existedConnection.Peer.UpdateLastActivity();
                            remoteUser = existedConnection;
                        }
                        else
                        {
                            remoteUser = new RemoteUser(user, e.Peer);
                        }
                        _activeConnections.Add(remoteUser);
                    }
                    else
                    {
                        remoteUser = new RemoteUser(new User(), e.Peer);
                        _activeConnections.Add(remoteUser);
                    }
                    CommandRecieved(this, new RemoteUserCommandEventArgs {
                        Command = command, RemoteUser = remoteUser
                    });
                }
            }
            catch (Exception exc)
            {
                Logger.Exception(exc, "_resource_OnReceived");
            }
        }
Exemple #31
0
        private void HandleVoicePacket(Command command, RemoteUser remoteUser)
        {
            if (remoteUser.IsInCallWith == null)
            {
                return;
            }

            _translationResource.AppendRawData(_commandBuilder.GetUnderlyingObject <byte[]>(command),
                                               data =>
            {
                _commandBuilder.ChangeUnderlyingObject(command, data);
                remoteUser.IsInCallWith.Peer.SendCommand(command);
            });
        }
Exemple #32
0
        public void AddRemoteUserToItsRemoteUsersProperty()
        {
            string testuser     = "******";
            string testpassword = "******";
            string IP           = "127.0.0.1";
            int    port         = 4444;

            RemoteUser    remoteUser    = new RemoteUser(testuser, testpassword);
            RemoteDesktop remoteDesktop = new RemoteDesktop(IP, port);

            remoteDesktop.AddRemoteUser(remoteUser);

            Assert.Contains(remoteUser, remoteDesktop.RemoteUsers);
        }
        private void ImportUsers(StreamWriter streamWriter, SpiraSoapService.SoapServiceClient spiraClient, APIClient testRailApi, int userId)
        {
            //Get the users from the TestRail API
            JArray users = (JArray)testRailApi.SendGet("get_users");

            if (users != null)
            {
                foreach (JObject user in users)
                {
                    //Extract the user data
                    int    testRailId = user["id"].Value <int>();
                    string userName   = user["email"].Value <string>();
                    string fullName   = user["name"].Value <string>();
                    string firstName  = userName;
                    string lastName   = userName;
                    if (fullName.Contains(' '))
                    {
                        firstName = fullName.Substring(0, fullName.IndexOf(' '));
                        lastName  = fullName.Substring(fullName.IndexOf(' ') + 1);
                    }
                    else
                    {
                        firstName = fullName;
                        lastName  = fullName;
                    }
                    string emailAddress = userName;
                    bool   isActive     = user["is_active"].Value <bool>();

                    //See if we're importing users or mapping to a single user
                    if (Properties.Settings.Default.Users)
                    {
                        //Default to observer role for all imports, for security reasons
                        RemoteUser remoteUser = new RemoteUser();
                        remoteUser.FirstName    = firstName;
                        remoteUser.LastName     = lastName;
                        remoteUser.UserName     = userName;
                        remoteUser.EmailAddress = emailAddress;
                        remoteUser.Active       = isActive;
                        remoteUser.Approved     = true;
                        remoteUser.Admin        = false;
                        userId = spiraClient.User_Create(remoteUser, Properties.Settings.Default.NewUserPassword, "What was my default email address?", emailAddress, PROJECT_ROLE_ID).UserId.Value;
                    }

                    //Add the mapping to the hashtable for use later on
                    this.usersMapping.Add(testRailId, userId);
                }
            }
        }
        public bool exists(RemoteUser rUser)
        {
            //Check whether the entry with the specified System & Username already exists
            int count = 0;
            this.connect();
            String query = "Select count(*) from " + TABLE_NAME + " where system='" + rUser.getSystemName() + "' and username='******'" ;
            SqlCeCommand cmd = new SqlCeCommand(query, this.conn);
            count = (int)cmd.ExecuteScalar();
            this.disconnect();

            if (count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
 public void addUserToGroup(string in0, RemoteGroup in1, RemoteUser in2) {
     this.Invoke("addUserToGroup", new object[] {
                 in0,
                 in1,
                 in2});
 }
 public void updateStatus(RemoteUser rUser)
 {
     //Set status
     this.connect();
     SqlCeCommand cmd = this.conn.CreateCommand();
     cmd.CommandText = "update " + TABLE_NAME + " set status='" + rUser.getStatus() + "'  where username='******' and system='" + rUser.getSystemName() + "'";
     cmd.ExecuteNonQuery();
     this.disconnect();
 }
 public void updatePassword(RemoteUser rUser)
 {
     //change user password
     this.connect();
     SqlCeCommand cmd = this.conn.CreateCommand();
     DateTime currentTime = DateTime.Now;
     cmd.CommandText = "update " + TABLE_NAME + " set password='******',status='',modified_date='" + currentTime.ToString() + "' where username='******' and system='" + rUser.getSystemName() + "'";
     cmd.ExecuteNonQuery();
     this.disconnect();
 }
        //Get All Users from the local database table
        public List<RemoteUser> getAllRemoteUsers()
        {
            this.connect();
            List<RemoteUser> usersList = new List<RemoteUser>();
            String query = "Select * from " + TABLE_NAME;
            SqlCeCommand cmd = new SqlCeCommand(query,this.conn);
            SqlCeDataReader sqlReader = cmd.ExecuteReader();

            while(sqlReader.Read())
            {
                RemoteUser rUser = new RemoteUser();

                if (!DBNull.Value.Equals(sqlReader[0]))
                    rUser.setID(sqlReader.GetInt32(0));
                if (!DBNull.Value.Equals(sqlReader[1]))
                    rUser.setSystemName(sqlReader.GetString(1));
                if (!DBNull.Value.Equals(sqlReader[2]))
                    rUser.setUsername(sqlReader.GetString(2));
                if (!DBNull.Value.Equals(sqlReader[3]))
                    rUser.setPassword(sqlReader.GetString(3));
                if(! DBNull.Value.Equals(sqlReader[4]))
                    rUser.setModifiedDate(sqlReader.GetDateTime(4));
                if (!DBNull.Value.Equals(sqlReader[5]))
                    rUser.setStatus(sqlReader.GetString(5));

                usersList.Add(rUser);
            }
            this.disconnect();
            return usersList;
        }
 public void removeUserFromGroup(string in0, RemoteGroup in1, RemoteUser in2) {
     this.Invoke("removeUserFromGroup", new object[] {
                 in0,
                 in1,
                 in2});
 }
 /// <remarks/>
 public void removeUserFromGroupAsync(string in0, RemoteGroup in1, RemoteUser in2) {
     this.removeUserFromGroupAsync(in0, in1, in2, null);
 }
 public RemoteGroup createGroup(string in0, string in1, RemoteUser in2) {
     object[] results = this.Invoke("createGroup", new object[] {
                 in0,
                 in1,
                 in2});
     return ((RemoteGroup)(results[0]));
 }
 /// <remarks/>
 public void createGroupAsync(string in0, string in1, RemoteUser in2) {
     this.createGroupAsync(in0, in1, in2, null);
 }
 /// <remarks/>
 public void createGroupAsync(string in0, string in1, RemoteUser in2, object userState) {
     if ((this.createGroupOperationCompleted == null)) {
         this.createGroupOperationCompleted = new System.Threading.SendOrPostCallback(this.OncreateGroupOperationCompleted);
     }
     this.InvokeAsync("createGroup", new object[] {
                 in0,
                 in1,
                 in2}, this.createGroupOperationCompleted, userState);
 }
 /// <remarks/>
 public void addUserToGroupAsync(string in0, RemoteGroup in1, RemoteUser in2) {
     this.addUserToGroupAsync(in0, in1, in2, null);
 }
 /// <remarks/>
 public System.IAsyncResult BegincreateGroup(string in0, string in1, RemoteUser in2, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("createGroup", new object[] {
                 in0,
                 in1,
                 in2}, callback, asyncState);
 }