Exemplo n.º 1
0
 public AppReleaseInfo(AppRelease r)
 {
     Id = r.Id;
     AppVersion = r.AppVersion;
     LastUpdateTime = r.LastUpdateTime;
     ZipUrl = "/Project/AppReleasePackage/" + Id;
 }
Exemplo n.º 2
0
 internal void UpdateAppRelease(AppRelease release, HttpPostedFileBase file)
 {
     CheckIsAdmin();
     UpdateAppReleaseFile(release, file);
     release.LastUpdateTime = DateTime.Now;
     db.UpdateObject(release);
 }
Exemplo n.º 3
0
        internal void UpdateAppReleaseFileFromUrl(AppRelease release, string url)
        {
            CheckIsAdmin();
            var rid = release.Id;

            System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                string file = Path.GetTempFileName();
                try {
                    System.Net.WebClient wc = new System.Net.WebClient();
                    wc.DownloadFile(url, file);

                    string filePath = release.ZipPath;
                    string dir      = Path.GetDirectoryName(filePath);

                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }

                    if (File.Exists(filePath))
                    {
                        File.Delete(filePath);
                    }
                    File.Move(file, filePath);

                    using (var db = DataConnection.GetConnection()) {
                        var r            = db.SelectObjectById <AppRelease> (rid);
                        r.LastUpdateTime = DateTime.Now;
                        db.UpdateObject(r);
                    }
                } finally {
                    File.Delete(file);
                }
            });
        }
Exemplo n.º 4
0
 public ActionResult UploadAssemblies(AppRelease release)
 {
     AppRelease rp = CurrentUserModel.GetAppRelease (release.Id);
     rp.AppVersion = release.AppVersion;
     rp.AddinRootVersion = release.AddinRootVersion;
     CurrentUserModel.UpdateAppRelease (rp, Request.Files.Count > 0 ? Request.Files[0] : null);
     return RedirectToAction ("Index", "Admin");
 }
 public ActionResult UpdateRelease(AppRelease release)
 {
     AppRelease rp = CurrentUserModel.GetAppRelease (release.Id);
     rp.AppVersion = release.AppVersion;
     rp.AddinRootVersion = release.AddinRootVersion;
     rp.CompatibleAppReleaseId = release.CompatibleAppReleaseId;
     if (release.ZipUrl != null)
         CurrentUserModel.UpdateAppReleaseFileFromUrl (rp, release.ZipUrl);
     else
         CurrentUserModel.UpdateAppRelease (rp, Request.Files.Count > 0 ? Request.Files[0] : null);
     return RedirectToAction ("Index", "Admin");
 }
Exemplo n.º 6
0
 public AppReleaseInfo(UserModel m, AppRelease r)
 {
     Id = r.Id;
     AppVersion = r.AppVersion;
     AddinRootVersion = r.AddinRootVersion;
     LastUpdateTime = r.LastUpdateTime;
     if (r.CompatibleAppReleaseId != null) {
         var cr = m.GetAppRelease (r.CompatibleAppReleaseId.Value);
         CompatibleAppVersion = cr.AppVersion;
     }
     ZipUrl = "/Project/AppReleasePackage/" + Id;
 }
Exemplo n.º 7
0
        void UpdateAppReleaseFile(AppRelease release, HttpPostedFileBase file)
        {
            if (file != null && file.ContentLength > 0)
            {
                string filePath = release.ZipPath;
                string dir      = Path.GetDirectoryName(filePath);

                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }

                file.SaveAs(filePath);
            }
        }
Exemplo n.º 8
0
 internal void CreateAppRelease(AppRelease release, HttpPostedFileBase file)
 {
     CheckIsAdmin();
     release.ApplicationId  = application.Id;
     release.LastUpdateTime = DateTime.Now;
     db.InsertObject(release);
     if (release.ZipUrl != null)
     {
         UpdateAppReleaseFileFromUrl(release, release.ZipUrl);
     }
     else
     {
         UpdateAppReleaseFile(release, file);
     }
 }
