public static bool CreateNewProfile(string name) { if (!Profiles.Exists(a => a.Parameters.ProfileName == name)) { var newProfileModel = new ProfileModel { ProfileName = name, EnableLinkExport = false, EnableScheduleJob = false }; DataExportClientDataManager.AddNewProfile(newProfileModel, UserId); return true; } return false; }
public static void EditCurrentProfile(ProfileModel newProfileModel) { DataExportClientDataManager.EditProfile(CurrentProfile.Parameters.ProfileId, newProfileModel); LoadProfiles(); SetCurrentProfile(newProfileModel.ProfileName); }
public static List<ProfileModel> GetProfilesForUser(int userId) { var profilesList = new List<ProfileModel>(); var sql = "SELECT * FROM " + TblProfiles + " WHERE UserID = '" + userId + "';"; var reader = GetReader(sql); if (reader != null) { try { while (reader.Read()) { var profile = new ProfileModel { ProfileId = reader.GetInt32(0), UserId = reader.GetInt32(1), ProfileName = reader.GetString(2), EnableLinkExport = reader.GetBoolean(3), EnableScheduleJob = reader.GetBoolean(4) }; profilesList.Add(profile); } } finally { reader.Close(); } for (int index = 0; index < profilesList.Count; index++) { var item = profilesList[index]; item.SheduleJobs = new List<SheduleJobModel>(GetShedulesForProfile(item.ProfileId)); profilesList[index] = item; } } return profilesList; }
public static bool RenameCurrentProfile(string name) { if (!Profiles.Exists(a => a.Parameters.ProfileName == name) && CurrentProfile.Parameters.ProfileName != name) { var newProfileModel = new ProfileModel { ProfileName = name, EnableLinkExport = CurrentProfile.Parameters.EnableLinkExport, EnableScheduleJob = CurrentProfile.Parameters.EnableScheduleJob, SheduleJobs = CurrentProfile.Parameters.SheduleJobs ?? new List<SheduleJobModel>() }; DataExportClientDataManager.EditProfile(CurrentProfile.Parameters.ProfileId, newProfileModel); return true; } return false; }
public static bool EditProfile(int profileId, ProfileModel newProfile) { var sql = "UPDATE " + TblProfiles + " SET ProfileName = '" + newProfile.ProfileName + "', EnableLink = " + newProfile.EnableLinkExport + ", EnableShedule = " + newProfile.EnableScheduleJob + " WHERE ID = '" + profileId + "' ; COMMIT;"; if (DoSql(sql)) { var sheduleJobs = GetShedulesForProfile(profileId); foreach (var shedule in sheduleJobs) { if (!newProfile.SheduleJobs.Exists(a => a.Id == shedule.Id && a.Date == shedule.Date && a.Name == shedule.Name && a.IsDaily == shedule.IsDaily && a.SelectedDays == shedule.SelectedDays)) { DoSql("DELETE FROM `" + TblSheduleJobs + "` WHERE ID = " + shedule.Id + ";COMMIT;"); } else { newProfile.SheduleJobs.Remove(shedule); } } foreach (var sheduleJobModel in newProfile.SheduleJobs) { AddSheduleToProfile(profileId, sheduleJobModel); } return true; } return false; }
public static ProfileModel GetProfileInfo(int profileId) { var profile = new ProfileModel(); var sql = "SELECT * FROM " + TblProfiles + "WHERE ID = " + profileId + ";"; var reader = GetReader(sql); if (reader != null) { try { while (reader.Read()) { profile = new ProfileModel { ProfileId = reader.GetInt32(0), UserId = reader.GetInt32(1), ProfileName = reader.GetString(2), EnableLinkExport = reader.GetBoolean(3), EnableScheduleJob = reader.GetBoolean(4) }; } } finally { reader.Close(); } } return profile; }
public static bool AddNewProfile(ProfileModel profile, int userId) { var sql = "INSERT IGNORE INTO " + TblProfiles + " (`UserID`, `ProfileName`, `EnableLink`, `EnableShedule`)" + "VALUES('" + userId + "', '" + profile.ProfileName + "', '" + profile.EnableLinkExport + "', '" + profile.EnableScheduleJob + "');COMMIT;"; if (DoSql(sql)) { if (profile.SheduleJobs != null && (profile.SheduleJobs.Count > 0)) { long profileId = 0; const string sqlId = "SELECT LAST_INSERT_ID();"; var reader = GetReader(sqlId); if (reader.Read()) { profileId = reader.GetInt64(0); } reader.Close(); foreach (var shedule in profile.SheduleJobs) { AddSheduleToProfile(profileId, shedule); } } return true; } return false; }
public Profile(ProfileModel parameters) { Parameters = parameters; Queries = DataExportClientDataManager.GetQueriesForProfile(Parameters.ProfileId); }
public Profile() { Parameters = new ProfileModel(); Queries = new List<QueryModel>(); }
private void ScheduleJobControl_SaveClisk(object sender, EventArgs e) { var profileModel = new ProfileModel { ProfileName = ProfilesManager.CurrentProfile.Parameters.ProfileName, ProfileId = ProfilesManager.CurrentProfile.Parameters.ProfileId, EnableLinkExport = ui_EnableLiveExport_checkBox.Checked, EnableScheduleJob = ui_AutomaticJob_checkBox.Checked, SheduleJobs = _scheduleJobControl.Schedulas }; ProfilesManager.EditCurrentProfile(profileModel); RefreshJobList(_scheduleJobControl.Schedulas); CloseScheduleJobControl(); }
private void ui_SaveProfile_button_Click(object sender, EventArgs e) { if (ui_Profiles_comboBox.SelectedIndex < 0) { ToastNotification.Show(this, @"Please select a profile.", 2000, eToastPosition.TopCenter); return; } var profileModel = new ProfileModel { ProfileName = ProfilesManager.CurrentProfile.Parameters.ProfileName, ProfileId = ProfilesManager.CurrentProfile.Parameters.ProfileId, EnableLinkExport = ui_EnableLiveExport_checkBox.Checked, EnableScheduleJob = ui_AutomaticJob_checkBox.Checked, SheduleJobs = new List<SheduleJobModel>(ProfilesManager.CurrentProfile.GetSheduleTimes()) }; ProfilesManager.EditCurrentProfile(profileModel); if(!ProfilesManager.CurrentProfile.Parameters.EnableScheduleJob) _exportJobs.ClearJobs(ProfilesManager.CurrentProfile.Parameters.ProfileName); else RefreshJobList(ProfilesManager.CurrentProfile.Parameters.SheduleJobs); }