public ReportTypeModel GetReportTypeModelWithUniqueCodeDB(string UniqueCode) { ReportTypeModel reportTypeModelRet = (from c in db.ReportTypes where c.UniqueCode == UniqueCode select new ReportTypeModel { Error = "", ReportTypeID = c.ReportTypeID, DBCommand = DBCommandEnum.Original, TVType = (TVTypeEnum)c.TVType, FileType = (FileTypeEnum)c.FileType, UniqueCode = c.UniqueCode, Language = (LanguageEnum)c.Language, Name = c.Name, Description = c.Description, StartOfFileName = c.StartOfFileName, LastUpdateDate_UTC = c.LastUpdateDate_UTC, LastUpdateContactTVItemID = c.LastUpdateContactTVItemID, }).FirstOrDefault <ReportTypeModel>(); if (reportTypeModelRet == null) { return(ReturnError(string.Format(ServiceRes.CouldNotFind_With_Equal_, ServiceRes.ReportType, ServiceRes.UniqueCode, UniqueCode))); } return(reportTypeModelRet); }
public static async Task <bool> ReportTypeExists(ReportTypeModel reportType) { using (SqlConnection dbConn = new SqlConnection(connectionString)) { var isReportTypeExist = "SELECT * from ReportType WHERE Name = '" + reportType.Name + "'"; SqlDataReader reader; try { dbConn.Open(); SqlCommand cmd = new SqlCommand(isReportTypeExist, dbConn); reader = await cmd.ExecuteReaderAsync(); if (reader.HasRows) { return(true); } else { return(false); } } catch (Exception ex) { reader = null; Console.WriteLine(ex); return(false); } finally { dbConn.Close(); } } }
public async Task <IHttpActionResult> AddNewReportType(ReportTypeModel reportType) { CommonResponse validatedResponse = await AuthService.ValidateUserAndToken(); if (!validatedResponse.IsError) { if (await ReportService.ReportTypeExists(reportType)) { return(BadRequest("Report Type Already Exists")); } else { var reportTypeTocreate = new ReportTypeModel { Name = reportType.Name }; CommonResponse roleResponse = await ReportService.AddNewReportType(reportTypeTocreate); if (roleResponse.IsError) { return(BadRequest("Error In Adding The New Report Type!")); } else { return(Ok("Successfully Added A New Report Type!")); } } } else { return(Unauthorized()); } }
public static async Task <CommonResponse> DeleteReportType(ReportTypeModel reportType) { CommonResponse response = new CommonResponse(); using (SqlConnection dbConn = new SqlConnection(connectionString)) { try { dbConn.Open(); SqlCommand cmd = new SqlCommand("SP_DeleteReportType", dbConn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@ReportType", reportType.Name); cmd.Parameters.AddWithValue("@ReportTypeID", reportType.ID); await cmd.ExecuteNonQueryAsync(); dbConn.Close(); response.IsError = false; } catch (Exception ex) { response.IsError = true; } finally { dbConn.Close(); } } return(response); }
public async Task <IHttpActionResult> DeleteReportType(ReportTypeModel reportType) { CommonResponse validatedResponse = await AuthService.ValidateUserAndToken(); if (!validatedResponse.IsError) { if (await ReportService.ReportTypeExistsForUpdateAndDelete(reportType.ID)) { var reportTypeToDelete = new ReportTypeModel { ID = reportType.ID, Name = reportType.Name }; CommonResponse roleResponse = await ReportService.DeleteReportType(reportTypeToDelete); if (roleResponse.IsError) { return(BadRequest("Error In Deleting The User Role!")); } else { return(Ok("User Role Deleted Successfully!")); } } else { return(BadRequest("User Role Does Not Exist!")); } } else { return(Unauthorized()); } }
// Check public string ReportTypeModelOK(ReportTypeModel reportTypeModel) { string retStr = _BaseEnumService.TVTypeOK(reportTypeModel.TVType); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.FileTypeOK(reportTypeModel.FileType); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = FieldCheckNotEmptyAndMaxLengthString(reportTypeModel.UniqueCode, ServiceRes.UniqueCode, 100); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.LanguageOK(reportTypeModel.Language); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } retStr = _BaseEnumService.DBCommandOK(reportTypeModel.DBCommand); if (!string.IsNullOrWhiteSpace(retStr)) { return(retStr); } return(""); }
public ReportTypeModel PostAddReportTypeDB(ReportTypeModel reportTypeModel) { string retStr = ReportTypeModelOK(reportTypeModel); if (!string.IsNullOrEmpty(retStr)) { return(ReturnError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } ReportTypeModel reportTypeModelExist = GetReportTypeModelWithUniqueCodeDB(reportTypeModel.UniqueCode); if (string.IsNullOrWhiteSpace(reportTypeModelExist.Error)) { return(ReturnError(string.Format(ServiceRes._AlreadyExists, ServiceRes.ReportType))); } ReportType reportTypeNew = new ReportType(); retStr = FillReportType(reportTypeNew, reportTypeModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } using (TransactionScope ts = new TransactionScope()) { db.ReportTypes.Add(reportTypeNew); retStr = DoAddChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } LogModel logModel = _LogService.PostAddLogForObj("ReportTypes", reportTypeNew.ReportTypeID, LogCommandEnum.Add, reportTypeNew); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } ts.Complete(); } return(GetReportTypeModelWithReportTypeIDDB(reportTypeNew.ReportTypeID)); }
public ReportTypeModel PostUpdateReportTypeDB(ReportTypeModel reportTypeModel) { string retStr = ReportTypeModelOK(reportTypeModel); if (!string.IsNullOrEmpty(retStr)) { return(ReturnError(retStr)); } ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } ReportType reportTypeToUpdate = GetReportTypeWithReportTypeIDDB(reportTypeModel.ReportTypeID); if (reportTypeToUpdate == null) { return(ReturnError(string.Format(ServiceRes.CouldNotFind_ToUpdate, ServiceRes.ReportType))); } retStr = FillReportType(reportTypeToUpdate, reportTypeModel, contactOK); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } using (TransactionScope ts = new TransactionScope()) { retStr = DoUpdateChanges(); if (!string.IsNullOrWhiteSpace(retStr)) { return(ReturnError(retStr)); } LogModel logModel = _LogService.PostAddLogForObj("ReportTypes", reportTypeToUpdate.ReportTypeID, LogCommandEnum.Change, reportTypeToUpdate); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } ts.Complete(); } return(GetReportTypeModelWithReportTypeIDDB(reportTypeToUpdate.ReportTypeID)); }
public static void UpdateReportType(ReportTypeModel reportTypeModel) { using (ctaDBEntities entities = new ctaDBEntities()) { Report_Type st = entities.Report_Type.Where(s => s.Id == reportTypeModel.Id).FirstOrDefault(); if (st != null) { st.name = reportTypeModel.name; st.active = reportTypeModel.active; entities.SaveChanges(); } if (!(entities.Database.Connection.State == ConnectionState.Closed)) { entities.Database.Connection.Close(); } } }
public static void CreateReportType(ref ReportTypeModel reportTypeModel) { using (ctaDBEntities entities = new ctaDBEntities()) { Report_Type st = new Report_Type() { name = reportTypeModel.name, active = reportTypeModel.active }; entities.Report_Type.Add(st); entities.SaveChanges(); reportTypeModel.Id = st.Id; if (!(entities.Database.Connection.State == ConnectionState.Closed)) { entities.Database.Connection.Close(); } } }
public JsonResult Edit(ReportTypeModel reporttype) { try { if (reporttype.Id > 0) { ReportTypeService.UpdateReportType(reporttype); } else { ReportTypeService.CreateReportType(ref reporttype); } return(Json(new { Status = "OK", ItemId = reporttype.Id }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Status = "ERROR", ItemId = 0 }, JsonRequestBehavior.AllowGet)); } }
public PartialViewResult _reportSectionList(int ReportTypeID) { ViewBag.ReportTypeController = _ReportTypeController; ViewBag.ReportTypeModel = null; ViewBag.ReportSectionYearList = null; ViewBag.ReportSectionModelList = null; ReportTypeModel reportTypeModel = _ReportTypeService.GetReportTypeModelWithReportTypeIDDB(ReportTypeID); ViewBag.ReportTypeModel = reportTypeModel; List <int?> reportSectionYearList = _ReportSectionService.GetReportSectionYearListWithReportTypeIDDB(ReportTypeID); ViewBag.ReportSectionYearList = reportSectionYearList; List <ReportSectionModel> reportSectionModelList = _ReportSectionService.GetReportSectionModelListWithReportTypeIDAndTVItemIDNoReportSectionTextDB(ReportTypeID, null); ViewBag.ReportSectionModelList = reportSectionModelList; return(PartialView()); }
public static async Task <List <ReportTypeModel> > GetReportTypes() { List <ReportTypeModel> ReportTypes = new List <ReportTypeModel>(); using (SqlConnection dbConn = new SqlConnection(connectionString)) { SqlDataReader reader; try { dbConn.Open(); SqlCommand cmd = new SqlCommand("SP_GetReportTypes", dbConn); cmd.CommandType = CommandType.StoredProcedure; reader = await cmd.ExecuteReaderAsync(); if (reader.HasRows) { while (reader.Read()) { ReportTypeModel reportItem = new ReportTypeModel(); reportItem.ID = reader.GetInt32(0); reportItem.Name = reader.GetString(1); reportItem.DateAdded = reader.GetDateTime(2); ReportTypes.Add(reportItem); } } } catch (Exception ex) { ReportTypes = null; } finally { dbConn.Close(); } return(ReportTypes); } }
// Fill public string FillReportType(ReportType reportType, ReportTypeModel reportTypeModel, ContactOK contactOK) { reportType.DBCommand = (int)reportTypeModel.DBCommand; reportType.ReportTypeID = reportTypeModel.ReportTypeID; reportType.TVType = (int)reportTypeModel.TVType; reportType.FileType = (int)reportTypeModel.FileType; reportType.UniqueCode = reportTypeModel.UniqueCode; reportType.Language = (int)reportTypeModel.Language; reportType.Name = reportTypeModel.Name; reportType.Description = reportTypeModel.Description; reportType.StartOfFileName = reportTypeModel.StartOfFileName; reportType.LastUpdateDate_UTC = DateTime.UtcNow; if (contactOK == null) { reportType.LastUpdateContactTVItemID = 2; } else { reportType.LastUpdateContactTVItemID = contactOK.ContactTVItemID; } return(""); }
private bool GenerateHTMLSubsectorMWQMSites(FileInfo fi, StringBuilder sbHTML, string parameters, ReportTypeModel reportTypeModel) { string NotUsed = ""; int TVItemID = 0; Random random = new Random(); string FileNameExtra = ""; for (int i = 0; i < 10; i++) { FileNameExtra = FileNameExtra + (char)random.Next(97, 122); } _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 3); if (!GetTopHTML(sbHTML)) { return(false); } List <string> ParamValueList = parameters.Split("|||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); if (!int.TryParse(GetParameters("TVItemID", ParamValueList), out TVItemID)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind__, TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotFind__", TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); return(false); } TVItemModel tvItemModelSubsector = _TVItemService.GetTVItemModelWithTVItemIDDB(TVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelSubsector.Error)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind_With_Equal_, TaskRunnerServiceRes.TVItem, TaskRunnerServiceRes.TVItemID, TVItemID.ToString()); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat3List("CouldNotFind_With_Equal_", TaskRunnerServiceRes.TVItem, TaskRunnerServiceRes.TVItemID, TVItemID.ToString()); return(false); } string ServerPath = _TVFileService.GetServerFilePath(tvItemModelSubsector.TVItemID); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 5); List <TVItemModel> tvItemModelListMWQMSites = _TVItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModelSubsector.TVItemID, TVTypeEnum.MWQMSite).Where(c => c.IsActive == true).ToList(); List <MWQMSiteModel> mwqmSiteModelList = _MWQMSiteService.GetMWQMSiteModelListWithSubsectorTVItemIDDB(TVItemID); List <MWQMRunModel> mwqmRunModelList = _MWQMRunService.GetMWQMRunModelListWithSubsectorTVItemIDDB(TVItemID); List <MWQMSampleModel> mwqmSampleModelList = _MWQMSampleService.GetMWQMSampleModelListWithSubsectorTVItemIDDB(TVItemID); sbHTML.AppendLine($@" <h3>{ TaskRunnerServiceRes.MWQMSiteSampleDataAvailability }</h3>"); sbHTML.AppendLine($@" <table cellpadding=""5"">"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <th>{ TaskRunnerServiceRes.Site }</th>"); bool FirstHit = false; for (int year = DateTime.Now.Year; year > 1975; year--) { if (year % 5 == 0) { FirstHit = true; int colSpan = 5; if (year == 1980) { colSpan = 4; } sbHTML.AppendLine($@" <th class=""textAlignLeftAndLeftBorder"" colspan=""{ colSpan }"">{ year }</th>"); } if (!FirstHit) { sbHTML.AppendLine($@" <th> </th>"); } } sbHTML.AppendLine($@" </tr>"); int countSite = 0; foreach (MWQMSiteModel mwqmSiteModel in mwqmSiteModelList) { TVItemModel tvItemModel = tvItemModelListMWQMSites.Where(c => c.TVItemID == mwqmSiteModel.MWQMSiteTVItemID).FirstOrDefault(); if (tvItemModel != null) { if (tvItemModel.IsActive) { countSite += 1; string bottomClass = ""; if (countSite % 5 == 0) { bottomClass = "bottomBorder"; } sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""{ bottomClass }"">{ mwqmSiteModel.MWQMSiteTVText }</td>"); for (int year = DateTime.Now.Year; year > 1979; year--) { string leftClass = year % 5 == 0 ? "leftBorder" : ""; bool hasSamples = mwqmSampleModelList.Where(c => c.MWQMSiteTVItemID == mwqmSiteModel.MWQMSiteTVItemID && c.SampleDateTime_Local.Year == year && c.SampleTypesText.Contains(((int)SampleTypeEnum.Routine).ToString())).Any(); if (hasSamples) { if (leftClass != "") { if (bottomClass != "") { sbHTML.AppendLine($@" <td class=""bggreenfLeftAndBottomBorder""> </td>"); } else { sbHTML.AppendLine($@" <td class=""bggreenfLeftBorder""> </td>"); } } else { if (bottomClass != "") { sbHTML.AppendLine($@" <td class=""bggreenfBottomBorder""> </td>"); } else { sbHTML.AppendLine($@" <td class=""bggreenf""> </td>"); } } } else { if (leftClass != "") { if (bottomClass != "") { sbHTML.AppendLine($@" <td class=""leftAndBottomBorder""> </td>"); } else { sbHTML.AppendLine($@" <td class=""leftBorder""> </td>"); } } else { if (bottomClass != "") { sbHTML.AppendLine($@" <td class=""bottomBorder""> </td>"); } else { sbHTML.AppendLine($@" <td> </td>"); } } } } sbHTML.AppendLine($@" </tr>"); } } } sbHTML.AppendLine($@" </table>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 10); // --------------------------------------------------------------------------------------------- // MWQM Sites Summary // --------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------ // doing number of sites by year //------------------------------------------------------------------------------ List <int> YearList = new List <int>(); List <int> CountPerYear = new List <int>(); for (int i = 1980; i < DateTime.Now.Year + 1; i++) { YearList.Add(i); int count = (from s in mwqmSiteModelList from samp in mwqmSampleModelList where s.MWQMSiteTVItemID == samp.MWQMSiteTVItemID && samp.SampleDateTime_Local.Year == i select s.MWQMSiteTVItemID).Distinct().Count(); CountPerYear.Add(count); } Microsoft.Office.Interop.Excel._Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook workbook = xlApp.Workbooks.Add(); Microsoft.Office.Interop.Excel.Worksheet worksheet = workbook.Worksheets.get_Item(1); Microsoft.Office.Interop.Excel.ChartObjects xlCharts = (Microsoft.Office.Interop.Excel.ChartObjects)worksheet.ChartObjects(); Microsoft.Office.Interop.Excel.ChartObject chart = xlCharts.Add(100, 100, 600, 200); Microsoft.Office.Interop.Excel.Chart chartPage = chart.Chart; chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered; Microsoft.Office.Interop.Excel.SeriesCollection seriesCollection = chartPage.SeriesCollection(); Microsoft.Office.Interop.Excel.Series series = seriesCollection.NewSeries(); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 40); series.XValues = YearList.ToArray(); series.Values = CountPerYear.ToArray(); chartPage.ApplyLayout(9, Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered); chartPage.ChartTitle.Select(); xlApp.Selection.Delete(); chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue).AxisTitle.Select(); xlApp.Selection.Delete(); chartPage.Legend.Select(); xlApp.Selection.Delete(); //chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory).TickLabelSpacing = 5; chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory).MajorTickMark = Microsoft.Office.Interop.Excel.Constants.xlOutside; chartPage.Parent.RoundedCorners = true; chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = TaskRunnerServiceRes.NumberOfMWQMSitesByYear; // need to save the file with a unique name under the TVItemID FileInfo fiImageNumberOfSitesByYearStat = new FileInfo(fi.DirectoryName + @"\NumberOfSitesByYearStat" + FileNameExtra + ".png"); DirectoryInfo di = new DirectoryInfo(fi.DirectoryName); if (!di.Exists) { try { di.Create(); } catch (Exception ex) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotCreateDirectory__, di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotCreateDirectory__", di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); return(false); } } chartPage.Export(fiImageNumberOfSitesByYearStat.FullName, "PNG", false); //------------------------------------------------------------------------------ // doing number of runs by year //------------------------------------------------------------------------------ YearList = new List <int>(); CountPerYear = new List <int>(); for (int i = 1980; i < DateTime.Now.Year + 1; i++) { YearList.Add(i); int count = (from r in mwqmRunModelList from samp in mwqmSampleModelList where r.MWQMRunTVItemID == samp.MWQMRunTVItemID && samp.SampleDateTime_Local.Year == i select r.MWQMRunTVItemID).Distinct().Count(); CountPerYear.Add(count); } chart = xlCharts.Add(100, 100, 600, 200); chartPage = chart.Chart; chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered; seriesCollection = chartPage.SeriesCollection(); series = seriesCollection.NewSeries(); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 40); series.XValues = YearList.ToArray(); series.Values = CountPerYear.ToArray(); chartPage.ApplyLayout(9, Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered); chartPage.ChartTitle.Select(); xlApp.Selection.Delete(); chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue).AxisTitle.Select(); xlApp.Selection.Delete(); chartPage.Legend.Select(); xlApp.Selection.Delete(); //chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory).TickLabelSpacing = 5; chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory).MajorTickMark = Microsoft.Office.Interop.Excel.Constants.xlOutside; chartPage.Parent.RoundedCorners = true; chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = TaskRunnerServiceRes.NumberOfMWQMRunsByYear; // need to save the file with a unique name under the TVItemID FileInfo fiImageNumberOfRunsByYearStat = new FileInfo(fi.DirectoryName + @"\NumberOfRunsByYearStat" + FileNameExtra + ".png"); di = new DirectoryInfo(fi.DirectoryName); if (!di.Exists) { try { di.Create(); } catch (Exception ex) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotCreateDirectory__, di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotCreateDirectory__", di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); return(false); } } chartPage.Export(fiImageNumberOfRunsByYearStat.FullName, "PNG", false); //------------------------------------------------------------------------------ // doing number of samples by year //------------------------------------------------------------------------------ YearList = new List <int>(); CountPerYear = new List <int>(); for (int i = 1980; i < DateTime.Now.Year + 1; i++) { YearList.Add(i); int count = (from samp in mwqmSampleModelList where samp.SampleDateTime_Local.Year == i select samp.MWQMSampleID).Distinct().Count(); CountPerYear.Add(count); } chart = xlCharts.Add(100, 100, 600, 200); chartPage = chart.Chart; chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered; seriesCollection = chartPage.SeriesCollection(); series = seriesCollection.NewSeries(); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 40); series.XValues = YearList.ToArray(); series.Values = CountPerYear.ToArray(); chartPage.ApplyLayout(9, Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered); chartPage.ChartTitle.Select(); xlApp.Selection.Delete(); chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue).AxisTitle.Select(); xlApp.Selection.Delete(); chartPage.Legend.Select(); xlApp.Selection.Delete(); //chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory).TickLabelSpacing = 5; chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory).MajorTickMark = Microsoft.Office.Interop.Excel.Constants.xlOutside; chartPage.Parent.RoundedCorners = true; chartPage.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = TaskRunnerServiceRes.NumberOfSamplesByYear; // need to save the file with a unique name under the TVItemID FileInfo fiImageNumberOfSamplesByYearStat = new FileInfo(fi.DirectoryName + @"\NumberOfSamplesByYearStat" + FileNameExtra + ".png"); di = new DirectoryInfo(fi.DirectoryName); if (!di.Exists) { try { di.Create(); } catch (Exception ex) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotCreateDirectory__, di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotCreateDirectory__", di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); return(false); } } chartPage.Export(fiImageNumberOfSamplesByYearStat.FullName, "PNG", false); if (workbook != null) { workbook.Close(false); } if (xlApp != null) { xlApp.Quit(); } sbHTML.AppendLine($@" <h3>{ TaskRunnerServiceRes.MWQMSitesSummary }</h3>"); sbHTML.AppendLine($@" <br /"); sbHTML.AppendLine($@" <h4>{ TaskRunnerServiceRes.NumberOfMWQMSitesByYear }</h4>"); sbHTML.AppendLine($@"<div class=""textAlignCenter"">|||Image|FileName,{ fiImageNumberOfSitesByYearStat.FullName }|width,400|height,150|||</div>"); sbHTML.AppendLine($@" <h4>{ TaskRunnerServiceRes.NumberOfMWQMRunsByYear }</h4>"); sbHTML.AppendLine($@"<div class=""textAlignCenter"">|||Image|FileName,{ fiImageNumberOfRunsByYearStat.FullName }|width,400|height,150|||</div>"); sbHTML.AppendLine($@" <h4>{ TaskRunnerServiceRes.NumberOfSamplesByYear }</h4>"); sbHTML.AppendLine($@"<div class=""textAlignCenter"">|||Image|FileName,{ fiImageNumberOfSamplesByYearStat.FullName }|width,400|height,150|||</div>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 40); sbHTML.AppendLine($@" <h3>{ TaskRunnerServiceRes.MWQMSitesInformation }</h3>"); sbHTML.AppendLine($@" <table cellpadding=""5"" class=""textAlignCenter"">"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <th colspan=""2"">{ TaskRunnerServiceRes.Site }</th>"); sbHTML.AppendLine($@" <th>{ TaskRunnerServiceRes.Coordinates }</th>"); sbHTML.AppendLine($@" <th>{ TaskRunnerServiceRes.Description }</th>"); sbHTML.AppendLine($@" <th>{ TaskRunnerServiceRes.Photos }</th>"); sbHTML.AppendLine($@" </tr>"); foreach (MWQMSiteModel mwqmSiteModel in mwqmSiteModelList) { TVItemModel tvItemModel = tvItemModelListMWQMSites.Where(c => c.TVItemID == mwqmSiteModel.MWQMSiteTVItemID).FirstOrDefault(); if (tvItemModel != null) { if (tvItemModel.IsActive) { string classificationLetter = ""; string classificationColor = ""; classificationLetter = GetLastClassificationInitial(mwqmSiteModel.MWQMSiteLatestClassification); classificationColor = GetLastClassificationColor(mwqmSiteModel.MWQMSiteLatestClassification); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td>{ mwqmSiteModel.MWQMSiteTVText }</td>"); sbHTML.AppendLine($@" <td class=""{ classificationColor }"">{ classificationLetter }</td>"); List <MapInfoPointModel> mapInfoPointModelList = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(mwqmSiteModel.MWQMSiteTVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point); if (mapInfoPointModelList.Count > 0) { sbHTML.AppendLine($@" <td>{ mapInfoPointModelList[0].Lat.ToString("F5") } { mapInfoPointModelList[0].Lng.ToString("F5") }</td>"); } else { sbHTML.AppendLine($@" <td> </td>"); } sbHTML.AppendLine($@" <td class=""textAlignLeft"">{ mwqmSiteModel.MWQMSiteDescription }</td>"); sbHTML.AppendLine($@" <td>Photo</td>"); sbHTML.AppendLine($@" </tr>"); } } } sbHTML.AppendLine($@" </table>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 50); List <MWQMSiteModel> mwqmSiteModelList2 = (from s in mwqmSiteModelList from t in tvItemModelListMWQMSites where s.MWQMSiteTVItemID == t.TVItemID && t.IsActive == true orderby s.MWQMSiteTVText select s).ToList(); int skip = 0; int take = 15; bool HasData = true; int countRun = 0; while (HasData) { countRun += 1; if (countRun > 2) { break; } List <MWQMRunModel> mwqmRunModelList2 = mwqmRunModelList.Where(c => c.RunSampleType == SampleTypeEnum.Routine).OrderByDescending(c => c.DateTime_Local).Skip(skip).Take(take).ToList(); if (mwqmRunModelList2.Count > 0) { sbHTML.AppendLine($@" <h4>{ TaskRunnerServiceRes.ActiveMWQMSites } { TaskRunnerServiceRes.FCDensities } ({ TaskRunnerServiceRes.Routine }) { mwqmRunModelList2[0].DateTime_Local.ToString("yyyy MMMM dd") } { TaskRunnerServiceRes.To } { mwqmRunModelList2[mwqmRunModelList2.Count -1].DateTime_Local.ToString("yyyy MMMM dd") }</h4>"); sbHTML.AppendLine($@" <table class=""FCSalTempDataTableClass"">"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <th class=""rightBottomBorder"">{ TaskRunnerServiceRes.Site }</th>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { sbHTML.AppendLine($@" <th class=""bottomBorder"">{ mwqmRunModel.DateTime_Local.ToString("yyyy") }<br />{ mwqmRunModel.DateTime_Local.ToString("MMM") }<br />{ mwqmRunModel.DateTime_Local.ToString("dd") }</th>"); } sbHTML.AppendLine($@" </tr>"); foreach (MWQMSiteModel mwqmSiteModel in mwqmSiteModelList2) { sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""rightBorder"">{ mwqmSiteModel.MWQMSiteTVText }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { float?value = (from s in mwqmSampleModelList where s.MWQMRunTVItemID == mwqmRunModel.MWQMRunTVItemID && s.MWQMSiteTVItemID == mwqmSiteModel.MWQMSiteTVItemID select s.FecCol_MPN_100ml).FirstOrDefault(); string valueStr = value != null ? (value == 1 ? "< 2" : ((float)value).ToString("F0")) : "--"; sbHTML.AppendLine($@" <td>{ valueStr }</td>"); } sbHTML.AppendLine($@" </tr>"); } sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ TaskRunnerServiceRes.StartTide }<br />{ TaskRunnerServiceRes.EndTide }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { string StartTide = GetTideInitial(mwqmRunModel.Tide_Start); string EndTide = GetTideInitial(mwqmRunModel.Tide_End); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ StartTide }<br />{ EndTide }</td>"); } sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ TaskRunnerServiceRes.Rain }(mm)<br />{ TaskRunnerServiceRes.Minus1Day }<br />{ TaskRunnerServiceRes.Minus2Day }<br />{ TaskRunnerServiceRes.Minus3Day }<br />{ TaskRunnerServiceRes.Minus4Day }<br />{ TaskRunnerServiceRes.Minus5Day }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { string RainDay1 = mwqmRunModel.RainDay1_mm != null ? ((double)mwqmRunModel.RainDay1_mm).ToString("F0") : "--"; string RainDay2 = mwqmRunModel.RainDay2_mm != null ? ((double)mwqmRunModel.RainDay2_mm).ToString("F0") : "--"; string RainDay3 = mwqmRunModel.RainDay3_mm != null ? ((double)mwqmRunModel.RainDay3_mm).ToString("F0") : "--"; string RainDay4 = mwqmRunModel.RainDay4_mm != null ? ((double)mwqmRunModel.RainDay4_mm).ToString("F0") : "--"; string RainDay5 = mwqmRunModel.RainDay5_mm != null ? ((double)mwqmRunModel.RainDay5_mm).ToString("F0") : "--"; sbHTML.AppendLine($@" <td class=""topRightBorder""> <br />{ RainDay1 }<br />{ RainDay2 }<br />{ RainDay3 }<br />{ RainDay4 }<br />{ RainDay5 }</td>"); } sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" </table>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); skip += take; } else { HasData = false; } } _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 60); skip = 0; take = 15; HasData = true; countRun = 0; while (HasData) { countRun += 1; if (countRun > 2) { break; } List <MWQMRunModel> mwqmRunModelList2 = mwqmRunModelList.Where(c => c.RunSampleType == SampleTypeEnum.Routine).OrderByDescending(c => c.DateTime_Local).Skip(skip).Take(take).ToList(); if (mwqmRunModelList2.Count > 0) { sbHTML.AppendLine($@" <h4>{ TaskRunnerServiceRes.ActiveMWQMSites } { TaskRunnerServiceRes.Salinity } ({ TaskRunnerServiceRes.Routine }) { mwqmRunModelList2[0].DateTime_Local.ToString("yyyy MMMM dd") } { TaskRunnerServiceRes.To } { mwqmRunModelList2[mwqmRunModelList2.Count - 1].DateTime_Local.ToString("yyyy MMMM dd") }</h4>"); sbHTML.AppendLine($@" <table class=""FCSalTempDataTableClass"">"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <th class=""rightBottomBorder"">{ TaskRunnerServiceRes.Site }</th>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { sbHTML.AppendLine($@" <th class=""bottomBorder"">{ mwqmRunModel.DateTime_Local.ToString("yyyy") }<br />{ mwqmRunModel.DateTime_Local.ToString("MMM") }<br />{ mwqmRunModel.DateTime_Local.ToString("dd") }</th>"); } sbHTML.AppendLine($@" </tr>"); foreach (MWQMSiteModel mwqmSiteModel in mwqmSiteModelList2) { sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""rightBorder"">{ mwqmSiteModel.MWQMSiteTVText }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { float?value = (float?)(from s in mwqmSampleModelList where s.MWQMRunTVItemID == mwqmRunModel.MWQMRunTVItemID && s.MWQMSiteTVItemID == mwqmSiteModel.MWQMSiteTVItemID select s.Salinity_PPT).FirstOrDefault(); string valueStr = value != null ? (value == 1 ? "< 2" : ((float)value).ToString("F0")) : "--"; sbHTML.AppendLine($@" <td>{ valueStr }</td>"); } sbHTML.AppendLine($@" </tr>"); } sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ TaskRunnerServiceRes.StartTide }<br />{ TaskRunnerServiceRes.EndTide }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { string StartTide = GetTideInitial(mwqmRunModel.Tide_Start); string EndTide = GetTideInitial(mwqmRunModel.Tide_End); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ StartTide }<br />{ EndTide }</td>"); } sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ TaskRunnerServiceRes.Rain }(mm)<br />{ TaskRunnerServiceRes.Minus1Day }<br />{ TaskRunnerServiceRes.Minus2Day }<br />{ TaskRunnerServiceRes.Minus3Day }<br />{ TaskRunnerServiceRes.Minus4Day }<br />{ TaskRunnerServiceRes.Minus5Day }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { string RainDay1 = mwqmRunModel.RainDay1_mm != null ? ((double)mwqmRunModel.RainDay1_mm).ToString("F0") : "--"; string RainDay2 = mwqmRunModel.RainDay2_mm != null ? ((double)mwqmRunModel.RainDay2_mm).ToString("F0") : "--"; string RainDay3 = mwqmRunModel.RainDay3_mm != null ? ((double)mwqmRunModel.RainDay3_mm).ToString("F0") : "--"; string RainDay4 = mwqmRunModel.RainDay4_mm != null ? ((double)mwqmRunModel.RainDay4_mm).ToString("F0") : "--"; string RainDay5 = mwqmRunModel.RainDay5_mm != null ? ((double)mwqmRunModel.RainDay5_mm).ToString("F0") : "--"; sbHTML.AppendLine($@" <td class=""topRightBorder""> <br />{ RainDay1 }<br />{ RainDay2 }<br />{ RainDay3 }<br />{ RainDay4 }<br />{ RainDay5 }</td>"); } sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" </table>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); skip += take; } else { HasData = false; } } _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 70); skip = 0; take = 15; HasData = true; countRun = 0; while (HasData) { countRun += 1; if (countRun > 2) { break; } List <MWQMRunModel> mwqmRunModelList2 = mwqmRunModelList.Where(c => c.RunSampleType == SampleTypeEnum.Routine).OrderByDescending(c => c.DateTime_Local).Skip(skip).Take(take).ToList(); if (mwqmRunModelList2.Count > 0) { sbHTML.AppendLine($@" <h4>{ TaskRunnerServiceRes.ActiveMWQMSites } { TaskRunnerServiceRes.Temperature } ({ TaskRunnerServiceRes.Routine }) { mwqmRunModelList2[0].DateTime_Local.ToString("yyyy MMMM dd") } { TaskRunnerServiceRes.To } { mwqmRunModelList2[mwqmRunModelList2.Count - 1].DateTime_Local.ToString("yyyy MMMM dd") }</h4>"); sbHTML.AppendLine($@" <table class=""FCSalTempDataTableClass"">"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <th class=""rightBottomBorder"">{ TaskRunnerServiceRes.Site }</th>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { sbHTML.AppendLine($@" <th class=""bottomBorder"">{ mwqmRunModel.DateTime_Local.ToString("yyyy") }<br />{ mwqmRunModel.DateTime_Local.ToString("MMM") }<br />{ mwqmRunModel.DateTime_Local.ToString("dd") }</th>"); } sbHTML.AppendLine($@" </tr>"); foreach (MWQMSiteModel mwqmSiteModel in mwqmSiteModelList2) { sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""rightBorder"">{ mwqmSiteModel.MWQMSiteTVText }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { float?value = (float?)(from s in mwqmSampleModelList where s.MWQMRunTVItemID == mwqmRunModel.MWQMRunTVItemID && s.MWQMSiteTVItemID == mwqmSiteModel.MWQMSiteTVItemID select s.WaterTemp_C).FirstOrDefault(); string valueStr = value != null ? (value == 1 ? "< 2" : ((float)value).ToString("F0")) : "--"; sbHTML.AppendLine($@" <td>{ valueStr }</td>"); } sbHTML.AppendLine($@" </tr>"); } sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ TaskRunnerServiceRes.StartTide }<br />{ TaskRunnerServiceRes.EndTide }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { string StartTide = GetTideInitial(mwqmRunModel.Tide_Start); string EndTide = GetTideInitial(mwqmRunModel.Tide_End); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ StartTide }<br />{ EndTide }</td>"); } sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" <tr>"); sbHTML.AppendLine($@" <td class=""topRightBorder"">{ TaskRunnerServiceRes.Rain }(mm)<br />{ TaskRunnerServiceRes.Minus1Day }<br />{ TaskRunnerServiceRes.Minus2Day }<br />{ TaskRunnerServiceRes.Minus3Day }<br />{ TaskRunnerServiceRes.Minus4Day }<br />{ TaskRunnerServiceRes.Minus5Day }</td>"); foreach (MWQMRunModel mwqmRunModel in mwqmRunModelList2) { string RainDay1 = mwqmRunModel.RainDay1_mm != null ? ((double)mwqmRunModel.RainDay1_mm).ToString("F0") : "--"; string RainDay2 = mwqmRunModel.RainDay2_mm != null ? ((double)mwqmRunModel.RainDay2_mm).ToString("F0") : "--"; string RainDay3 = mwqmRunModel.RainDay3_mm != null ? ((double)mwqmRunModel.RainDay3_mm).ToString("F0") : "--"; string RainDay4 = mwqmRunModel.RainDay4_mm != null ? ((double)mwqmRunModel.RainDay4_mm).ToString("F0") : "--"; string RainDay5 = mwqmRunModel.RainDay5_mm != null ? ((double)mwqmRunModel.RainDay5_mm).ToString("F0") : "--"; sbHTML.AppendLine($@" <td class=""topRightBorder""> <br />{ RainDay1 }<br />{ RainDay2 }<br />{ RainDay3 }<br />{ RainDay4 }<br />{ RainDay5 }</td>"); } sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" </table>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); skip += take; } else { HasData = false; } } sbHTML.AppendLine($@"|||FileNameExtra|Random,{ FileNameExtra }|||"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); if (!GetBottomHTML(sbHTML, fi, parameters)) { return(false); } _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 80); return(true); }
private bool GenerateKMZMWQMRun_NotImplementedKMZ(FileInfo fi, StringBuilder sbKMZ, string parameters, ReportTypeModel reportTypeModel) { sbKMZ.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>"); sbKMZ.AppendLine(@"<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">"); sbKMZ.AppendLine(@"<Document>"); sbKMZ.AppendLine(@" <name>" + fi.FullName.Replace(".kml", ".kmz") + "</name>"); sbKMZ.AppendLine(@" <Placemark>"); sbKMZ.AppendLine(@" <name>Not Implemented</name> "); sbKMZ.AppendLine(@" <Point>"); sbKMZ.AppendLine(@" <coordinates>-90,50,0</coordinates>"); sbKMZ.AppendLine(@" </Point> "); sbKMZ.AppendLine(@" </Placemark>"); sbKMZ.AppendLine(@"</Document> "); sbKMZ.AppendLine(@"</kml>"); return(true); }
private bool GenerateKMZMWQMRun(FileInfo fi, StringBuilder sbKMZ, string parameters, ReportTypeModel reportTypeModel) { switch (reportTypeModel.UniqueCode) { case "MWQMRunTestFRKMZ": case "MWQMRunTestENKMZ": { if (!GenerateKMZMWQMRun_MWQMRunTestKMZ(fi, sbKMZ, parameters, reportTypeModel)) { return(false); } } break; case "SomethingElseAsUniqueCode": { } break; default: break; } return(true); }
private bool GenerateKMZPolSourceSite_PolSourceSiteTestKMZ(FileInfo fi, StringBuilder sbKMZ, string parameters, ReportTypeModel reportTypeModel) { sbKMZ.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>"); sbKMZ.AppendLine(@"<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">"); sbKMZ.AppendLine(@"<Document>"); sbKMZ.AppendLine(@" <name>" + fi.FullName.Replace(".kml", ".kmz") + "</name>"); sbKMZ.AppendLine(@" <Placemark>"); sbKMZ.AppendLine(@" <name>My Parents Home</name> "); sbKMZ.AppendLine(@" <Point>"); sbKMZ.AppendLine(@" <coordinates>-64.69002452357093,46.48465663502946,0</coordinates>"); sbKMZ.AppendLine(@" </Point> "); sbKMZ.AppendLine(@" </Placemark>"); sbKMZ.AppendLine(@"</Document> "); sbKMZ.AppendLine(@"</kml>"); return(true); }
public void GenerateMikeScenarioPollutionAnimationKMZ_Test() { //AppTaskID TVItemID TVItemID2 AppTaskCommand AppTaskStatus PercentCompleted Parameters Language StartDateTime_UTC EndDateTime_UTC EstimatedLength_second RemainingTime_second LastUpdateDate_UTC LastUpdateContactTVItemID //10371 336990 336990 19 2 1 |||TVItemID,336925|||ReportTypeID,31|||ContourValues,14 88||| 1 2018-02-12 14:25:06.863 NULL NULL NULL 2018-02-12 14:25:07.663 2 foreach (LanguageEnum LanguageRequest in new List <LanguageEnum>() { LanguageEnum.en, LanguageEnum.fr }) { SetupTest(LanguageRequest); int MikeScenarioTVItemID = 336990; int ReportTypeID = 31; string ContourValues = "14 88"; int Year = 2017; FileInfo fi = new FileInfo(@"C:\Users\leblancc\Desktop\TestHTML\TestPolSourceAnimation" + LanguageRequest.ToString() + ".kml"); StringBuilder sbHTML = new StringBuilder(); string Parameters = $"|||TVItemID,{ MikeScenarioTVItemID }|||ReportTypeID,{ ReportTypeID }|||ContourValues,{ ContourValues }|||"; ReportTypeModel reportTypeModel = _ReportTypeService.GetReportTypeModelWithReportTypeIDDB(ReportTypeID); AppTaskModel appTaskModel = new AppTaskModel() { AppTaskID = 100000, TVItemID = MikeScenarioTVItemID, TVItemID2 = MikeScenarioTVItemID, AppTaskCommand = AppTaskCommandEnum.CreateDocumentFromParameters, AppTaskStatus = AppTaskStatusEnum.Created, PercentCompleted = 1, Parameters = Parameters, Language = LanguageRequest, StartDateTime_UTC = DateTime.Now, EndDateTime_UTC = null, EstimatedLength_second = null, RemainingTime_second = null, LastUpdateDate_UTC = DateTime.Now, LastUpdateContactTVItemID = 2, // Charles LeBlanc }; appTaskModel.AppTaskStatus = AppTaskStatusEnum.Running; BWObj bwObj = new BWObj() { Index = 1, appTaskModel = appTaskModel, appTaskCommand = appTaskModel.AppTaskCommand, TextLanguageList = new List <TextLanguage>(), bw = new BackgroundWorker(), }; TaskRunnerBaseService taskRunnerBaseService = new TaskRunnerBaseService(new List <BWObj>() { bwObj }); taskRunnerBaseService._BWObj = bwObj; ParametersService parameterService = new ParametersService(taskRunnerBaseService); parameterService.fi = fi; parameterService.sb = sbHTML; parameterService.Parameters = Parameters; parameterService.reportTypeModel = reportTypeModel; parameterService.TVItemID = MikeScenarioTVItemID; parameterService.Year = Year; StringBuilder sbTemp = new StringBuilder(); bool retBool = parameterService.GenerateMikeScenarioPollutionAnimationKMZ(); Assert.AreEqual(true, retBool); StreamWriter sw = fi.CreateText(); sw.Write(parameterService.sb.ToString()); sw.Close(); break; } }
public void FillElementLayerList_Test() { //AppTaskID TVItemID TVItemID2 AppTaskCommand AppTaskStatus PercentCompleted Parameters Language StartDateTime_UTC EndDateTime_UTC EstimatedLength_second RemainingTime_second LastUpdateDate_UTC LastUpdateContactTVItemID //10371 336990 336990 19 2 1 |||TVItemID,336925|||ReportTypeID,30|||ContourValues,14 88||| 1 2018-02-12 14:25:06.863 NULL NULL NULL 2018-02-12 14:25:07.663 2 foreach (LanguageEnum LanguageRequest in new List <LanguageEnum>() { LanguageEnum.en, LanguageEnum.fr }) { SetupTest(LanguageRequest); int MikeScenarioTVItemID = 336990; int ReportTypeID = 30; string ContourValues = "14 88"; int Year = 2017; FileInfo fi = new FileInfo(@"C:\Users\leblancc\Desktop\TestHTML\FillElementLayerList_" + LanguageRequest.ToString() + ".KML"); StringBuilder sbKML = new StringBuilder(); string Parameters = $"|||TVItemID,{ MikeScenarioTVItemID }|||ReportTypeID,{ ReportTypeID }|||CoutourValues,{ ContourValues }|||"; ReportTypeModel reportTypeModel = _ReportTypeService.GetReportTypeModelWithReportTypeIDDB(ReportTypeID); AppTaskModel appTaskModel = new AppTaskModel() { AppTaskID = 100000, TVItemID = MikeScenarioTVItemID, TVItemID2 = MikeScenarioTVItemID, AppTaskCommand = AppTaskCommandEnum.CreateDocumentFromParameters, AppTaskStatus = AppTaskStatusEnum.Created, PercentCompleted = 1, Parameters = Parameters, Language = LanguageRequest, StartDateTime_UTC = DateTime.Now, EndDateTime_UTC = null, EstimatedLength_second = null, RemainingTime_second = null, LastUpdateDate_UTC = DateTime.Now, LastUpdateContactTVItemID = 2, // Charles LeBlanc }; appTaskModel.AppTaskStatus = AppTaskStatusEnum.Running; BWObj bwObj = new BWObj() { Index = 1, appTaskModel = appTaskModel, appTaskCommand = appTaskModel.AppTaskCommand, TextLanguageList = new List <TextLanguage>(), bw = new BackgroundWorker(), }; TaskRunnerBaseService taskRunnerBaseService = new TaskRunnerBaseService(new List <BWObj>() { bwObj }); taskRunnerBaseService._BWObj = bwObj; ParametersService parameterService = new ParametersService(taskRunnerBaseService); parameterService.fi = fi; parameterService.sb = sbKML; parameterService.Parameters = Parameters; parameterService.reportTypeModel = reportTypeModel; parameterService.TVItemID = MikeScenarioTVItemID; parameterService.Year = Year; DfsuFile dfsuFile = null; List <Element> elementList = new List <Element>(); List <ElementLayer> elementLayerList = new List <ElementLayer>(); List <NodeLayer> topNodeLayerList = new List <NodeLayer>(); List <NodeLayer> bottomNodeLayerList = new List <NodeLayer>(); List <Node> nodeList = new List <Node>(); dfsuFile = parameterService.GetTransportDfsuFile(); Assert.IsNotNull(dfsuFile); Assert.AreEqual(0, taskRunnerBaseService._BWObj.TextLanguageList.Count); StringBuilder sbTemp = new StringBuilder(); bool retBool = parameterService.FillRequiredList(dfsuFile, elementList, elementLayerList, nodeList, topNodeLayerList, bottomNodeLayerList); Assert.AreEqual(true, retBool); Assert.AreEqual(15829, nodeList.Count); Assert.AreEqual(22340, elementLayerList.Count); Assert.AreEqual(22340, elementList.Count); try { dfsuFile.Close(); } catch (Exception) { // nothing } break; } }
public void PublicGenerateHTMLSUBSECTOR_MWQM_SITES_FC_TABLE_Test() { foreach (LanguageEnum LanguageRequest in new List <LanguageEnum>() { LanguageEnum.en, LanguageEnum.fr }) { SetupTest(LanguageRequest); int SubsectorTVItemID = 776; int ReportTypeID = 23; int Year = 2019; FileInfo fi = new FileInfo(@"C:\Users\leblancc\Desktop\TestHTML\PublicGenerateHTMLSUBSECTOR_MWQM_SITES_FC_TABLE" + LanguageRequest.ToString() + ".html"); StringBuilder sbHTML = new StringBuilder(); string Parameters = $"|||TVItemID,{ SubsectorTVItemID }|||ReportTypeID,{ ReportTypeID }|||Year,{ Year }|||"; ReportTypeModel reportTypeModel = _ReportTypeService.GetReportTypeModelWithReportTypeIDDB(ReportTypeID); AppTaskModel appTaskModel = new AppTaskModel() { AppTaskID = 10000, TVItemID = SubsectorTVItemID, TVItemID2 = SubsectorTVItemID, AppTaskCommand = AppTaskCommandEnum.CreateDocumentFromParameters, AppTaskStatus = AppTaskStatusEnum.Created, PercentCompleted = 1, Parameters = Parameters, Language = LanguageRequest, StartDateTime_UTC = DateTime.Now, EndDateTime_UTC = null, EstimatedLength_second = null, RemainingTime_second = null, LastUpdateDate_UTC = DateTime.Now, LastUpdateContactTVItemID = 2, // Charles LeBlanc }; appTaskModel.AppTaskStatus = AppTaskStatusEnum.Running; BWObj bwObj = new BWObj() { Index = 1, appTaskModel = appTaskModel, appTaskCommand = appTaskModel.AppTaskCommand, TextLanguageList = new List <TextLanguage>(), bw = new BackgroundWorker(), }; TaskRunnerBaseService taskRunnerBaseService = new TaskRunnerBaseService(new List <BWObj>() { bwObj }); taskRunnerBaseService._BWObj = bwObj; ParametersService parameterService = new ParametersService(taskRunnerBaseService); parameterService.fi = fi; parameterService.sb = sbHTML; parameterService.Parameters = Parameters; parameterService.reportTypeModel = reportTypeModel; parameterService.TVItemID = SubsectorTVItemID; parameterService.Year = Year; StringBuilder sbTemp = new StringBuilder(); bool retBool = parameterService.PublicGenerateHTMLSUBSECTOR_MWQM_SITES_FC_TABLE(sbTemp); Assert.AreEqual(true, retBool); StreamWriter sw = fi.CreateText(); sw.Write(sbTemp.ToString()); sw.Flush(); sw.Close(); break; } }
private bool GenerateHTMLSubsectorFullReportCoverPage(FileInfo fi, StringBuilder sbHTML, string parameters, ReportTypeModel reportTypeModel) { string NotUsed = ""; int TVItemID = 0; int Year = 0; Random random = new Random(); string FileNameExtra = ""; for (int i = 0; i < 10; i++) { FileNameExtra = FileNameExtra + (char)random.Next(97, 122); } _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 3); if (!GetTopHTML(sbHTML)) { return(false); } List <string> ParamValueList = parameters.Split("|||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); if (!int.TryParse(GetParameters("TVItemID", ParamValueList), out TVItemID)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind__, TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotFind__", TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); return(false); } TVItemModel tvItemModelSubsector = _TVItemService.GetTVItemModelWithTVItemIDDB(TVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelSubsector.Error)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind_With_Equal_, TaskRunnerServiceRes.TVItem, TaskRunnerServiceRes.TVItemID, TVItemID.ToString()); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageList(tvItemModelSubsector.Error); return(false); } if (!int.TryParse(GetParameters("Year", ParamValueList), out Year)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind__, TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.Year); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotFind__", TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.Year); return(false); } TVItemModel tvItemModelRoot = _TVItemService.GetRootTVItemModelDB(); if (!string.IsNullOrWhiteSpace(tvItemModelRoot.Error)) { NotUsed = TaskRunnerServiceRes.CouldNotFindTVItemRoot; _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageList("CouldNotFindTVItemRoot"); return(false); } string ServerPath = _TVFileService.GetServerFilePath(tvItemModelRoot.TVItemID); TVFileModel tvFileModelFullReportCoverPageCanadaFlag = _TVFileService.GetTVFileModelWithServerFilePathAndServerFileNameDB(ServerPath, "CanadaFlag.png"); if (!string.IsNullOrWhiteSpace(tvFileModelFullReportCoverPageCanadaFlag.Error)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFindFile_, ServerPath + "CanadaFlag.png"); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFindFile_", ServerPath + "CanadaFlag.png"); return(false); } FileInfo fiFullReportCoverPageImageCanadaFlag = new FileInfo(tvFileModelFullReportCoverPageCanadaFlag.ServerFilePath + tvFileModelFullReportCoverPageCanadaFlag.ServerFileName); if (!fiFullReportCoverPageImageCanadaFlag.Exists) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFindFile_, fiFullReportCoverPageImageCanadaFlag.FullName); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFindFile_", fiFullReportCoverPageImageCanadaFlag.FullName); return(false); } TVFileModel tvFileModelFullReportCoverPageCanadaBanner = _TVFileService.GetTVFileModelWithServerFilePathAndServerFileNameDB(ServerPath, "CanadaBanner.png"); if (!string.IsNullOrWhiteSpace(tvFileModelFullReportCoverPageCanadaBanner.Error)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFindFile_, ServerPath + "CanadaBanner.png"); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFindFile_", ServerPath + "CanadaBanner.png"); return(false); } FileInfo fiFullReportCoverPageImageCanadaBanner = new FileInfo(tvFileModelFullReportCoverPageCanadaBanner.ServerFilePath + tvFileModelFullReportCoverPageCanadaBanner.ServerFileName); if (!fiFullReportCoverPageImageCanadaBanner.Exists) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFindFile_, fiFullReportCoverPageImageCanadaBanner.FullName); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFindFile_", fiFullReportCoverPageImageCanadaBanner.FullName); return(false); } TVFileModel tvFileModelFullReportCoverPageCanadaWithFlag = _TVFileService.GetTVFileModelWithServerFilePathAndServerFileNameDB(ServerPath, "CanadaWithFlag.png"); if (!string.IsNullOrWhiteSpace(tvFileModelFullReportCoverPageCanadaWithFlag.Error)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFindFile_, ServerPath + "CanadaWithFlag.png"); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFindFile_", ServerPath + "CanadaWithFlag.png"); return(false); } FileInfo fiFullReportCoverPageImageCanadaWithFlag = new FileInfo(tvFileModelFullReportCoverPageCanadaWithFlag.ServerFilePath + tvFileModelFullReportCoverPageCanadaWithFlag.ServerFileName); if (!fiFullReportCoverPageImageCanadaWithFlag.Exists) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFindFile_, fiFullReportCoverPageImageCanadaBanner.FullName); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CouldNotFindFile_", fiFullReportCoverPageImageCanadaWithFlag.FullName); return(false); } List <TVItemModel> tvItemModelListParent = _TVItemService.GetParentsTVItemModelList(tvItemModelSubsector.TVPath); TVItemModel tvItemModelProvince = new TVItemModel(); foreach (TVItemModel tvItemModel in tvItemModelListParent) { if (tvItemModel.TVType == TVTypeEnum.Province) { tvItemModelProvince = tvItemModel; break; } } int Pos = tvItemModelSubsector.TVText.IndexOf(" "); string SubsectorShort = "Error"; string SubsectorEndPart = "Error"; if (Pos > 0) { SubsectorShort = tvItemModelSubsector.TVText.Substring(0, Pos).Trim(); SubsectorEndPart = tvItemModelSubsector.TVText.Substring(Pos).Trim(); } string NamesOfAuthors = "Name of authors"; string ReportDateText = DateTime.Now.ToString("MMMM yyyy"); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 5); sbHTML.AppendLine($@" <p> </p>"); sbHTML.AppendLine($@" <table>"); sbHTML.AppendLine($@" <tr> "); sbHTML.AppendLine($@" <td>|||Image|FileName,{ fiFullReportCoverPageImageCanadaFlag.FullName }|width,45|height,20|||</td> "); sbHTML.AppendLine($@" <td> </td>"); sbHTML.AppendLine($@" <td class=""textAlignLeft""><h5 class=""ECCCCoverPage"">Environment and <br />Climate Change Canada</h5></td>"); sbHTML.AppendLine($@" <td> </td>"); sbHTML.AppendLine($@" <td class=""textAlignLeft""><h5 class=""ECCCCoverPage"">Environnement et <br />Changement climatique Canada</h5></td>"); sbHTML.AppendLine($@" </tr>"); sbHTML.AppendLine($@" </table>"); sbHTML.AppendLine($@" <div class=""textAlignLeft"">"); sbHTML.AppendLine($@" |||Image|FileName,{ fiFullReportCoverPageImageCanadaBanner.FullName }|width,480|height,48|||"); sbHTML.AppendLine($@" </div>"); sbHTML.AppendLine($@" <div>"); sbHTML.AppendLine($@" <br />"); sbHTML.AppendLine($@" <br />"); sbHTML.AppendLine($@" <blockquote>"); sbHTML.AppendLine($@" <hr />"); sbHTML.AppendLine($@" <h5 class=""textAlignLeft"">{ TaskRunnerServiceRes.MarineWaterQualityReEvaluationReport }</h5>"); sbHTML.AppendLine($@" <hr />"); sbHTML.AppendLine($@" <h5 class=""textAlignLeft"">{ tvItemModelProvince.TVText } { TaskRunnerServiceRes.ShellfishGrowingArea}</h5>"); sbHTML.AppendLine($@" <h5 class=""textAlignLeft"">{ SubsectorShort }</h5>"); sbHTML.AppendLine($@" <h5 class=""textAlignLeft"">{ SubsectorEndPart }</h5>"); sbHTML.AppendLine($@" <hr />"); sbHTML.AppendLine($@" <h5 class=""textAlignLeft"">{ NamesOfAuthors }</h5>"); sbHTML.AppendLine($@" <hr />"); sbHTML.AppendLine($@" </blockquote>"); sbHTML.AppendLine($@" <h5> </h5>"); sbHTML.AppendLine($@" <h5> </h5>"); sbHTML.AppendLine($@" <h5> </h5>"); sbHTML.AppendLine($@" <h5> </h5>"); sbHTML.AppendLine($@" <h5> </h5>"); sbHTML.AppendLine($@" <h5> </h5>"); sbHTML.AppendLine($@" <h5 class=""textAlignRight"">{ TaskRunnerServiceRes.AtlanticMarineWaterQualityMonitoring }</h5>"); sbHTML.AppendLine($@" <h5 class=""textAlignRight"">{ TaskRunnerServiceRes.Report } <span>_______________________</span></h5>"); sbHTML.AppendLine($@" <h5 class=""textAlignRight"">{ ReportDateText }</h5>"); sbHTML.AppendLine($@" </div>"); sbHTML.AppendLine($@" <div class=""textAlignRight"">|||Image|FileName,{ fiFullReportCoverPageImageCanadaWithFlag.FullName }|width,76|height,22|||</div>"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); if (!GetBottomHTML(sbHTML, fi, parameters)) { return(false); } return(true); }
private bool GenerateHTMLSubsectorMapMWQMSitesDocx(FileInfo fi, StringBuilder sbHTML, string parameters, ReportTypeModel reportTypeModel) { string NotUsed = ""; int TVItemID = 0; string HideVerticalScale = ""; string HideHorizontalScale = ""; string HideNorthArrow = ""; string HideSubsectorName = ""; _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 3); if (!GetTopHTML(sbHTML)) { return(false); } List <string> ParamValueList = parameters.Split("|||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); if (!int.TryParse(GetParameters("TVItemID", ParamValueList), out TVItemID)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind__, TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotFind__", TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); return(false); } HideVerticalScale = GetParameters("HideVerticalScale", ParamValueList); HideHorizontalScale = GetParameters("HideHorizontalScale", ParamValueList); HideNorthArrow = GetParameters("HideNorthArrow", ParamValueList); HideSubsectorName = GetParameters("HideSubsectorName", ParamValueList); string SubsectorTVText = _MWQMSubsectorService.GetMWQMSubsectorModelWithMWQMSubsectorTVItemIDDB(TVItemID).MWQMSubsectorTVText; sbHTML.AppendLine($@"<h1>{ SubsectorTVText }</h1>"); sbHTML.AppendLine($@"<br />"); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 5); GoogleMapToPNG googleMapToPNG = new GoogleMapToPNG(_TaskRunnerBaseService, HideVerticalScale, HideHorizontalScale, HideNorthArrow, HideSubsectorName); DirectoryInfo di = new DirectoryInfo(googleMapToPNG.DirName); if (!di.Exists) { try { di.Create(); } catch (Exception ex) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotCreateDirectory__, di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotCreateDirectory__", di.FullName, ex.Message + (ex.InnerException != null ? " Inner: " + ex.InnerException.Message : "")); return(false); } } if (!googleMapToPNG.CreateSubsectorGoogleMapPNGForMWQMSites(_TaskRunnerBaseService._BWObj.appTaskModel.TVItemID, "hybrid")) { string Error = _TaskRunnerBaseService._BWObj.TextLanguageList[(_TaskRunnerBaseService._BWObj.appTaskModel.Language == LanguageEnum.fr ? 1 : 0)].Text; sbHTML.AppendLine($@"<h1>{ Error }</h1>"); } sbHTML.AppendLine($@"|||Image|FileName,{ googleMapToPNG.DirName }{ googleMapToPNG.FileNameFullAnnotated }|width,490|height,460|||"); sbHTML.AppendLine($@"|||FileNameExtra|Random,{ googleMapToPNG.FileNameExtra }|||"); sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); if (!GetBottomHTML(sbHTML, fi, parameters)) { return(false); } return(true); }
public ReportTypeModel PostAddOrModifyReportTypeDB(FormCollection fc) { int tempInt = 0; int ReportTypeID = 0; TVTypeEnum TVType = TVTypeEnum.Error; FileTypeEnum FileType = FileTypeEnum.Error; string UniqueCode = ""; LanguageEnum Language = LanguageEnum.Error; //string Name = ""; //string StartOfFileName = ""; //string Description = ""; int.TryParse(fc["ReportTypeID"], out ReportTypeID); // if ReportTypeID == 0 then we should create a new one else we should modify the existing one ReportTypeModel reportTypeModel = new ReportTypeModel(); if (ReportTypeID != 0) { reportTypeModel = GetReportTypeModelWithReportTypeIDDB(ReportTypeID); if (!string.IsNullOrWhiteSpace(reportTypeModel.Error)) { return(ReturnError(reportTypeModel.Error)); } } reportTypeModel.DBCommand = DBCommandEnum.Original; int.TryParse(fc["TVType"], out tempInt); TVType = (TVTypeEnum)tempInt; reportTypeModel.TVType = TVType; int.TryParse(fc["FileType"], out tempInt); FileType = (FileTypeEnum)tempInt; reportTypeModel.FileType = FileType; UniqueCode = fc["UniqueCode"]; reportTypeModel.UniqueCode = UniqueCode; int.TryParse(fc["Language"], out tempInt); Language = (LanguageEnum)tempInt; reportTypeModel.Language = Language; reportTypeModel.Name = fc["Name"]; reportTypeModel.StartOfFileName = fc["StartOfFileName"]; reportTypeModel.Description = fc["Description"]; ContactOK contactOK = IsContactOK(); if (!string.IsNullOrEmpty(contactOK.Error)) { return(ReturnError(contactOK.Error)); } ReportTypeModel reportTypeModelHasUniqueCode = GetReportTypeModelWithUniqueCodeDB(UniqueCode); if (string.IsNullOrWhiteSpace(reportTypeModelHasUniqueCode.Error)) { return(ReturnError(string.Format(ServiceRes._AlreadyExists, ServiceRes.UniqueCode))); } ReportTypeModel reportTypeModelRet = new ReportTypeModel(); using (TransactionScope ts = new TransactionScope()) { if (ReportTypeID == 0) { reportTypeModelRet = PostAddReportTypeDB(reportTypeModel); if (!string.IsNullOrWhiteSpace(reportTypeModelRet.Error)) { return(ReturnError(reportTypeModelRet.Error)); } LogModel logModel = _LogService.PostAddLogForObj("ReportTypes", reportTypeModelRet.ReportTypeID, LogCommandEnum.Add, reportTypeModelRet); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } } else { reportTypeModelRet = PostUpdateReportTypeDB(reportTypeModel); if (!string.IsNullOrWhiteSpace(reportTypeModelRet.Error)) { return(ReturnError(reportTypeModelRet.Error)); } LogModel logModel = _LogService.PostAddLogForObj("ReportTypes", reportTypeModelRet.ReportTypeID, LogCommandEnum.Change, reportTypeModelRet); if (!string.IsNullOrWhiteSpace(logModel.Error)) { return(ReturnError(logModel.Error)); } } ts.Complete(); } return(GetReportTypeModelWithReportTypeIDDB(reportTypeModelRet.ReportTypeID)); }
public JsonResult ReportTypeAddOrModifyJSON(FormCollection fc) { ReportTypeModel reportTypeModel = _ReportTypeService.PostAddOrModifyReportTypeDB(fc); return(Json(reportTypeModel.Error, JsonRequestBehavior.AllowGet)); }
// for testing only can comment out when test is completed public bool PublicGenerateHTMLSubsectorMWQMSites(FileInfo fi, StringBuilder sbHTML, string parameters, ReportTypeModel reportTypeModel) { bool retBool = GenerateHTMLSubsectorMWQMSites(fi, sbHTML, parameters, reportTypeModel); StreamWriter sw = fi.CreateText(); sw.Write(sbHTML.ToString()); sw.Flush(); sw.Close(); return(retBool); }
public JsonResult ReportTypeDeleteJSON(int ReportTypeID) { ReportTypeModel reportTypeModel = _ReportTypeService.PostDeleteReportTypeWithReportTypeIDDB(ReportTypeID); return(Json(reportTypeModel.Error, JsonRequestBehavior.AllowGet)); }
public void Public_Generate_FC_SummaryStatistics_Test() { //AppTaskID TVItemID TVItemID2 AppTaskCommand AppTaskStatus PercentCompleted Parameters Language StartDateTime_UTC EndDateTime_UTC EstimatedLength_second RemainingTime_second LastUpdateDate_UTC LastUpdateContactTVItemID //18044 778 778 19 2 10 |||TVItemID,778|||ReportTypeID,23|||Year,2019||| 1 2019-10-10 11:59:59.993 NULL NULL NULL 2019-10-10 12:00:03.653 2 // foreach (LanguageEnum LanguageRequest in new List <LanguageEnum>() { LanguageEnum.en, LanguageEnum.fr }) { SetupTest(LanguageRequest); int SubsectorTVItemID = 778; int ReportTypeID = 23; int Year = 2019; //FileInfo fi = new FileInfo(@"C:\Users\leblancc\Desktop\TestHTML\PublicGenerateReEvaluation_" + LanguageRequest.ToString() + ".html"); //StringBuilder sbHTML = new StringBuilder(); string Parameters = $"|||TVItemID,{ SubsectorTVItemID }|||ReportTypeID,{ ReportTypeID }|||Year,{ Year }|||"; ReportTypeModel reportTypeModel = _ReportTypeService.GetReportTypeModelWithReportTypeIDDB(ReportTypeID); AppTaskModel appTaskModel = new AppTaskModel() { AppTaskID = 10000, TVItemID = SubsectorTVItemID, TVItemID2 = SubsectorTVItemID, AppTaskCommand = AppTaskCommandEnum.CreateDocumentFromParameters, AppTaskStatus = AppTaskStatusEnum.Created, PercentCompleted = 1, Parameters = Parameters, Language = LanguageRequest, StartDateTime_UTC = DateTime.Now, EndDateTime_UTC = null, EstimatedLength_second = null, RemainingTime_second = null, LastUpdateDate_UTC = DateTime.Now, LastUpdateContactTVItemID = 2, // Charles LeBlanc }; appTaskModel.AppTaskStatus = AppTaskStatusEnum.Running; BWObj bwObj = new BWObj() { Index = 1, appTaskModel = appTaskModel, appTaskCommand = appTaskModel.AppTaskCommand, TextLanguageList = new List <TextLanguage>(), bw = new BackgroundWorker(), }; TaskRunnerBaseService taskRunnerBaseService = new TaskRunnerBaseService(new List <BWObj>() { bwObj }); taskRunnerBaseService._BWObj = bwObj; ParametersService parameterService = new ParametersService(taskRunnerBaseService); //parameterService.fi = fi; //parameterService.sb = sbHTML; //parameterService.Parameters = Parameters; //parameterService.reportTypeModel = reportTypeModel; //parameterService.TVItemID = SubsectorTVItemID; //parameterService.Year = Year; //StringBuilder sbTemp = new StringBuilder(); parameterService.Generate(); Assert.AreEqual(0, taskRunnerBaseService._BWObj.TextLanguageList.Count); //StreamWriter sw = fi.CreateText(); //sw.Write(sbTemp.ToString()); //sw.Flush(); //sw.Close(); } }
private bool GenerateHTMLSubsectorFullReport(FileInfo fi, StringBuilder sbHTML, string parameters, ReportTypeModel reportTypeModel) { string NotUsed = ""; int TVItemID = 0; Random random = new Random(); string FileNameExtra = ""; for (int i = 0; i < 10; i++) { FileNameExtra = FileNameExtra + (char)random.Next(97, 122); } _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 3); if (!GetTopHTML(sbHTML)) { return(false); } List <string> ParamValueList = parameters.Split("|||".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); if (!int.TryParse(GetParameters("TVItemID", ParamValueList), out TVItemID)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind__, TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat2List("CouldNotFind__", TaskRunnerServiceRes.Parameter, TaskRunnerServiceRes.TVItemID); return(false); } TVItemModel tvItemModelSubsector = _TVItemService.GetTVItemModelWithTVItemIDDB(TVItemID); if (!string.IsNullOrWhiteSpace(tvItemModelSubsector.Error)) { NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind_With_Equal_, TaskRunnerServiceRes.TVItem, TaskRunnerServiceRes.TVItemID, TVItemID.ToString()); _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat3List("CouldNotFind_With_Equal_", TaskRunnerServiceRes.TVItem, TaskRunnerServiceRes.TVItemID, TVItemID.ToString()); return(false); } string ServerPath = _TVFileService.GetServerFilePath(tvItemModelSubsector.TVItemID); _TaskRunnerBaseService.SendPercentToDB(_TaskRunnerBaseService._BWObj.appTaskModel.AppTaskID, 5); if (!GenerateHTMLSubsectorFullReportCoverPage(fi, sbHTML, parameters, reportTypeModel)) { return(false); } if (!GenerateHTMLSubsectorMapMWQMSitesDocx(fi, sbHTML, parameters, reportTypeModel)) { return(false); } if (!GenerateHTMLSubsectorFCSummaryStatDocx(fi, sbHTML, parameters, reportTypeModel)) { return(false); } if (!GenerateHTMLSubsectorMWQMSites(fi, sbHTML, parameters, reportTypeModel)) { return(false); } if (!GenerateHTMLSubsectorMapActivePolSourceSitesDocx(fi, sbHTML, parameters, reportTypeModel)) { return(false); } if (!GenerateHTMLSubsectorPollutionSourceSites(fi, sbHTML, parameters, reportTypeModel)) { return(false); } sbHTML.AppendLine(@"<span>|||PageBreak|||</span>"); sbHTML.AppendLine($@"|||FileNameExtra|Random,{ FileNameExtra }|||"); if (!GetBottomHTML(sbHTML, fi, parameters)) { return(false); } return(true); }