public static GetConnection ( ) : Mono.Data.Sqlite.SqliteConnection | ||
Résultat | Mono.Data.Sqlite.SqliteConnection |
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); } }); }
public static ServiceModel GetCurrent() { ServiceModel m = new ServiceModel(); m.db = DataConnection.GetConnection(); return(m); }
internal static UserModel GetAdmin(int applicationId) { UserModel m = new UserModel(); m.db = DataConnection.GetConnection(); m.user = new User(); m.user.IsAdmin = true; m.application = m.db.SelectObjectById <Application> (applicationId); return(m); }
public static UserModel GetForUser(string login, string password, int appId) { UserModel m = new UserModel(); m.db = DataConnection.GetConnection(); if (appId != -1) { m.application = m.db.SelectObjectById <Application> (appId); } else if (Settings.Default.SupportsMultiApps) { string app = GetCurrentAppName(); if (app != null) { m.application = m.db.SelectObjectWhere <Application> ("Subdomain={0}", app); } } else { m.application = m.db.SelectObjects <Application> ().FirstOrDefault(); } ServiceModel sm = ServiceModel.GetCurrent(); if (!string.IsNullOrEmpty(login)) { m.user = sm.GetUser(login); if (password != null && !m.user.CheckPassword(password)) { m.user = null; } } sm.Dispose(); if (m.application != null && m.user != null) { UserApplication uap = m.db.SelectObjectWhere <UserApplication> ("UserId={0} AND ApplicationId={1}", m.user.Id, m.application.Id); m.isAdmin = (uap != null && (uap.Permissions & ApplicationPermission.Administer) != 0); } else { m.isAdmin = false; } return(m); }
public static Settings GetSettings() { using (var db = DataConnection.GetConnection()) { return(db.ReadSettings <Settings> ()); } }