private void btnSave_Click(object sender, EventArgs e)
        {
            DbServerParameters dbServerParameters = new DbServerParameters();

            dbServerParameters.AuthType   = chckBoxDbServerLogInType.Checked;
            dbServerParameters.ServerName = txtBoxDbServerName.Text.ToString();
            dbServerParameters.UserName   = txtBoxDbServerUserName.Text.ToString();
            dbServerParameters.Password   = txtBoxDbServerPass.Text.ToString();

            ////List<ListItem> selected = new List<ListItem>();
            //foreach (var item in chckdLstBoxDbNamesOnDbServer.Items)
            //    dbNameOnThisDbServer.Name = item.name;
            List <DbNameOnThisDbServer> dbNameOnThisDbServerList = new List <DbNameOnThisDbServer>();

            foreach (var item in chckdLstBoxDbNamesOnDbServer.CheckedItems)
            {
                DbNameOnThisDbServer dbNameOnThisDbServer = new DbNameOnThisDbServer
                {
                    Name       = item.ToString(),
                    IsSelected = true
                };
                dbNameOnThisDbServerList.Add(dbNameOnThisDbServer);
            }
            dbServerParameters.DatabasesOnThisServer = dbNameOnThisDbServerList;

            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                foreach (var uj in dbContext.UserJobs)
                {
                    if (uj.name == _vM_Main_Form_DTO.SelectedJob_And_Details.selectedJob.name)
                    {
                        if (uj.DbServerParameters is null)
                        {
                            uj.DbServerParameters = dbServerParameters;
                            //dbContext.SaveChanges();
                        }
                        else
                        {
                            //uj.DbServerParameters = null;
                            dbContext.DbServerParameters.Remove(uj.DbServerParameters);
                            //uj.DbServerParameters = null;
                            dbContext.SaveChanges();
                            uj.DbServerParameters = dbServerParameters;
                            //dbContext.SaveChanges();
                        }
                    }
                }
                dbContext.SaveChanges();
            }


            string name  = _vM_Main_Form_DTO.UserSqlBackup.AccountName.ToString();
            string pass  = _vM_Main_Form_DTO.UserSqlBackup.Password.ToString();
            string jName = _vM_Main_Form_DTO.SelectedJob_And_Details.selectedJob.name;

            _vM_Main_Form_DTO.update_VM_with_accountName_pass(name, pass.decryption(), jName);
            this._mainFormSqlBackup.update_main_form_full_with_VM_Main_Form_DTO();
            this._mainFormSqlBackup.Show();
            this.Hide();
        }
Exemplo n.º 2
0
 public List <UserJobs> UserJobs_GET_for_a_user(UserSqlBackup usr)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr_jobs = dbContext.UserJobs.Where(x => x.UserSqlBackupId == usr.Id).ToList();
         return(usr_jobs);
     }
 }
Exemplo n.º 3
0
 public void schedule_Delete_for_a_job(Schedule schedule)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         dbContext.Schedule.Remove(schedule);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public UserSqlBackup UserSqlBackup_GET_from_name_and_pass_(string name, string pass)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr = dbContext.User.Where(x => x.AccountName == name && x.Password == pass.encryption()).FirstOrDefault();
         return(usr);
     }
 }
Exemplo n.º 5
0
 public UserJobs UserJobs_GET_for_a_user_and_jobName(UserSqlBackup usr, string jobName)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr_selected_job = dbContext.UserJobs.Where(x => x.UserSqlBackupId == usr.Id && x.name == jobName).FirstOrDefault();
         return(usr_selected_job);
     }
 }
Exemplo n.º 6
0
 public void UserSqlBackup_CREATE_(UserSqlBackup usr)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         dbContext.User.Add(usr);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 7
0
 public void UserJobs_REMOVE_for_a_user(UserSqlBackup _usr, UserJobs uj)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr = dbContext.User.Find(_usr.Id);
         usr.UserJobs.Add(uj);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public void update_a_job_for_a_user(int userJobID, string uj_name)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         UserJobs usr_j = dbContext.UserJobs.Find(userJobID);
         usr_j.name = uj_name;
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public Schedule schedule_GET_for_job(string jobName)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr_selected_job = dbContext.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
         var schedule         = dbContext.Schedule.Where(x => x.UserJobsId == usr_selected_job.Id).FirstOrDefault();
         return(schedule);
     }
 }
