private void OnCommandDeleteMemberGroup(object sender, System.EventArgs e) { IGroupsView view = base._view as IGroupsView; IGroupsModel model = base._model as IGroupsModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); string email = view.UserEmail; if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread deletemembergroup = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { if (email.Contains(",")) { char delimiter = ','; string[] emails = email.Split(delimiter); foreach (string newEmail in emails) { this.DeleteMemberGroup(model, newEmail, presenter); } } if (!email.Contains(",")) { this.DeleteMemberGroup(model, email, presenter); } if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>( ref view, model ); // update result and update view. view.RenderGroupList(); presenter.ActivateSpinner(false); presenter.EnableControl(true); presenter.UpdateProgressInfo("Completed."); }, null); } } }); deletemembergroup.Start(); }
private void OnCommandListMembers(object sender, EventArgs e) { IDumpUserContentView view = base._view as IDumpUserContentView; IDumpUserContentModel model = base._model as IDumpUserContentModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); // notify view to mark start of process if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } // TODO: to improve stability, we will need to ensure to kill // thread when user exits application while thread is running for REST service call Thread memberSearch = new Thread(() => { if (string.IsNullOrEmpty(model.UserAccessToken)) { SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.INVALID_TOKEN, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } else { // perform search this.SearchMembers(model, presenter); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IDumpUserContentView, IDumpUserContentModel>( ref view, model ); view.RenderMembersSearchResult(); if (model.MemberList.Count > 0) { view.LazyInitializeContextMenu(); view.EnableContextMenuItems(true); //view.EnableDumpControl(true); } presenter.UpdateProgressInfo("Completed"); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); // start async search memberSearch.Start(); }
protected override void Initialize() { IDataMigrationView view = base._view as IDataMigrationView; IDataMigrationModel model = base._model as IDataMigrationModel; PresenterBase.SetViewPropertiesFromModel <IDataMigrationView, IDataMigrationModel>( ref view, model ); }
protected override void Initialize() { // read data from model ILegalView view = base._view as ILegalView; ILegalModel model = base._model as ILegalModel; PresenterBase.SetViewPropertiesFromModel <ILegalView, ILegalModel>( ref view, model ); }
private void OnCommandSetFolderSyncSetting(object sender, System.EventArgs e) { ITeamFoldersView view = base._view as ITeamFoldersView; ITeamFoldersModel model = base._model as ITeamFoldersModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); TeamFoldersModel teamModel = view.GetTeamFolderIds(); bool syncSetting = view.SyncSetting; if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread setfoldersyncsetting = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { foreach (TeamFoldersListViewItemModel lvItem in teamModel.TeamFolders) { this.SetDefaultSyncSetting(model, lvItem.TeamFolderId, syncSetting, presenter); } if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <ITeamFoldersView, ITeamFoldersModel>( ref view, model ); // update result and update view. view.RenderTeamFoldersList(); presenter.ActivateSpinner(false); presenter.EnableControl(true); //presenter.UpdateProgressInfo("Completed."); }, null); } } }); setfoldersyncsetting.Start(); }
protected override void Initialize() { ConfigurationManager.RefreshSection("configuration"); FileUtil.ResetConfigMechanism(); GetConfigSettings(); ISettingsView view = base._view as ISettingsView; ISettingsModel model = base._model as ISettingsModel; PresenterBase.SetViewPropertiesFromModel <ISettingsView, ISettingsModel>( ref view, model ); }
protected override void Initialize() { ITeamFoldersView view = base._view as ITeamFoldersView; ITeamFoldersModel model = base._model as ITeamFoldersModel; PresenterBase.SetViewPropertiesFromModel <ITeamFoldersView, ITeamFoldersModel>( ref view, model ); SyncContext.Post(delegate { view.RefreshAccessToken(); }, null); }
private void OnCommandCreateTeamFolder(object sender, System.EventArgs e) { ITeamFoldersView view = base._view as ITeamFoldersView; ITeamFoldersModel model = base._model as ITeamFoldersModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); string teamFolderName = view.TeamFolderName; bool syncSetting = view.SyncSetting; if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread createteamfolder = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { this.CreateTeamFolder(model, teamFolderName, presenter); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <ITeamFoldersView, ITeamFoldersModel>( ref view, model ); // update result and update view. view.RenderTeamFoldersList(); presenter.ActivateSpinner(false); presenter.EnableControl(true); presenter.UpdateProgressInfo("Completed."); }, null); } } }); createteamfolder.Start(); }
private void OnCommandDownloadPaper(object sender, System.EventArgs e) { IPaperView view = base._view as IPaperView; IPaperModel model = base._model as IPaperModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread downloadpaperdocs = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { this.DownloadPaperDocs(model, view, presenter); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IPaperView, IPaperModel>( ref view, model ); // update result and update view. view.RenderPaperList(); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); downloadpaperdocs.Start(); }
protected override void Initialize() { // read data from model ITextSearchView view = base._view as ITextSearchView; ITextSearchModel model = base._model as ITextSearchModel; PresenterBase.SetViewPropertiesFromModel <ITextSearchView, ITextSearchModel>( ref view, model ); SyncContext.Post(delegate { view.RefreshAccessToken(); view.RenderSearchModeSelections(); view.SetSearchResultLimit(model.SearchResultsLimit); }, null); }
private void OnCommandCreateGroup(object sender, System.EventArgs e) { IGroupsView view = base._view as IGroupsView; IGroupsModel model = base._model as IGroupsModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); string groupName = view.GroupName; string groupType = view.GroupType; if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread creategroup = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { this.CreateGroup(model, groupName, groupType, presenter); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>( ref view, model ); // update result and update view. view.RenderGroupList(); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); creategroup.Start(); }
protected override void Initialize() { // read data from model IDumpUserContentView view = base._view as IDumpUserContentView; IDumpUserContentModel model = base._model as IDumpUserContentModel; PresenterBase.SetViewPropertiesFromModel <IDumpUserContentView, IDumpUserContentModel>( ref view, model ); ContextMenuItemText = new string[] { LIST_FILES }; view.SetContextMenuItemText(ContextMenuItemText); SyncContext.Post(delegate { view.RefreshAccessToken(); }, null); }
private void OnCommandClear(object sender, EventArgs e) { ITextSearchModel model = base._model as ITextSearchModel; ITextSearchView view = base._view as ITextSearchView; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); model.QueryString = string.Empty; model.SelectedSearchMode = TextSearchModel.TextSearchMode.Filename_only.ToString(); model.SearchResultsLimit = ApplicationResource.SearchDefaultLimit; model.MemberList = new List <MemberListViewItemModel>(); PresenterBase.SetViewPropertiesFromModel <ITextSearchView, ITextSearchModel>( ref view, model ); if (SyncContext != null) { SyncContext.Post(delegate { view.RenderComponents(); }, null); } }
private void OnCommandExportPaper(object sender, System.EventArgs e) { IPaperView view = base._view as IPaperView; IPaperModel model = base._model as IPaperModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread exportpapertocsv = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { if (SyncContext != null) { SyncContext.Post(delegate { PresenterBase.SetViewPropertiesFromModel <IPaperView, IPaperModel>( ref view, model ); string sPath = string.Empty; if (model.Paper.Count > 0) { //create CSV file in My Documents folder sPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\PaperDocExport.csv"; CsvConfiguration config = new CsvConfiguration() { HasHeaderRecord = true, Delimiter = ",", Encoding = System.Text.Encoding.UTF8 }; config.RegisterClassMap(new PaperHeaderMap()); int total = model.Paper.Count; using (CsvWriter writer = new CsvWriter(new StreamWriter(sPath), config)) { writer.WriteHeader <PaperHeaderRecord>(); int count = 0; foreach (var item in model.Paper) { writer.WriteField <string>(item.PaperName); writer.WriteField <string>(item.PaperId); writer.WriteField <string>(item.FolderPath); writer.WriteField <string>(item.Status); writer.WriteField <string>(item.Owner); writer.WriteField <string>(item.CreatedDate.ToString()); writer.WriteField <string>(item.LastUpdatedDate.ToString()); writer.WriteField <string>(item.LastEditor); writer.WriteField <string>(item.Revision.ToString()); count++; if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Writing Record: {0}/{1}", (count), total)); }, null); } writer.NextRecord(); } } if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Completed. Exported file located at " + sPath); }, null); } } if (model.Paper.Count == 0) { presenter.UpdateProgressInfo("No Paper docs were chosen to export."); } presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); exportpapertocsv.Start(); }
private void OnCommandGetPaper(object sender, System.EventArgs e) { IPaperView view = base._view as IPaperView; IPaperModel model = base._model as IPaperModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread getpaperdocs = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { // clear existing data first model.Paper.Clear(); //get members first IList <TeamListViewItemModel> members = SearchOwners(model, presenter); //get Paper Ids Parallel.ForEach(members, (member) => { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Retrieving member's Paper docs: {0}", member.Email)); }, null); } IList <PaperListViewItemModel> docIds = new List <PaperListViewItemModel>(); docIds = this.GetPaperDocs(model, presenter, member); //get metadata from ids foreach (PaperListViewItemModel item in docIds) { this.GetPaperMetadata(model, presenter, item.PaperId, item.MemberId); } }); if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Sorting Paper docs...")); }, null); } // sort by email then by folder path model.Paper = model.Paper.OrderBy(s => s.Owner).ThenBy(s => s.LastUpdatedDate).ToList(); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IPaperView, IPaperModel>( ref view, model ); // update result and update view. view.RenderPaperList(); presenter.ActivateSpinner(false); presenter.EnableControl(true); presenter.UpdateProgressInfo("Paper doc list completed. Total Docs [" + model.Paper.Count.ToString() + "]"); }, null); } } }); getpaperdocs.Start(); }
private void OnCommandContextMenuClicked(object sender, Common.DataExchange.DataUpdatedEventArgs e) { MenuItem selectedContextMenuItem = sender as MenuItem; if (selectedContextMenuItem != null) { if (selectedContextMenuItem.Text.ToLower().Equals(LIST_FILES, StringComparison.CurrentCultureIgnoreCase)) { if (e.Data != null) { IDumpUserContentView view = base._view as IDumpUserContentView; IDumpUserContentModel model = base._model as IDumpUserContentModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); ArrayList list = (ArrayList)e.Data; IList <TeamListViewItemModel> selectedLvItems = list.Cast <TeamListViewItemModel>().ToList(); if (selectedLvItems != null && selectedLvItems.Count > 0) { // lock UI if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Preparing Search..."); }, null); } Thread search = new Thread(() => { if (string.IsNullOrEmpty(model.UserAccessToken)) { SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.INVALID_TOKEN, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } else { MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); model.MemberList.Clear(); foreach (TeamListViewItemModel item in selectedLvItems) { SearchFiles(service, item, model, presenter); } // complete. if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IDumpUserContentView, IDumpUserContentModel>( ref view, model ); //view.ShowGroups(true); view.RenderMembersFileSearchResult(); view.EnableDumpControl(true); presenter.UpdateProgressInfo("Completed"); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); search.Start(); } } } } }
private void OnCommandDisplayContent(object sender, System.EventArgs e) { IDataMigrationView view = base._view as IDataMigrationView; IDataMigrationModel model = base._model as IDataMigrationModel; IList <ContentDisplayListViewItemModel> items = model.Contents; if (items != null) { IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); // lock UI if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Searching..."); }, null); } Thread search = new Thread(() => { TimerUtils util = new TimerUtils(); util.Start(); if (string.IsNullOrEmpty(model.AccessToken)) { presenter.ShowErrorMessage(ErrorMessages.INVALID_TOKEN, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); } else { MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); // search all owners first. IList <TeamListViewItemModel> owners = SearchOwner(model, presenter); model.Contents.Clear(); // clear existing contents Parallel.ForEach(owners, (owner) => { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Retrieving Owner's Content: {0}", owner.Email)); }, null); } SearchItems(service, owner, model, presenter); }); // compute folder size. if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Sorting Data...")); }, null); } // sort by email then by folder path model.Contents = model.Contents.OrderBy(s => s.Email).ThenBy(s => s.ItemPathDisplay).ToList(); ContentDisplayListViewItemModel currentFolderSelected = null; foreach (ContentDisplayListViewItemModel lvItem in model.Contents) { if (lvItem.ItemType.ToLower().Equals("folder")) { if (currentFolderSelected != null) { // had previously selected folder. currentFolderSelected.ItemSize = FileUtil.FormatFileSize(currentFolderSelected.ItemSizeByte); if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Calculating Folder Size: {0}", currentFolderSelected.ItemName)); }, null); } } currentFolderSelected = lvItem; } else if (lvItem.ItemType.ToLower().Equals("file")) { if (currentFolderSelected != null) { currentFolderSelected.ItemSizeByte += lvItem.ItemSizeByte; } } } } if (SyncContext != null) { TimeSpan diff = util.Stop(); SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IDataMigrationView, IDataMigrationModel>( ref view, model ); view.RenderContentSearchResult(); view.EnableExportControl(true); presenter.UpdateProgressInfo( string.Format("Completed. Total Content Count: {0} Elapsed Time: {1}", model.Contents.Count, TimerUtils.ToTimeStamp(diff)) ); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } }); search.Start(); } }
//need work private void OnCommandExportGroupPerms(object sender, System.EventArgs e) { IGroupsView view = base._view as IGroupsView; IGroupsModel model = base._model as IGroupsModel; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } Thread exportgroupperms = new Thread(() => { if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.EnableControl(true); presenter.ActivateSpinner(false); presenter.UpdateProgressInfo(""); }, null); } else { //need to get groups checked then get shared folders for each this.ExportGroups(model, presenter); this.ExportGroupPerms(model, presenter); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. PresenterBase.SetViewPropertiesFromModel <IGroupsView, IGroupsModel>( ref view, model ); string sPath = string.Empty; if (model.GroupPerms.Count > 0) { //create CSV file in My Documents folder sPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\GroupPermsExport.csv"; CsvConfiguration config = new CsvConfiguration() { HasHeaderRecord = true, Delimiter = ",", Encoding = System.Text.Encoding.UTF8 }; config.RegisterClassMap(new GroupPermsHeaderMap()); int total = model.GroupPerms.Count; using (CsvWriter writer = new CsvWriter(new StreamWriter(sPath), config)) { writer.WriteHeader <GroupPermsHeaderRecord>(); int count = 0; foreach (var item in model.GroupPerms) { writer.WriteField <string>(item.GroupName); writer.WriteField <string>(item.GroupId); writer.WriteField <string>(item.GroupManagementType); writer.WriteField <string>(item.GroupType); writer.WriteField <string>(item.SharedFolderName); writer.WriteField <string>(item.SharedFolderId); writer.WriteField <string>(item.IsMember); writer.WriteField <string>(item.IsOwner); writer.WriteField <string>(item.AccessType); writer.WriteField <string>(item.IsInherited); writer.WriteField <string>(item.IsTeamFolder); writer.WriteField <string>(item.IsInsideTeamFolder); count++; if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Writing Record: {0}/{1}", (count), total)); }, null); } writer.NextRecord(); } } if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Completed. Exported file located at " + sPath); }, null); } } if (model.GroupPerms.Count == 0) { presenter.UpdateProgressInfo("No groups were selected to export."); } presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); exportgroupperms.Start(); }