private string DeprovisionRoles(IProvisioningModel model, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.RemoveMemberUrl = ApplicationResource.ActionRemoveMember; service.UserAgentVersion = ApplicationResource.UserAgent; try { foreach (MemberListViewItemModel item in model.Members.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.RemoveMember(new MemberData() { Email = item.Email, KeepAccount = model.KeepAccount }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Removed Member: {0}", item.Email)); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_REMOVE_MEMBER; } } } catch (Exception) { // error message. SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_REMOVE_MEMBER, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return errorMessage; }
private void DumpFiles(IDumpUserContentModel model, IMainPresenter presenter) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Preparing Download..."); }, null); } string ProvisionToken = ApplicationResource.DefaultProvisionToken; int counter = 0; int total = model.MemberList.Where(d => d.IsChecked && !string.IsNullOrEmpty(d.FileName)).ToList().Count; IMemberServices service = new MemberServices(ApplicationResource.ContentUrl, ApplicationResource.ApiVersion); service.FileDumpUrl = ApplicationResource.ActionFilesDownload; service.UserAgentVersion = ApplicationResource.UserAgent; foreach (TeamListViewItemModel lvItem in model.MemberList) { if (lvItem.IsChecked && !string.IsNullOrEmpty(lvItem.FileName)) { // notify progress if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Downloading File: {0}/{1}", ++counter, total)); }, null); } service.DumpFile( new MemberData() { Email = lvItem.Email, Path = lvItem.FilePath, FileName = lvItem.FileName, MemberId = lvItem.TeamId, ZipFiles = model.ZipFiles }, model.OutputFolder, model.UserAccessToken ); if (model.SuspendUser) { IMemberServices serviceSus = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); serviceSus.SuspendMemberUrl = ApplicationResource.ActionSuspendMember; serviceSus.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = serviceSus.SuspendMember(new MemberData() { Email = lvItem.Email }, ProvisionToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Suspended Member: {0}", lvItem.Email)); }, null); } } else { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format(ErrorMessages.FAILED_TO_SUSPEND_MEMBER)); }, null); } } } if (model.DeleteUser) { IMemberServices serviceDel = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); serviceDel.RemoveMemberUrl = ApplicationResource.ActionRemoveMember; serviceDel.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = serviceDel.RemoveMember(new MemberData() { Email = lvItem.Email, KeepAccount = model.KeepAccount }, ProvisionToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Removed Member: {0}", lvItem.Email)); }, null); } } else { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format(ErrorMessages.FAILED_TO_REMOVE_MEMBER)); }, null); } } } } } }