Exemplo n.º 1
0
 public int GetProjectId(LoginInfo login, string name)
 {
     using (UserModel m = GetUserModel (login)) {
         var p = m.GetProjectByName (name);
         return p != null ? p.Id : -1;
     }
 }
Exemplo n.º 2
0
 public void DeleteAppRelease(LoginInfo login, AppReleaseInfo appRelease)
 {
     using (UserModel m = GetUserModel (login)) {
         var arel = m.GetAppRelease (appRelease.Id);
         m.DeleteAppRelease (arel.Id);
     }
 }
Exemplo n.º 3
0
 public AppReleaseInfo[] GetAppReleases(LoginInfo login)
 {
     List<AppReleaseInfo> list = new List<AppReleaseInfo> ();
     using (UserModel m = GetUserModel (login)) {
         foreach (AppRelease r in m.GetAppReleases ()) {
             list.Add (new AppReleaseInfo (m, r));
         }
         return list.ToArray ();
     }
 }
Exemplo n.º 4
0
 public SourceTagAddinInfo GetAddinInfo(LoginInfo login, string projectName, string targetAppVersion, string addinId, string version)
 {
     using (UserModel m = GetUserModel (login)) {
         int pid = GetProjectId (m, projectName);
         m.ValidateProject (pid);
         var s = m.GetProjectSourceTags (pid).FirstOrDefault (st => st.TargetAppVersion == targetAppVersion && st.AddinVersion == version && st.AddinId == addinId);
         if (s != null)
             return new SourceTagAddinInfo (s);
         else
             return null;
     }
 }
Exemplo n.º 5
0
 public string GetReleasePackageHash(LoginInfo login, int releaseId, string platform)
 {
     using (UserModel m = GetUserModel (login)) {
         var rel = m.GetRelease (releaseId);
         string file = rel.GetFilePath (platform);
         using (var f = System.IO.File.OpenRead (file)) {
             MD5 md5 = MD5.Create ();
             byte[] hash = md5.ComputeHash (f);
             return Convert.ToBase64String (hash);
         }
     }
 }
Exemplo n.º 6
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.º 7
0
 public SourceTagAddinInfo[] GetProjectSourceTags(LoginInfo login, string projectName)
 {
     using (UserModel m = GetUserModel (login)) {
         return m.GetProjectSourceTags (GetProjectId (m, projectName)).Select (r => new SourceTagAddinInfo (r)).ToArray ();
     }
 }
Exemplo n.º 8
0
 public ReleaseInfo[] GetProjectReleases(LoginInfo login, string projectName)
 {
     using (UserModel m = GetUserModel (login)) {
         return m.GetProjectReleases (GetProjectId(m, projectName)).Select (r => new ReleaseInfo (r)).ToArray ();
     }
 }
Exemplo n.º 9
0
 UserModel GetUserModel(LoginInfo login)
 {
     return UserModel.GetForUser (login.User, login.Password ?? "", login.AppId);
 }
Exemplo n.º 10
0
 public ReleaseInfo[] GetProjectReleases(LoginInfo login, string projectName)
 {
     using (UserModel m = GetUserModel(login)) {
         return(m.GetProjectReleases(GetProjectId(m, projectName)).Select(r => new ReleaseInfo(r)).ToArray());
     }
 }
Exemplo n.º 11
0
        public void UpdateAppRelease(LoginInfo login, AppReleaseInfo appRelease)
        {
            using (UserModel m = GetUserModel (login)) {
                var arel = m.GetAppRelease (appRelease.Id);
                if (arel == null)
                    throw new Exception ("Release not found: " + appRelease.Id);
                arel.AppVersion = appRelease.AppVersion;
                if (!string.IsNullOrEmpty (appRelease.CompatibleAppVersion)) {
                    var compatRel = m.GetAppReleases ().FirstOrDefault (r => r.AppVersion == appRelease.CompatibleAppVersion);
                    if (compatRel != null)
                        arel.CompatibleAppReleaseId = compatRel.Id;
                    else
                        throw new Exception ("Invalid compatible release number. Release '" + appRelease.CompatibleAppVersion + "' not found");
                } else
                    arel.CompatibleAppReleaseId = null;

                m.UpdateAppRelease (arel, null);
                Cydin.Builder.BuildService.UpdateRepositories (true);
            }
        }
Exemplo n.º 12
0
 public ReleaseInfo PublishAddin(LoginInfo login, int addinSourceId, DevStatus devStatus)
 {
     using (UserModel m = GetUserModel (login)) {
         var st = m.GetSourceTag (addinSourceId);
         if (st.DevStatus != devStatus) {
             st.DevStatus = devStatus;
             m.UpdateSourceTag (st);
         }
         return new ReleaseInfo (m.PublishRelease (addinSourceId));
     }
 }
Exemplo n.º 13
0
        public LoginInfo Login(string user, string password, string applicationName)
        {
            LoginInfo login = new LoginInfo ();
            login.User = user;
            login.Password = password;
            login.AppId = -1;

            using (UserModel m = GetUserModel (login)) {
                var app = m.GetApplications ().FirstOrDefault (a => a.Name == applicationName);
                if (app != null)
                    login.AppId = app.Id;
            }
            return login;
        }
Exemplo n.º 14
0
 public void RemoveAddinSourceTag(LoginInfo login, int addinSourceId)
 {
     using (UserModel m = GetUserModel (login)) {
         var st = m.GetSourceTag (addinSourceId);
         m.DeleteSourceTag (st);
     }
 }
Exemplo n.º 15
0
 public SourceTagAddinInfo[] GetProjectSourceTags(LoginInfo login, string projectName)
 {
     using (UserModel m = GetUserModel(login)) {
         return(m.GetProjectSourceTags(GetProjectId(m, projectName)).Select(r => new SourceTagAddinInfo(r)).ToArray());
     }
 }
Exemplo n.º 16
0
 public SourceTagAddinInfo UploadAddin(LoginInfo login, string projectName, string targetAppVersion, string[] platforms, byte[] fileContent)
 {
     using (UserModel m = GetUserModel (login)) {
         int pid = GetProjectId (m, projectName);
         m.ValidateProject (pid);
         return new SourceTagAddinInfo (m.UploadRelease (pid, fileContent, targetAppVersion, platforms));
     }
 }
Exemplo n.º 17
0
 public string GetSourceTagPackageHash(LoginInfo login, int sourceId, string platform)
 {
     using (UserModel m = GetUserModel (login)) {
         var rel = m.GetSourceTag (sourceId);
         string file = rel.GetFilePath (platform);
         using (var f = System.IO.File.OpenRead (file)) {
             MD5 md5 = MD5.Create ();
             byte[] hash = md5.ComputeHash (f);
             StringBuilder sb = new StringBuilder ();
             foreach (byte b in hash)
                 sb.Append (b.ToString ("x"));
             return sb.ToString ();
         }
     }
 }
Exemplo n.º 18
0
 UserModel GetUserModel(LoginInfo login)
 {
     return(UserModel.GetForUser(login.User, login.Password ?? "", login.AppId));
 }