/// <summary> /// Get a bbCode url for insertion into an email. Allows a hyperlink to be hidden in a hrefText /// </summary> /// <param name="dto">The Release DTO</param> /// <returns></returns> private string getReleaseUrl(Release_DTO dto) { return("[url=" + Configuration_BSO.GetCustomConfig("url.application") + "/" + Utility.GetCustomConfig("APP_COOKIELINK_RELEASE") + '/' + dto.RlsCode.ToString() + "]" + Label.Get("static.release") + " " + dto.RlsVersion.ToString() + "." + dto.RlsRevision.ToString() + "[/url]"); }
/// <summary> /// /// </summary> /// <param name="parameters"></param> public Build_DTO(dynamic parameters) { if (parameters.MtrInput != null) { this.MtrInput = Utility.DecodeBase64ToUTF8((string)parameters["MtrInput"]); } this.LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); if (parameters.MtrOfficialFlag != null) { this.MtrOfficialFlag = parameters.MtrOfficialFlag; } else { this.MtrOfficialFlag = Configuration_BSO.GetCustomConfig(ConfigType.global, "dataset.officialStatistics"); } if (parameters.MtrCode != null) { this.MtrCode = parameters.MtrCode; } if (parameters.CprCode != null) { this.CprCode = parameters.CprCode; } if (parameters.FrqCode != null) { this.FrqCode = parameters.FrqCode; } if (parameters.FrqValue != null) { this.FrqValue = parameters.FrqValue; } Format = new Format_DTO_Read(); if (parameters.FrmType != null && parameters.FrmVersion != null) { Format = new Format_DTO_Read { FrmVersion = parameters.FrmVersion, FrmType = parameters.FrmType, FrmDirection = Format_DTO_Read.FormatDirection.UPLOAD.ToString() }; } if (parameters.Elimination != null) { Elimination = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Elimination.ToString()); } if (parameters.Dimension != null) { matrixDto = new Matrix_DTO(); if (parameters.LngIsoCode != null) { matrixDto.LngIsoCode = parameters.LngIsoCode; } else { matrixDto.LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); } if (parameters.MtrCode != null) { matrixDto.MtrCode = parameters.MtrCode; } if (parameters.MtrOfficialFlag != null) { matrixDto.MtrOfficialFlag = parameters.MtrOfficialFlag; } DimensionList = new List <Dimension_DTO>(); foreach (var dim in parameters.Dimension) { Dimension_DTO mlDto = new Dimension_DTO(dim); if (dim.MtrTitle != null) { mlDto.Contents = dim.MtrTitle; if (mlDto.Classifications != null) { mlDto.MtrTitle = mlDto.Contents + " (" + String.Join(", ", ((mlDto.Classifications.Select(c => c.Value.ToString())).ToList <string>()).ToArray()) + ')'; } else { mlDto.MtrTitle = dim.MtrTitle; } if (mlDto.MtrTitle.Length > 256) { mlDto.MtrTitle = mlDto.MtrTitle.Substring(0, 256); } } if (this.CprCode != null) { mlDto.CprCode = this.CprCode; Copyright_BSO cBso = new Copyright_BSO(); Copyright_DTO_Create cDTO = cBso.Read(this.CprCode); mlDto.CprValue = cDTO.CprValue; } if (dim.CprValue != null) { mlDto.CprValue = dim.CprValue; } if (dim.Frequency != null) { mlDto.Frequency = new FrequencyRecordDTO_Create(); if (parameters.FrqCode != null) { mlDto.Frequency.Code = parameters.FrqCode; } if (dim.Frequency.FrqValue != null) { mlDto.Frequency.Value = dim.Frequency.FrqValue; } if (dim.Frequency.Period != null) { mlDto.Frequency.Period = new List <PeriodRecordDTO_Create>(); foreach (var per in dim.Frequency.Period) { PeriodRecordDTO_Create period = new Data.PeriodRecordDTO_Create(); if (per.PrdCode != null) { period.Code = per.PrdCode; } if (per.PrdValue != null) { period.Value = per.PrdValue; } mlDto.Frequency.Period.Add(period); } } } if (this.FrqCode != null) { mlDto.FrqCode = this.FrqCode; //Get Frequency value Frequency_BSO bso = new Frequency_BSO(); Frequency_DTO dto = new Frequency_DTO(); dto = bso.Read(this.FrqCode); mlDto.FrqValue = dto.FrqValue; } if (dim.FrqCode != null) { mlDto.FrqCode = dim.FrqCode; } if (dim.FrqValue != null) { mlDto.FrqValue = dim.FrqValue; } if (dim.LngIsoCode != null) { mlDto.LngIsoCode = dim.LngIsoCode; } if (dim.MtrTitle != null) { mlDto.MtrTitle = dim.MtrTitle; } if (dim.MtrNote != null) { mlDto.MtrNote = dim.MtrNote; } if (dim.Statistic != null) { mlDto.Statistics = new List <StatisticalRecordDTO_Create>(); foreach (var stat in dim.Statistic) { StatisticalRecordDTO_Create src = new StatisticalRecordDTO_Create(stat); mlDto.Statistics.Add(src); } } DimensionList.Add(mlDto); } } if (parameters.Map != null) { Map = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Map.ToString()); } }
/// <summary> /// Create and get a spreadsheet as a serialized string based on the Matrix /// </summary> /// <param name="theMatrix"></param> /// <param name="rowLists"></param> /// <param name="lngIsoCode"></param> /// <param name="ci"></param> /// <returns></returns> internal string GetXlsx(Matrix theMatrix, string lngIsoCode = null, CultureInfo ci = null, string pivot = null, bool viewCodes = true) { Specification spec = theMatrix.GetSpecFromLanguage(lngIsoCode); if (spec == null) { spec = theMatrix.MainSpec; lngIsoCode = spec.Language; } XlsxClosedXL xcl = new XlsxClosedXL(); MemoryStream documentStream = xcl.CreatAboutPage(theMatrix, "About", lngIsoCode, new CultureInfo(Configuration_BSO.GetCustomConfig(ConfigType.global, "language.culture"))); if (pivot != null) { //We must get the dimension name from the dimension code - the pivot variable contains only the code if (pivot.Equals(spec.Frequency.Code)) { pivot = spec.Frequency.Value; } foreach (var cls in spec.Classification) { if (pivot.Equals(cls.Code)) { pivot = cls.Value; break; } } } xcl = new XlsxClosedXL(documentStream); documentStream = xcl.InsertTableAndPivotSheet(theMatrix.GetMatrixDataTable(lngIsoCode, false, 1, viewCodes), Label.Get("xlsx.pivoted", lngIsoCode), pivot, Label.Get("xlsx.unpivoted", lngIsoCode), Label.Get("xlsx.value", lngIsoCode), Label.Get("xlsx.unit", lngIsoCode), spec); //Test option...get a local version of the xlsx file //SaveToFile(@"C:\nok\Schemas\" + theMatrix.Code + ".xlsx", documentStream); //return the serialized version of the spreadsheet return(SerializeSpreadsheetFromByteArrayBase64(documentStream)); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { // uses authentication and filters privileges according to user access var currentRelease = Release_ADO.GetReleaseDTO(new Matrix_ADO(Ado).Read(DTO.RlsCode, Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"), SamAccountName)); if (currentRelease == null) { Response.data = null; return(true); } int previousReleaseId = new Compare_ADO(Ado).ReadPreviousReleaseForUser(DTO.RlsCode, SamAccountName); if (previousReleaseId == 0) { Response.data = null; } else { Response.data = previousReleaseId; } return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { Build_BSO buildBso = new Build_BSO(); if (!buildBso.HasBuildPermission(Ado, SamAccountName, "import")) { Response.error = Label.Get("error.privilege"); return(false); } Stopwatch swMatrix = new Stopwatch(); swMatrix.Start(); var signature = Utility.GetMD5(Utility.GetCustomConfig("APP_SALSA") + Utility.JsonSerialize_IgnoreLoopingReference(DTO.GetSignatureDTO())); if (signature != DTO.Signature) { Response.error = Label.Get("error.validation"); return(false); } Matrix theMatrixData; PxDoc = PxStatEngine.ParsePxInput(DTO.MtrInput); theMatrixData = new Matrix(PxDoc, DTO); Matrix_BSO mBso = new Matrix_BSO(Ado); int releaseId; // Check if a WIP Release already exists for the Matrix to Upload var latestRelease = mBso.GetLatestRelease(theMatrixData); if (latestRelease != null && !DTO.Overwrite && releaseAdo.IsWip(latestRelease.RlsCode)) // { Group_DTO_Create dtoGroup = this.GetGroup(DTO.GrpCode); if (latestRelease.GrpCode != DTO.GrpCode) { Response.data = String.Format(Label.Get("px.duplicate-different-group"), theMatrixData.Code, latestRelease.GrpName + " (" + latestRelease.GrpCode + ")", dtoGroup.GrpName + " (" + DTO.GrpCode + ")"); } else { Response.data = String.Format(Label.Get("px.duplicate"), theMatrixData.Code); } return(true); } // Check if this Release already has a pending WorkflowRequest if (latestRelease != null && new WorkflowRequest_ADO().IsCurrent(Ado, latestRelease.RlsCode)) { Response.error = String.Format(Label.Get("error.workflow"), theMatrixData.Code); return(false); } // Check if this Release has another pending live release if (latestRelease != null && new Release_ADO(Ado).IsLiveNext(latestRelease.RlsCode)) { Response.error = String.Format(Label.Get("px.pendinglive"), theMatrixData.Code); return(false); } //Check if the matrix code is locked in the dataset table using (DatasetAdo dAdo = new DatasetAdo(new ADO("defaultConnection"))) { ADO_readerOutput dResult = dAdo.ReadDatasetLocked(theMatrixData.Code); if (dResult.hasData) { DateTime lockedTime = dResult.data[0].DttDatetimeLocked.Equals(DBNull.Value) ? default : (DateTime)dResult.data[0].DttDatetimeLocked; if (lockedTime.AddMinutes(Configuration_BSO.GetCustomConfig(ConfigType.server, "release.lockTimeMinutes")) > DateTime.Now) { Response.error = Label.Get("error.release.locked"); return(false); } } dAdo.DatasetLockUpdate(theMatrixData.Code, DateTime.Now); } if (latestRelease != null) { if (latestRelease.RlsLiveFlag) { releaseId = mBso.CloneRelease(latestRelease.RlsCode, DTO.GrpCode, SamAccountName); mBso.CloneComment(latestRelease.RlsCode, releaseId, SamAccountName); } else { if (latestRelease.GrpCode != DTO.GrpCode) { releaseId = releaseAdo.IncrementRevision(latestRelease.RlsCode, SamAccountName, DTO.GrpCode); } else { releaseId = releaseAdo.IncrementRevision(latestRelease.RlsCode, SamAccountName); } matrixAdo.Delete(latestRelease.RlsCode, SamAccountName); } // Clean up caching MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_ADDITION + latestRelease.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_DELETION + latestRelease.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_AMENDMENT + latestRelease.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_DATASET + latestRelease.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_METADATA + latestRelease.RlsCode); } else { releaseId = mBso.CreateRelease(theMatrixData, 0, 1, DTO.GrpCode, SamAccountName); } mBso.CreateMatrix(theMatrixData, releaseId, SamAccountName, DTO); swMatrix.Stop(); Log.Instance.Info(string.Format("Matrix object created in {0} ms", Math.Round((double)swMatrix.ElapsedMilliseconds))); Stopwatch swLoad = new Stopwatch(); swLoad.Start(); //Do a Cartesian join to correctly label each data point with its dimensions //Create bulk tables from this and load them to the database var asyncTask = buildBso.CreateAndLoadDataTables(Ado, theMatrixData, true); //We must specifically retrieve any exceptions from the Task and then throw them. Otherwise they will be silent. if (asyncTask.Exception != null) { throw asyncTask.Exception; } matrixAdo.MarkMatrixAsContainingData(theMatrixData.MainSpec.MatrixId, true); Keyword_Release_BSO_CreateMandatory krBSO = new Keyword_Release_BSO_CreateMandatory(); krBSO.Create(Ado, releaseId, SamAccountName, theMatrixData); swLoad.Stop(); Log.Instance.Info(string.Format("Matrix loaded in DB in {0} ms", Math.Round((double)swLoad.ElapsedMilliseconds))); using (DatasetAdo dAdo = new DatasetAdo(new ADO("defaultConnection"))) { dAdo.DatasetLockUpdate(theMatrixData.Code, default); } Response.data = JSONRPC.success; return(true); }
/// <summary> /// /// </summary> /// <returns></returns> public string ToPxString() { return(Configuration_BSO.GetCustomConfig(ConfigType.server, "px.confidential-value")); }
/// <summary> /// For Add and Delete - mark items that have been amended /// </summary> /// <param name="dataItems"></param> /// <param name="theSpec"></param> /// <returns></returns> internal List <DataItem_DTO> GetFlaggedItemsAddDelete(List <DataItem_DTO> dataItems, Specification theSpec, Matrix theMatrixData) { int counter = 0; //Now mark any ADDED datapoint foreach (DataItem_DTO dataItem in dataItems) { dataItem.dataValue = theMatrixData.Cells.ElementAt(counter).TdtValue.Equals(DBNull.Value) ? Configuration_BSO.GetCustomConfig("px.confidential-value") : theMatrixData.Cells.ElementAt(counter).TdtValue; counter++; //if a new classification was added then we must mark everything as amended if (theSpec.Classification.Count > 0) { foreach (ClassificationRecordDTO_Create cls in dataItem.classifications) { //cls will have just one variable - is that a new variable? If so, then flag the data point ClassificationRecordDTO_Create specCls = theSpec.Classification.Where(x => x.Code == cls.Code).FirstOrDefault(); if (specCls != null && specCls.Variable.Where(x => x.Code == cls.Variable.FirstOrDefault().Code).Count() > 0) { dataItem.wasAmendment = true; //the datapoint has been marked as amended, we can now just go straight to the next data point the the foreach loop continue; } } } //If the datapoint has a new statistic then we mark the datapoint as amended if (theSpec.Statistic.Count > 0) { if (theSpec.Statistic.Where(x => x.Code == dataItem.statistic.Code).Count() > 0) { dataItem.wasAmendment = true; //we're in a foreach loop, so there's no point in checking the period - the datapoint is already marked and we move on to the next data point continue; } } //If the datapoint has a new period then we mark the datapoint as amended if (theSpec.Frequency.Period.Count > 0) { if (theSpec.Frequency.Period.Where(x => x.Code == dataItem.period.Code).Count() > 0) { dataItem.wasAmendment = true; } } } return(dataItems); }
/// <summary> /// Reformats the returned data into a complex object /// </summary> /// <param name="rawList"></param> /// <returns></returns> private List <dynamic> FormatOutput(List <dynamic> rawList, string lngIsoCode) { List <dynamic> releases = GetReleases(rawList).ToList(); List <dynamic> classifications = GetClassifications(rawList).ToList(); List <dynamic> periods = GetPeriods(rawList).ToList(); List <dynamic> outList = new List <dynamic>(); foreach (var release in releases) { dynamic rel = new ExpandoObject(); rel.MtrCode = release.MtrCode; rel.MtrTitle = release.MtrTitle; rel.MtrOfficialFlag = release.MtrOfficialFlag; rel.SbjCode = release.SbjCode; rel.SbjValue = release.SbjValue; rel.PrcCode = release.PrcCode; rel.PrcValue = release.PrcValue; rel.RlsLiveDatetimeFrom = release.RlsLiveDatetimeFrom; rel.RlsExceptionalFlag = release.RlsExceptionalFlag; rel.RlsReservationFlag = release.RlsReservationFlag; rel.RlsArchiveFlag = release.RlsArchiveFlag; rel.RlsAnalyticalFlag = release.RlsAnalyticalFlag; rel.RlsDependencyFlag = release.RlsDependencyFlag; rel.CprCode = release.CprCode; rel.CprValue = release.CprValue; rel.LngIsoCode = release.LngIsoCode; rel.LngIsoName = release.LngIsoName; rel.classification = new List <dynamic>(); List <dynamic> classList = new List <dynamic>(); var rlsCls = classifications.Where(x => x.RlsCode == release.RlsCode); foreach (var cls in rlsCls) { dynamic RlsCls = new ExpandoObject(); string readLanguage = Configuration_BSO.GetCustomConfig("language.iso.code"); //If this classification exists in the requested language, return it, otherwise return it in the default language if ((classifications.Where(x => (x.RlsCode == release.RlsCode && x.LngIsoCode == DTO.LngIsoCode)).Count() > 0)) { readLanguage = DTO.LngIsoCode; } if (cls.RlsCode == release.RlsCode && (cls.LngIsoCode == readLanguage)) { RlsCls.ClsCode = cls.ClsCode; RlsCls.ClsValue = cls.ClsValue; RlsCls.ClsGeoFlag = cls.ClsGeoFlag; RlsCls.ClsGeoUrl = cls.ClsGeoUrl; classList.Add(RlsCls); } } rel.classification = classList; rel.FrqCode = release.FrqCode; rel.FrqValue = release.FrqValue; List <dynamic> prdList = new List <dynamic>(); var rlsPrd = periods.Where(x => x.RlsCode == release.RlsCode); foreach (var prd in rlsPrd) { prdList.Add(prd.PrdValue); } rel.period = prdList.ToArray(); rel.Score = release.Score; //Does a version of this matrix exist in our preferred language? bool existsInPreferredLangauge = releases.Where(x => x.LngIsoCode == lngIsoCode && x.MtrCode == release.MtrCode).ToList <dynamic>().Count > 0; // We need to conditionally display our results depending on the preferred language //Either this matrix exists in our preferred language.. //..Or else it doesn't exist in our preferred language but a version exists in the default language if (release.LngIsoCode == lngIsoCode || (release.LngIsoCode == Configuration_BSO.GetCustomConfig("language.iso.code") && !existsInPreferredLangauge)) { outList.Add(rel); } } //merged.OrderBy(x => x.sortID).ToList(); return(outList.OrderByDescending(x => x.Score).ToList()); }
internal static bool ExecuteReadDataset(ADO theAdo, CubeQuery_DTO theDto, Release_DTO releaseDto, JSONRPC_Output theResponse, string requestLanguage, string culture = null, bool defaultPivot = false) { var theMatrix = new Matrix(theAdo, releaseDto, theDto.jStatQueryExtension.extension.Language.Code).ApplySearchCriteria(theDto); if (theMatrix == null) { theResponse.data = null; return(true); } if (theDto.jStatQueryExtension.extension.Format.Type.Equals(Resources.Constants.C_SYSTEM_XLSX_NAME)) { int dataSize = theMatrix.MainSpec.GetDataSize(); int maxSize = Configuration_BSO.GetCustomConfig(ConfigType.global, "dataset.download.threshold.xlsx"); if (dataSize > maxSize) { theResponse.error = String.Format(Label.Get("error.dataset.limit", requestLanguage), dataSize, Resources.Constants.C_SYSTEM_XLSX_NAME, maxSize); return(false); } } else if (theDto.jStatQueryExtension.extension.Format.Type.Equals(Resources.Constants.C_SYSTEM_CSV_NAME)) { int dataSize = theMatrix.MainSpec.GetDataSize(); int maxSize = Configuration_BSO.GetCustomConfig(ConfigType.global, "dataset.download.threshold.csv"); if (dataSize > maxSize) { theResponse.error = String.Format(Label.Get("error.dataset.limit", requestLanguage), dataSize, Resources.Constants.C_SYSTEM_CSV_NAME, maxSize); return(false); } } var matrix = new Cube_ADO(theAdo).ReadCubeData(theMatrix); if (matrix == null) { theResponse.data = null; return(true); } if (!string.IsNullOrEmpty(theDto.jStatQueryExtension.extension.Pivot)) { if (theMatrix.MainSpec.Classification.Where(x => x.Code == theDto.jStatQueryExtension.extension.Pivot).Count() == 0 && Utility.GetCustomConfig("APP_CSV_STATISTIC") != theDto.jStatQueryExtension.extension.Pivot && theMatrix.MainSpec.Frequency.Code != theDto.jStatQueryExtension.extension.Pivot) { theResponse.error = Label.Get("error.validation", theDto.jStatQueryExtension.extension.Language.Code); return(false); } } else { theDto.jStatQueryExtension.extension.Pivot = null; } CultureInfo readCulture; if (culture == null) { readCulture = CultureInfo.CurrentCulture; } else { readCulture = CultureInfo.CreateSpecificCulture(culture); }; if (theDto.jStatQueryExtension.extension.Pivot == null && defaultPivot && theDto.jStatQueryExtension.extension.Format.Type == DatasetFormat.Csv) { theDto.jStatQueryExtension.extension.Pivot = matrix.MainSpec.Frequency.Code; } switch (theDto.jStatQueryExtension.extension.Format.Type) { case DatasetFormat.JsonStat: matrix.FormatType = theDto.jStatQueryExtension.extension.Format.Type; matrix.FormatVersion = theDto.jStatQueryExtension.extension.Format.Version; if (theDto.jStatQueryExtension.extension.Format.Version == "1.0") { var jsonStat = matrix.GetJsonStatV1Object(true, null); theResponse.data = new JRaw(SerializeJsonStatV1.ToJson(jsonStat)); } else if (theDto.jStatQueryExtension.extension.Format.Version == "1.1") { var jsonStat = matrix.GetJsonStatV1_1Object(false, true, null, readCulture); theResponse.data = new JRaw(SerializeJsonStatV1_1.ToJson(jsonStat)); } else { var jsonStat = matrix.GetJsonStatObject(false, true, null, readCulture); theResponse.data = new JRaw(Serialize.ToJson(jsonStat)); } break; case DatasetFormat.Csv: theResponse.data = matrix.GetCsvObject(requestLanguage, false, readCulture, theDto.jStatQueryExtension.extension.Pivot, theDto.jStatQueryExtension.extension.Codes == null ? true : (bool)theDto.jStatQueryExtension.extension.Codes); break; case DatasetFormat.Px: theResponse.data = matrix.GetPxObject(); break; case DatasetFormat.Xlsx: theResponse.data = matrix.GetXlsxObject(requestLanguage, CultureInfo.CurrentCulture, theDto.jStatQueryExtension.extension.Pivot, theDto.jStatQueryExtension.extension.Codes == null ? true : (bool)theDto.jStatQueryExtension.extension.Codes); break; case DatasetFormat.Sdmx: theResponse.data = matrix.GetSdmx(theDto.jStatQueryExtension.extension.Language.Code); break; } if (releaseDto.RlsLiveDatetimeTo != default(DateTime)) { MemCacheD.Store_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadDataset", theDto, theResponse.data, releaseDto.RlsLiveDatetimeTo, Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + matrix.Code); } else { MemCacheD.Store_BSO <dynamic>("PxStat.Data", "Cube_API", "ReadDataset", theDto, theResponse.data, new DateTime(), Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + matrix.Code); } return(true); }
/// <summary> /// Validate Px Settings /// </summary> /// <param name="theMatrix"></param> /// <returns></returns> internal bool PxSettingsAreValid(Matrix theMatrix) { SettingsValidatorResult = new PxSettingsValidator(Ado, true, DTO.LngIsoCode).Validate(theMatrix); if (RequestLanguage.LngIsoCode != null) { if (!DTO.LngIsoCode.Equals(Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"))) { SettingsValidatorResultDefaultLanguage = new PxSettingsValidator(Ado, true, Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")).Validate(theMatrix); } } return(SettingsValidatorResult.IsValid); }
static public string GetFromRequestLanguage(string label) { return(Get(label, RequestLanguage.LngIsoCode == null ? Configuration_BSO.GetCustomConfig("language.iso.code") : RequestLanguage.LngIsoCode)); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoProduct = new Product_ADO(Ado); int nUpdatedProductID = 0; //Check if the product exists if (!adoProduct.ExistsCode(DTO.PrcCode)) { Response.error = Label.Get("error.update"); return(false); } //Duplicate product names aren't allowed, so we check first if (adoProduct.Exists(DTO.PrcValue, DTO.SbjCode)) //|| ) { Response.error = Label.Get("error.duplicate"); return(false); } if (DTO.PrcCodeNew != null) { if (adoProduct.ExistsCode(DTO.PrcCodeNew) && DTO.PrcCode != DTO.PrcCodeNew) { Response.error = Label.Get("error.duplicate"); return(false); } } //We must delete all of the mandatory product keywords for the product Keyword_Product_BSO_Mandatory kpBso = new Keyword_Product_BSO_Mandatory(); int nchanged = kpBso.Delete(Ado, DTO, true); if (nchanged == 0) { Log.Instance.Debug("Delete of keywords failed"); } //Update and retrieve the number of updated rows if (DTO.LngIsoCode != Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")) { ProductLangauge_BSO productLanguageBso = new ProductLangauge_BSO(); nUpdatedProductID = productLanguageBso.CreateOrUpdate(DTO, Ado); if (nUpdatedProductID == 0) { Log.Instance.Debug("Update of ProductLanguage failed"); Response.error = Label.Get("error.update"); return(false); } } if (DTO.PrcCodeNew == null) { DTO.PrcCodeNew = DTO.PrcCode; } bool IsDefault = DTO.LngIsoCode == Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); nUpdatedProductID = adoProduct.Update(DTO, IsDefault, SamAccountName); if (nUpdatedProductID == 0) { Log.Instance.Debug("Update of Product failed"); Response.error = Label.Get("error.update"); return(false); } //Finally we must recreate the mandatory keywords in line with the updated product kpBso.Create(Ado, DTO, nUpdatedProductID); //Flush the cache for search - it's now out of date MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_NAVIGATION_SEARCH); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_NAVIGATION_READ); //Flush caches for each MtrCode affected by this change var mtrResult = adoProduct.GetMtrCodeListForProduct(DTO); if (mtrResult.hasData) { foreach (var mtrCode in mtrResult.data) { MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + mtrCode.MtrCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_METADATA + mtrCode.MtrCode); } } //Flush caches for each RlsCode affected by this change var rlsResult = adoProduct.GetRlsCodeListForProduct(DTO); if (rlsResult.hasData) { foreach (var rlsCode in rlsResult.data) { MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_DATASET + rlsCode.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_METADATA + rlsCode.RlsCode); } } Response.data = JSONRPC.success; return(true); }
/// <summary> /// Modify the search terms as a table of keywords /// </summary> /// <returns></returns> internal DataTable PrepareSearchData() { //Get a keyword extractor. The keyword extractor should, if possible, correspond to the supplied LngIsoCode //If an extractor is not found for the supplied LngIsoCode then a basic default extractor is supplied. Keyword_BSO_Extract kbe = new Keyword_BSO_Extract(DTO.LngIsoCode); // IKeywordExtractor extractor = kbe.GetExtractor(); //Get a list of keywords based on the supplied search term List <string> searchList = new List <string>(); List <string> searchListInvariant = new List <string>(); if (DTO.Search != null) { //Get a singularised version of each word searchList = kbe.ExtractSplitSingular(DTO.Search); //We need a count of search terms (ignoring duplicates caused by singularisation) searchTermCount = searchList.Count; //Some words will not be searched for in their singular form (flagged on the table), so we need those as well searchListInvariant = kbe.ExtractSplit(DTO.Search); //Eliminate duplicates from the list searchList = searchList.Union(searchListInvariant).ToList(); } //The list of keywords must be supplied to the search stored procedure //In order to do this, we pass a datatable as a parameter //First we create the table DataTable dt = new DataTable(); dt.Columns.Add("Key"); dt.Columns.Add("Value"); dt.Columns.Add("Attribute"); int searchSynonymMult = Configuration_BSO.GetCustomConfig(ConfigType.server, "search.synonym-multiplier"); int searchWordMult = Configuration_BSO.GetCustomConfig(ConfigType.server, "search.search-word-multiplier"); //Gather any synonyms and include them in the search, in the synonyms column foreach (string word in searchList) { var hitlist = kbe.extractor.SynonymList.Where(x => x.match == word.ToLower()); if ((kbe.extractor.SynonymList.Where(x => x.match == word.ToLower())).Count() > 0) { foreach (var syn in hitlist) { var row = dt.NewRow(); row["Key"] = syn.lemma; row["Value"] = syn.match; row["Attribute"] = searchSynonymMult; dt.Rows.Add(row); } } else { var row = dt.NewRow(); row["Key"] = word; row["Value"] = word; row["Attribute"] = searchSynonymMult; dt.Rows.Add(row); } //The main search term must be included along with the synonyms, i.e. a word is a synonym of itself //But with a higher search priority, which goes into the Attribute column var keyrow = dt.NewRow(); if (dt.Select("Key = '" + word + "'").Count() == 0) { keyrow["Key"] = word; keyrow["Value"] = word; keyrow["Attribute"] = searchWordMult; dt.Rows.Add(keyrow); } } //Sort the search terms to ensure invariant word order in the search dt.DefaultView.Sort = "Key,Value asc"; dt = dt.DefaultView.ToTable(); return(dt); }
/// <summary> /// Constructor /// </summary> /// <param name="parameters"></param> public Navigation_DTO_Search(dynamic parameters) { if (parameters.LngIsoCode != null) { LngIsoCode = parameters.LngIsoCode; } else { LngIsoCode = Configuration_BSO.GetCustomConfig("language.iso.code"); } if (parameters.MtrCode != null) { MtrCode = parameters.MtrCode; } if (parameters.MtrOfficialFlag != null) { MtrOfficialFlag = parameters.MtrOfficialFlag; } if (parameters.SbjCode != null) { SbjCode = parameters.SbjCode; } if (parameters.PrcCode != null) { PrcCode = parameters.PrcCode; } if (parameters.CprCode != null) { CprCode = parameters.CprCode; } if (parameters.RlsExceptionalFlag != null) { RlsExceptionalFlag = parameters.RlsExceptionalFlag; } if (parameters.RlsReservationFlag != null) { RlsReservationFlag = parameters.RlsReservationFlag; } if (parameters.RlsArchiveFlag != null) { RlsArchiveFlag = parameters.RlsArchiveFlag; } if (parameters.RlsAnalyticalFlag != null) { RlsAnalyticalFlag = parameters.RlsAnalyticalFlag; } if (parameters.Search != null) { Search = parameters.Search; if (string.IsNullOrEmpty(Search) || string.IsNullOrWhiteSpace(Search)) { Search = null; } } }
/// <summary> /// Search method /// </summary> /// <param name="dto"></param> /// <returns></returns> internal dynamic Search(Navigation_DTO_Search dto) { //Get a keyword extractor. The keyword extractor should, if possible, correspond to the supplied LngIsoCode //If an extractor is not found for the supplied LngIsoCode then a basic default extractor is supplied. Keyword_BSO_Extract kbe = new Keyword_BSO_Extract(dto.LngIsoCode); // IKeywordExtractor extractor = kbe.GetExtractor(); //Get a list of keywords based on the supplied search term List <string> searchList = new List <string>(); List <string> searchListInvariant = new List <string>(); int searchTermCount = 0; if (dto.Search != null) { //Get a singularised version of each word searchList = kbe.ExtractSplitSingular(dto.Search); //We need a count of search terms (ignoring duplicates caused by singularisation) searchTermCount = searchList.Count; //Some words will not be searched for in their singular form (flagged on the table), so we need those as well searchListInvariant = kbe.ExtractSplit(dto.Search); //Eliminate duplicates from the list searchList = searchList.Union(searchListInvariant).ToList(); } //The list of keywords must be supplied to the search stored procedure //In order to do this, we pass a datatable as a parameter //First we create the table DataTable dt = new DataTable(); dt.Columns.Add("Key"); dt.Columns.Add("Value"); dt.Columns.Add("Attribute"); //Gather any synonyms and include them in the search, in the synonyms column foreach (string word in searchList) { var hitlist = kbe.extractor.SynonymList.Where(x => x.match == word.ToLower()); if ((kbe.extractor.SynonymList.Where(x => x.match == word.ToLower())).Count() > 0) { foreach (var syn in hitlist) { var row = dt.NewRow(); row["Key"] = syn.lemma; row["Value"] = syn.match; row["Attribute"] = Configuration_BSO.GetCustomConfig("search.synonym-multiplier"); dt.Rows.Add(row); } } else { var row = dt.NewRow(); row["Key"] = word; row["Value"] = word; row["Attribute"] = Configuration_BSO.GetCustomConfig("search.synonym-multiplier"); dt.Rows.Add(row); } //The main search term must be included along with the synonyms, i.e. a word is a synonym of itself //But with a higher search priority, which goes into the Attribute column var keyrow = dt.NewRow(); if (dt.Select("Key = '" + word + "'").Count() == 0) { keyrow["Key"] = word; keyrow["Value"] = word; keyrow["Attribute"] = Configuration_BSO.GetCustomConfig("search.search-word-multiplier"); dt.Rows.Add(keyrow); } } //Sort the search terms to ensure invariant word order in the search dt.DefaultView.Sort = "Key,Value asc"; dt = dt.DefaultView.ToTable(); //The ExecuteReaderProcedure method requires that the parameters be contained in a List<ADO_inputParams> List <ADO_inputParams> paramList = new List <ADO_inputParams>() { new ADO_inputParams() { name = "@LngIsoCode", value = dto.LngIsoCode } }; ADO_inputParams param = new ADO_inputParams() { name = "@Search", value = dt }; param.typeName = "KeyValueVarcharAttribute"; paramList.Add(param); //We need a count of search terms (ignoring duplicates caused by singularisation) paramList.Add(new ADO_inputParams() { name = "@SearchTermCount", value = searchTermCount }); if (dto.MtrCode != null) { paramList.Add(new ADO_inputParams() { name = "@MtrCode", value = dto.MtrCode }); } if (dto.MtrOfficialFlag != null) { paramList.Add(new ADO_inputParams() { name = "@MtrOfficialFlag", value = dto.MtrOfficialFlag }); } if (dto.SbjCode != default(int)) { paramList.Add(new ADO_inputParams() { name = "@SbjCode", value = dto.SbjCode }); } if (dto.PrcCode != null) { paramList.Add(new ADO_inputParams() { name = "@PrcCode", value = dto.PrcCode }); } if (dto.CprCode != null) { paramList.Add(new ADO_inputParams() { name = "@CprCode", value = dto.CprCode }); } if (dto.RlsExceptionalFlag != null) { paramList.Add(new ADO_inputParams() { name = "@RlsExceptionalFlag", value = dto.RlsExceptionalFlag }); } if (dto.RlsReservationFlag != null) { paramList.Add(new ADO_inputParams() { name = "@RlsReservationFlag", value = dto.RlsReservationFlag }); } if (dto.RlsArchiveFlag != null) { paramList.Add(new ADO_inputParams() { name = "@RlsArchiveFlag", value = dto.RlsArchiveFlag }); } if (dto.RlsAnalyticalFlag != null) { paramList.Add(new ADO_inputParams() { name = "@RlsAnalyticalFlag", value = dto.RlsAnalyticalFlag }); } //We store from the ADO because the search terms may have been changed by keyword rules MemCachedD_Value cache = MemCacheD.Get_ADO("PxStat.System.Navigation", "System_Navigation_Search", paramList); // if (cache.hasData) { return(cache.data.ToObject <List <dynamic> >()); } //Call the stored procedure ADO_readerOutput output = ado.ExecuteReaderProcedure("System_Navigation_Search", paramList); MemCacheD.Store_ADO <dynamic>("PxStat.System.Navigation", "System_Navigation_Search", paramList, output.data, new DateTime(), Resources.Constants.C_CAS_NAVIGATION_SEARCH); //return the list of entities that have been found return(output.data); }
internal static void SendLoginTemplateEmail(string subject, List <string> addressTo, string header, string content, string footer, string subHeader, string lngIsoCode, List <string> addressCc = null, List <string> addressBcc = null) { using (eMail email = new eMail()) { email.Subject = subject; foreach (string to in addressTo) { email.To.Add(to); } if (addressCc != null) { foreach (string cc in addressCc) { email.CC.Add(cc); } } if (addressBcc != null) { foreach (string bcc in addressBcc) { email.Bcc.Add(bcc); } } var listToParse = new List <eMail_KeyValuePair>(); string body = header + Environment.NewLine + content + Environment.NewLine + footer; listToParse.Add(new eMail_KeyValuePair() { key = "{header}", value = header }); listToParse.Add(new eMail_KeyValuePair() { key = "{sub_header}", value = subHeader }); listToParse.Add(new eMail_KeyValuePair() { key = "{content}", value = content }); listToParse.Add(new eMail_KeyValuePair() { key = "{footer}", value = footer }); listToParse.Add(new eMail_KeyValuePair() { key = "{subject}", value = subject }); listToParse.Add(new eMail_KeyValuePair() { key = "{image_source}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo") }); listToParse.Add(new eMail_KeyValuePair() { key = "{datetime_label}", value = Label.Get("label.date-time", lngIsoCode) }); listToParse.Add(new eMail_KeyValuePair() { key = "{date_format}", value = Label.Get("label.date-format", lngIsoCode) }); listToParse.Add(new eMail_KeyValuePair() { key = "{timezone}", value = Label.Get("label.timezone", lngIsoCode) }); email.Body = email.ParseTemplate(Properties.Resources.template_Login, listToParse); try { email.Send(); } catch (Exception ex) { Log.Instance.Error("Email failure: " + ex.Message); } } }
/// <summary> /// Constructor /// </summary> /// <param name="parameters"></param> public Cube_DTO_Read(dynamic parameters) { if (parameters.matrix != null) { this.matrix = parameters.matrix; } if (parameters.release != null) { this.release = parameters.release; } if (parameters.language != null) { this.language = parameters.language; } else { this.language = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); } Format = new Format_DTO_Read(); if (parameters.format != null) { if (parameters.format.type != null) { Format.FrmType = parameters.format.type; } Format.FrmDirection = API.Utility.GetCustomConfig("APP_FORMAT_DOWNLOAD_NAME"); if (parameters.format.version != null) { Format.FrmVersion = parameters.format.version; } } if (parameters.role != null) { this.role = GetJsonObject <Role>(parameters.role, Converter.Settings); } if (parameters.dimension != null) { this.dimension = this.GetJsonObject <IList <Dimension> >(parameters.dimension, Converter.Settings); } // Default language if (string.IsNullOrEmpty(this.language)) { this.language = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); } // Default format if (string.IsNullOrEmpty(this.Format.FrmType)) { this.Format.FrmType = Utility.GetCustomConfig("APP_DEFAULT_DATASET_FORMAT"); } }
/// <summary> /// Create and get a spreadsheet as a serialized string based on the Matrix /// </summary> /// <param name="theMatrix"></param> /// <param name="rowLists"></param> /// <param name="lngIsoCode"></param> /// <param name="ci"></param> /// <returns></returns> internal string GetXlsx(Matrix theMatrix, List <List <XlsxValue> > rowLists, string lngIsoCode = null, CultureInfo ci = null) { ExcelDocument xl = new ExcelDocument(); xl.CreateSpreadsheet(); Specification spec = theMatrix.GetSpecFromLanguage(lngIsoCode); if (spec == null) { spec = theMatrix.MainSpec; } //First we create a contents page. This is built up piecemeal List <XlsxValue> line; List <List <XlsxValue> > matrix = new List <List <XlsxValue> >(); //some blank lines first for (int i = 0; i < 7; i++) { line = new List <XlsxValue>(); int headerId = i == 0 ? 1 : 0; for (int j = 0; j < 1; j++) { XlsxValue xval = new XlsxValue() { Value = "", StyleId = 0, DataType = CellValues.String }; line.Add(xval); } matrix.Add(line); } //Now create the actual entries in the contents page line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, CellWidth = 20, Value = Label.Get("xlsx.table", lngIsoCode), StyleId = 8 }); line.Add(new XlsxValue() { DataType = CellValues.String, CellWidth = 20, Value = "", StyleId = 8 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.code", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Code, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.name", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = spec.Contents, StyleId = 0 }); matrix.Add(line); string lngCulture = Utility.GetUserAcceptLanguage(); DateTime dtLast; string dateString = ""; if (theMatrix.CreationDate.Length > 15) { dtLast = new DateTime(Convert.ToInt32(theMatrix.CreationDate.Substring(0, 4)), Convert.ToInt32(theMatrix.CreationDate.Substring(4, 2)), Convert.ToInt32(theMatrix.CreationDate.Substring(6, 2)), Convert.ToInt32(theMatrix.CreationDate.Substring(9, 2)), Convert.ToInt32(theMatrix.CreationDate.Substring(12, 2)), 0); dateString = dtLast.ToString(ci != null ? ci : CultureInfo.InvariantCulture); } else { dateString = theMatrix.CreationDate; } line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.last-updated", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = dateString, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.note", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = spec.Notes != null ? String.Join(" ", spec.Notes) : spec.NotesAsString != null ? spec.NotesAsString : "", StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.url", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Configuration_BSO.GetCustomConfig("url.application") + "/" + Utility.GetCustomConfig("APP_COOKIELINK_RELEASE") + '/' + theMatrix.Release.RlsCode.ToString(), StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.product", lngIsoCode), StyleId = 8 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = " ", StyleId = 8 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.code", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.PrcCode, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.name", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.PrcValue, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.contacts", lngIsoCode), StyleId = 8 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = " ", StyleId = 8 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.name", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.GrpContactName, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.email", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.GrpContactEmail, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.phone", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.GrpContactPhone, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.copyright", lngIsoCode), StyleId = 8 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = " ", StyleId = 8 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.code", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Copyright.CprCode, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.name", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Copyright.CprValue, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.url", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Copyright.CprUrl, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.properties", lngIsoCode), StyleId = 8 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = " ", StyleId = 8 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.official-statistics", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.IsOfficialStatistic ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode), StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.exceptional", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.RlsExceptionalFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode), StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.archived", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.RlsArchiveFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode), StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.analytical", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.RlsAnalyticalFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode), StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.dependency", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = theMatrix.Release.RlsDependencyFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode), StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = "", StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.language", lngIsoCode), StyleId = 8 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = " ", StyleId = 8 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.iso-code", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = spec.Language, StyleId = 0 }); matrix.Add(line); line = new List <XlsxValue>(); line.Add(new XlsxValue() { DataType = CellValues.String, Value = Label.Get("xlsx.iso-name", lngIsoCode), StyleId = 1 }); line.Add(new XlsxValue() { DataType = CellValues.String, Value = new Language_BSO().Read(spec.Language).LngIsoName, StyleId = 0 }); matrix.Add(line); //We've created the 2D object to represent the contents, so now we can create a worksheet from that: xl.InsertDataWorksheet(matrix, Label.Get("About", lngIsoCode), OrientationValues.Landscape, true); //On the worksheet we've just created, add an image to the top left hand corner xl.AddImage(Configuration_BSO.GetCustomConfig("url.logo"), Label.Get("About", lngIsoCode), 1, 1); //Create a second worksheet based on the Matrix contents xl.InsertDataWorksheet(theMatrix.GetMatrixSheet(null, false, 1), theMatrix.Code, OrientationValues.Landscape, true); //cleanup xl.Close(); //Test option...get a local version of the xlsx file //xl.SaveToFile(@"C:\nok\Schemas\" + theMatrix.Code + ".xlsx"); //return the serialized version of the spreadsheet return(xl.SerializeSpreadsheetFromByteArrayBase64()); }
/// <summary> /// Compare Releases and find data points that have changed /// </summary> /// <param name="Ado"></param> /// <param name="dtoRight"></param> /// <param name="dtoLeft"></param> /// <returns></returns> internal Matrix CompareAmendment(ADO Ado, Compare_DTO_Read dtoRight, Compare_DTO_Read dtoLeft) { bool totalChange = false; Release_DTO lDto = new Release_DTO(); Release_DTO rDto = new Release_DTO(); lDto.RlsCode = dtoLeft.RlsCode; rDto.RlsCode = dtoRight.RlsCode; Matrix leftMatrix = new Matrix(Ado, lDto, dtoLeft.LngIsoCode); Matrix rightMatrix = new Matrix(Ado, rDto, dtoRight.LngIsoCode); Specification spec = new Data.Matrix.Specification(); spec.Statistic = leftMatrix.MainSpec.Statistic.Intersect(rightMatrix.MainSpec.Statistic).ToList <StatisticalRecordDTO_Create>(); spec.Frequency = new FrequencyRecordDTO_Create(); spec.Frequency.Code = rightMatrix.MainSpec.Frequency.Code; spec.Frequency.Value = rightMatrix.MainSpec.Frequency.Value; spec.Frequency.Period = new List <PeriodRecordDTO_Create>(); spec.Frequency.Period = leftMatrix.MainSpec.Frequency.Period.Intersect(rightMatrix.MainSpec.Frequency.Period).ToList <PeriodRecordDTO_Create>(); //We now get the added variables. Note that this only applies where the classifications themselves have not been added //Classifications will contain (1) Brand new classifications, (2) classifications that have had variables added to them List <ClassificationRecordDTO_Create> intersectCls = leftMatrix.MainSpec.Classification.Intersect(rightMatrix.MainSpec.Classification).ToList <ClassificationRecordDTO_Create>(); //if there are different classifications in each matrix (something added or deleted) then return all false for amendments if (intersectCls != null) { if (intersectCls.Count != leftMatrix.MainSpec.Classification.Count || intersectCls.Count != rightMatrix.MainSpec.Classification.Count) { totalChange = true; } } else { totalChange = true; } spec.Classification = new List <ClassificationRecordDTO_Create>(); foreach (ClassificationRecordDTO_Create cls in intersectCls) { ClassificationRecordDTO_Create otherCls = rightMatrix.MainSpec.Classification.Where(x => x.Equals(cls)).FirstOrDefault();//lefttoright List <VariableRecordDTO_Create> newVars = cls.Variable.Intersect(otherCls.Variable).ToList <VariableRecordDTO_Create>(); if (newVars.Count > 0) { cls.Variable = newVars; spec.Classification.Add(cls); } if (newVars.Count == 0) { totalChange = true; } } //If there are no periods or statistics in common then everything has changed and this is flagged if (spec.Frequency.Period.Count == 0 || spec.Statistic.Count == 0) { totalChange = true; } leftMatrix.MainSpec = spec; //If there are no periods in common then nothing could have been amended - prepare for a graceful exit if (spec.Frequency.Period.Count > 0) { rightMatrix.MainSpec = spec; } //Get the matrix based on a database read of the DTO RlsCode Matrix_ADO mAdo = new Matrix_ADO(Ado); //Get the data for leftMatrix //Get the data for rightMatrix //Compare and flag where they're not equal //return the matrix leftMatrix.TimeFilterWasApplied = true; rightMatrix.TimeFilterWasApplied = true; leftMatrix.StatFilterWasApplied = true; rightMatrix.StatFilterWasApplied = true; foreach (var cls in leftMatrix.MainSpec.Classification) { cls.ClassificationFilterWasApplied = true; } if (!totalChange) { leftMatrix = new Cube_ADO(Ado).ReadCubeData(leftMatrix); } rightMatrix = new Cube_ADO(Ado).ReadCubeData(rightMatrix); int counter = 0; foreach (var cell in rightMatrix.Cells) { //If there are no periods in common then nothing could have been amended. //Similarly, if there was a difference in the number of classifications if (totalChange) { cell.WasAmendment = false; } else { if (cell.TdtValue.Equals(DBNull.Value)) { cell.TdtValue = Configuration_BSO.GetCustomConfig("px.confidential-value"); } if (leftMatrix.Cells.ElementAt(counter).TdtValue.Equals(DBNull.Value)) { leftMatrix.Cells.ElementAt(counter).TdtValue = Configuration_BSO.GetCustomConfig("px.confidential-value"); } if (cell.TdtValue != leftMatrix.Cells.ElementAt(counter).TdtValue) { cell.WasAmendment = true; } else { cell.WasAmendment = false; } } counter++; } return(rightMatrix); }
/// <summary> /// Map RESTful parameters to JsonRpc parameters /// </summary> /// <param name="restfulParameters"></param> /// <returns></returns> internal dynamic ReadDataset_MapParameters(dynamic restfulParameters) { dynamic jsonStatParameters = new ExpandoObject(); dynamic obj = new ExpandoObject(); var dict = (IDictionary <string, object>)obj; dynamic extension = new ExpandoObject(); dynamic dimension = new ExpandoObject(); extension.codes = false; extension.matrix = restfulParameters[1]; extension.language = restfulParameters.Count >= 5 ? new { code = restfulParameters[4] } : new { code = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code") }; if (((string)extension.language.code).Length == 0) { extension.language = new { code = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code") } } ; extension.format = new { type = restfulParameters[2], version = restfulParameters[3] }; if (restfulParameters.Count >= 6) { extension.pivot = restfulParameters[5]; } else { extension.pivot = null; } jsonStatParameters.extension = extension; jsonStatParameters.dimension = dimension; dict["class"] = Constants.C_JSON_STAT_QUERY_CLASS; dict["id"] = new string[] { }; dict["dimension"] = dimension; dict["extension"] = extension; dict["version"] = Constants.C_JSON_STAT_QUERY_VERSION; dict["m2m"] = true; string suffix; using (Format_BSO bso = new Format_BSO(new ADO("defaultConnection"))) { this.MimeType = bso.GetMimetypeForFormat(new Format_DTO_Read() { FrmType = restfulParameters[2], FrmVersion = restfulParameters[3] }); suffix = bso.GetFileSuffixForFormat(new Format_DTO_Read() { FrmType = restfulParameters[2], FrmVersion = restfulParameters[3] }); }; if (suffix != null) { this.FileName = extension.matrix + DateTime.Now.ToString("yyyyMMddHHmmss") + suffix; } return(Utility.JsonSerialize_IgnoreLoopingReference(dict)); } }
/// <summary> /// In the constructor, we will attempt to get the language specific extractor. /// If we can't find one then we'll revert to the default language /// </summary> /// <param name="lngIsoCode"></param> internal Keyword_BSO_Extract(string lngIsoCode) { keyword = new PxStat.Keyword(lngIsoCode); string extractorClassName = Utility.GetCustomConfig("APP_INTERNATIONALISATION_EXTRACTOR_CLASS_NAME") + lngIsoCode; Type extractorType = Type.GetType(extractorClassName); if (extractorType != null) { this.extractor = (IKeywordExtractor)Assembly.GetAssembly(extractorType).CreateInstance(extractorType.FullName); } else { extractorClassName = Utility.GetCustomConfig("APP_INTERNATIONALISATION_EXTRACTOR_CLASS_NAME") + Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); extractorType = Type.GetType(extractorClassName); this.extractor = (IKeywordExtractor)Assembly.GetAssembly(extractorType).CreateInstance(extractorClassName); } }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { var adoProduct = new Product_ADO(Ado); int nUpdatedProductID = 0; //Check if the product exists if (!adoProduct.ExistsCode(DTO.PrcCode)) { Response.error = Label.Get("error.update"); return(false); } //Duplicate product names aren't allowed, so we check first if (adoProduct.Exists(DTO.PrcValue, DTO.SbjCode) || (adoProduct.ExistsCode(DTO.PrcCodeNew) && DTO.PrcCode != DTO.PrcCodeNew)) { Response.error = Label.Get("error.duplicate"); return(false); } //We must delete all of the mandatory product keywords for the product Keyword_Product_BSO_Mandatory kpBso = new Keyword_Product_BSO_Mandatory(); int nchanged = kpBso.Delete(Ado, DTO, true); if (nchanged == 0) { Log.Instance.Debug("Delete of keywords failed"); } //Update and retrieve the number of updated rows if (DTO.LngIsoCode != Configuration_BSO.GetCustomConfig("language.iso.code")) { ProductLangauge_BSO productLanguageBso = new ProductLangauge_BSO(); nUpdatedProductID = productLanguageBso.CreateOrUpdate(DTO, Ado); if (nUpdatedProductID == 0) { Log.Instance.Debug("Update of ProductLanguage failed"); Response.error = Label.Get("error.update"); return(false); } } if (DTO.PrcCodeNew == null) { DTO.PrcCodeNew = DTO.PrcCode; } bool IsDefault = DTO.LngIsoCode == Configuration_BSO.GetCustomConfig("language.iso.code"); nUpdatedProductID = adoProduct.Update(DTO, IsDefault, SamAccountName); if (nUpdatedProductID == 0) { Log.Instance.Debug("Update of Product failed"); Response.error = Label.Get("error.update"); return(false); } //Finally we must recreate the mandatory keywords in line with the updated product kpBso.Create(Ado, DTO, nUpdatedProductID); Response.data = JSONRPC.success; return(true); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { //only if the WorkflowRequest is AwaitingResponse Workflow_ADO wfAdo = new Workflow_ADO(); ADO_readerOutput output = wfAdo.ReadAwaitingResponse(Ado, SamAccountName, DTO.RlsCode, Configuration_BSO.GetCustomConfig("language.iso.code")); if (!output.hasData) { Log.Instance.Debug("No valid AwaitingResponse workflow found for RlsCode " + DTO.RlsCode); return(false); } WorkflowRequest_ADO wfReqAdo = new WorkflowRequest_ADO(); int deleted = wfReqAdo.Delete(Ado, DTO.RlsCode, SamAccountName); if (deleted == 0) { Log.Instance.Debug("Can't delete the workflow for RlsCode " + DTO.RlsCode); return(false); } Response.data = JSONRPC.success; return(true); }
/// <summary> /// Send mails for a workflow /// </summary> /// <param name="email"></param> /// <param name="title"></param> /// <param name="subject"></param> /// <param name="body"></param> private void sendMail(eMail email, string title, string subject, string body) { var listToParse = new List <eMail_KeyValuePair>(); List <string> grpCodes = new List <string>(); grpCodes = DTO.GroupCodes.Select(s => (string)s.GrpCode).ToList(); string grouplist = grpCodes.Any() ? String.Join(", ", grpCodes) : Label.Get("static.all-groups"); listToParse.Add(new eMail_KeyValuePair() { key = "{title}", value = title }); listToParse.Add(new eMail_KeyValuePair() { key = "{subject}", value = subject }); listToParse.Add(new eMail_KeyValuePair() { key = "{body}", value = body }); listToParse.Add(new eMail_KeyValuePair() { key = "{received-by}", value = string.Format(Label.Get("label.timezone", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")), grouplist) }); listToParse.Add(new eMail_KeyValuePair() { key = "{website_name}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "title") }); listToParse.Add(new eMail_KeyValuePair() { key = "{website_url}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.application") }); listToParse.Add(new eMail_KeyValuePair() { key = "{image_source}", value = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo") }); listToParse.Add(new eMail_KeyValuePair() { key = "{datetime_label}", value = Label.Get("label.date-time", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")) }); listToParse.Add(new eMail_KeyValuePair() { key = "{date_format}", value = Label.Get("label.date-format", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")) }); listToParse.Add(new eMail_KeyValuePair() { key = "{timezone}", value = Label.Get("label.timezone", Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")) }); email.Subject = subject; email.Body = email.ParseTemplate(Properties.Resources.template_GroupMessage, listToParse); email.Send(); }
internal JSONRPC_Output WorkflowSignoffCreate(ADO Ado, WorkflowSignoff_DTO DTO, string SamAccountName) { JSONRPC_Output response = new JSONRPC_Output(); ADO_readerOutput moderators = new ADO_readerOutput(); ADO_readerOutput powerUsers = new ADO_readerOutput(); var adoWorkflowRequest = new WorkflowRequest_ADO(); var adoWorkflowResponse = new WorkflowResponse_ADO(); Release_DTO dtoWip = null; if (!adoWorkflowResponse.IsInUse(Ado, DTO)) // is current workflow -- this should be the response!! { //No Live workflow found so we can't proceed Log.Instance.Debug("No Current workflow response found for this Release Code"); response.error = Label.Get("error.create"); return(response); } //Is this awaiting signoff? var adoWorkflow = new Workflow_ADO(); ADO_readerOutput resultStatus = adoWorkflow.ReadAwaitingSignoff(Ado, SamAccountName, DTO.RlsCode, Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code")); if (!resultStatus.hasData) { //Release not awaiting signoff so we can't proceed Log.Instance.Debug("Release not in status Awaiting Signoff"); response.error = Label.Get("error.update"); return(response); } Security.ActiveDirectory_DTO signoffUser = new Security.ActiveDirectory_DTO() { CcnUsername = SamAccountName }; Security.ActiveDirectory_ADO accAdo = new Security.ActiveDirectory_ADO(); Security.Account_DTO_Read accDto = new Security.Account_DTO_Read() { CcnUsername = signoffUser.CcnUsername }; DTO.SignoffAccount = accAdo.GetUser(Ado, accDto); var adoSignoff = new WorkflowSignoff_ADO(); //Create a comment var adoComment = new Comment_ADO(); int commentCode = adoComment.Create(Ado, DTO, SamAccountName); if (commentCode == 0) { // Can't create a comment so we can't proceed Log.Instance.Debug("Can't create a comment "); response.error = Label.Get("error.create"); return(response); } DTO.CmmCode = commentCode; //We must read the Request and in order to see how we are going to proceed WorkflowRequest_ADO adoWrq = new WorkflowRequest_ADO(); List <WorkflowRequest_DTO> dtoWrqList = adoWrq.Read(Ado, DTO.RlsCode, true); if (dtoWrqList.Count > 1) { //Multiple requests found for this release Log.Instance.Debug("More than one request found for this release "); response.error = Label.Get("error.create"); return(response); } //there must be exactly one live Workflow request at this point WorkflowRequest_DTO dtoWrq = dtoWrqList.Find(x => x.RqsCode != null); //Get the current Release Release_ADO adoRelease = new Release_ADO(Ado); Release_DTO dtoRelease = Release_ADO.GetReleaseDTO(adoRelease.Read(DTO.RlsCode, SamAccountName)); if (dtoRelease == null) { Log.Instance.Debug("Release not found"); response.error = Label.Get("error.create"); return(response); } Account_BSO aBso = new Account_BSO(Ado); moderators = aBso.getReleaseUsers(DTO.RlsCode, null); powerUsers = aBso.getUsersOfPrivilege(Constants.C_SECURITY_PRIVILEGE_POWER_USER); //Is this a Reject? if (DTO.SgnCode.Equals(Constants.C_WORKFLOW_STATUS_REJECT)) { int res = adoSignoff.Create(Ado, DTO, SamAccountName); if (res == 0) { //Can't create a Workflow Signoff so we can't proceed Log.Instance.Debug("Can't create a Workflow Signoff "); response.error = Label.Get("error.create"); return(response); } WorkflowRequest_DTO_Update dtoReq = new WorkflowRequest_DTO_Update(DTO.RlsCode); dtoReq.WrqCurrentFlag = false; //update the request int reqUpdate = adoWorkflowRequest.Update(Ado, dtoReq, SamAccountName); if (reqUpdate == 0) { //Can't save the Request so we can't proceed Log.Instance.Debug("Can't save the Workflow Request"); response.error = Label.Get("error.update"); return(response); } DTO.MtrCode = dtoRelease.MtrCode; // we need this to see which cache we must flush response.data = JSONRPC.success; Email_BSO_NotifyWorkflow notifyReject = new Email_BSO_NotifyWorkflow(); try { notifyReject.EmailSignoff(dtoWrq, DTO, dtoRelease, moderators, powerUsers); } catch { } return(response); } //Not a Reject so we proceed... switch (dtoWrq.RqsCode) { case Constants.C_WORKFLOW_REQUEST_PUBLISH: if (String.IsNullOrEmpty(dtoRelease.PrcCode)) { //There must be a valid product for this release Log.Instance.Debug("No product found for the release "); response.error = Label.Get("error.publish"); return(response); } //Update the current release LiveDatetimeTo to the request Date time dtoRelease.RlsLiveDatetimeFrom = dtoWrq.WrqDatetime; //set the release live flag //update the release version and set the current revision to 0 DateTime switchDate; switchDate = DateTime.Now > dtoWrq.WrqDatetime ? DateTime.Now : dtoWrq.WrqDatetime; dtoRelease.RlsVersion++; dtoRelease.RlsRevision = 0; dtoRelease.RlsLiveFlag = true; dtoRelease.RlsExceptionalFlag = dtoWrq.WrqExceptionalFlag != null ? dtoWrq.WrqExceptionalFlag.Value : false; dtoRelease.RlsReservationFlag = dtoWrq.WrqReservationFlag != null ? dtoWrq.WrqReservationFlag.Value : false; dtoRelease.RlsArchiveFlag = dtoWrq.WrqArchiveFlag != null ? dtoWrq.WrqArchiveFlag.Value : false; dtoRelease.RlsExperimentalFlag = dtoWrq.WrqExperimentalFlag != null ? dtoWrq.WrqExperimentalFlag.Value : false; dtoRelease.RlsLiveDatetimeFrom = switchDate; //get the current live release Release_DTO releaseDTONow = Release_ADO.GetReleaseDTO(adoRelease.ReadLiveNow(DTO.RlsCode)); //Save the changes for the release we're changing int update = adoRelease.Update(dtoRelease, SamAccountName); if (update == 0) { Log.Instance.Debug("Can't update the Release, RlsCode:" + dtoRelease.RlsCode); response.error = Label.Get("error.update"); return(response); } if (releaseDTONow != null) { //...if there is a previous release if (releaseDTONow.RlsCode != 0) { //Update the Live LiveDatetimeTo to the request Datetime releaseDTONow.RlsLiveDatetimeTo = switchDate; //Save the changes for the previous release adoRelease.Update(releaseDTONow, SamAccountName); } } break; case Constants.C_WORKFLOW_REQUEST_PROPERTY: //update release to transfer all flag values from the request to the release dtoRelease.RlsReservationFlag = dtoWrq.WrqReservationFlag != null ? dtoWrq.WrqReservationFlag.Value : false; dtoRelease.RlsArchiveFlag = dtoWrq.WrqArchiveFlag != null ? dtoWrq.WrqArchiveFlag.Value : false; dtoRelease.RlsExperimentalFlag = dtoWrq.WrqExperimentalFlag != null ? dtoWrq.WrqExperimentalFlag.Value : false; //Save the release int updateCount = adoRelease.Update(dtoRelease, SamAccountName); if (updateCount == 0) { //Update of Release failed Log.Instance.Debug("Can't update the Release, RlsCode:" + DTO.RlsCode); response.error = Label.Get("error.update"); return(response); } //if there is a WIP or a pending live associated with this matrix then we need to update the WIP/Pending Live as well: Release_BSO rBso = new Release_BSO(Ado); dynamic wipForLive = rBso.GetWipForLive(dtoRelease.RlsCode, SamAccountName); if (wipForLive == null) { wipForLive = rBso.GetPendingLiveForLive(dtoRelease.RlsCode, SamAccountName); } if (wipForLive != null) { //if a workflow exists for wipForLive, then we must update the flags on that workflow as well var wfForLive = adoWorkflowRequest.Read(Ado, wipForLive.RlsCode, true); if (wfForLive != null) { if (wfForLive.Count > 0) { adoWorkflowRequest.Update(Ado, new WorkflowRequest_DTO_Update() { RlsCode = wipForLive.RlsCode, WrqArchiveFlag = dtoWrq.WrqArchiveFlag, WrqCurrentFlag = true, WrqExperimentalFlag = dtoWrq.WrqExperimentalFlag, WrqReservationFlag = dtoWrq.WrqReservationFlag }, SamAccountName); } } dtoWip = Release_ADO.GetReleaseDTO(adoRelease.Read(wipForLive.RlsCode, SamAccountName)); dtoWip.RlsReservationFlag = dtoRelease.RlsReservationFlag; dtoWip.RlsArchiveFlag = dtoRelease.RlsArchiveFlag; dtoWip.RlsExperimentalFlag = dtoRelease.RlsExperimentalFlag; if (adoRelease.Update(dtoWip, SamAccountName) == 0) { Log.Instance.Debug("Failed to update associated WIP " + dtoWip.MtrCode + " " + dtoWip.RlsVersion + '.' + dtoWip.RlsRevision); } //if this wip has a workflow request, then the workflow request details must also be updated List <WorkflowRequest_DTO> wfList = adoWrq.Read(Ado, dtoWip.RlsCode, true); if (wfList.Count > 0) { foreach (var wf in wfList) { wf.WrqReservationFlag = dtoWrq.WrqReservationFlag; wf.WrqArchiveFlag = dtoWrq.WrqArchiveFlag; wf.WrqExperimentalFlag = dtoWrq.WrqExperimentalFlag; adoWrq.Update(Ado, new WorkflowRequest_DTO_Update() { RlsCode = wf.RlsCode, WrqCurrentFlag = dtoWrq.WrqCurrentFlag, WrqArchiveFlag = dtoWrq.WrqArchiveFlag, WrqExperimentalFlag = dtoWrq.WrqExperimentalFlag, WrqReservationFlag = dtoWrq.WrqReservationFlag }, SamAccountName); } } } break; case Constants.C_WORKFLOW_REQUEST_DELETE: //We can't soft delete the release just yet. We need it to be live until the Request is updated. break; case Constants.C_WORKFLOW_REQUEST_ROLLBACK: //Delete the future release if it exists and set the current to_date to null //Otherwise delete the current release and make the previous release current by setting its to_date to null if (adoRelease.IsLiveNext(dtoRelease.RlsCode)) //this is a future release so get the previous release to roll back to (even if that previous is now historical) { Compare_ADO cAdo = new Compare_ADO(Ado); Release_DTO dtoNowRelease = Release_ADO.GetReleaseDTO(adoRelease.Read(cAdo.ReadPreviousRelease(DTO.RlsCode), SamAccountName)); dtoNowRelease.RlsLiveDatetimeTo = default(DateTime); int rows = adoRelease.Update(dtoNowRelease, SamAccountName); if (rows == 0) { Log.Instance.Debug("Can't update the Release, RlsCode:" + dtoNowRelease.RlsCode); response.error = Label.Get("error.update"); return(response); } //As things stand, dtoRelease is the requested Release (which is a Live Next). This will be deleted in the Delete section below } else { //This isn't a future release - it had better be a Live Now (with a previous) if (!adoRelease.IsLiveNow(dtoRelease.RlsCode)) { //If the request is neither a Live Now release then there's a problem Log.Instance.Debug("Can't delete the Release, RlsCode:" + dtoRelease.RlsCode + ". Release is not current live"); response.error = Label.Get("error.delete"); return(response); } //Find the release that we're trying to rollback to Release_DTO dtoPrevious = Release_ADO.GetReleaseDTO(adoRelease.ReadLivePrevious(dtoRelease.RlsCode)); if (dtoPrevious.RlsCode == 0) { //Previous release not found //You can't roll back unless there's something to roll back to, so... Log.Instance.Debug("Can't delete the Release, RlsCode:" + dtoRelease.RlsCode + ". Release is not current live"); response.error = Label.Get("error.delete"); return(response); } //We set the DatetimeTo to null in the previous release dtoPrevious.RlsLiveDatetimeTo = default(DateTime); int rows = adoRelease.Update(dtoPrevious, SamAccountName); if (rows == 0) { Log.Instance.Debug("Can't update the Release, RlsCode:" + dtoPrevious.RlsCode); response.error = Label.Get("error.update"); return(response); } //Do the rollback of the current release dtoRelease.RlsVersion = dtoPrevious.RlsVersion; dtoRelease.RlsLiveDatetimeFrom = default(DateTime); rows = adoRelease.Update(dtoRelease, SamAccountName); if (rows == 0) { Log.Instance.Debug("Can't update the Release, RlsCode:" + dtoRelease.RlsCode); response.error = Label.Get("error.update"); return(response); } adoRelease.IncrementRevision(dtoRelease.RlsCode, SamAccountName); } break; default: response.error = Label.Get("error.update"); return(response); } int signoffID = adoSignoff.Create(Ado, DTO, SamAccountName); if (signoffID == 0) { //Can't create a Workflow Signoff so we can't proceed Log.Instance.Debug("Can't create a Workflow Signoff "); response.error = Label.Get("error.create"); return(response); } //In all cases, if we have reached this stage, we must update the request to make it non-current WorkflowRequest_DTO_Update dtoRequest = new WorkflowRequest_DTO_Update(DTO.RlsCode); dtoRequest.WrqCurrentFlag = false; //save the request int updated = adoWorkflowRequest.Update(Ado, dtoRequest, SamAccountName); if (updated == 0) { //Can't save the Request so we can't proceed Log.Instance.Debug("Can't save the Workflow Signoff"); response.error = Label.Get("error.update"); return(response); } // We may now proceed with the soft delete Release_BSO_Delete bsoDelete = new Release_BSO_Delete(); System.Navigation.Keyword_Release_ADO krbAdo = new System.Navigation.Keyword_Release_ADO(); switch (dtoWrq.RqsCode) { case Constants.C_WORKFLOW_REQUEST_DELETE: //Soft delete the Release. We had to hold this over to last because the Request updates wouldn't work without a live Release dtoRelease.RlsCode = DTO.RlsCode; Request_ADO adoRequest = new Request_ADO(); if (adoRelease.IsLiveNow(dtoRelease.RlsCode)) { Release_DTO dtoNowRelease = Release_ADO.GetReleaseDTO(adoRelease.ReadLiveNow(dtoRequest.RlsCode)); //Set the toDate to now, thus setting the release to historical if (dtoNowRelease != null) { dtoNowRelease.RlsLiveDatetimeTo = DateTime.Now; int updateCount = adoRelease.Update(dtoNowRelease, SamAccountName); if (updateCount == 0) { Log.Instance.Debug("Can't update the Release, RlsCode:" + dtoNowRelease.RlsCode); response.error = Label.Get("error.update"); return(response); } } //Delete the search keywords for this release krbAdo.Delete(Ado, DTO.RlsCode, null, true); } else if (adoRelease.IsLiveNext(dtoRelease.RlsCode) || adoRelease.IsWip(dtoRelease.RlsCode)) { //Find the previous list if it exists Compare_ADO cAdo = new Compare_ADO(Ado); Release_DTO dtoPreviousRelease = Release_ADO.GetReleaseDTO(adoRelease.Read(cAdo.ReadPreviousRelease(DTO.RlsCode), SamAccountName)); //if there is a previous live set it to historical, but not if we're deleting a WIP if (dtoPreviousRelease != null && !adoRelease.IsWip(dtoRelease.RlsCode)) { //Delete the search keywords for the previous release krbAdo.Delete(Ado, dtoPreviousRelease.RlsCode, null, true); dtoPreviousRelease.RlsLiveDatetimeTo = DateTime.Now; int updateCount = adoRelease.Update(dtoPreviousRelease, SamAccountName); if (updateCount == 0) { Log.Instance.Debug("Can't update the Release, RlsCode:" + dtoPreviousRelease.RlsCode); response.error = Label.Get("error.update"); return(response); } } //Delete the search keywords for this release krbAdo.Delete(Ado, DTO.RlsCode, null, true); // We may now proceed with the soft delete if (bsoDelete.Delete(Ado, DTO.RlsCode, SamAccountName, true) == 0) { Log.Instance.Debug("Can't delete the Release, RlsCode:" + DTO.RlsCode); response.error = Label.Get("error.delete"); return(response); } } else { //Only LiveNow, LiveNext and WIP releases can be deleted. Anything else means there's a problem. Log.Instance.Debug("Can't delete the Release - invalid release status, RlsCode:" + DTO.RlsCode); response.error = Label.Get("error.delete"); return(response); } break; case Constants.C_WORKFLOW_REQUEST_ROLLBACK: //First, if there is a WIP ahead of this live release then that WIP must be deleted Release_ADO releaseAdo = new Release_ADO(Ado); var releaseDTORead = new Release_DTO_Read() { MtrCode = dtoRelease.MtrCode }; var latestRelease = releaseAdo.ReadLatest(releaseDTORead); if (latestRelease != null) { if (dtoRelease.RlsCode != latestRelease.RlsCode) { if (bsoDelete.Delete(Ado, latestRelease.RlsCode, SamAccountName, true) == 0) { Log.Instance.Debug("Can't delete the Release, RlsCode:" + latestRelease.RlsCode); response.error = Label.Get("error.delete"); return(response); } } } // Only Live Next gets soft deleted, while Live Now is turned historical above if (adoRelease.IsLiveNext(dtoRelease.RlsCode)) { if (bsoDelete.Delete(Ado, DTO.RlsCode, SamAccountName, true) == 0) { Log.Instance.Debug("Can't delete the Release, RlsCode:" + DTO.RlsCode); response.error = Label.Get("error.delete"); return(response); } //Delete the search keywords for this release krbAdo.Delete(Ado, DTO.RlsCode, null, true); } // Delete the requested release (it may have been live but may also have been demoted to WIP by now) if (adoRelease.IsWip(dtoRelease.RlsCode)) { if (bsoDelete.Delete(Ado, dtoRelease.RlsCode, SamAccountName, true) == 0) { Log.Instance.Debug("Can't delete the Release, RlsCode:" + dtoRelease.RlsCode); response.error = Label.Get("error.delete"); return(response); } //Delete the search keywords for this release krbAdo.Delete(Ado, DTO.RlsCode, null, true); } break; } DTO.MtrCode = dtoRelease.MtrCode; // we need this to see which cache we must flush response.data = JSONRPC.success; Email_BSO_NotifyWorkflow notify = new Email_BSO_NotifyWorkflow(); var sendMailThread = new Thread(() => { //If an email error occurs, just ignore it and continue as before try { notify.EmailSignoff(dtoWrq, DTO, dtoRelease, moderators, powerUsers); } catch { } }); sendMailThread.Start(); // Clean up caching MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_ADDITION + DTO.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_DELETION + DTO.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_AMENDMENT + DTO.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_DATASET + DTO.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_METADATA + DTO.RlsCode); if (dtoWip != null) { MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_ADDITION + dtoWip.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_DELETION + dtoWip.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_COMPARE_READ_AMENDMENT + dtoWip.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_DATASET + dtoWip.RlsCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_PRE_METADATA + dtoWip.RlsCode); } MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_NAVIGATION_SEARCH); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_NAVIGATION_READ); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_COLLECTION); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + DTO.MtrCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_DATASET + DTO.MtrCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_METADATA + DTO.MtrCode); MemCacheD.CasRepositoryFlush(Resources.Constants.C_CAS_DATA_CUBE_READ_COLLECTION_PXAPI); return(response); }
/// <summary> /// Execute /// </summary> /// <returns></returns> protected override bool Execute() { //Translate from bbCode to html Resources.BBCode bbc = new Resources.BBCode(); DTO.Body = bbc.Transform(DTO.Body, true); List <string> groupCodes = new List <string>(); GroupAccount_ADO gAdo = new GroupAccount_ADO(); foreach (var code in DTO.GroupCodes) { groupCodes.Add(code.GrpCode); } //Get accounts associated with the Group(s) ADO_readerOutput readGroupAccounts = gAdo.ReadMultiple(Ado, groupCodes); Account_ADO accAdo = new Account_ADO(); Account_DTO_Read dtoRead = new Account_DTO_Read(); dtoRead.PrvCode = Resources.Constants.C_SECURITY_PRIVILEGE_POWER_USER; ADO_readerOutput readPowerUsers = accAdo.Read(Ado, dtoRead); //Get the AD data associated with the users, specifically ActiveDirectory_ADO adAdo = new ActiveDirectory_ADO(); adAdo.MergeAdToUsers(ref readGroupAccounts); adAdo.MergeAdToUsers(ref readPowerUsers); eMail email = new eMail(); if (!readGroupAccounts.hasData && !readPowerUsers.hasData) { Response.data = JSONRPC.success; Log.Instance.Debug("No email addresses found"); return(true); } string emailRegex = Utility.GetCustomConfig("APP_REGEX_EMAIL"); foreach (var user in readGroupAccounts.data) { if (user.CcnEmail != null) { string address = user.CcnEmail.ToString(); if (Regex.IsMatch(address, emailRegex)) { email.Bcc.Add(address); } } } foreach (var user in readPowerUsers.data) { if (user.CcnEmail != null) { string address = user.CcnEmail.ToString(); if (Regex.IsMatch(address, emailRegex)) { email.Bcc.Add(address); } } } email.Subject = DTO.Subject; email.Body = DTO.Body; sendMail(email, Configuration_BSO.GetCustomConfig(ConfigType.global, "title"), DTO.Subject, DTO.Body); Response.data = JSONRPC.success; return(true); }
/// <summary> /// /// </summary> /// <param name="parameters"></param> public BuildUpdate_DTO(dynamic parameters) { if (parameters.MtrInput != null) { this.MtrInput = Utility.DecodeBase64ToUTF8((string)parameters["MtrInput"]); } if (parameters.Data != null) { PxData = new PxData_DTO(parameters); } if (parameters.LngIsoCode != null) { LngIsoCode = parameters.LngIsoCode; } else { LngIsoCode = Configuration_BSO.GetCustomConfig(ConfigType.global, "language.iso.code"); } Periods = new List <PeriodRecordDTO_Create>(); if (parameters.MtrCode != null) { MtrCode = parameters.MtrCode; } if (parameters.CprCode != null) { CprCode = parameters.CprCode; } if (parameters.FrqCodeTimeval != null) { FrqCodeTimeval = parameters.FrqCodeTimeval; } if (parameters.FrqValueTimeval != null) { FrqValueTimeval = parameters.FrqValueTimeval; } if (parameters.MtrOfficialFlag != null) { MtrOfficialFlag = parameters.MtrOfficialFlag; } Format = new Format_DTO_Read(); if (parameters.FrmType != null && parameters.FrmVersion != null) { Format.FrmType = parameters.FrmType; Format.FrmVersion = parameters.FrmVersion; Format.FrmDirection = Format_DTO_Read.FormatDirection.UPLOAD.ToString(); } if (parameters.Signature != null) { this.Signature = parameters.Signature; } if (parameters.Labels != null) { this.Labels = parameters.Labels; } else { this.Labels = true; } if (parameters.Elimination != null) { Elimination = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Elimination.ToString()); } if (parameters.Dimension != null) { Dimension = new List <Dimension_DTO>(); foreach (var dim in parameters.Dimension) { Dimension_DTO dimension = new Dimension_DTO(); if (dim.Frequency != null) { dimension.Frequency = new FrequencyRecordDTO_Create(); if (dim.Frequency.Period != null) { dimension.Frequency.Period = new List <Data.PeriodRecordDTO_Create>(); foreach (var per in dim.Frequency.Period) { PeriodRecordDTO_Create period = new PeriodRecordDTO_Create(); if (per.PrdCode != null) { period.Code = per.PrdCode; } if (per.PrdValue != null) { period.Value = per.PrdValue; } if (Periods.Where(x => x.Code.Equals(period.Code)).FirstOrDefault() == null) { Periods.Add(period); } dimension.Frequency.Period.Add(period); } } if (dim.Frequency.FrqValue != null) { dimension.Frequency.Value = dim.Frequency.FrqValue; } } if (dim.Classification != null) { dimension.Classifications = new List <ClassificationRecordDTO_Create>(); foreach (var cls in dim.Classification) { ClassificationRecordDTO_Create classification = new ClassificationRecordDTO_Create(); if (cls.ClsCode != null) { classification.Code = cls.ClsCode; } dimension.Classifications.Add(classification); } } if (dim.LngIsoCode != null) { dimension.LngIsoCode = dim.LngIsoCode; } if (dim.MtrTitle != null) { dimension.MtrTitle = dim.Dimension; } if (dim.FrqValue != null) { dimension.FrqValue = dim.FrqValue; } if (dim.MtrNote != null) { dimension.MtrNote = dim.MtrNote; } if (dim.StatisticLabel != null) { dimension.StatisticLabel = dim.StatisticLabel; } if (dim.MtrTitle != null) { dimension.MtrTitle = dim.MtrTitle; } Dimension.Add(dimension); } } if (parameters.Map != null) { Map = JsonConvert.DeserializeObject <Dictionary <string, string> >(parameters.Map.ToString()); } }
internal MemoryStream CreatAboutPage(Data.Matrix theMatrix, string title, string lngIsoCode, CultureInfo ci = null) { Specification theSpec = theMatrix.GetSpecFromLanguage(lngIsoCode); if (theSpec == null) { theSpec = theMatrix.MainSpec; } string noteString = ""; if (theSpec.NotesAsString != null) { noteString = new BBCode().Transform(theSpec.NotesAsString, true); //This Regex must be compatible with the output of the BBCode Transform noteString = Regex.Replace(noteString, "<a\\shref=\"([^\"]*)\">([^<]*)<\\/a>", "$2 ($1)", RegexOptions.IgnoreCase | RegexOptions.Multiline); } if (theMatrix.Release != null) { if (theMatrix.Release.RlsLiveFlag && theMatrix.Release.RlsLiveDatetimeFrom < DateTime.Now) { string Href = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.api.restful") + '/' + string.Format(Utility.GetCustomConfig("APP_RESTFUL_DATASET"), Utility.GetCustomConfig("APP_READ_DATASET_API"), theMatrix.Code, Constants.C_SYSTEM_XLSX_NAME, Constants.C_SYSTEM_XLSX_VERSION, theSpec.Language), Type = Utility.GetCustomConfig("APP_XLSX_MIMETYPE"); } } var sheet = workbook.AddWorksheet(title); sheet.AddPicture(new MemoryStream(GetImage(Configuration_BSO.GetCustomConfig(ConfigType.global, "url.logo")))).MoveTo(sheet.Cell("A1")); sheet.Columns("B").Width = 100; int row = 8; int counter = 0; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.table", lngIsoCode); sheet.Cell(row + counter, 1).Style.Font.FontSize = 13; sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 1).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1);// XLColor.AirForceBlue; //( "A2B8E1"); sheet.Cell(row + counter, 2).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.code"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Code; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.name"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theSpec.Title; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.last-updated"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).DataType = XLDataType.Text; sheet.Cell(row + counter, 2).SetValue <string>(Convert.ToString(theMatrix.Release.RlsLiveDatetimeFrom.ToString(ci ?? CultureInfo.InvariantCulture))); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.note"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = noteString; counter++; if (theMatrix.Release != null) { if (theMatrix.Release.RlsLiveFlag && theMatrix.Release.RlsLiveDatetimeFrom < DateTime.Now) { string Href = Configuration_BSO.GetCustomConfig(ConfigType.global, "url.api.restful") + '/' + string.Format(Utility.GetCustomConfig("APP_RESTFUL_DATASET"), Utility.GetCustomConfig("APP_READ_DATASET_API"), theMatrix.Code, Constants.C_SYSTEM_XLSX_NAME, Constants.C_SYSTEM_XLSX_VERSION, theSpec.Language), Type = Utility.GetCustomConfig("APP_XLSX_MIMETYPE"); sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.url"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = Href; sheet.Cell(row + counter, 2).Hyperlink = new XLHyperlink(Href); } } counter += 2; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.product", lngIsoCode); sheet.Cell(row + counter, 1).Style.Font.FontSize = 13; sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 1).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); sheet.Cell(row + counter, 2).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.code"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.PrcCode; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.name"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.PrcValue; counter += 2; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.contacts", lngIsoCode); sheet.Cell(row + counter, 1).Style.Font.FontSize = 13; sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 1).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); sheet.Cell(row + counter, 2).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.name"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.GrpContactName; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.email"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.GrpContactEmail; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.phone"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.GrpContactPhone; counter += 2; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.copyright", lngIsoCode); sheet.Cell(row + counter, 1).Style.Font.FontSize = 13; sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 1).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); sheet.Cell(row + counter, 2).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.code"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Copyright.CprCode; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.name"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Copyright.CprValue; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.url"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Copyright.CprUrl; sheet.Cell(row + counter, 2).Hyperlink = new XLHyperlink(theMatrix.Copyright.CprUrl); counter += 2; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.properties", lngIsoCode); sheet.Cell(row + counter, 1).Style.Font.FontSize = 13; sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 1).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); sheet.Cell(row + counter, 2).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.official-statistics"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.IsOfficialStatistic ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.exceptional"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.RlsExceptionalFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.archived"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.RlsArchiveFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.analytical"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.RlsAnalyticalFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.experimental"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theMatrix.Release.RlsExperimentalFlag ? Label.Get("xlsx.yes", lngIsoCode) : Label.Get("xlsx.no", lngIsoCode); counter += 2; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.language", lngIsoCode); sheet.Cell(row + counter, 1).Style.Font.FontSize = 13; sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 1).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 2).Style.Border.BottomBorder = XLBorderStyleValues.Thick; sheet.Cell(row + counter, 1).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); sheet.Cell(row + counter, 2).Style.Border.BottomBorderColor = XLColor.FromArgb(0xA2B8E1); counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.iso-code"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = theSpec.Language; counter++; sheet.Cell(row + counter, 1).Value = Label.Get("xlsx.iso-name"); sheet.Cell(row + counter, 1).Style.Font.Bold = true; sheet.Cell(row + counter, 2).Value = new Language_BSO().Read(theSpec.Language).LngIsoName; sheet.Columns("A").Width = 20; MemoryStream output = new MemoryStream(); workbook.SaveAs(output); return(output); }