private void simpleButtonUpdateShorcuts_Click(object sender, EventArgs e) { string message = string.Empty; memoEditResult.EditValue = null; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Updating Shortcuts..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.UpdateShortcuts(out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!String.IsNullOrEmpty(message)) memoEditResult.EditValue = message.Replace("\n", "\r\n"); }
public void RefreshData(bool showMessages) { string message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading Users, Groups, Libraries\nfrom website..."; form.TopMost = true; form.Show(); Application.DoEvents(); UpdateUsers(false, ref message); if (string.IsNullOrEmpty(message)) UpdateGroups(false, ref message); if (string.IsNullOrEmpty(message)) UpdateLibraries(false, ref message); form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { UpdateUsers(showMessages, ref message); UpdateGroups(showMessages, ref message); UpdateLibraries(showMessages, ref message); } }
public void RefreshData(bool showMessages) { _loading = true; ClearData(); var loadAction = new ThreadStart(() => { LinkConfigProfilesDataHelper.LoadReferences(WebSiteManager.Instance.SelectedSite); _profileModels.AddRange(WebSiteManager.Instance.SelectedSite.GetLinkConfigProfiles()); }); var message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading data..."; form.TopMost = true; var thread = new Thread(loadAction); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { var thread = new Thread(loadAction); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } } ApplyData(); _loading = false; }
public void UpdateData(bool showMessages, ref string updateMessage) { ClearData(); if (!Active) return; var message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading data..."; form.TopMost = true; var thread = new Thread(() => { _userRecords.AddRange(WebSiteManager.Instance.SelectedSite.GetQuizPassUserReport(StartDate, EndDate, out message)); _groupRecords.AddRange(WebSiteManager.Instance.SelectedSite.GetQuizPassGroupReport(StartDate, EndDate, out message)); }); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { var thread = new Thread(() => { _userRecords.AddRange(WebSiteManager.Instance.SelectedSite.GetQuizPassUserReport(StartDate, EndDate, out message)); _groupRecords.AddRange(WebSiteManager.Instance.SelectedSite.GetQuizPassGroupReport(StartDate, EndDate, out message)); }); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } } updateMessage = message; _filterControl.UpdateDataSource(_userRecords.OrderBy(g => g.group).Select(x => x.group).Where(x => !string.IsNullOrEmpty(x)).Distinct().ToArray(), _userRecords.Select(r => r.topLevelName).Distinct()); ApplyData(); }
public void RefreshData(bool showMessages) { ClearData(); var startDate = dateEditStart.DateTime; var endDate = dateEditEnd.DateTime.AddDays(1); var message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading data..."; form.TopMost = true; var thread = new Thread(() => _records.AddRange(WebSiteManager.Instance.SelectedSite.GetInactiveUsers(startDate, endDate, out message))); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { var thread = new Thread(() => _records.AddRange(WebSiteManager.Instance.SelectedSite.GetInactiveUsers(startDate, endDate, out message))); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } } _filterControl.UpdateDataSource(_records.SelectMany(x => x.GroupNameList).OrderBy(g => g).Distinct().ToArray()); ApplyData(); }
private void InitializePresentationLayer() { using (var formProgress = new FormProgress()) { formProgress.TopMost = true; FormMain.Instance.ribbonControl.Enabled = false; FormMain.Instance.pnMain.Controls.Clear(); var thread = new Thread(delegate() { FormMain.Instance.Invoke((MethodInvoker)delegate { formProgress.laProgress.Text = "Loading data..."; Application.DoEvents(); UsersController.InitController(); Application.DoEvents(); ActivitiesController.InitController(); Application.DoEvents(); LinkConfigProfilesController.InitController(); Application.DoEvents(); LibraryFilesController.InitController(); Application.DoEvents(); InactiveUsersController.InitController(); Application.DoEvents(); QBuilderController.InitController(); Application.DoEvents(); UtilitiesController.InitController(); Application.DoEvents(); }); }); formProgress.Show(); Application.DoEvents(); thread.Start(); Application.DoEvents(); while (thread.IsAlive) Application.DoEvents(); formProgress.Close(); FormMain.Instance.ribbonControl.Enabled = true; FormMain.Instance.pnMain.BringToFront(); } }
public void RefreshData(bool showMessages) { ClearData(); var message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading data..."; form.TopMost = true; var thread = new Thread(() => _records.AddRange(WebSiteManager.Instance.SelectedSite.GetLibraryFiles(out message))); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { var thread = new Thread(() => _records.AddRange(WebSiteManager.Instance.SelectedSite.GetLibraryFiles(out message))); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } } _filterControl.UpdateDataSource(_records.OrderBy(g => g.library).Select(x => x.library).Where(x => !String.IsNullOrEmpty(x)).Distinct().ToArray()); ApplyData(); }
public void DeletePage() { var pageRecord = gridViewRecords.GetFocusedRow() as QPageModel; if (pageRecord == null || AppManager.Instance.ShowWarningQuestion(string.Format("Are you sure want to delete this {0}?", pageRecord.Type)) != DialogResult.Yes) return; string message = string.Empty; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = string.Format("Deleting {0}...", pageRecord.Type); form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.DeletePages(new[] { pageRecord.id }, out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) { AppManager.Instance.ShowWarning(message); return; } RefreshData(false); }
public void ExportData() { using (var dialog = new SaveFileDialog()) { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.FileName = string.Format("quickSITES & Emails({0}).xlsx", DateTime.Now.ToString("MMddyy-hmmtt")); dialog.Filter = "Excel files|*.xlsx"; dialog.Title = "Export quickSites & Emails"; if (dialog.ShowDialog() != DialogResult.OK) return; var options = new XlsxExportOptions(); options.SheetName = Path.GetFileNameWithoutExtension(dialog.FileName); options.TextExportMode = TextExportMode.Text; options.ExportHyperlinks = true; options.ShowGridLines = true; options.ExportMode = XlsxExportMode.SingleFile; var parts = new Dictionary<string, string>(); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Exporting data..."; form.TopMost = true; form.Show(); Application.DoEvents(); var thread = new Thread(() => { var tempFile = Path.Combine(Path.GetTempPath(), String.Format("{0}.xlsx", Guid.NewGuid())); BeginInvoke(new Action(() => { using (var printingSystem = new PrintingSystem()) { var printLink = new PrintableComponentLink { Landscape = true, PaperKind = PaperKind.A4, Component = gridControlRecords }; printLink.CreateReportHeaderArea += OnCreateReportHeaderArea; printLink.CreateDocument(printingSystem); printingSystem.ExportToXlsx(tempFile, options); } })); parts.Add("quickSITES & Emails", tempFile); ActivityExportHelper.ExportCommonData(dialog.FileName, parts); }); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (File.Exists(dialog.FileName)) Process.Start(dialog.FileName); } }
public void ExportData() { if (!xtraTabControlGroups.TabPages.Any()) return; using (var dialog = new SaveFileDialog()) { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.FileName = string.Format("UserSalesCertificationStatus({0}).xlsx", DateTime.Now.ToString("MMddyy-hmmtt")); dialog.Filter = "Excel files|*.xlsx"; dialog.Title = "User Sales Certification Status"; if (dialog.ShowDialog() != DialogResult.OK) return; var header = String.Format("Date Range: {0} - {1}{2}Active Quizzes in the System: {3}", StartDate.ToString("M/d/yy"), EndDate.ToString("M/d/yy"), Environment.NewLine, _filteredRecords.Select(r => r.quizName).Distinct().Count()); var topLevelGroup = _filterControl.Enabled ? _filterControl.TopLevelQuizGroup : String.Empty; var totalUsers = _filteredRecords.Select(r => r.FullName).Distinct().Count(); var totalGroups = _filteredRecords.Select(r => r.group).Distinct().Count(); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Exporting data..."; form.TopMost = true; var thread = new Thread(() => QuizStatisticExportHelper.ExportQuizStatistic(dialog.FileName, header, topLevelGroup, totalUsers, totalGroups, xtraTabControlGroups.TabPages.OfType<TotalControl>().First().Records, xtraTabControlGroups.TabPages.OfType<GroupControl>().Select(tp => tp.Records)) ); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (File.Exists(dialog.FileName)) Process.Start(dialog.FileName); } }
public void UpdateUsers(bool showMessages, ref string updateMessage) { gridControlUsers.DataSource = null; _users.Clear(); string message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading users..."; form.TopMost = true; var thread = new Thread(() => { _complexPassword = WebSiteManager.Instance.SelectedSite.IsUserPasswordComplex(out message); _users.AddRange(WebSiteManager.Instance.SelectedSite.GetUsers(out message)); }); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { var thread = new Thread(() => { _complexPassword = WebSiteManager.Instance.SelectedSite.IsUserPasswordComplex(out message); _users.AddRange(WebSiteManager.Instance.SelectedSite.GetUsers(out message)); }); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } } updateMessage = message; UpdateFilter(_users.SelectMany(x => x.groups != null ? x.groups : new GroupModel[] { }).OrderBy(g => g.name).Select(g => g.name).Distinct().ToArray()); FilterUsers(); _userCollectionChanged = false; }
private void LoadAffectedLinks() { _loading = true; gridControlFiles.DataSource = null; var affectedLinks = new List<LibraryLinkReference>(); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading Files..."; form.TopMost = true; var thread = new Thread(() => affectedLinks.AddRange(WebSiteManager.Instance.SelectedSite.GetLinkConfigProfileAffectedLinks(Profile))); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } foreach (var linkReference in affectedLinks) { if (Profile.config.ignoredLinkReferences.Any(ignoredLink => ignoredLink.id == linkReference.id)) linkReference.Selected = true; } gridControlFiles.DataSource = affectedLinks; UpdateFilesTotals(); _loading = false; }
public void DeleteProfile() { if (_selectedProfileControl == null) return; if (AppManager.Instance.ShowWarningQuestion(String.Format("Are you sure want to delete profile {0}?", _selectedProfileControl.ProfileName)) != DialogResult.Yes) return; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Deleting Profile..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.DeleteLinkConfigProfile(_selectedProfileControl.Profile)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _profileControls.Remove(_selectedProfileControl); pnProfileContentContainer.Controls.Remove(_selectedProfileControl); RefreshGrid(); }
private void DeleteGroup() { var groupRecord = gridViewGroups.GetFocusedRow() as GroupModel; if (groupRecord != null && AppManager.Instance.ShowWarningQuestion(string.Format("Are you sure want to delete group {0}?", groupRecord.name)) == DialogResult.Yes) { string message = string.Empty; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Deleting group..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.DeleteGroup(groupRecord.id, out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateGroups(true, ref message); if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } }
private void EditGroup() { string message = string.Empty; var groupRecord = gridViewGroups.GetFocusedRow() as GroupModel; if (groupRecord != null) { using (var formEdit = new FormEditGroup(false, _groupTemplates.ToArray(), _groups.Where(x => !x.name.Equals(groupRecord.name)).Select(x => x.name).ToArray(), _users.Select(x => new UserModel { id = x.id, login = x.login, firstName = x.firstName, lastName = x.lastName, email = x.email, selected = (groupRecord.users != null && groupRecord.users.Any(y => y.id == x.id)) }).ToArray(), _libraries.Select(x => new SoapLibrary { id = x.id, name = x.name, selected = (groupRecord.libraries != null && groupRecord.libraries.Any(y => y.id == x.id)), pages = x.pages.Select(y => new SoapLibraryPage { id = y.id, name = y.name, libraryId = y.libraryId, selected = (groupRecord.libraries != null && groupRecord.libraries.SelectMany(library => library.pages).Select(groupPage => groupPage.id).Contains(y.id)) }).ToArray() }).ToArray())) { formEdit.comboBoxEditName.EditValue = groupRecord.name; if (formEdit.ShowDialog() == DialogResult.OK) { string id = groupRecord.id; string name = formEdit.comboBoxEditName.EditValue != null ? formEdit.comboBoxEditName.EditValue.ToString() : string.Empty; var users = new List<UserModel>(formEdit.AssignedUsers); var pages = new List<SoapLibraryPage>(formEdit.AssignedPages); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Updating group..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetGroup(id, name, users.ToArray(), pages.ToArray(), out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateGroups(true, ref message); } } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } }
private void AddGroup() { string message = string.Empty; using (var formEdit = new FormEditGroup(true, _groupTemplates.ToArray(), _groups.Select(x => x.name).ToArray(), _users.Select(x => new UserModel { id = x.id, login = x.login, firstName = x.firstName, lastName = x.lastName, email = x.email }).ToArray(), _libraries.Select(x => new SoapLibrary { id = x.id, name = x.name, pages = x.pages.Select(y => new SoapLibraryPage { id = y.id, name = y.name, libraryId = y.libraryId }).ToArray() }).ToArray())) { if (formEdit.ShowDialog() == DialogResult.OK) { string id = Guid.NewGuid().ToString(); string name = formEdit.comboBoxEditName.EditValue != null ? formEdit.comboBoxEditName.EditValue.ToString() : string.Empty; var users = new List<UserModel>(formEdit.AssignedUsers); var pages = new List<SoapLibraryPage>(formEdit.AssignedPages); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Adding group..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetGroup(id, name, users.ToArray(), pages.ToArray(), out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateGroups(true, ref message); } } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); }
public void DeleteUser() { var userRecord = gridViewUsers.GetFocusedRow() as UserModel; if (userRecord == null || AppManager.Instance.ShowWarningQuestion(string.Format("Are you sure want to delete user {0}?", userRecord.FullName)) != DialogResult.Yes) return; string message = string.Empty; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Deleting user..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.DeleteUser(userRecord.login, out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateUsers(true, ref message); if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); }
public void EditUser() { string message = string.Empty; var userRecord = gridViewUsers.GetFocusedRow() as UserModel; if (userRecord == null) return; using (var formEdit = new FormEditUser(false, _complexPassword, _users.Select(x => x.login).ToArray(), _groups.Select(x => new GroupModel { id = x.id, name = x.name, selected = (userRecord.groups != null && userRecord.groups.Any(y => y.id == x.id)) }).ToArray(), _libraries.Select(x => new SoapLibrary { id = x.id, name = x.name, selected = (userRecord.libraries != null && userRecord.libraries.Any(y => y.id == x.id)), pages = x.pages.Select(y => new SoapLibraryPage { id = y.id, name = y.name, libraryId = y.libraryId, selected = (userRecord.libraries != null && userRecord.libraries.Where(library => library.pages != null).SelectMany(library => library.pages).Select(userPage => userPage.id).Contains(y.id)) }).ToArray() }).ToArray())) { formEdit.textEditLogin.EditValue = userRecord.login; formEdit.textEditFirstName.EditValue = userRecord.firstName; formEdit.textEditLastName.EditValue = userRecord.lastName; formEdit.textEditPhone.EditValue = userRecord.phone; formEdit.textEditEmail.EditValue = userRecord.email; formEdit.textEditEmailConfirm.EditValue = userRecord.email; if (formEdit.ShowDialog() == DialogResult.OK) { string login = formEdit.textEditLogin.EditValue != null ? formEdit.textEditLogin.EditValue.ToString() : string.Empty; string password = formEdit.buttonEditPassword.EditValue != null ? formEdit.buttonEditPassword.EditValue.ToString() : string.Empty; string firstName = formEdit.textEditFirstName.EditValue != null ? formEdit.textEditFirstName.EditValue.ToString() : string.Empty; string lastName = formEdit.textEditLastName.EditValue != null ? formEdit.textEditLastName.EditValue.ToString() : string.Empty; string email = formEdit.textEditEmail.EditValue != null ? formEdit.textEditEmail.EditValue.ToString() : string.Empty; string phone = formEdit.textEditPhone.EditValue != null ? formEdit.textEditPhone.EditValue.ToString() : string.Empty; var role = 0; var groups = new List<GroupModel>(formEdit.AssignedGroups); var pages = new List<SoapLibraryPage>(formEdit.AssignedPages); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Updating user..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetUser(login, password, firstName, lastName, email, phone, role, groups.ToArray(), pages.ToArray(), out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateUsers(true, ref message); } } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); }
public void AddUser() { string message = string.Empty; using (var formEdit = new FormEditUser(true, _complexPassword, _users.Select(x => x.login).ToArray(), _groups.Select(x => new GroupModel { id = x.id, name = x.name }).ToArray(), _libraries.Select(x => new SoapLibrary { id = x.id, name = x.name, pages = x.pages.Select(y => new SoapLibraryPage { id = y.id, name = y.name, libraryId = y.libraryId }).ToArray() }).ToArray())) { if (formEdit.ShowDialog() == DialogResult.OK) { string login = formEdit.textEditLogin.EditValue != null ? formEdit.textEditLogin.EditValue.ToString() : string.Empty; string password = formEdit.buttonEditPassword.EditValue != null ? formEdit.buttonEditPassword.EditValue.ToString() : string.Empty; string firstName = formEdit.textEditFirstName.EditValue != null ? formEdit.textEditFirstName.EditValue.ToString() : string.Empty; string lastName = formEdit.textEditLastName.EditValue != null ? formEdit.textEditLastName.EditValue.ToString() : string.Empty; string email = formEdit.textEditEmail.EditValue != null ? formEdit.textEditEmail.EditValue.ToString() : string.Empty; string phone = formEdit.textEditPhone.EditValue != null ? formEdit.textEditPhone.EditValue.ToString() : string.Empty; int role = 0; var groups = new List<GroupModel>(formEdit.AssignedGroups); var pages = new List<SoapLibraryPage>(formEdit.AssignedPages); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Adding user..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SetUser(login, password, firstName, lastName, email, phone, role, groups.ToArray(), pages.ToArray(), out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateUsers(true, ref message); } } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); }
private void ResetUsers() { var message = string.Empty; var userIds = _records.Where(x => x.Selected).Select(x => x.id.ToString()).ToArray(); var onlyEmail = !_filterControl.EmailReset; var sender = textEditEmailResetSender.EditValue != null ? textEditEmailResetSender.EditValue.ToString() : string.Empty; var subject = textEditEmailResetSubject.EditValue != null ? textEditEmailResetSubject.EditValue.ToString() : string.Empty; var body = memoEditEmailResetBody.EditValue != null ? memoEditEmailResetBody.EditValue.ToString() : string.Empty; SettingsManager.Instance.InactiveUsersSettings.ResetEmailSender = sender; SettingsManager.Instance.InactiveUsersSettings.ResetEmailSubject = subject; SettingsManager.Instance.InactiveUsersSettings.ResetEmailBody = body; SettingsManager.Instance.InactiveUsersSettings.Save(); if (userIds.Length == 0 || string.IsNullOrEmpty(sender)) return; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Sending Emails..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.ResetUsers(userIds, onlyEmail, sender, subject, body, out message)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } if (string.IsNullOrEmpty(message)) RefreshData(false); form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) RefreshData(true); }
public void ExportData() { using (var dialog = new SaveFileDialog()) { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.FileName = string.Format("ActiveLibraries({0}).xlsx", DateTime.Now.ToString("MMddyy-hmmtt")); dialog.Filter = "Excel files|*.xlsx"; dialog.Title = "Export Active Libraries"; if (dialog.ShowDialog() != DialogResult.OK) return; var options = new XlsxExportOptions(); options.SheetName = Path.GetFileNameWithoutExtension(dialog.FileName); options.TextExportMode = TextExportMode.Text; options.ExportHyperlinks = true; options.ShowGridLines = true; options.ExportMode = XlsxExportMode.SingleFile; var groupControls = xtraTabControlLibraries.TabPages.OfType<IGroupControl>().Reverse(); var parts = new Dictionary<string, string>(); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Exporting data..."; form.TopMost = true; form.Show(); Application.DoEvents(); var thread = new Thread(() => { foreach (var groupControl in groupControls) { var tempFile = Path.Combine(Path.GetTempPath(), String.Format("{0}.xlsx", Guid.NewGuid())); BeginInvoke(new Action(() => { using (var printingSystem = new PrintingSystem()) { groupControl.GetPrintLink().CreateDocument(printingSystem); printingSystem.ExportToXlsx(tempFile, options); } })); parts.Add(groupControl.GroupName, tempFile); } ActivityExportHelper.ExportCommonData(dialog.FileName, parts); }); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (File.Exists(dialog.FileName)) Process.Start(dialog.FileName); } }
public void UpdateLibraries(bool showMessages, ref string updateMessage) { gridControlPages.DataSource = null; _libraries.Clear(); string message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading libraries..."; form.TopMost = true; var thread = new Thread(() => _libraries.AddRange(WebSiteManager.Instance.SelectedSite.GetLibraries(out message))); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else { var thread = new Thread(() => _libraries.AddRange(WebSiteManager.Instance.SelectedSite.GetLibraries(out message))); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } } updateMessage = message; gridControlPages.DataSource = _libraries.SelectMany(x => x.pages).ToList(); gridViewPages.ExpandAllGroups(); UpdateControlsState(); _libraraiesCollectionChanged = false; }
public void SaveData() { gridViewLibraries.CloseEditor(); gridViewSecurityGroups.CloseEditor(); gridViewFiles.CloseEditor(); if (!NeedToSave) return; if (_dataLoaded) { Profile.config.disablePreview = checkEditDisablePreview.Checked; Profile.config.disableDownload = checkEditDisableDownload.Checked; Profile.config.disableEmail = checkEditDisableEmail.Checked; Profile.config.disableFavorites = checkEditDisableFavorites.Checked; Profile.config.disablePdf = checkEditDisablePdf.Checked; Profile.config.disableQuickSite = checkEditDisableQuickSite.Checked; Profile.config.disableSave = checkEditDisableSave.Checked; Profile.config.libraryReferences = ((List<LibraryReference>)gridControlLibraries.DataSource).Where(l => l.Selected).ToArray(); Profile.config.securityGroupReferences = ((List<SecurityGroupReference>)gridControlSecurityGroups.DataSource).Where(l => l.Selected).ToArray(); var linkTags = textEditFilesTags.EditValue as String; if (!String.IsNullOrEmpty(linkTags)) Profile.config.libraryLinkTags = linkTags.Split(';').Where(item => !String.IsNullOrEmpty(item)).Select(item => item.Trim()).ToArray(); else Profile.config.libraryLinkTags = new string[] { }; Profile.config.ignoredLinkReferences = ((List<LibraryLinkReference>)gridControlFiles.DataSource).Where(linkReference => linkReference.Selected).ToArray(); } using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Saving Profile..."; form.TopMost = true; var thread = new Thread(() => WebSiteManager.Instance.SelectedSite.SaveLinkConfigProfile(Profile)); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } NeedToSave = false; }
private void EditPage() { string message = string.Empty; var pageRecord = gridViewPages.GetFocusedRow() as SoapLibraryPage; if (pageRecord != null) { using (var formEdit = new FormEditPage(_users.Select(x => new UserModel { id = x.id, login = x.login, firstName = x.firstName, lastName = x.lastName, email = x.email, selected = (pageRecord.users != null && pageRecord.users.Any(y => y.id == x.id)) }).ToArray(), _groups.Select(x => new GroupModel { id = x.id, name = x.name, selected = (pageRecord.groups != null && pageRecord.groups.Any(y => y.id == x.id)) }).ToArray())) { formEdit.laLibrary.Text = string.Format(formEdit.laLibrary.Text, pageRecord.libraryName); formEdit.laPage.Text = string.Format(formEdit.laPage.Text, pageRecord.name); formEdit.checkEditapplyForLibrary.Text = string.Format(formEdit.checkEditapplyForLibrary.Text, pageRecord.libraryName); if (formEdit.ShowDialog() == DialogResult.OK) { var users = new List<UserModel>(formEdit.AssignedUsers); var groups = new List<GroupModel>(formEdit.AssignedGroups); bool allLibrary = formEdit.checkEditapplyForLibrary.Checked; using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = allLibrary ? "Updating library..." : "Updating page..."; form.TopMost = true; var thread = new Thread(() => { if (allLibrary) { var libraray = _libraries.FirstOrDefault(x => x.id.Equals(pageRecord.libraryId)); if (libraray != null) foreach (SoapLibraryPage page in libraray.pages) WebSiteManager.Instance.SelectedSite.SetPage(page.id, users.ToArray(), groups.ToArray(), out message); } else WebSiteManager.Instance.SelectedSite.SetPage(pageRecord.id, users.ToArray(), groups.ToArray(), out message); }); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; UpdateLibraries(true, ref message); } } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } }
public void RefreshData(bool showMessages) { var message = string.Empty; if (showMessages) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Loading Activities..."; form.TopMost = true; form.Show(); Application.DoEvents(); foreach (var view in _views.Values) { view.StartDate = dateEditStart.DateTime; view.EndDate = dateEditEnd.DateTime.AddDays(1); view.UpdateData(false, ref message); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); } else foreach (var view in _views.Values) view.UpdateData(true, ref message); }
public void ImportUsers() { string message = string.Empty; using (var dialog = new OpenFileDialog()) { dialog.Title = "Import Users"; dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); dialog.Filter = "Excel files|*.xls;*.xlsx"; if (dialog.ShowDialog() == DialogResult.OK) { using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Import users..."; form.TopMost = true; var thread = new Thread(() => { var users = ImportManager.ImportUsers(dialog.FileName, _users.ToArray(), _groups.ToArray(), _complexPassword, out message); if (string.IsNullOrEmpty(message)) WebSiteManager.Instance.SelectedSite.SetUsers(users.ToArray(), out message); }); form.Show(); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } _userCollectionChanged = true; _groupsCollectionChanged = true; _libraraiesCollectionChanged = true; if (string.IsNullOrEmpty(message)) UpdateUsers(true, ref message); } } if (!string.IsNullOrEmpty(message)) AppManager.Instance.ShowWarning(message); }