public static bool HaveUserActivity(int tenantID, Guid productID, int action) { var q = new SqlQuery("webstudio_useractivity").Where("tenantid", tenantID); if (productID != default(Guid)) { q.Where("productid", productID.ToString()); } if (action != UserActivityConstants.AllActionType) { q.Where("actiontype", action); } using (var db = GetDbManager()) { return db.ExecuteScalar<int>(q.SelectCount()) > 0; } }
public static List<StatisticUser> GetUserStatisticForModules(string login, DateTime from, DateTime till) { using (var dbManager = new DbManager("tmresource")) { var sql = new SqlQuery("res_data as r1"); sql.SelectCount().Select(new[] {"concat_ws(':', res_files.projectName,res_files.moduleName)", "r1.authorLogin", "sum(length(r2.textvalue))"}) .InnerJoin("res_data as r2", Exp.And(Exp.EqColumns("r1.fileID", "r2.fileID"), Exp.EqColumns("r1.title", "r2.title"))) .InnerJoin("res_files", Exp.EqColumns("r1.fileid", "res_files.id")) .Where(!Exp.Eq("r1.flag", 4)) .Where(!Exp.Eq("r1.flag", 3)) .Where(!Exp.Eq("r1.authorLogin", "Console")) .Where(!Exp.Eq("r1.cultureTitle", "Neutral")) .Where(Exp.Ge("r1.timeChanges", from)) .Where(Exp.Le("r1.timeChanges", till)) .Where("r2.cultureTitle", "Neutral") .Where(Exp.Eq("r1.authorLogin", login)) .GroupBy(new[] {"r1.fileid", "r1.authorLogin"}) .OrderBy("r1.fileid", true) .OrderBy("r1.authorLogin", true); return dbManager.ExecuteList(sql).Select(r => new StatisticUser {WordsCount = Convert.ToInt32(r[0]), Module = (string)r[1], Login = (string)r[2], SignCount = Convert.ToInt32(r[3])}).ToList(); } }
public static List<StatisticUser> GetUserStatisticForLang(DateTime from, DateTime till) { using (var dbManager = new DbManager("tmresource")) { var sql = new SqlQuery("res_data as r1"); sql.SelectCount().Select(new[] {"res_cultures.title", "r1.authorLogin", "sum(length(r2.textvalue))"}) .InnerJoin("res_data as r2", Exp.And(Exp.EqColumns("r1.fileID", "r2.fileID"), Exp.EqColumns("r1.title", "r2.title"))) .InnerJoin("res_cultures", Exp.EqColumns("r1.cultureTitle", "res_cultures.title")) .Where(!Exp.Eq("r1.flag", 4)) .Where(!Exp.Eq("r1.flag", 3)) .Where(!Exp.Eq("r1.authorLogin", "Console")) .Where(!Exp.Eq("r1.cultureTitle", "Neutral")) .Where(Exp.Ge("r1.timeChanges", from)) .Where(Exp.Le("r1.timeChanges", till)) .Where("r2.cultureTitle", "Neutral") .GroupBy(new[] {"title", "authorLogin"}) .OrderBy("title", true) .OrderBy("authorLogin", true); return dbManager.ExecuteList(sql).ConvertAll(r => GetUserStatisticFromDB(r)); } }