Exemplo n.º 9
0
 public void CreateAppRelease(LoginInfo login, string version, string addinsVersion, string compatibleVersion)
 {
     using (UserModel m = GetUserModel (login)) {
         AppRelease rel = new AppRelease ();
         rel.AppVersion = version;
         rel.AddinRootVersion = addinsVersion;
         if (!string.IsNullOrEmpty (compatibleVersion)) {
             var compatRel = m.GetAppReleases ().FirstOrDefault (r => r.AppVersion == compatibleVersion);
             if (compatRel != null)
                 rel.CompatibleAppReleaseId = compatRel.Id;
             else
                 throw new Exception ("Invalid compatible release number. Release '" + compatibleVersion + "' not found");
         }
         m.CreateAppRelease (rel, null);
     }
 }
Exemplo n.º 10
0
        internal void UpdateAppRelease(AppRelease release, HttpPostedFileBase file)
        {
            release.LastUpdateTime = DateTime.Now;
            db.UpdateObject (release);

            string filePath = release.ZipPath;
            string dir = Path.GetDirectoryName (filePath);

            if (!Directory.Exists (dir))
                Directory.CreateDirectory (dir);

            file.SaveAs (filePath);
        }
Exemplo n.º 11
0
 //
 // GET: /AppRelease/Create
 public ActionResult Create()
 {
     AppRelease rel = new AppRelease ();
     ViewData["Creating"] = true;
     return View("Edit", rel);
 }
Exemplo n.º 12
0
 public ActionResult CreateRelease(AppRelease release)
 {
     CurrentUserModel.CreateAppRelease (release, Request.Files.Count > 0 ? Request.Files[0] : null);
     return RedirectToAction ("Index", "Admin");
 }
Exemplo n.º 13
0
        void UpdateAppReleaseFile(AppRelease release, HttpPostedFileBase file)
        {
            if (file != null) {
                string filePath = release.ZipPath;
                string dir = Path.GetDirectoryName (filePath);

                if (!Directory.Exists (dir))
                    Directory.CreateDirectory (dir);

                file.SaveAs (filePath);
            }
        }
Exemplo n.º 14
0
 internal void UpdateAppRelease(AppRelease release, HttpPostedFileBase file)
 {
     CheckIsAdmin ();
     release.LastUpdateTime = DateTime.Now;
     db.UpdateObject (release);
     UpdateAppReleaseFile (release, file);
 }
Exemplo n.º 15
0
 internal void CreateAppRelease(AppRelease release, HttpPostedFileBase file)
 {
     CheckIsAdmin ();
     release.ApplicationId = application.Id;
     release.LastUpdateTime = DateTime.Now;
     db.InsertObject (release);
     UpdateAppReleaseFile (release, file);
 }
Exemplo n.º 16
0
 internal void CreateAppRelease(AppRelease release, HttpPostedFileBase file)
 {
     CheckIsAdmin ();
     release.ApplicationId = application.Id;
     release.LastUpdateTime = DateTime.Now;
     db.InsertObject (release);
     if (release.ZipUrl != null)
         UpdateAppReleaseFileFromUrl (release, release.ZipUrl);
     else
         UpdateAppReleaseFile (release, file);
 }
Exemplo n.º 17
0
        internal void UpdateAppReleaseFileFromUrl(AppRelease release, string url)
        {
            CheckIsAdmin ();
            var rid = release.Id;
            System.Threading.ThreadPool.QueueUserWorkItem (delegate {
                string file = Path.GetTempFileName ();
                try {
                    System.Net.WebClient wc = new System.Net.WebClient ();
                    wc.DownloadFile (url, file);

                    string filePath = release.ZipPath;
                    string dir = Path.GetDirectoryName (filePath);

                    if (!Directory.Exists (dir))
                        Directory.CreateDirectory (dir);

                    if (File.Exists (filePath))
                        File.Delete (filePath);
                    File.Move (file, filePath);

                    using (var db = DataConnection.GetConnection ()) {
                        var r = db.SelectObjectById<AppRelease> (rid);
                        r.LastUpdateTime = DateTime.Now;
                        db.UpdateObject (r);
                    }
                } finally {
                    File.Delete (file);
                }
            });
        }