public static ImportStatus GetStatus() { ImportFromBasecamp importd = null; lock (Imports.SynchRoot) { importd = Imports.GetItems().Where(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId). SingleOrDefault(); } if (importd == null) { lock (Completed) { //Maybe it's completed already importd = Completed.Where(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId). FirstOrDefault(); } } if (importd != null) { return(importd.Status); } throw new KeyNotFoundException("Import not found"); }
public static int Add(string url, string token, bool processClosed, bool disableNotifications) { lock (Imports.SynchRoot) { if (Imports.GetItems().Count(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId) > 0) { throw new DuplicateNameException("Import already running"); } } lock (Completed) { Completed.RemoveAll(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId); } SecurityContext.DemandPermissions(ASC.Core.Users.Constants.Action_AddRemoveUser); ProjectSecurity.DemandCreateProject(); var importTask = new ImportFromBasecamp(url, token, HttpContext.Current, SecurityContext.CurrentAccount.ID, processClosed, disableNotifications, Global.EngineFactory);//NOTE: engine factory newly created!!! lock (Imports.SynchRoot) { Imports.Add(importTask); } return(importTask.Id); }
public static IEnumerable <Project> GetProjects(string url, string userName, string password) { var basecampManager = BaseCamp.GetInstance(ImportFromBasecamp.PrepUrl(url).ToString().TrimEnd('/') + "/api/v1", userName, password); return(basecampManager.Projects.Select(r => new Project { ID = r.ID, Title = r.Name, Status = r.IsClosed ? ProjectStatus.Closed : ProjectStatus.Open }).ToList()); }
public bool Equals(ImportFromBasecamp other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other.Id == Id); }
public static int CheckUsersQuota(string url, string userName, string password) { var basecampManager = BaseCamp.GetInstance(ImportFromBasecamp.PrepUrl(url).ToString().TrimEnd('/') + "/api/v1", userName, password); var countImportedUsers = basecampManager.People.Count(); var remainingAmount = TenantExtra.GetRemainingCountUsers(); if (remainingAmount == 0) { return(0); } var difference = remainingAmount - countImportedUsers; return(difference >= 0 ? remainingAmount : -remainingAmount); }
public static int Add(string url, string userName, string password, bool processClosed, bool disableNotifications, bool importUsersAsCollaborators, IEnumerable <int> projects) { var status = GetStatus(); if (imports.GetItems().Count(x => x.Id == TenantProvider.CurrentTenantID) > 0 || (status.Started && !status.Completed)) { throw new DuplicateNameException("Import already running"); } SecurityContext.DemandPermissions(Constants.Action_AddRemoveUser); var importTask = new ImportFromBasecamp(url, userName, password, SecurityContext.CurrentAccount.ID, processClosed, disableNotifications, importUsersAsCollaborators, Global.EngineFactory, projects); imports.Add(importTask); return(importTask.Id); }
private static void DoImport(ImportFromBasecamp obj) { try { obj.StartImport(); NotifyClient.Instance.SendAboutImportComplite(obj.InitiatorId); } catch (Exception e) { obj.ImportError(e); } finally { obj.ImportComplete(); } }
public static int Add(string url, string userName, string password, bool processClosed, bool disableNotifications, bool importUsersAsCollaborators, IEnumerable<int> projects) { if (Imports.GetItems().Count(x => x.Id == TenantProvider.CurrentTenantID) > 0) throw new DuplicateNameException("Import already running"); lock (Completed) { Completed.RemoveAll(x => x.Id == TenantProvider.CurrentTenantID); } SecurityContext.DemandPermissions(Constants.Action_AddRemoveUser); var importTask = new ImportFromBasecamp(url, userName, password, SecurityContext.CurrentAccount.ID, processClosed, disableNotifications, importUsersAsCollaborators, Global.EngineFactory, projects); Imports.Add(importTask); return importTask.Id; }
public static ImportStatus GetStatus() { ImportFromBasecamp importd = Imports.GetItems().SingleOrDefault(x => x.Id == TenantProvider.CurrentTenantID); if (importd == null) { lock (Completed) { //Maybe it's completed already importd = Completed.FirstOrDefault(x => x.Id == TenantProvider.CurrentTenantID); Completed.RemoveAll(x => x.Id == TenantProvider.CurrentTenantID); } } if (importd != null) { return(importd.Status); } throw new KeyNotFoundException("Import not found"); //todo: return ImportStatus }
public static int Add(string url, string token, bool processClosed, bool disableNotifications) { lock (Imports.SynchRoot) { if (Imports.GetItems().Count(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId) > 0) throw new DuplicateNameException("Import already running"); } lock (Completed) { Completed.RemoveAll(x => x.Id == CoreContext.TenantManager.GetCurrentTenant().TenantId); } SecurityContext.DemandPermissions(ASC.Core.Users.Constants.Action_AddRemoveUser); ProjectSecurity.DemandCreateProject(); var importTask = new ImportFromBasecamp(url, token, HttpContext.Current, SecurityContext.CurrentAccount.ID, processClosed, disableNotifications, Global.EngineFactory);//NOTE: engine factory newly created!!! lock (Imports.SynchRoot) { Imports.Add(importTask); } return importTask.Id; }
private static void DoImport(ImportFromBasecamp obj) { try { obj.StartImport(); obj.Status.Completed = true; NotifyClient.Instance.SendAboutImportComplite(obj.InitiatorId); } catch (Exception e) { obj.Status.LogError(ImportResource.ImportFailed, e); obj.Status.Error = e; obj.LogError("generic error", e); } finally { obj.Status.CompletedAt = DateTime.Now; lock (Completed) { Completed.Add(obj); } } }
private static void DoImport(ImportFromBasecamp obj) { try { obj.StartImport(); obj.Status.Completed = true; NotifyClient.Instance.SendAboutImportComplite(obj.InitiatorId); } catch (Exception e) { obj.Status.LogError(SettingsResource.ImportFailed, e); obj.Status.Error = e.GetType().ToString(); obj.LogError("generic error", e); } finally { obj.Status.CompletedAt = DateTime.Now; lock (Completed) { Completed.Add(obj); } } }
public bool Equals(ImportFromBasecamp other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other.Id == Id; }