public ActionResult ImportFromAppHarbor(string Username, string Password) { if (null != HttpContext) { var user = database.Users.First(u => u.UserName == HttpContext.User.Identity.Name); ApplicationImporter a = new ApplicationImporter(); try { a.AuthenticateAs(Username, Password); var ret = a.GetProjects(); foreach (var p in ret) { a.SetProjectServiceHook(p.AppHarborProjectUrl, user.GetServiceHookUrl()); user.Projects.Add(p); } database.SaveChanges(); return(RedirectToAction("Index", "Account")); } catch (Exception e) { ViewData["import_error"] = e.Message == "NotAuthorized" ? "We could not log you in with those credentials" : "An error occurred. Please try again"; return(RedirectToAction("Index", new { Action = "Index", Controller = "Account", error = "Import" + e.Message })); } } return(RedirectToAction("Authorize", new { Controller = "Account" })); }
public JsonResult CheckServiceHookUrlStatus(string Id, string Username, string Password) { if (null != HttpContext) { var user = database.Users.FirstOrDefault(f => f.UserName == HttpContext.User.Identity.Name); ApplicationImporter a = new ApplicationImporter(); a.AuthenticateAs(Username, Password); var projects = a.GetProjects(); foreach (var p in projects) { if (a.DoesServiceHookExist(p.AppHarborProjectUrl, user.GetServiceHookUrl())) { return(Json(new JsonResultModel() { Success = true, Message = "OK" })); } else { return(Json(new JsonResultModel() { Success = true, Message = "NOT SET" })); } } } return(Json(new { Error = "Not and Http Request" })); }
public ActionResult DeleteAllServiceHooks(string Username, string Password) { if (null != HttpContext) { var user = database.Users.First(u => u.UserName == HttpContext.User.Identity.Name); if (!user.IsAdmin) { throw new SecurityException("Not authorized"); } ApplicationImporter a = new ApplicationImporter(); a.AuthenticateAs(Username, Password); a.DeleteAllServiceHooks(); } return(new EmptyResult()); }
protected override void EndProcessing() { Action <string, object> writeVerbose = (targetType, target) => WriteVerbose($"Exporting {CachedObjects.Objects.Count()} object(s) to {targetType} {target}"); switch (ParameterSetName) { case "ToPath": var path = GetUnresolvedProviderPathFromPSPath(Path); writeVerbose("path", path); this.WriteObjectIf(!PassThru, Directory ? CachedObjects.WriteToFolder(path) : CachedObjects.WriteToFile(path).AsEnumerable()); this.WriteObjectIf(PassThru, CachedObjects); break; case "ToTextWriter": writeVerbose("TextWriter", ""); CachedObjects.WriteToTextWriter(TextWriter ?? Console.Out); this.WriteObjectIf(PassThru, CachedObjects); break; case "ToStream": writeVerbose("Stream", ""); CachedObjects.WriteToStream(Stream); this.WriteObjectIf(PassThru, CachedObjects); break; case "ToDatabase": writeVerbose("database", Database); ApplicationImporter.Import(CachedObjects, DevClientPath ?? DefaultDevClientPath, ServerName, Database, ImportAction); if (AutoCompile) { ApplicationCompiler.Compile(CachedObjects, DevClientPath ?? DefaultDevClientPath, ServerName, Database); } this.WriteObjectIf(PassThru, CachedObjects); break; } }
public void TestApplicationImport() { ApplicationImporter a = new ApplicationImporter(); //TODO: Rewrite this test }
public ActionResult VerifyServiceHooks(string Username, string Password) { if (null != HttpContext) { var user = database.Users.First(u => u.TwitterUserName == HttpContext.User.Identity.Name); ApplicationImporter a = new ApplicationImporter(); try { a.AuthenticateAs(Username, Password); var ret = a.GetProjects(); foreach (var p in ret) { a.SetProjectServiceHook(p.AppHarborProjectUrl, user.GetServiceHookUrl()); } return RedirectToAction("Index", "Account"); } catch (Exception e) { ViewData["import_error"] = e.Message == "NotAuthorized" ? "We could not log you in with those credentials" : "An error occurred. Please try again"; return RedirectToAction("Index", new { Action = "Index", Controller = "Account", error = "Import" + e.Message }); } } return RedirectToAction("Authorize", new { Controller = "Account" }); }
public ActionResult DeleteAllServiceHooks(string Username, string Password) { if (null != HttpContext) { var user = database.Users.First(u => u.TwitterUserName == HttpContext.User.Identity.Name); if (!user.IsAdmin) { throw new SecurityException("Not authorized"); } ApplicationImporter a = new ApplicationImporter(); a.AuthenticateAs(Username, Password); a.DeleteAllServiceHooks(); } return new EmptyResult(); }
public JsonResult CheckServiceHookUrlStatus(string Id, string Username, string Password) { if (null != HttpContext) { var user = database.Users.FirstOrDefault(f => f.TwitterUserName == HttpContext.User.Identity.Name); ApplicationImporter a = new ApplicationImporter(); a.AuthenticateAs(Username, Password); var projects = a.GetProjects(); foreach (var p in projects) { if (a.DoesServiceHookExist(p.AppHarborProjectUrl, user.GetServiceHookUrl())) { return Json(new JsonResultModel() { Success = true, Message = "OK" }); } else { return Json(new JsonResultModel() { Success = true, Message = "NOT SET" }); } } } return Json(new { Error = "Not and Http Request" }); }