Esempio n. 1
0
        public void BackupSqlServerData()
        {
            try
            {
                var folder = new FolderBrowserDialog();
                if (folder.ShowDialog() == DialogResult.OK)
                {
                    FileLocation = folder.SelectedPath;

                    if (_server != null)
                    {
                        var status = BackUpRestoreUtil.BackUpServerDatabase(_server, FileLocation);
                        if (string.IsNullOrEmpty(status))
                        {
                            NotifyUtility.ShowCustomBalloon("Backup Successfull", "Bakup of Database " + " successfully created", 4000);
                        }
                        else
                        {
                            MessageBox.Show("ERROR: An error ocurred while backing up DataBase" + status, "Backup Error");
                        }
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("ERROR: An error ocurred while backing up DataBase" + x.Message, "Server Error");
            }
        }
Esempio n. 2
0
 private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     ProgressBarVisibility = "Collapsed";
     CommandsEnability     = true;
     if (string.IsNullOrEmpty(_sent))
     {
         NotifyUtility.ShowCustomBalloon("Sent", "Report Successfully Sent", 4000);
         CloseWindow(_obj);
     }
     else
     {
         NotifyUtility.ShowCustomBalloon("Failed Sending", _sent, 4000);
     }
 }
Esempio n. 3
0
        public IHttpActionResult RequestChange(string account)
        {
            string                 mRetVal  = string.Empty;
            MAccountProfile        mProfile = AccountUtility.GetProfile(account);
            MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.CurrentProfile();
            MMessageProfile        mMessageProfile        = MessageUtility.GetProfile("Request Password Reset UI");

            mRetVal = mMessageProfile.Body;
            string clearTextAccount = string.Empty;
            Logger mLog             = Logger.Instance();

            if (mProfile != null)
            {
                MAccountProfile mAccountProfile = mProfile;
                mAccountProfile.FailedAttempts = 0;
                mAccountProfile.Status         = 4;
                mAccountProfile.Password       = CryptoUtility.Encrypt(GWWebHelper.GetNewGuid, mSecurityEntityProfile.EncryptionType);
                mAccountProfile.UpdatedBy      = AccountUtility.GetProfile("anonymous").Id;
                mAccountProfile.UpdatedDate    = DateTime.Now;

                clearTextAccount = CryptoUtility.Decrypt(mProfile.Password, mSecurityEntityProfile.EncryptionType);
                try
                {
                    mMessageProfile = MessageUtility.GetProfile("RequestNewPassword");
                    MRequestNewPassword mRequestNewPassword = new MRequestNewPassword(mMessageProfile);
                    mRequestNewPassword.AccountName = HttpUtility.UrlEncode(CryptoUtility.Encrypt(mProfile.Account, mSecurityEntityProfile.EncryptionType));
                    mRequestNewPassword.FullName    = mProfile.FirstName + " " + mProfile.LastName;
                    mRequestNewPassword.Password    = HttpUtility.UrlEncode(mProfile.Password);
                    mRequestNewPassword.Server      = GWWebHelper.RootSite;
                    mProfile = AccountUtility.Save(mProfile, false, false);
                    NotifyUtility.SendMail(mRequestNewPassword, mProfile);
                    mLog.Debug("Reset password for account " + clearTextAccount);
                }
                catch (SmtpException ex)
                {
                    Exception myException = new Exception("Could not send e-mail." + ex.Message);
                    mLog.Error(myException);
                    mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("PasswordSendMailError");
                    mRetVal         = mMessageProfile.Body;
                }
                catch (Exception ex)
                {
                    Exception mException = new Exception("Could not set account details." + ex.Message);
                    mLog.Error(mException);
                    mMessageProfile = (MMessageProfile)MessageUtility.GetProfile("ErrorAccountDetails");
                    mRetVal         = mMessageProfile.Body;
                }
            }
            return(Ok(mRetVal));
        }
        private void LoadTestimonyPersons()
        {
            try
            {
                var cri = new SearchCriteria <EmployeeRelativeDTO>();

                cri.FiList.Add(t => t.Type == RelativeTypes.Testimony);
                IEnumerable <EmployeeRelativeDTO> testimonies = new EmployeeRelativeService(true)
                                                                .GetAll(cri)
                                                                .GroupBy(o => o.FullName).Select(g => g.FirstOrDefault());//.Distinct();
                TestimonyPersons = new ObservableCollection <EmployeeRelativeDTO>(testimonies);
            }
            catch
            {
                NotifyUtility.ShowCustomBalloon("Can't Load", "Can't Load Previously added testimonial!", 4000);
            }
        }
Esempio n. 5
0
        private void ExcuteLoginCommand(object obj)
        {
            try
            {
                var values = (object[])obj;
                var psdBox = values[0] as PasswordBox;

                //Do Validation if not handled on the UI
                if (psdBox != null && psdBox.Password == "")
                {
                    psdBox.Focus();
                    return;
                }

                if (psdBox != null)
                {
                    var us = Membership.ValidateUser(User.UserName, psdBox.Password);

                    if (!us)
                    {
                        MessageBox.Show("Incorrect UserName/Password", "Error Logging",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                        User.Password           = "";
                        ServerUpdatesVisibility = "Visible";
                        return;
                    }

                    var userId = WebSecurity.GetUserId(User.UserName);
                    var user   = new UserService(true).GetUser(userId);

                    if (user == null)
                    {
                        MessageBox.Show("Incorrect UserName/Password", "Error Logging",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                        User.Password           = "";
                        ServerUpdatesVisibility = "Visible";
                    }
                    else
                    {
                        LockedVisibility   = "Collapsed";
                        UnLockedVisibility = "Visible";
                        //Thread.Sleep(1000);

                        Singleton.User          = user;
                        Singleton.User.Password = psdBox.Password;
                        Singleton.UserRoles     = new UserRolesModel();

                        Singleton.Setting = new UnitOfWork(DbContextUtil.GetDbContextInstance())
                                            .Repository <SettingDTO>()
                                            .FindById(1);

                        if (RememberMe)
                        {
                            var currentSetting = XmlSerializerCustom.GetUserSetting();

                            currentSetting.UserName = User.UserName;
                            currentSetting.Password = psdBox.Password;

                            XmlSerializerCustom.SetUserSetting(currentSetting);
                        }

                        switch (user.Status)
                        {
                        case UserTypes.Waiting:
                            new ChangePassword(psdBox.Password).Show();
                            break;

                        case UserTypes.Active:
                        {
                            NotifyUtility.ShowCustomBalloon("PinnaFace", "Welcome to PinnaFace", 4000);
                            new MainWindow().Show();
                        }
                        break;

                        default:
                            MessageBox.Show("Login Failed", "Error Logging", MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                            break;
                        }

                        CloseWindow(values[1]);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + Environment.NewLine + exception.InnerException);
            }
        }
        private void DirectLogin()
        {
            try
            {
                InitializeObjects.InitializeWebSecurity();

                var currentSetting = XmlSerializerCustom.GetUserSetting();
                var userDTO        = new UserDTO
                {
                    UserName = currentSetting.UserName,
                    Password = currentSetting.Password
                };

                var userExists = false;

                if (!string.IsNullOrEmpty(userDTO.UserName) && !string.IsNullOrEmpty(userDTO.Password))
                {
                    userExists = Membership.ValidateUser(userDTO.UserName, userDTO.Password);
                }

                if (!userExists)
                {
                    new Login().Show();
                }
                else
                {
                    Singleton.Agency = new LocalAgencyService(true).GetLocalAgency();
                    int     userId = WebSecurity.GetUserId(userDTO.UserName);
                    UserDTO user   = new UserService(true).GetUser(userId);

                    if (user == null)
                    {
                        MessageBox.Show("Incorrect UserName/Password", "Error Logging",
                                        MessageBoxButton.OK,
                                        MessageBoxImage.Error);
                        userDTO.Password = "";
                    }
                    else
                    {
                        Singleton.User          = user;
                        Singleton.User.Password = userDTO.Password;
                        Singleton.UserRoles     = new UserRolesModel();

                        Singleton.Setting = new UnitOfWork(DbContextUtil.GetDbContextInstance())
                                            .Repository <SettingDTO>()
                                            .FindById(1);


                        switch (user.Status)
                        {
                        case UserTypes.Waiting:
                            new ChangePassword(userDTO.Password).Show();
                            break;

                        case UserTypes.Active:
                        {
                            NotifyUtility.ShowCustomBalloon("PinnaFace", "Welcome to PinnaFace", 4000);
                            new MainWindow().Show();
                        }
                        break;

                        default:
                            MessageBox.Show("Login Failed", "Error Logging", MessageBoxButton.OK,
                                            MessageBoxImage.Error);
                            break;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message + Environment.NewLine + exception.InnerException);
            }
        }