Esempio n. 1
0
 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" }));
 }
Esempio n. 2
0
 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" }));
 }
Esempio n. 3
0
        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
 }
Esempio n. 6
0
 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" });
 }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
 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" });
 }
Esempio n. 9
0
 public void TestApplicationImport()
 {
     ApplicationImporter a = new ApplicationImporter();
     //TODO: Rewrite this test
 }