public static int Create(ReportDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("Report.Insert", sql, DataStoreKey); return(Convert.ToInt32(newId)); }
public static string Save(ReportDataModel data, string action, RequestProfile requestProfile) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.ReportInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.ReportUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, ReportDataModel.DataColumns.ReportId) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Name) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.Description) + ", " + ToSQLParameter(data, StandardDataModel.StandardDataColumns.SortOrder); return(sql); }
public async Task <IActionResult> Login(UserModel model) { //Login Logic here string email = string.Empty; string user = string.Empty; string name = string.Empty; int id = 0; #if DEBUG //Remove when login logic is available email = ""; user = ""; name = ""; id = 0; #endif // At this point you can optionally choose to check if the user has a report for the day by looking up their report by EmployeeId // You can then set the HasReport flag on the VM to display the previous report for the day ReportDataModel newReport = await _reportAccess.CreateReport(user, id, email); IndexViewModel indexViewModel = new IndexViewModel { ReportId = newReport.Id }; return(RedirectToAction("Index", indexViewModel)); }
protected override void ShowData(int reportId) { base.ShowData(reportId); oDetailButtonPanel.SetId = SetId; Clear(); var data = new ReportDataModel(); data.ReportId = reportId; var items = Framework.Components.Core.ReportDataManager.GetEntityDetails(data, SessionVariables.RequestProfile); if (items.Count == 1) { var item = items[0]; lblApplication.Text = item.Application; lblTitle.Text = item.Title; SetData(item); oUpdateInfo.LoadText(item.UpdatedDate, item.UpdatedBy, item.LastAction); oHistoryList.Setup(PrimaryEntity, reportId, "Report"); } }
public async Task <IActionResult> Login(UserModel model) { //Login Logic here string email = string.Empty; string user = string.Empty; string name = string.Empty; int id = 0; #if DEBUG //Remove when login logic is available email = ""; user = ""; name = ""; id = 0; #endif ReportDataModel newReport = await _reportAccess.CreateReport(user, id, email); IndexViewModel indexViewModel = new IndexViewModel { ReportId = newReport.Id, UserAdEmail = email, UserAdName = name, }; return(RedirectToAction("Index", indexViewModel)); }
public void LoadData(int ReportId, bool showId) { Clear(); var data = new ReportDataModel(); data.ReportId = ReportId; var items = Framework.Components.Core.ReportDataManager.GetEntityDetails(data, SessionVariables.RequestProfile); if (items.Count != 1) { return; } var item = items[0]; ReportTitle = item.Title; ApplicationId = item.ApplicationId; SetData(item); if (!showId) { SystemKeyId = item.ReportId; oHistoryList.Setup(PrimaryEntity, ReportId, PrimaryEntityKey); } else { CoreSystemKey.Text = String.Empty; } }
public async Task <IEnumerable <ReportDataModel> > GetTotalWorkingHoursBySupervisedProjectAsync(string projectSupervisorId) { var query = from p in _appDbContext.Project join pi in _appDbContext.Projectinfo on p.ProjectId equals pi.ProjectId into q1 from pi in q1 where p.AssignedByUserId == projectSupervisorId group new { p.ProjectId, p.Name, pi.HoursWorked } by new { p.ProjectId, p.Name } into q select new { q.Key, ProjectWorkingHours = q.Sum(c => c.HoursWorked) }; var queryResult = await query.OrderBy(c => c.ProjectWorkingHours).ToListAsync(); List <ReportDataModel> modelList = new List <ReportDataModel>(); for (int i = 0; i < queryResult.Count(); i++) { int totalWorkingHours = queryResult.ElementAt(i).ProjectWorkingHours; if (totalWorkingHours != 0) { ReportDataModel model = new ReportDataModel() { ProjectId = queryResult[i].Key.ProjectId, ProjectName = queryResult[i].Key.Name, TotalWorkingHours = totalWorkingHours }; modelList.Add(model); } } return(modelList); }
public override int?Save(string action) { var data = new ReportDataModel(); data.ReportId = SystemKeyId; data.Name = Name; data.Description = Description; data.Title = ReportTitle; data.SortOrder = SortOrder; data.ApplicationId = ApplicationId; if (action == "Insert") { var dtReport = Framework.Components.Core.ReportDataManager.DoesExist(data, SessionVariables.RequestProfile); if (dtReport.Rows.Count == 0) { Framework.Components.Core.ReportDataManager.Create(data, SessionVariables.RequestProfile); } else { throw new Exception("Record with given ID already exists."); } } else { Framework.Components.Core.ReportDataManager.Update(data, SessionVariables.RequestProfile); } return(data.ReportId); }
public static string ToSQLParameter(ReportDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case ReportDataModel.DataColumns.ReportId: if (data.ReportId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, ReportDataModel.DataColumns.ReportId, data.ReportId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ReportDataModel.DataColumns.ReportId); } break; case ReportDataModel.DataColumns.Title: if (!string.IsNullOrEmpty(data.Title)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ReportDataModel.DataColumns.Title, data.Title); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ReportDataModel.DataColumns.Title); } break; case BaseDataModel.BaseDataColumns.ApplicationId: if (data.ApplicationId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, BaseDataModel.BaseDataColumns.ApplicationId, data.ApplicationId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, BaseDataModel.BaseDataColumns.ApplicationId); } break; case ReportDataModel.DataColumns.Application: if (!string.IsNullOrEmpty(data.Application)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, ReportDataModel.DataColumns.Application, data.Application.Trim()); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, ReportDataModel.DataColumns.Application); } break; default: returnValue = StandardDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
private System.Data.DataTable GetData() { var data = new ReportDataModel(); var dt = Framework.Components.Core.ReportDataManager.Search(data, SessionVariables.RequestProfile); return(dt); }
private string UpdateReport(object data, int ID) { ReportDataModel report = jsonHelper.FromJson <ReportDataModel>(data.ToString()); if (!string.IsNullOrEmpty(jsonHelper.ErrorMessage)) { return(jsonHelper.ErrorMessage); } string result = "Error - No changes made"; List <ReportDataModel> existingReports = reportService.GetReports(); //Create list of existing reports ReportDataModel reportMatch = new ReportDataModel(); if (existingReports != null) { reportMatch = existingReports.Find(o => o.ReportID.Equals(ID)); if (reportMatch != null) //If report is found { report.ReportID = reportMatch.ReportID; if (reportService.UpdateReport(report)) { result = "Successfully updated report"; } } } return(result); }
public List <ReportDataModel> ReservationsData() { var data = new List <ReportDataModel>(); var reservations = _dbContext.Reservations .Where(r => r.DateTime.Year == DateTime.Now.Year) .Select(a => new { Description = a.Sitting.SittingType.Description }) .GroupBy(r => r.Description) .Select(group => new { Key = group.Key, Count = group.Count() }) .ToList(); foreach (var r in reservations) { var d = new ReportDataModel() { SittingType = r.Key, TotalReservation = r.Count }; data.Add(d); } return(data); }
public static List <ReportDataModel> GetEntityDetails(ReportDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.ReportSearch "; var parameters = new { AuditId = requestProfile.AuditId , ReportId = dataQuery.ReportId , ReturnAuditInfo = returnAuditInfo , Name = dataQuery.Name , Title = dataQuery.Title , Description = dataQuery.Description , CreatedDate = dataQuery.CreatedDate , ModifiedDate = dataQuery.ModifiedDate , CreatedByAuditId = dataQuery.CreatedByAuditId , ModifiedByAuditId = dataQuery.ModifiedByAuditId , ApplicationId = dataQuery.ApplicationId }; List <ReportDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <ReportDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
private int?[] BuildPeriodValues(ReportDataModel reportData) { var periodValues = new int?[] { null, null, null, null, null, null, null, null, null, null, null, null }; periodValues[reportData.OutcomeEffectiveDate.Month - 1] = reportData.Value; return(periodValues); }
protected override void Clear() { base.Clear(); var data = new ReportDataModel(); SetData(data); }
public static DataTable DoesExist(ReportDataModel data, RequestProfile requestProfile) { var doesExistRequest = new ReportDataModel(); doesExistRequest.Name = data.Name; return(Search(doesExistRequest, requestProfile)); }
public static DataTable GetDetails(ReportDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile); var table = list.ToDataTable(); return(table); }
protected override DataTable GetEntityData(int?entityKey) { var reportdata = new ReportDataModel(); reportdata.ReportId = entityKey; var results = Framework.Components.Core.ReportDataManager.Search(reportdata, SessionVariables.RequestProfile); return(results); }
public static DataSet GetChildren(ReportDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.ReportChildrenGet" + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(data, ReportDataModel.DataColumns.ReportId); var oDT = new Framework.Components.DataAccess.DBDataSet("Get Children", sql, DataStoreKey); return(oDT.DBDataset); }
protected override void Update(Dictionary <string, string> values) { var data = new ReportDataModel(); // copies properties from values dictionary object to data object PropertyMapper.CopyProperties(data, values); Framework.Components.Core.ReportDataManager.Update(data, SessionVariables.RequestProfile); base.Update(values); }
static public DataSet DeleteChildren(ReportDataModel data, RequestProfile requestProfile) { var sql = "EXEC dbo.ReportChildrenDelete " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(data, ReportDataModel.DataColumns.ReportId); var oDT = new DBDataSet("Report.DeleteChildren", sql, DataStoreKey); return(oDT.DBDataset); }
public static bool DoesExist(ReportDataModel data, RequestProfile requestProfile) { var doesExistRequest = new ReportDataModel(); doesExistRequest.ApplicationId = data.ApplicationId; doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
private void UpdateData(ArrayList values) { var data = new ReportDataModel(); data.ReportId = int.Parse(values[0].ToString()); data.Name = values[1].ToString(); data.Title = values[2].ToString(); data.Description = values[3].ToString(); data.SortOrder = int.Parse(values[4].ToString()); Framework.Components.Core.ReportDataManager.Update(data, SessionVariables.RequestProfile); ReBindEditableGrid(); }
public bool AddNewReport(ReportDataModel report) { bool result = false; if (report != null) { if (report.Date == null || report.Date == DateTime.MinValue) { report.Date = DateTime.Now; } string SqlQuery = "INSERT INTO Report (responseID, Name, Report_file, Date) VALUES (@responseID, @Name, @Report_file, @Date)"; try { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = new SqlCommand(SqlQuery, conn); if (SqlQuery.Length > 0) { command = new SqlCommand(SqlQuery, conn); command.Parameters.AddWithValue("@responseID", report.ResponseID); command.Parameters.AddWithValue("@Name", report.Name = report.Name ?? ""); command.Parameters.AddWithValue("@Report_file", report.ReportFile = report.ReportFile ?? ""); command.Parameters.AddWithValue("@Date", report.Date); } int sqlResult = command.ExecuteNonQuery(); result = sqlResult < 0 ? false : true; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception Caught - " + ex.Message); } } if (!result) { System.Diagnostics.Debug.WriteLine("Error - record not saved to database"); } return(result); }
public IActionResult Report() { ReportDataModel reportDataModel = new ReportDataModel(); var current = reportDataModel.CurrentC02Emmissions = 12; var potential = reportDataModel.PotentialC02Emmissions = 10; reportDataModel.CompareCurrentAndPotentialNumericalValues("C02 Emissions", current, potential); reportDataModel.CompareCurrentAndPotentialNumericalValues("Heating Costs", 100, 75); reportDataModel.CompareCurrentAndPotentialNumericalValues("Hot Water", 30, 10); reportDataModel.CompareCurrentAndPotentialNumericalValues("Energy Consumption", 100, 75); reportDataModel.CompareCurrentAndPotentialNumericalValues("Lighting Costs", 50, 30); List <Recommendation> recommendationList = reportDataModel.RecommendationsList; return(View(recommendationList)); }
public static bool IsDeletable(ReportDataModel data, RequestProfile requestProfile) { var isDeletable = true; var ds = GetChildren(data, requestProfile); if (ds != null && ds.Tables.Count > 0) { if (ds.Tables.Cast <DataTable>().Any(dt => dt.Rows.Count > 0)) { isDeletable = false; } } return(isDeletable); }
public static void Delete(ReportDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.ReportDelete "; var parameters = new { AuditId = requestProfile.AuditId , ReportId = data.ReportId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public bool UpdateReport(ReportDataModel report) { bool result = false; if (report != null) { if (report.Date == null || report.Date == DateTime.MinValue) { report.Date = DateTime.Now; } string SqlQuery = "UPDATE Report SET name = @name, report_file = @report_file, Date = @Date WHERE ReportID = " + report.ReportID; try { using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = CONNECTION_STRING; conn.Open(); SqlCommand command = new SqlCommand(SqlQuery, conn); if (SqlQuery.Length > 0) { command = new SqlCommand(SqlQuery, conn); command.Parameters.AddWithValue("@name", report.Name = report.Name ?? ""); command.Parameters.AddWithValue("@report_file", report.ReportFile = report.ReportFile ?? ""); command.Parameters.AddWithValue("@Date", report.Date); } int sqlResult = command.ExecuteNonQuery(); result = sqlResult < 0 ? false : true; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception Caught - " + ex.Message); } } if (!result) { System.Diagnostics.Debug.WriteLine("Error - record not updated in database"); } return(result); }
protected void btnDelete_Click(object sender, EventArgs e) { try { string[] deleteIndexList = DeleteIds.Split(','); foreach (string index in deleteIndexList) { var data = new ReportDataModel(); data.ReportId = int.Parse(index); Framework.Components.Core.ReportDataManager.Delete(data, SessionVariables.RequestProfile); DeleteAndRedirect(); } } catch (Exception ex) { Response.Write(ex.Message); } }
public static bool IsDeletable(ReportDataModel data, RequestProfile requestProfile) { var isDeletable = true; var ds = GetChildren(data, requestProfile); if (ds != null && ds.Tables.Count > 0) { foreach (DataTable dt in ds.Tables) { if (dt.Rows.Count > 0) { isDeletable = false; break; } } } return(isDeletable); }