Exemplo n.º 10
0
 public void delete_a_job_from_a_usr(string jName)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         UserJobs usr_j = dbContext.UserJobs.Where(x => x.name == jName).FirstOrDefault();
         dbContext.UserJobs.Remove(usr_j);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 11
0
 public DbServerParameters DB_Server_Parameters_CREATE_for_job(DbServerParameters dbServerParameters, UserJobs usrJob)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         dbServerParameters.UserJobsId = usrJob.Id;
         dbContext.DbServerParameters.Add(dbServerParameters);
         dbContext.SaveChanges();
     }
     return(dbServerParameters);
 }
Exemplo n.º 12
0
 public Schedule schedule_Create_for_a_job(Schedule schedule, UserJobs userJob)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         schedule.UserJobsId = userJob.Id;
         dbContext.Schedule.Add(schedule);
         dbContext.SaveChanges();
         return(schedule);
     }
 }
Exemplo n.º 13
0
 public List <DbNameOnThisDbServer> dBNames_GET_for_job(string jobName)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr_selected_job           = dbContext.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
         var jobDatabaseServerParameter = dbContext.DbServerParameters.Where(x => x.UserJobsId == usr_selected_job.Id).FirstOrDefault();
         var dBNames = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == jobDatabaseServerParameter.Id).ToList();
         return(dBNames);
     }
 }
Exemplo n.º 14
0
        public DbServerParameters DB_Server_Parameters_Remove_for_job(string jobName)
        {
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                var usr_selected_job           = dbContext.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
                var jobDatabaseServerParameter = dbContext.DbServerParameters.Where(x => x.UserJobsId == usr_selected_job.Id).FirstOrDefault();

                return(jobDatabaseServerParameter);
            }
        }
Exemplo n.º 15
0
 public void create_a_job_for_a_user(int usr_ID, string uj_name)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         UserJobs uj = new UserJobs();
         uj.name            = uj_name;
         uj.UserSqlBackupId = usr_ID;
         dbContext.UserJobs.Add(uj);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 16
0
        public void UserSqlBackup_DELETE(UserSqlBackup _usr)
        {
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                var usr = dbContext.User.Find(_usr.Id);

                dbContext.User.Remove(usr);

                dbContext.SaveChanges();
            }
        }
Exemplo n.º 17
0
 public void dBNames_Remove_for_job(List <DbNameOnThisDbServer> dbNames, string jobName)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         var usr_selected_job           = dbContext.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
         var jobDatabaseServerParameter = dbContext.DbServerParameters.Where(x => x.UserJobsId == usr_selected_job.Id).FirstOrDefault();
         foreach (var dbn in dbNames)
         {
             dbn.DbServerParametersId = jobDatabaseServerParameter.Id;
             dbContext.DbNameOnThisDbServer.Add(dbn);
         }
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 18
0
        public void update_VM_with_jobName(string jobName = "")
        {
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                if (this.UserJobs.Count > 0)
                {
                    this.SelectedJob_And_Details.selectedJob = this.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
                    if (!(this.SelectedJob_And_Details.selectedJob is null))
                    {
                        this.SelectedJob_And_Details.DbServerParameters = dbContext.DbServerParameters.Where(x => x.UserJobsId == SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();

                        if (!(this.SelectedJob_And_Details.DbServerParameters is null))
                        {
                            this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == SelectedJob_And_Details.DbServerParameters.Id).ToList <DbNameOnThisDbServer>();
                        }

                        if (!(this.SelectedJob_And_Details.DbServerParameters is null))
                        {
                            this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == SelectedJob_And_Details.DbServerParameters.Id).ToList <DbNameOnThisDbServer>();
                        }

                        this.SelectedJob_And_Details.Schedule            = dbContext.Schedule.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                        this.SelectedJob_And_Details.Destination_Local   = dbContext.Destination_Local.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                        this.SelectedJob_And_Details.Destination_Network = dbContext.Destination_Network.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                        this.SelectedJob_And_Details.Destination_Cloud   = dbContext.Destination_Cloud.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                    }
                }
                else
                {
                    this.SelectedJob_And_Details.selectedJob = null;
                }
            }

            //if (!(this.SelectedJob_And_Details.selectedJob is null))
            //{

            //    this.SelectedJob_And_Details.DbServerParameters = dbContext.DbServerParameters.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();

            //    if (!(this.SelectedJob_And_Details.DbServerParameters is null))
            //        this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == this.SelectedJob_And_Details.DbServerParameters.Id).ToList<DbNameOnThisDbServer>();

            //    if (!(this.SelectedJob_And_Details.DbServerParameters is null))
            //        this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == this.SelectedJob_And_Details.DbServerParameters.Id).ToList<DbNameOnThisDbServer>();

            //    this.SelectedJob_And_Details.Schedule = dbContext.Schedule.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
            //    this.SelectedJob_And_Details.Destination_Local = dbContext.Destination_Local.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
            //    this.SelectedJob_And_Details.Destination_Network = dbContext.Destination_Network.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
            //    this.SelectedJob_And_Details.Destination_Cloud = dbContext.Destination_Cloud.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
            //}
        }
