private static ClientModel GetModel(ClientData client, string contractFileName) { return(new ClientModel { BIC = client.BIC, Phone = client.Phone, Emails = client.Emails, LegalEntity = client.LegalEntity, Bank = client.Bank, Contacts = client.Contacts, INN = client.INN, KPP = client.KPP, KS = client.KS, LegalAddress = client.LegalAddress, MailingAddress = client.MailingAddress, Nic = client.Nic, OGRN = client.OGRN, RS = client.RS, ContractFile = null, ContractFileName = contractFileName, Authentication = new AuthenticationModel(client.Login), ContractDate = LocalizationHelper.GetDate(client.ContractDate, CultureProvider.GetCultureInfo()), ContractNumber = client.ContractNumber, DefaultSenderId = client.DefaultSenderId, FactureCost = client.FactureCost, FactureCostEx = client.FactureCostEx, InsuranceRate = client.InsuranceRate * 100, PickupCost = client.PickupCost, TransitCost = client.TransitCost, TariffPerKg = client.TariffPerKg, ScotchCostEdited = client.ScotchCostEdited, Comments = client.Comments }); }
public IActionResult Index(string url) { url = string.Format("/{0}", url); CachedObject cachedObject = this.Storage.GetRepository <ICachedObjectRepository>().WithCultureIdAndUrl( CultureProvider.GetCulture(this.Storage).Id, url ); if (cachedObject == null) { Object @object = this.Storage.GetRepository <IObjectRepository>().WithUrl(url); if (@object == null) { return(this.NotFound()); } ObjectViewModel result = new ObjectViewModelBuilder(this).Build(@object); return(this.View(result.ViewName, result)); } { ObjectViewModel result = new ObjectViewModelBuilder(this).Build(cachedObject); return(this.View(result.ViewName, result)); } }
public virtual string this[string identifier, params object[] objects] { get { return(this.GetString(SingleCulture(CultureProvider.DetermineRequestCulture()), identifier, objects)); } }
public MemoryStream Get(T[] rows, string language) { CultureProvider.Set(language); var properties = rows.GetType().GetElementType().GetProperties(); var stream = new MemoryStream(); using (var pck = new ExcelPackage()) { var ws = pck.Workbook.Worksheets.Add(Pages.Applications); ws.Cells.Style.Font.Name = ExcelConstants.DefaultFontName; ws.Cells.Style.Font.Size = ExcelConstants.DefaultFontSize; DrawHeader(properties, ws); DrawRows(rows, properties, ws); for (var iCol = 1; iCol <= properties.Length; iCol++) { ws.Column(iCol).AutoFit(); } pck.SaveAs(stream); } stream.Position = 0; return(stream); }
private void DrawRow(int iRow) { var money = CalculationDataHelper.GetMoney(_data, _data.InsuranceRate); var iColumn = 1; _excel.Cells[iRow, iColumn++].Value = _clientNick; _excel.Cells[iRow, iColumn++].Value = _data.ApplicationDisplay; _excel.Cells[iRow, iColumn++].Value = _data.FactoryName; _excel.Cells[iRow, iColumn++].Value = _data.MarkName; _excel.Cells[iRow, iColumn++].Value = _data.Class; _excel.Cells[iRow, iColumn++].Value = _data.Count; _excel.Cells[iRow, iColumn++].Value = _data.Weight; _excel.Cells[iRow, iColumn++].Value = _data.Invoice; _excel.Cells[iRow, iColumn++].Value = _data.Value; _excel.Cells[iRow, iColumn++].Value = _data.TariffPerKg; _excel.Cells[iRow, iColumn].Style.Font.Bold = true; _excel.Cells[iRow, iColumn++].Value = CalculationHelper.GetTotalTariffCost(_data.TotalTariffCost, _data.TariffPerKg, _data.Weight); _excel.Cells[iRow, iColumn++].Value = _data.ScotchCost; _excel.Cells[iRow, iColumn++].Value = CalculationHelper.GetInsuranceCost(_data.Value, _data.InsuranceRate); _excel.Cells[iRow, iColumn++].Value = _data.FactureCost; _excel.Cells[iRow, iColumn++].Value = _data.FactureCostEx; _excel.Cells[iRow, iColumn++].Value = _data.PickupCost; _excel.Cells[iRow, iColumn++].Value = _data.TransitCost; _excel.Cells[iRow, iColumn].Style.Font.Bold = true; _excel.Cells[iRow, iColumn].Value = money; _excel.Cells[iRow, iColumn + 1].Value = (-money).ToString("N2") + CurrencyName.Euro; _excel.Cells[iRow, iColumn + 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; _excel.Cells[iRow, iColumn + 1].Style.Font.Color.SetColor(Color.Red); var cultureInfo = CultureProvider.GetCultureInfo(); _excel.Cells[iRow, _columnCount + 2].Value = LocalizationHelper.GetDate(_data.CreationTimestamp, cultureInfo); }
public int Draw(int iRow) { _excel.Row(iRow++).Height = ExcelConstants.DefaultRowHeight; var cultureInfo = CultureProvider.GetCultureInfo(); var money = _item.EventType == EventType.BalanceDecreased ? -_item.Money : _item.Money; _excel.Cells[iRow, _columnCount].Value = _item.EventType.ToLocalString(); var moneyCell = _excel.Cells[iRow, _columnCount + 1]; moneyCell.Value = money.ToString("N2") + CurrencyName.Euro; moneyCell.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right; if (_item.EventType == EventType.BalanceDecreased) { moneyCell.Style.Font.Color.SetColor(Color.Red); } _excel.Cells[iRow, _columnCount + 2].Value = LocalizationHelper.GetDate(_item.Timestamp, cultureInfo); _excel.Cells[iRow, _columnCount + 3].Value = _item.Comment; _excel.Row(iRow).Height = ExcelConstants.DefaultRowHeight; var range = _excel.Cells[iRow, 1, iRow, _columnCount]; range.Style.Fill.PatternType = ExcelFillStyle.Solid; range.Style.Fill.BackgroundColor.SetColor(_item.EventType == EventType.BalanceDecreased ? Color.Yellow : Color.LawnGreen); return(++iRow); }
private static string GetValueString(decimal value, CurrencyType currencyId) { var currency = currencyId; var culture = CultureProvider.Get(); return(LocalizationHelper.GetValueString(value, currency, CultureInfo.GetCultureInfo(culture))); }
public ListCollection <AirWaybillListItem> List(int take, int skip, long?brokerId, long?senderUserId, string language) { var data = _awbs.GetRange(take, skip, brokerId, senderUserId); var ids = data.Select(x => x.Id).ToArray(); var aggregates = _awbs.GetAggregate(ids).ToDictionary(x => x.AirWaybillId, x => x); var states = _states.Get(language); var currentCulture = CultureProvider.GetCultureInfo(); var awbFiles = GetFileInfo(ids, AwbFileType.AWB); var packingFiles = GetFileInfo(ids, AwbFileType.Packing); var drawFiles = GetFileInfo(ids, AwbFileType.Draw); var gtdFiles = GetFileInfo(ids, AwbFileType.GTD); var gtdAddFiles = GetFileInfo(ids, AwbFileType.GTDAdditional); var invoiceFiles = GetFileInfo(ids, AwbFileType.Invoice); var otherFiles = GetFileInfo(ids, AwbFileType.Other); var items = data.Select(x => new AirWaybillListItem { Id = x.Id, PackingFiles = GetFileInfo(packingFiles, x.Id), InvoiceFiles = GetFileInfo(invoiceFiles, x.Id), State = new ApplicationStateModel { StateName = states[x.StateId].LocalizedName, StateId = x.StateId }, AWBFiles = GetFileInfo(awbFiles, x.Id), OtherFiles = GetFileInfo(otherFiles, x.Id), ArrivalAirport = x.ArrivalAirport, Bill = x.Bill, CreationTimestampLocalString = LocalizationHelper.GetDate(x.CreationTimestamp, currentCulture), DateOfArrivalLocalString = LocalizationHelper.GetDate(x.DateOfArrival, currentCulture), DateOfDepartureLocalString = LocalizationHelper.GetDate(x.DateOfDeparture, currentCulture), StateChangeTimestampLocalString = LocalizationHelper.GetDate(x.StateChangeTimestamp, currentCulture), DepartureAirport = x.DepartureAirport, GTD = x.GTD, GTDAdditionalFiles = GetFileInfo(gtdAddFiles, x.Id), GTDFiles = GetFileInfo(gtdFiles, x.Id), DrawFiles = GetFileInfo(drawFiles, x.Id), TotalCount = aggregates[x.Id].TotalCount, TotalWeight = aggregates[x.Id].TotalWeight, AdditionalCost = x.AdditionalCost, TotalCostOfSenderForWeight = x.TotalCostOfSenderForWeight, BrokerCost = x.BrokerCost, CustomCost = x.CustomCost, FlightCost = x.FlightCost, IsActive = x.IsActive }).ToArray(); var total = _awbs.Count(brokerId, senderUserId); return(new ListCollection <AirWaybillListItem> { Data = items, Total = total }); }
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return(value); } var currency = System.Convert.ToDouble(value); return(CultureProvider.FormatCurrency(currency)); }
public override IEnumerable <CachedObject> GetCachedObjects() { if (this.args.ContainsKey("MemberId")) { return(this.handler.Storage.GetRepository <ICachedObjectRepository>().Primary( CultureProvider.GetCulture(this.handler.Storage).Id, int.Parse(this.args["MemberId"]), this.cachedObject.ObjectId )); } return(this.handler.Storage.GetRepository <ICachedObjectRepository>().Primary( CultureProvider.GetCulture(this.handler.Storage).Id, this.cachedObject.ObjectId )); }
public string GetObjectLocalizationValue(int dictionaryId) { Localization localization = this.handler.Storage.GetRepository <ILocalizationRepository>().WithDictionaryIdAndCultureId( dictionaryId, CultureProvider.GetCulture(this.handler.Storage).Id ); if (localization == null) { return(string.Empty); } return(localization.Value); }
internal MemoryStream Get(CalculationListCollection data, string language) { CultureProvider.Set(language); var stream = new MemoryStream(); using (var pck = new ExcelPackage()) { var ws = pck.Workbook.Worksheets.Add(Pages.Applications); ws.Cells.Style.Font.Name = ExcelConstants.DefaultFontName; ws.Cells.Style.Font.Size = ExcelConstants.DefaultFontSize; ws.Cells.Style.Numberformat.Format = "0.00"; var count = DrawHeader(ws); var iRow = 2; for (int index = 0; index < data.Groups.Length; index++) { var group = data.Groups[index]; var awb = HttpUtility.HtmlDecode(((dynamic)@group.value).text); DrawAwb(awb, ws, iRow++, count); foreach (var item in group.items) { ws.Row(iRow).Height = ExcelConstants.DefaultRowHeight; DrawRow(ws, item, iRow++); } ws.Row(iRow).Height = ExcelConstants.DefaultRowHeight; DrawGroupTotal(ws, group, iRow++); iRow = DrawInfo(ws, data.Info[index], iRow, count); } for (int j = 1; j <= count; j++) { ws.Column(j).AutoFit(); for (int i = 1; i < iRow; i++) { ws.Cells[i, j].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Gray); } } pck.SaveAs(stream); } stream.Position = 0; return(stream); }
public MemoryStream Get(long clientId, string language) { CultureProvider.Set(language); var client = _clients.Get(clientId); var balance = _balance.GetBalance(clientId); var calculations = _calculations.GetByClient(clientId); var history = _balance.GetHistory(clientId).Where(x => !x.IsCalculation).ToArray(); return(Get(client, balance, calculations, history)); }
public static AwbSenderModel GetSenderModel(AirWaybillEditData data) { var currentCulture = CultureProvider.GetCultureInfo(); return(new AwbSenderModel { ArrivalAirport = data.ArrivalAirport, Bill = data.Bill, DateOfArrivalLocalString = LocalizationHelper.GetDate(data.DateOfArrival, currentCulture), DateOfDepartureLocalString = LocalizationHelper.GetDate(data.DateOfDeparture, currentCulture), DepartureAirport = data.DepartureAirport, FlightCost = data.FlightCost, TotalCostOfSenderForWeight = data.TotalCostOfSenderForWeight }); }
protected override void Initialize(RequestContext requestContext) { base.Initialize(requestContext); var userId = requestContext.HttpContext.Request.Params["userId"]; if (!string.IsNullOrEmpty(userId)) { ViewBag.userInfo = new UserManager().GetUserById(int.Parse(userId)); } object cultureValue; if (requestContext.RouteData.Values.TryGetValue("culture", out cultureValue)) { try { CultureInfo culture = CultureProvider.GetCultureInfo(cultureValue.ToString()); if (culture == null) { culture = CultureProvider.GetCultureInfo(defaultLanguage); } Thread.CurrentThread.CurrentUICulture = culture; Thread.CurrentThread.CurrentCulture = culture; //requestContext.HttpContext.Response.Cookies.Add(new HttpCookie(CultureProvider.culturecookiekey, // culture.Name)); } catch (Exception) { } } else { try { Thread.CurrentThread.CurrentUICulture = CultureProvider.GetCultureInfo(defaultLanguage); Thread.CurrentThread.CurrentCulture = CultureProvider.GetCultureInfo(defaultLanguage); requestContext.HttpContext.Response.Cookies.Add(new HttpCookie(CultureProvider.culturecookiekey, defaultLanguage)); } catch (Exception) { } } }
public async Task <IViewComponentResult> InvokeAsync(string code) { CachedMenu cachedMenu = this.Storage.GetRepository <ICachedMenuRepository>().WithCultureIdAndCode( CultureProvider.GetCulture(this.Storage).Id, code ); if (cachedMenu == null) { Menu menu = this.Storage.GetRepository <IMenuRepository>().WithCode(code); if (menu == null) { return(null); } return(this.View(new MenuViewModelBuilder(this).Build(menu))); } return(this.View(new MenuViewModelBuilder(this).Build(cachedMenu))); }
public async Task <IViewComponentResult> InvokeAsync(string code) { CachedForm cachedForm = this.Storage.GetRepository <ICachedFormRepository>().WithCultureIdAndCode( CultureProvider.GetCulture(this.Storage).Id, code ); if (cachedForm == null) { Form form = this.Storage.GetRepository <IFormRepository>().WithCode(code); if (form == null) { return(null); } return(this.View(new FormViewModelBuilder(this).Build(form))); } return(this.View(new FormViewModelBuilder(this).Build(cachedForm))); }
public static AwbAdminModel GetAdminModel(AirWaybillEditData data) { var cultureInfo = CultureProvider.GetCultureInfo(); return(new AwbAdminModel { ArrivalAirport = data.ArrivalAirport, Bill = data.Bill, DateOfArrivalLocalString = LocalizationHelper.GetDate(data.DateOfArrival, cultureInfo), DateOfDepartureLocalString = LocalizationHelper.GetDate(data.DateOfDeparture, cultureInfo), DepartureAirport = data.DepartureAirport, GTD = data.GTD, BrokerId = data.BrokerId, AdditionalCost = data.AdditionalCost, BrokerCost = data.BrokerCost, CustomCost = data.CustomCost, FlightCost = data.FlightCost, TotalCostOfSenderForWeight = data.TotalCostOfSenderForWeight, SenderUserId = data.SenderUserId }); }
public string GetFareEstimateDisplay(DirectionInfo direction) { var fareEstimate = _localize[_appSettings.Data.DestinationIsRequired ? "NoFareTextIfDestinationIsRequired" : "NoFareText"]; if (direction.ValidationResult != null && direction.ValidationResult.HasError) { fareEstimate = direction.ValidationResult.Message; } else if (direction.Distance.HasValue) { var willShowFare = direction.Price.HasValue && direction.Price.Value > 0; if (willShowFare) { var isOverMaxFare = direction.Price.Value > _appSettings.Data.MaxFareEstimate; var formattedCurrency = CultureProvider.FormatCurrency(direction.Price.Value); fareEstimate = String.Format( CultureProvider.CultureInfo, _localize[isOverMaxFare ? "EstimatePriceOver100" : "EstimatePriceFormat"], formattedCurrency, direction.FormattedDistance); } else { fareEstimate = _localize["EstimatedFareNotAvailable"]; } } return(fareEstimate); }
public override IEnumerable <CachedObject> GetCachedObjects() { return(this.handler.Storage.GetRepository <ICachedObjectRepository>().FilteredByCultureId(CultureProvider.GetCulture(this.handler.Storage).Id).Where(o => o.ClassId == int.Parse(this.args["ClassId"]))); }
public void OnAuthorization(AuthorizationContext filterContext) { CultureProvider.Set(_getLanguage); }
public ApplicationListItem[] Map(ApplicationData[] data, string language) { var appIds = data.Select(x => x.Id).ToArray(); var stateIds = data.Select(x => x.StateId).ToArray(); var countries = _countries.All(language).ToDictionary(x => x.Id, x => x.Name); var states = _states.Get(language, stateIds); var stateAvailability = _stateFilter.GetStateAvailabilityToSet(); var calculations = _applications.GetCalculations(appIds); var cps = _files.GetInfo(appIds, ApplicationFileType.CP); var deliveryBills = _files.GetInfo(appIds, ApplicationFileType.DeliveryBill); var invoices = _files.GetInfo(appIds, ApplicationFileType.Invoice); var packings = _files.GetInfo(appIds, ApplicationFileType.Packing); var otherFiles = _files.GetInfo(appIds, ApplicationFileType.Other); var swifts = _files.GetInfo(appIds, ApplicationFileType.Swift); var torg12 = _files.GetInfo(appIds, ApplicationFileType.Torg12); var t1 = _files.GetInfo(appIds, ApplicationFileType.T1); var ex1 = _files.GetInfo(appIds, ApplicationFileType.Ex1); var cities = _cities.All(language).ToDictionary(x => x.Id, x => x.Name); return(data.Select(x => new ApplicationListItem { CountryName = countries[x.CountryId], State = new ApplicationStateModel { StateId = x.StateId, StateName = states[x.StateId].LocalizedName }, CanClose = x.StateId == _stateConfig.CargoOnTransitStateId, CanSetState = stateAvailability.Contains(x.StateId), AddressLoad = x.AddressLoad, Id = x.Id, FactoryName = x.FactoryName, Invoice = x.Invoice, MarkName = x.MarkName, Volume = x.Volume, Count = x.Count, AirWaybill = x.AirWaybill, Characteristic = x.Characteristic, ClientLegalEntity = x.ClientLegalEntity, ClientNic = x.ClientNic, ClientId = x.ClientId, CreationTimestamp = x.CreationTimestamp, DateInStock = x.DateInStock, DateOfCargoReceipt = x.DateOfCargoReceipt, FactoryContact = x.FactoryContact, FactoryEmail = x.FactoryEmail, FactoryPhone = x.FactoryPhone, StateChangeTimestamp = x.StateChangeTimestamp, StateId = x.StateId, TermsOfDelivery = x.TermsOfDelivery, TransitAddress = x.TransitAddress, CarrierName = x.CarrierName, CarrierContact = x.CarrierContact, CarrierAddress = x.CarrierAddress, CarrierPhone = x.CarrierPhone, TransitId = x.TransitId, TransitCity = cities[x.TransitCityId], TransitDeliveryTypeString = x.TransitDeliveryType.ToLocalString(), TransitMethodOfTransitString = x.TransitMethodOfTransit.ToLocalString(), TransitPhone = x.TransitPhone, TransitRecipientName = x.TransitRecipientName, TransitReference = x.TransitReference, TransitWarehouseWorkingTime = x.TransitWarehouseWorkingTime, WarehouseWorkingTime = x.WarehouseWorkingTime, Weight = x.Weight, MethodOfDeliveryId = (int)x.MethodOfDelivery, IsPickup = x.IsPickup, TransitMethodOfTransitId = (int)x.TransitMethodOfTransit, Value = x.Value, CurrencyId = (int)x.CurrencyId, AirWaybillId = x.AirWaybillId, PickupCost = x.GetAdjustedPickupCost(), FactureCost = x.GetAdjustedFactureCost(), FactureCostEx = x.GetAdjustedFactureCostEx(), ScotchCost = x.GetAdjustedScotchCost(), SenderName = x.SenderName, ForwarderName = x.ForwarderName, SenderScotchCost = x.SenderScotchCost, TariffPerKg = x.TariffPerKg, TransitCost = x.GetAdjustedTransitCost(), ForwarderTransitCost = x.TransitCost, CanSetTransitCost = !calculations.ContainsKey(x.Id), CPFiles = cps.ContainsKey(x.Id) ? cps[x.Id].ToArray() : null, DeliveryBillFiles = deliveryBills.ContainsKey(x.Id) ? deliveryBills[x.Id].ToArray() : null, InvoiceFiles = invoices.ContainsKey(x.Id) ? invoices[x.Id].ToArray() : null, PackingFiles = packings.ContainsKey(x.Id) ? packings[x.Id].ToArray() : null, OtherFiles = otherFiles.ContainsKey(x.Id) ? otherFiles[x.Id].ToArray() : null, SwiftFiles = swifts.ContainsKey(x.Id) ? swifts[x.Id].ToArray() : null, Torg12Files = torg12.ContainsKey(x.Id) ? torg12[x.Id].ToArray() : null, T1Files = t1.ContainsKey(x.Id) ? t1[x.Id].ToArray() : null, Ex1Files = ex1.ContainsKey(x.Id) ? ex1[x.Id].ToArray() : null, DisplayNumber = x.GetApplicationDisplay(), DaysInWork = x.GetDaysInWork(), CreationTimestampLocalString = LocalizationHelper.GetDate(x.CreationTimestamp, CultureProvider.GetCultureInfo()), StateChangeTimestampLocalString = LocalizationHelper.GetDate(x.StateChangeTimestamp, CultureProvider.GetCultureInfo()), DateOfCargoReceiptLocalString = x.DateOfCargoReceipt.HasValue ? LocalizationHelper.GetDate(x.DateOfCargoReceipt.Value, CultureProvider.GetCultureInfo()) : null, DateInStockLocalString = x.DateInStock.HasValue ? LocalizationHelper.GetDate(x.DateInStock.Value, CultureProvider.GetCultureInfo()) : null, MethodOfDeliveryLocalString = x.MethodOfDelivery.ToLocalString(), ValueString = GetValueString(x.Value, x.CurrencyId), MRN = x.MRN, CountInInvoce = x.CountInInvoce, DocumentWeight = x.DocumentWeight }).ToArray()); }