Ejemplo 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");
            }
        }
Ejemplo 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);
     }
 }
        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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
        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);
            }
        }