Exemplo n.º 19
0
 public void delete_a_DbServerAndDbNames_from_a_job(string jobName)
 {
     using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
     {
         UserJobs           usr_j = dbContext.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
         DbServerParameters dbServerParameters      = dbContext.DbServerParameters.Where(x => x.UserJobsId == usr_j.Id).FirstOrDefault();
         ICollection <DbNameOnThisDbServer> dbNames = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == dbServerParameters.Id).ToList();
         foreach (DbNameOnThisDbServer dbn in dbNames)
         {
             dbContext.DbNameOnThisDbServer.Remove(dbn);
         }
         dbContext.DbServerParameters.Remove(dbServerParameters);
         dbContext.SaveChanges();
     }
 }
Exemplo n.º 20
0
        public void UserSqlBackup_update(UserSqlBackup _usr)
        {
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                var usr = dbContext.User.Find(_usr.Id);

                usr.Name        = _usr.Name;
                usr.AccountName = _usr.AccountName;
                usr.Password    = _usr.Password;
                usr.Lastname    = _usr.Lastname;


                dbContext.SaveChanges();
            }
        }
Exemplo n.º 21
0
        private void button1_Click(object sender, EventArgs e)
        {
            //utility utility = new utility();

            UserSqlBackup UserSqlBackup = new UserSqlBackup();

            UserSqlBackup.Name        = txtBoxName.Text.ToString();
            UserSqlBackup.Lastname    = txtBoxLastName.Text.ToString();
            UserSqlBackup.AccountName = txtBoxNickName.Text.ToString();
            UserSqlBackup.Password    = utility.encryption(txtBoxUserPass.Text.ToString());
            //UserSqlBackup.CompanyName = txtCompanyName.Text.ToString();

            using (var dbContext = new DbContextSqlBackup())
            {
                dbContext.User.Add(UserSqlBackup);
                dbContext.SaveChanges();
            }
            MessageBox.Show(" kayıt yapıldı ...");
        }
Exemplo n.º 22
0
        public void update_VM_with_schedule_with_jobName(Schedule schedule, string jN)
        {
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                UserJobs uj = new UserJobs();
                uj = dbContext.UserJobs.Where(x => x.name == jN).FirstOrDefault();

                var sc = dbContext.Schedule.Where(x => x.UserJobsId == uj.Id).FirstOrDefault();

                if (sc == null)
                {
                    schedule.UserJobsId = uj.Id;
                    dbContext.Schedule.Add(schedule);
                }
                else
                {
                    uj.Schedule = sc;
                }
                dbContext.SaveChanges();
            }
        }
