public string GetJsonColumns() { StringBuilder oReturn = new StringBuilder(); oReturn.Append("["); CompareColumns.All(col => { oReturn.Append("{" + MarketPlace.Models.General.Constants.C_Program_Compare_ColumnItem. Replace("{Width}", "'380px'"). Replace("{Field}", "'_" + col + "'"). Replace("{HeaderTemplate}", "Compare_DetailObject.GetHeaderTemplate('" + col + "')"). Replace("{Template}", "Compare_DetailObject.GetItemTemplate('" + col + "')"). Replace("{Locked}", "false") + "},"); return(true); }); return(oReturn.ToString().Trim().TrimEnd(new char[] { ',' }) + "]"); }
public string GetJsonDataFinancial(ProveedoresOnLine.Company.Models.Util.GenericItemModel RelatedAccount) { StringBuilder oReturn = new StringBuilder(); MarketPlace.Models.Company.CompanyUtil.FinancialAccount. Where(ac => RelatedAccount != null ? (ac.ParentItem != null && ac.ParentItem.ItemId == RelatedAccount.ItemId) : (ac.ParentItem == null)). OrderBy(ac => ac.ItemInfo. Where(aci => aci.ItemInfoType.ItemId == (int)MarketPlace.Models.General.enumCategoryInfoType.AI_Order). Select(aci => Convert.ToInt32(aci.Value)). DefaultIfEmpty(0). FirstOrDefault()). All(ac => { #region Get Account Values //get account type string strAccountType = ac.ItemInfo. Where(y => y.ItemInfoType.ItemId == (int)MarketPlace.Models.General.enumCategoryInfoType.AI_IsValue). Select(y => y.Value.Replace(" ", "")). DefaultIfEmpty("2"). FirstOrDefault(); //get account unit string oAccountUnit = ac.ItemInfo. Where(y => y.ItemInfoType.ItemId == (int)MarketPlace.Models.General.enumCategoryInfoType.AI_Unit). Select(y => y.Value.Replace(" ", "")). DefaultIfEmpty(string.Empty). FirstOrDefault(); #endregion if (strAccountType != "2") { //get child values oReturn.AppendLine(GetJsonDataFinancial(ac)); } oReturn.Append("{"); #region Item data CompareColumns.All(col => { if (col == "EvaluationArea") { oReturn.Append("EvaluationArea:{" + MarketPlace.Models.General.Constants.C_Program_Compare_Value_EvaluationArea. Replace("{Name}", "'" + ac.ItemName + "'"). Replace("{Type}", "'" + strAccountType + "'") + "},"); } else if (col != "EvaluationArea" && RelatedCompare.RelatedProvider != null) { //get currency rate int oCurrencyFrom = RelatedCompare.RelatedProvider. Where(rp => rp.RelatedCompany != null && rp.RelatedCompany.CompanyPublicId == col && rp.CompareDetail != null && rp.CompareDetail.Count > 0). Select(rp => rp.CompareDetail. Where(cd => cd.EvaluationAreaId == ac.ItemId && !string.IsNullOrEmpty(cd.Currency)). Select(cd => Convert.ToInt32(cd.Currency)). FirstOrDefault()). FirstOrDefault(); decimal CurrencyRate = GetCurrencyRateCaching (oCurrencyFrom, CompareCurrency, Year == null ? DateTime.Now.Year : Year.Value); //get company values List <Tuple <int, string, string> > lstValItem = RelatedCompare.RelatedProvider. Where(rp => rp.RelatedCompany != null && rp.RelatedCompany.CompanyPublicId == col && rp.CompareDetail != null && rp.CompareDetail.Count > 0). Select(rp => rp.CompareDetail. Where(cd => cd.EvaluationAreaId == ac.ItemId && cd.Value != null && cd.Value.Count > 0). Select(cd => cd.Value). FirstOrDefault()). FirstOrDefault(); oReturn.Append("_" + col + ":{"); for (int i = 1; i <= MaxValueCount; i++) { //get current value Tuple <int, string, string> ValItem = null; if (lstValItem != null && lstValItem.Count > 0) { ValItem = lstValItem.Where(vi => vi.Item1 == i).FirstOrDefault(); } oReturn.Append(MarketPlace.Models.General.Constants.C_Program_Compare_Value_Item. Replace("{i}", i.ToString()). Replace("{Value}", "'" + (ValItem != null ? (oAccountUnit != "$" ? ValItem.Item2 : GetDecimalCurrency(ValItem.Item2, CurrencyRate)) : (strAccountType == "2" ? " - " : "0")) + "'"). Replace("{After}", "'" + (oAccountUnit == "$" ? string.Empty : (ValItem != null ? ValItem.Item3 : string.Empty)) + "'"). Replace("{Before}", "'" + (oAccountUnit != "$" ? string.Empty : (ValItem != null ? ValItem.Item3 : string.Empty)) + "'")); } oReturn.Append("},"); } return(true); }); #endregion oReturn.Append("},"); if (strAccountType == "2") { //get child values oReturn.Append(GetJsonDataFinancial(ac)); } return(true); }); return(oReturn.ToString()); }
private string GetJsonDataCertifications() { StringBuilder oReturn = new StringBuilder(); if (RelatedCompare.RelatedProvider != null && RelatedCompare.RelatedProvider.Count > 0) { //get all economic activity to eval List <ProveedoresOnLine.Company.Models.Util.GenericItemModel> olstEvaluationArea = new List <ProveedoresOnLine.Company.Models.Util.GenericItemModel>(); RelatedCompare.RelatedProvider.FirstOrDefault().CompareDetail.All(cd => { olstEvaluationArea.Add(new ProveedoresOnLine.Company.Models.Util.GenericItemModel() { ItemId = cd.EvaluationAreaId, ItemName = cd.EvaluationAreaName, }); return(true); }); olstEvaluationArea = olstEvaluationArea.OrderBy(x => x.ItemName).ToList(); //get all compare detail items olstEvaluationArea.All(ea => { oReturn.Append("{"); #region ItemData CompareColumns.All(col => { if (col == "EvaluationArea") { oReturn.Append("EvaluationArea:{" + MarketPlace.Models.General.Constants.C_Program_Compare_Value_EvaluationArea. Replace("{Name}", "'" + ea.ItemName + "'"). Replace("{Type}", "'0'") + "},"); } else if (col != "EvaluationArea" && RelatedCompare.RelatedProvider != null) { //get company values List <Tuple <int, string, string> > lstValItem = RelatedCompare.RelatedProvider. Where(rp => rp.RelatedCompany != null && rp.RelatedCompany.CompanyPublicId == col && rp.CompareDetail != null && rp.CompareDetail.Count > 0). Select(rp => rp.CompareDetail. Where(cd => cd.EvaluationAreaId == ea.ItemId && cd.Value != null && cd.Value.Count > 0). Select(cd => cd.Value). FirstOrDefault()). FirstOrDefault(); oReturn.Append("_" + col + ":{"); for (int i = 1; i <= MaxValueCount; i++) { //get current value Tuple <int, string, string> ValItem = null; if (lstValItem != null && lstValItem.Count > 0) { ValItem = lstValItem.Where(vi => vi.Item1 == i).FirstOrDefault(); } oReturn.Append(MarketPlace.Models.General.Constants.C_Program_Compare_Value_Item. Replace("{i}", i.ToString()). Replace("{Value}", "'" + (ValItem != null ? ValItem.Item2 : "0") + "'"). Replace("{After}", "'" + string.Empty + "'"). Replace("{Before}", "'" + ValItem.Item3 + "'")); } oReturn.Append("},"); } return(true); }); #endregion oReturn.Append("},"); return(true); }); } return(oReturn.ToString().Trim().TrimEnd(new char[] { ',' })); }