private string DeleteMemberGroup(IGroupsModel model, string email, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.DeleteMemberGroupUrl = ApplicationResource.ActionDeleteMemberGroup; service.UserAgentVersion = ApplicationResource.UserAgent; foreach (GroupListViewItemModel item in model.Groups.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.DeleteMemberGroup(new MemberData() { GroupId = item.GroupId, GroupName = item.GroupName }, email, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Deleted user [" + email + "] from group [" + item.GroupName + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_DELETE_MEMBER_FROM_GROUP; } } return(errorMessage); }
public ActionResult MakePayment(int myserviceid) { int userid = this._userTable.GetmemberId(User.Identity.Name); MemberServices memberServices = this._mySubscriptionRepo.GetSubscriptionDetail(myserviceid); return(View(memberServices)); }
public IActionResult LoadGameSelectionpage() { int memberId = (int)HttpContext.Session.GetInt32("memberId"); MemberServices ms = new MemberServices(); Member member = ms.GetMemberById(memberId); if (member is null) { throw new Exception("did not get member from database"); } if (member.OwnedGames is null) { member.OwnedGames = new List <Game>(); } if (member.LikeToPlayGames is null) { member.LikeToPlayGames = new List <Game>(); } member.OwnedGames = ms.GetMemberOwnedGames(memberId); GameChooseViewModel vm = new GameChooseViewModel(); vm.member = member; return(View("GameSelectionPage", vm)); }
private string CreateTeamFolder(ITeamFoldersModel model, string teamFolderName, IMainPresenter presenter) { string errorMessage = string.Empty; string fileAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.CreateTeamFolderUrl = ApplicationResource.ActionCreateTeamFolder; service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = service.CreateTeamFolder(teamFolderName, fileAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Created team folder [" + teamFolderName + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_CREATE_TEAMFOLDER; } return(errorMessage); }
private string DownloadPaperDocs(IPaperModel model, IPaperView view, IMainPresenter presenter) { string errorMessage = string.Empty; string outputFolder = view.OutputFolder; string fileAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.DownloadPaperDocUrl = ApplicationResource.ActionDownloadPaperDocs; service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = null; foreach (PaperListViewItemModel item in model.Paper) { if (item.IsChecked) { response = service.DownloadPaperDoc(item.MemberId, item.PaperId, outputFolder, item.PaperName, fileAccessToken); if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Downloaded Paper doc [" + item.PaperName + "]")); }, null); } } } return(errorMessage); }
private void metroButton1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtUserName.Text) || string.IsNullOrEmpty(txtPwd.Text)) { this.txtUserName.Focus(); MetroMessageBox.Show(this, "请输入用户名和密码", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } MemberLogin loginDto = new MemberLogin() { Pwd = txtPwd.Text, UserName = txtUserName.Text }; MemberServices mServices = new MemberServices(); var result = mServices.Login(loginDto); if (result.Code == ResultCodeEnums.Error) { MetroMessageBox.Show(this, result.Msg, "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.DialogResult = DialogResult.OK;//关键:设置登陆成功状态 this.Close(); } }
private string SetFolderStatus(ITeamFoldersModel model, string teamFolderId, bool activeSetting, IMainPresenter presenter) { string errorMessage = string.Empty; string fileAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); if (activeSetting) { service.ActivateTeamFolderUrl = ApplicationResource.ActionActivateTeamFolder; } if (!activeSetting) { service.ArchiveTeamFolderUrl = ApplicationResource.ActionArchiveTeamFolder; } service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = service.SetFolderStatus(teamFolderId, activeSetting, fileAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Updated team folder status for [" + teamFolderId + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_UPDATE_TEAM_FOLDER_STATUS; } return(errorMessage); }
private void RemoveFromAddButon_Click(object sender, RoutedEventArgs e) { MemberServices update = new MemberServices(); int i = update.RemoveFromPhotographer(removeId); addedListDataGrid.ItemsSource = update.SearchPhotogrpaherhData(); }
public ClassesController(ClassServices classServices, MemberServices memberServices) { log = this.Log(); log.Info("my message"); _classServices = classServices; _memberServices = memberServices; }
public void UpdateTitleBarTeamStats() { int licensed = 0; int provisioned = 0; string name = string.Empty; //do a call to get team info IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.GetInfoUrl = ApplicationResource.ActionGetInfo; service.UserAgentVersion = ApplicationResource.UserAgent; string AccessToken = ApplicationResource.DefaultAccessToken; IDataResponse response = service.GetInfo(AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data); name = jsonData["name"]; licensed = jsonData["num_licensed_users"]; provisioned = jsonData["num_provisioned_users"]; } } //get toolkit version and build title text string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.Text = "Dropbox Business Admin Toolkit v" + version + " Team: " + name + " Licensed Users: " + licensed.ToString() + " Provisioned Users: " + provisioned.ToString(); this.Update(); this.Refresh(); }
public ActionResult Delete(Member Member) { Member.MemberID = (int)TempData["MemberID"]; MemberServices services = new MemberServices(); services.DeleteMember(Member); return(RedirectToAction("Index")); }
private void PhotographyMemberButton_Click(object sender, RoutedEventArgs e) { MemberServices sr = new MemberServices(); MembersListGrid.ItemsSource = sr.PhotographerData("Photographer", "photographer"); MemberIdTextBox.Text = ""; MemberNameTextBox.Text = ""; }
private void StaffMemberButton_Click(object sender, RoutedEventArgs e) { MemberServices sr = new MemberServices(); MembersListGrid.ItemsSource = sr.StaffData("Staff", "staff"); MemberIdTextBox.Text = ""; MemberNameTextBox.Text = ""; }
private void AllMemberButton_Click(object sender, RoutedEventArgs e) { MemberServices sr = new MemberServices(); MembersListGrid.ItemsSource = sr.LoadData(); MemberIdTextBox.Text = ""; MemberNameTextBox.Text = ""; }
// GET: Payment public ActionResult Index(int myserviceid) { ViewBag.MemberServiceId = myserviceid; ViewBag.MemberId = this._userTable.GetmemberId(User.Identity.Name); MemberServices memberServices = this._mySubscriptionRepo.GetSubscriptionDetail(myserviceid); return(View(memberServices)); }
public SocietyController(UserManager <ApplicationUser> userManager, SocietyServices societyServices, ActivityServices activityServices, SocietyManagementSystemDbContext societyManagementSystemDbContext, MemberServices memberServices) { _userManager = userManager; _societyServices = societyServices; _activityServices = activityServices; _societyManagementSystemDbContext = societyManagementSystemDbContext; _memberServices = memberServices; }
public IActionResult FrontCreate(Member Member, IEncryption encryption) { MemberServices services = new MemberServices(); Member.MemberPassword = encryption.EncryptionMethod(Member.MemberPassword, Member.MemberName); services.CreateMember(Member); return(Redirect("/FrontEnd/Index")); }
private void ManagerMemberButton_Click(object sender, RoutedEventArgs e) { MemberServices sr = new MemberServices(); MembersListGrid.ItemsSource = sr.ManagerData("Manager", "manager"); MemberIdTextBox.Text = ""; MemberNameTextBox.Text = ""; }
private void MemberRemoveButton_Click(object sender, RoutedEventArgs e) { MemberServices sr = new MemberServices(); int i = sr.DeleteMember(MemberIdTextBox.Text, MemberNameTextBox.Text); MembersListGrid.ItemsSource = sr.LoadData(); MemberIdTextBox.Text = ""; MemberNameTextBox.Text = ""; }
private void SearchMembers(ITextSearchModel model) { if (!string.IsNullOrEmpty(model.QueryString) && !string.IsNullOrEmpty(model.AccessToken)) { MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ListMembersUrl = ApplicationResource.ActionListMembers; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.ListMembers(new MemberData() { SearchLimit = model.SearchResultsLimit }, model.AccessToken); IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject <dynamic>(data); // clear existing data first model.MemberList.Clear(); int resultCount = jsonData["members"].Count; for (int i = 0; i < resultCount; i++) { dynamic idObj = jsonData["members"][i]["profile"]["team_member_id"]; dynamic emailObj = jsonData["members"][i]["profile"]["email"]; string memberId = idObj.Value as string; string email = emailObj.Value as string; // update model MemberListViewItemModel lvItem = new MemberListViewItemModel() { Email = email, MemberId = memberId }; // perform file search if (!SearchFiles(service, memberId, model, email, presenter)) { model.MemberList.Add(lvItem); } SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Searching Content(s) From : {0}", email)); }, null); } } } else { // TODO: Report error } } }
public IActionResult Manage() { var viewModel = new MemberManageVm() { Members = MemberServices.GetActiveMembers() //Members = db.Members.ToList() }; return(View(viewModel)); }
private void AddToListButton_Click(object sender, RoutedEventArgs e) { MemberServices ms = new MemberServices(); int a = ms.AddtoPhotographer(searchId, searchName, searchConatact, searchEmail, searchDemand); if (a == 1) { addedListDataGrid.ItemsSource = ms.SearchPhotogrpaherhData(); } }
private void continueButton_Click(object sender, RoutedEventArgs e) { EventPhotography photography = new EventPhotography(); EventCalculation.date = Convert.ToDateTime(eventDateTextBox.Text); EventCalculation.eventDate = Convert.ToString(eventDateTextBox.Text); EventCalculation.eventStartTime = Convert.ToString(eventStartTimeTextBox.Text); photography.startTimeTextBox.Text = eventStartTimeTextBox.Text; Close(); MemberServices ms = new MemberServices(); photography.photographersDataGrid.ItemsSource = ms.PhotographerData("Photographer", "photographer"); photography.ShowDialog(); }
public IActionResult Edit(int id) { //var member = CorePracticeServices.GetMember(id); var member = MemberServices.GetMember(id); if (member != null) { return(View("MemberForm", new MemberVm(member, "edit"))); } else { return(RedirectToAction("Add")); } }
public IActionResult Delete(Members member) { member.IsActive = false; var result = MemberServices.UpdateMember(member); if (result.Equals(EnumServices.UpdateResult.success)) { return(Ok("Sucessfully deleted")); } else { return(BadRequest("Error Deleting")); } }
public IActionResult SaveMemberParams(Member newMember) { MemberServices memberService = new MemberServices(); string returnValue = memberService.SaveMember(newMember); if (returnValue.Equals("success")) { HttpContext.Session.SetInt32("memberId", newMember.MemberId); } return(Content(returnValue)); }
public ActionResult LineLogin() { var code = Request.QueryString ["code"]; if (string.IsNullOrEmpty(code)) { return(Content("沒有收到 Code")); } var url = HttpContext.Request.Url.Host; var token = Utility.GetTokenFromCodeLine(code, "1653659088", "27d426186987ed6e5d69cb7601129805", "https://" + url + "/FrontEnd/LineLogin"); var UserInfoResult = Utility.GetUserInfoLine(token.access_token, token.id_token); // 這邊不建議直接把 Token 當做參數傳給 CallAPI 可以避免 Token 洩漏 int i = 0; var email = UserInfoResult.email; var name = UserInfoResult.displayName; var password2 = UserInfoResult.userId; if (!item.Members.Any(x => x.MemberEmail == email)) { Member member = new Member(); MemberServices services = new MemberServices(); member.MemberPassword = Encryption.EncryptionMethod(password2, email); member.MemberName = name; member.MemberEmail = email; member.MemberGender = "Line"; member.MemberPhone = "Line"; services.CreateMember(member); } var membership = (from m in item.Members where m.MemberEmail == email select m).FirstOrDefault(); var password = Encryption.EncryptionMethod(password2, membership.MemberName); if (CheckAdmin(password2, password, "Admin")) { TempData["roles"] = "Admin"; } else { TempData["roles"] = "Client"; } LoginProcessmdfity("Client", membership.MemberName, true, membership); return(RedirectToAction("MemberPageAddresschange")); }
public ActionResult Create(Member Member) { var code = Request.QueryString["code"]; //Response.Write("<br/> code: " + code); //get token from code MemberServices services = new MemberServices(); Member.MemberPassword = Encryption.EncryptionMethod(Member.MemberPassword, Member.MemberName); services.CreateMember(Member); return(RedirectToAction("Index")); }
public ActionResult Charge(string stripeEmail, string stripeToken, MemberServices memberServices) { int userid = this._userTable.GetmemberId(User.Identity.Name); var memberServiceId = Request.Form["ServiceId"]; var customers = new CustomerService(); var charges = new ChargeService(); IEnumerable <MemberServices> allServices = this._mySubscriptionRepo.GetMySubscriptions(userid); string stripe_customerId = allServices.Where(a => !string.IsNullOrEmpty(a.StripeCustomerId)).Select(a => a.StripeCustomerId).FirstOrDefault(); if (string.IsNullOrEmpty(stripe_customerId)) { var customer = customers.Create(new CustomerCreateOptions { Email = stripeEmail, SourceToken = stripeToken }); stripe_customerId = customer.Id; } charges.ExpandBalanceTransaction = true; charges.ExpandCustomer = true; charges.ExpandInvoice = true; var charge = charges.Create(new ChargeCreateOptions { Amount = (Convert.ToInt32(memberServices.ServiceRate) * 100), Description = memberServices.ServiceType + " Charge", Currency = "usd", CustomerId = stripe_customerId, ReceiptEmail = stripeEmail, Metadata = new Dictionary <String, String>() { { "MemberId", memberServices.MemberId.ToString() }, { "ServiceId", memberServices.ServiceId.ToString() }, { "MemberName", memberServices.MemberName.ToString() }, { "ServiceType", memberServices.ServiceType.ToString() }, { "ServiceName", memberServices.ServiceName.ToString() }, } }); memberServices.StripeEmail = stripeEmail; memberServices.StripeToken = stripeToken; memberServices.StripeCustomerId = stripe_customerId; bool paid = this._mySubscriptionRepo.MakePaymentFor(memberServices); return(View(memberServices)); }
public ActionResult GoogleLogin() { var code = Request.QueryString ["code"]; if (string.IsNullOrEmpty(code)) { return(Content("沒有收到 Code")); } var token = Utility.GetTokenFromCode(code, "145015126077-5afcqbo9rc629k3ilceajnbfrlrdamlj.apps.googleusercontent.com", "At2kDe1L5weKB4Xf7dpf6rmx", "https://" + HttpContext.Request.Url.Host + "/FrontEnd/GoogleLogin"); var UserInfoResult = Utility.GetUserInfo(token.access_token); // 這邊不建議直接把 Token 當做參數傳給 CallAPI 可以避免 Token 洩漏 var email = UserInfoResult.email; var name = UserInfoResult.name; var password2 = UserInfoResult.id; if (!item.Members.Any(x => x.MemberEmail == email)) { Member member = new Member(); MemberServices services = new MemberServices(); member.MemberPassword = Encryption.EncryptionMethod(password2, email); member.MemberName = name; member.MemberEmail = email; member.MemberGender = "Google"; member.MemberPhone = "google"; services.CreateMember(member); } var membership = (from m in item.Members where m.MemberEmail == email select m).FirstOrDefault(); var password = Encryption.EncryptionMethod(password2, membership.MemberName); if (CheckAdmin(password2, password, "Admin")) { TempData["roles"] = "Admin"; } else { TempData["roles"] = "Client"; } LoginProcessmdfity("Client", membership.MemberName, true, membership); return(RedirectToAction("MemberPageAddresschange")); }
public GroupMeberServices( IRepository<group_member> GroupMemberRepository, MemberServices _MemberServices, GroupServices _GroupServices, PersonalMainPageServices _PersonalMainPageServices, NewsServices newsServices, IRepository<Group_Grade> GroupGradeRepository ) { this.GroupMemberRepository = GroupMemberRepository; this._MemberServices = _MemberServices; this._GroupServices = _GroupServices; this._PersonalMainPageServices = _PersonalMainPageServices; this.newsServices = newsServices; this.GroupGradeRepository = GroupGradeRepository; }
private void GetTeamFolders(ITeamFoldersModel model, IMainPresenter presenter) { IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ListTeamFolderUrl = ApplicationResource.ActionListTeamFolder; service.UserAgentVersion = ApplicationResource.UserAgent; string fileAccessToken = ApplicationResource.DefaultAccessToken; IDataResponse response = service.ListTeamFolders(fileAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); // clear existing data first model.TeamFolders.Clear(); //changed from entries to team_folders int resultCount = jsonData["team_folders"].Count; for (int i = 0; i < resultCount; i++) { dynamic team_folders = jsonData["team_folders"][i]; dynamic teamFolderName = team_folders["name"]; dynamic teamFolderId = team_folders["team_folder_id"]; dynamic status = team_folders["status"][".tag"]; // update model TeamFoldersListViewItemModel lvItem = new TeamFoldersListViewItemModel() { TeamFolderName = teamFolderName, TeamFolderId = teamFolderId, Status = status }; model.TeamFolders.Add(lvItem); } } } }
private string CreateGroup(IGroupsModel model, string groupName, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.CreateGroupUrl = ApplicationResource.ActionCreateGroup; service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = service.CreateGroup(groupName, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Created group [" + groupName + "]")); }, null); } } if (response.Message.Contains("group_name_already_used")) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(ErrorMessages.FAILED_TO_CREATE_GROUP_GROUP_EXISTS); }, null); } } if (response.Message.Contains("group_name_invalid")) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(ErrorMessages.FAILED_TO_CREATE_GROUP_GROUP_INVALID); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_CREATE_GROUP; } return errorMessage; }
private void GetGroups(IGroupsModel model, IMainPresenter presenter) { IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.GetGroupsUrl = ApplicationResource.ActionGetGroups; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.GetGroups(new MemberData() { }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); // clear existing data first model.Groups.Clear(); int resultCount = jsonData["groups"].Count; for (int i = 0; i < resultCount; i++) { dynamic groups = jsonData["groups"][i]; dynamic groupName = groups["group_name"]; dynamic groupId = groups["group_id"]; dynamic memberCount = groups["member_count"]; // update model GroupListViewItemModel lvItem = new GroupListViewItemModel() { GroupName = groupName, GroupId = groupId, MemberCount = memberCount }; model.Groups.Add(lvItem); } //if the group count is above limit - default 1000 we need to grab the cursor and call continue bool hasMore = jsonData["has_more"]; string cursor = jsonData["cursor"]; while (hasMore) { service.GetGroupsUrl = ApplicationResource.ActionGetGroupsContinuation; IDataResponse responseCont = service.GetGroups(new MemberData() { Cursor = cursor }, model.AccessToken); string dataCont = responseCont.Data.ToString(); dynamic jsonDataCont = JsonConvert.DeserializeObject<dynamic>(dataCont); int resultContCount = jsonDataCont["groups"].Count; for (int i = 0; i < resultContCount; i++) { dynamic groups = jsonDataCont["groups"][i]; dynamic groupName = groups["group_name"]; dynamic groupId = groups["group_id"]; dynamic memberCount = groups["member_count"]; // update model GroupListViewItemModel lvItem = new GroupListViewItemModel() { GroupName = groupName, GroupId = groupId, MemberCount = memberCount }; model.Groups.Add(lvItem); } hasMore = jsonDataCont["has_more"]; cursor = jsonDataCont["cursor"]; } } } }
private string CreateTeamFolder(ITeamFoldersModel model, string teamFolderName, IMainPresenter presenter) { string errorMessage = string.Empty; string fileAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.CreateTeamFolderUrl = ApplicationResource.ActionCreateTeamFolder; service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = service.CreateTeamFolder(teamFolderName, fileAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Created team folder [" + teamFolderName + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_CREATE_TEAMFOLDER; } return errorMessage; }
private string SetFolderStatus(ITeamFoldersModel model, string teamFolderId, bool activeSetting, IMainPresenter presenter) { string errorMessage = string.Empty; string fileAccessToken = ApplicationResource.DefaultAccessToken; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); if (activeSetting) { service.ActivateTeamFolderUrl = ApplicationResource.ActionActivateTeamFolder; } if (!activeSetting) { service.ArchiveTeamFolderUrl = ApplicationResource.ActionArchiveTeamFolder; } service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = service.SetFolderStatus(teamFolderId, activeSetting, fileAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Updated team folder status for [" + teamFolderId + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_UPDATE_TEAM_FOLDER_STATUS; } return errorMessage; }
private IList<TeamListViewItemModel> SearchOwner( IDataMigrationModel model, IMainPresenter presenter) { IList<TeamListViewItemModel> members = new List<TeamListViewItemModel>(); if (!string.IsNullOrEmpty(model.AccessToken)) { MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ListMembersUrl = ApplicationResource.ActionListMembers; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.ListMembers(new MemberData() { SearchLimit = ApplicationResource.SearchDefaultLimit }, model.AccessToken); if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Searching Owners..."); }, null); } if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); int resultCount = jsonData["members"].Count; int total = 0; for (int i = 0; i < resultCount; i++) { dynamic profile = jsonData["members"][i]["profile"]; dynamic idObj = profile["team_member_id"]; dynamic emailObj = profile["email"]; dynamic name = profile["name"]; dynamic status = profile["status"]; if (status != null && (status[".tag"].ToString().Equals("active") || status[".tag"].ToString().Equals("suspended"))) { string teamId = idObj.Value as string; string email = emailObj.Value as string; string firstName = name["given_name"].ToString(); string surName = name["surname"].ToString(); //string familiarName = name["familiar_name"] as string; //string displayName = name["display_name"] as string; // update model TeamListViewItemModel lvItem = new TeamListViewItemModel() { Email = email, TeamId = teamId, FirstName = firstName, LastName = surName }; members.Add(lvItem); } if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Scanning Account(s): " + (++total)); }, null); } } // collect more. bool hasMore = jsonData["has_more"]; string cursor = jsonData["cursor"]; while (hasMore) { service.ListMembersContinuationUrl = ApplicationResource.ActionListMembersContinuation; IDataResponse responseCont = service.ListMembersContinuation(new MemberData() { Cursor = cursor }, model.AccessToken); string dataCont = responseCont.Data.ToString(); dynamic jsonDataCont = JsonConvert.DeserializeObject<dynamic>(dataCont); int resultContCount = jsonDataCont["members"].Count; for (int i = 0; i < resultContCount; i++) { dynamic profile = jsonDataCont["members"][i]["profile"]; dynamic idObj = profile["team_member_id"]; dynamic emailObj = profile["email"]; dynamic name = profile["name"]; dynamic status = profile["status"]; string teamId = idObj.Value as string; string email = emailObj.Value as string; string firstName = name["given_name"].ToString(); string surName = name["surname"].ToString(); if (status != null && (status[".tag"].ToString().Equals("active") || status[".tag"].ToString().Equals("suspended"))) { // update model TeamListViewItemModel lvItem = new TeamListViewItemModel() { Email = email, TeamId = teamId, FirstName = firstName, LastName = surName }; members.Add(lvItem); } if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Scanning Account(s): " + (++total)); }, null); } } hasMore = jsonDataCont["has_more"]; cursor = jsonDataCont["cursor"]; } } } } return members; }
private string SetDefaultSyncSetting(ITeamFoldersModel model, string teamFolderId, bool syncSetting, IMainPresenter presenter) { string errorMessage = string.Empty; string fileAccessToken = ApplicationResource.DefaultAccessToken; string syncStringSetting = "sync"; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.SyncSettingTeamFolderUrl = ApplicationResource.ActionUpdateDefaultSyncSettingTeamFolder; if (!syncSetting) { syncStringSetting = "no_sync"; } service.UserAgentVersion = ApplicationResource.UserAgent; IServiceResponse response = service.SetFolderSyncSetting(teamFolderId, syncStringSetting, fileAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Updated default sync setting for [" + teamFolderId + "]")); }, null); } } if (response.StatusCode.ToString() == "BadRequest") { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo("Error: This endpoint is only available for teams with access to managed sync"); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_UPDATE_TEAM_FOLDER_STATUS; } return errorMessage; }
private void SearchMembersGetUsage(IProvisioningModel model) { string UserAccessToken = ApplicationResource.DefaultAccessToken; if (!string.IsNullOrEmpty(UserAccessToken)) { MemberServices serviceUsage = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); serviceUsage.GetUsageUrl = ApplicationResource.ActionGetUsage; List<string[]> members = new List<string[]>(); MemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.ListMembersUrl = ApplicationResource.ActionListMembers; service.UserAgentVersion = ApplicationResource.UserAgent; IDataResponse response = service.ListMembers(new MemberData() { SearchLimit = ApplicationResource.SearchDefaultLimit }, UserAccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); // clear existing data first model.Members.Clear(); int resultCount = jsonData["members"].Count; for (int i = 0; i < resultCount; i++) { dynamic emailObj = jsonData["members"][i]["profile"]["email"]; dynamic firstNameObj = jsonData["members"][i]["profile"]["name"]["given_name"]; dynamic lastNameObj = jsonData["members"][i]["profile"]["name"]["surname"]; dynamic idObj = jsonData["members"][i]["profile"]["team_member_id"]; string teamId = idObj.Value as string; string email = emailObj.Value as string; string firstName = firstNameObj.Value as string; string lastName = lastNameObj.Value as string; IDataResponse responseUsage = serviceUsage.GetUsage(new MemberData() { MemberId = teamId }, UserAccessToken); UInt64 used = 0; if (responseUsage.StatusCode == HttpStatusCode.OK) { if (responseUsage.Data != null) { string dataUsage = responseUsage.Data.ToString(); dynamic jsonDataUsage = JsonConvert.DeserializeObject<dynamic>(dataUsage); used = jsonDataUsage["used"]; } } // update model MemberListViewItemModel lvItem = new MemberListViewItemModel() { Email = email, MemberId = teamId, FirstName = firstName, LastName = lastName, Usage = FileUtil.FormatFileSizeMB(used) }; model.Members.Add(lvItem); } //if the memberID count is above limit - default 1000 we need to grab the cursor and call continue bool hasMore = jsonData["has_more"]; string cursor = jsonData["cursor"]; while (hasMore) { service.ListMembersContinuationUrl = ApplicationResource.ActionListMembersContinuation; IDataResponse responseCont = service.ListMembersContinuation(new MemberData() { Cursor = cursor }, UserAccessToken); string dataCont = responseCont.Data.ToString(); dynamic jsonDataCont = JsonConvert.DeserializeObject<dynamic>(dataCont); int resultContCount = jsonDataCont["members"].Count; for (int i = 0; i < resultContCount; i++) { dynamic emailObj = jsonDataCont["members"][i]["profile"]["email"]; dynamic firstNameObj = jsonDataCont["members"][i]["profile"]["name"]["given_name"]; dynamic lastNameObj = jsonDataCont["members"][i]["profile"]["name"]["surname"]; dynamic idObj = jsonData["members"][i]["profile"]["team_member_id"]; string teamId = idObj.Value as string; string email = emailObj.Value as string; string firstName = firstNameObj.Value as string; string lastName = lastNameObj.Value as string; IDataResponse responseUsage = serviceUsage.GetUsage(new MemberData() { MemberId = teamId }, UserAccessToken); decimal used = 0; if (responseUsage.StatusCode == HttpStatusCode.OK) { if (responseUsage.Data != null) { string dataUsage = responseUsage.Data.ToString(); dynamic jsonDataUsage = JsonConvert.DeserializeObject<dynamic>(dataUsage); used = jsonDataUsage["used"]; } } // update model MemberListViewItemModel lvItem = new MemberListViewItemModel() { Email = email, MemberId = teamId, FirstName = firstName, LastName = lastName, Usage = FileUtil.FormatFileSizeMB(used) }; model.Members.Add(lvItem); } hasMore = jsonDataCont["has_more"]; cursor = jsonDataCont["cursor"]; } } } } }
private string DeleteMemberGroup(IGroupsModel model, string email, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.DeleteMemberGroupUrl = ApplicationResource.ActionDeleteMemberGroup; service.UserAgentVersion = ApplicationResource.UserAgent; foreach (GroupListViewItemModel item in model.Groups.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.DeleteMemberGroup(new MemberData() { GroupId = item.GroupId, GroupName = item.GroupName }, email, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Deleted user [" + email + "] from group [" + item.GroupName + "]")); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_DELETE_MEMBER_FROM_GROUP; } } return errorMessage; }
private string UpdateProfile(IProvisioningModel model, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.SetProfileUrl = ApplicationResource.ActionSetProfile; service.UserAgentVersion = ApplicationResource.UserAgent; try { foreach (MemberListViewItemModel item in model.Members.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.SetProfile(new MemberData() { Email = item.Email, NewEmail = item.NewEmail, NewExternalId = item.NewExternalId }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Updated profile for: {0}", item.Email)); }, null); } } else if ((response.Message).Contains("user_not_found")) { errorMessage = ErrorMessages.USER_NOT_FOUND; } else if ((response.Message).Contains("user_not_in_team")) { errorMessage = ErrorMessages.USER_NOT_IN_TEAM; } else { errorMessage = ErrorMessages.FAILED_TO_UPDATE_PROFILE; } } } catch(Exception) { //just catch the exception and return error message SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_UPDATE_PROFILE, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return errorMessage; }
private string UnsuspendMember(IProvisioningModel model, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.UnSuspendMemberUrl = ApplicationResource.ActionUnsuspendMember; service.UserAgentVersion = ApplicationResource.UserAgent; try { foreach (MemberListViewItemModel item in model.Members.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.UnSuspendMember(new MemberData() { Email = item.Email }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Unsuspended Member: {0}", item.Email)); }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_UNSUSPEND_MEMBER; } } } catch (Exception) { // error message. SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_UNSUSPEND_MEMBER, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return errorMessage; }
private string ProvisionRoles(IProvisioningModel model, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.AddMemberUrl = ApplicationResource.ActionAddMember; service.UserAgentVersion = ApplicationResource.UserAgent; try { foreach (MemberListViewItemModel item in model.Members.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.AddMember(new MemberData() { Email = item.Email, FirstName = item.FirstName, LastName = item.LastName, SendWelcomeEmail = model.SendWelcomeEmail, ProvisionStatus = item.ProvisionStatus, RoleName = model.SelectedRole }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { if (response.Message.Contains("success")) { item.ProvisionStatus = "Provisioned successfully."; presenter.UpdateProgressInfo(string.Format("Added Member: {0}: {1} {2}", item.Email, item.FirstName, item.LastName)); } if (response.Message.Contains("team_license_limit")) { item.ProvisionStatus = "Team is already full.The organization has no available licenses."; presenter.UpdateProgressInfo("Team is already full. The organization has no available licenses."); } if (response.Message.Contains("free_team_member_limit_reached")) { item.ProvisionStatus = "Team is already full. The free team member limit has been reached."; presenter.UpdateProgressInfo("Team is already full. The free team member limit has been reached."); } if (response.Message.Contains("user_already_on_team")) { item.ProvisionStatus = "User is already on this team. The provided email address is associated with a user who is already a member of (including in recoverable state) or invited to the team."; presenter.UpdateProgressInfo("User is already on this team. The provided email address is associated with a user who is already a member of (including in recoverable state) or invited to the team."); } if (response.Message.Contains("user_on_another_team")) { item.ProvisionStatus = "User is already on another team. The provided email address is associated with a user that is already a member or invited to another team."; presenter.UpdateProgressInfo("User is already on another team. The provided email address is associated with a user that is already a member or invited to another team."); } if (response.Message.Contains("user_already_paired")) { item.ProvisionStatus = "User is already paired."; presenter.UpdateProgressInfo("User is already paired."); } if (response.Message.Contains("user_migration_failed")) { item.ProvisionStatus = "User migration has failed."; presenter.UpdateProgressInfo("User migration has failed."); } if (response.Message.Contains("duplicate_external_member_id")) { item.ProvisionStatus = "A user with the given external member ID already exists on the team (including in recoverable state)."; presenter.UpdateProgressInfo("A user with the given external member ID already exists on the team (including in recoverable state)."); } if (response.Message.Contains("user_creation_failed")) { item.ProvisionStatus = "User creation has failed."; presenter.UpdateProgressInfo("User creation has failed."); } }, null); } } else { errorMessage = ErrorMessages.FAILED_TO_ADD_MEMBER; } } } catch (Exception) { // error message. SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_ADD_MEMBER, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return errorMessage; }
public void UpdateTitleBarTeamStats() { int licensed = 0; int provisioned = 0; string name = string.Empty; //do a call to get team info IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.GetInfoUrl = ApplicationResource.ActionGetInfo; service.UserAgentVersion = ApplicationResource.UserAgent; string AccessToken = ApplicationResource.DefaultAccessToken; IDataResponse response = service.GetInfo(AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (response.Data != null) { string data = response.Data.ToString(); dynamic jsonData = JsonConvert.DeserializeObject<dynamic>(data); name = jsonData["name"]; licensed = jsonData["num_licensed_users"]; provisioned = jsonData["num_provisioned_users"]; } } //get toolkit version and build title text string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.Text = "Dropbox Business Admin Toolkit v" + version + " Team: " + name + " Licensed Users: " + licensed.ToString() + " Provisioned Users: " + provisioned.ToString(); this.Update(); this.Refresh(); }
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(s) Count: {0} Elapsed Time: {1}", model.Contents.Count, TimerUtils.ToTimeStamp(diff)) ); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } }); search.Start(); } }