Exemplo n.º 23
0
        public Schedule schedule_Update_for_job(Schedule schedule, UserJobs userJob)
        {
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                Schedule _schedule = dbContext.Schedule.Where(x => x.UserJobsId == userJob.Id).FirstOrDefault();

                _schedule.IsMonday    = schedule.IsMonday;
                _schedule.IsThursday  = schedule.IsThursday;
                _schedule.IsWednesday = schedule.IsWednesday;
                _schedule.IsTuesday   = schedule.IsTuesday;
                _schedule.IsFriday    = schedule.IsFriday;
                _schedule.IsSaturday  = schedule.IsSaturday;
                _schedule.IsSunday    = schedule.IsSunday;

                _schedule.howmanyBackup = schedule.howmanyBackup;
                _schedule.interval      = schedule.interval;
                _schedule.StartDateTime = schedule.StartDateTime;

                dbContext.Schedule.Update(_schedule);

                dbContext.SaveChanges();
                return(_schedule);
            }
        }
Exemplo n.º 24
0
        public void update_VM_with_accountName_pass(string name = "", string pass = "", string jobName = "")
        {
            //try
            //{
            using (DbContextSqlBackup dbContext = new DbContextSqlBackup())
            {
                UserSqlBackup = dbContext.User.Where(x => x.AccountName == name && x.Password == pass.encryption()).FirstOrDefault();
                if (!(UserSqlBackup is null))
                {
                    UserJobs = dbContext.UserJobs.Where(x => x.UserSqlBackupId == UserSqlBackup.Id).ToList <UserJobs>();
                }

                if (jobName == "")
                {
                    if (this.UserJobs.Count > 0)
                    {
                        this.SelectedJob_And_Details.selectedJob = UserJobs[0];
                    }
                    else
                    {
                        this.SelectedJob_And_Details.selectedJob = null;
                    }
                }
                else
                {
                    if (this.UserJobs.Count > 0)
                    {
                        this.SelectedJob_And_Details.selectedJob = this.UserJobs.Where(x => x.name == jobName).FirstOrDefault();
                        if (!(this.SelectedJob_And_Details.selectedJob is null))
                        {
                            this.SelectedJob_And_Details.DbServerParameters = dbContext.DbServerParameters.Where(x => x.UserJobsId == SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();

                            if (!(this.SelectedJob_And_Details.DbServerParameters is null))
                            {
                                this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == SelectedJob_And_Details.DbServerParameters.Id).ToList <DbNameOnThisDbServer>();
                            }

                            if (!(this.SelectedJob_And_Details.DbServerParameters is null))
                            {
                                this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == SelectedJob_And_Details.DbServerParameters.Id).ToList <DbNameOnThisDbServer>();
                            }

                            this.SelectedJob_And_Details.Schedule            = dbContext.Schedule.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                            this.SelectedJob_And_Details.Destination_Local   = dbContext.Destination_Local.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                            this.SelectedJob_And_Details.Destination_Network = dbContext.Destination_Network.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                            this.SelectedJob_And_Details.Destination_Cloud   = dbContext.Destination_Cloud.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                        }
                    }
                    else
                    {
                        this.SelectedJob_And_Details.selectedJob = null;
                    }
                }

                if (!(this.SelectedJob_And_Details.selectedJob is null))
                {
                    this.SelectedJob_And_Details.DbServerParameters = dbContext.DbServerParameters.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();

                    if (!(this.SelectedJob_And_Details.DbServerParameters is null))
                    {
                        this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == this.SelectedJob_And_Details.DbServerParameters.Id).ToList <DbNameOnThisDbServer>();
                    }

                    if (!(this.SelectedJob_And_Details.DbServerParameters is null))
                    {
                        this.SelectedJob_And_Details.dbNamesOnThisDbServers = dbContext.DbNameOnThisDbServer.Where(x => x.DbServerParametersId == this.SelectedJob_And_Details.DbServerParameters.Id).ToList <DbNameOnThisDbServer>();
                    }

                    this.SelectedJob_And_Details.Schedule            = dbContext.Schedule.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                    this.SelectedJob_And_Details.Destination_Local   = dbContext.Destination_Local.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                    this.SelectedJob_And_Details.Destination_Network = dbContext.Destination_Network.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                    this.SelectedJob_And_Details.Destination_Cloud   = dbContext.Destination_Cloud.Where(x => x.UserJobsId == this.SelectedJob_And_Details.selectedJob.Id).FirstOrDefault();
                }
            }
            //}
            //catch
            //{

            //}

            //return vM_Main_Form_DTO;
        }