void FindOrAddCxlfee(ICoreSys sys, FlextourEntities context, string code, int ntsPrior, decimal pctPenalty) { CXLFEE cxlFee = context.CXLFEE.FirstOrDefault(c => c.TYPE == "OPT" && c.CODE == code && c.CAT == null && c.START_DATE == null && c.END_DATE == null && c.AGENCY == sys.Settings.DefaultAgency); if (cxlFee == null) { cxlFee = new CXLFEE() { TYPE = "OPT", CODE = code, CAT = null, START_DATE = null, END_DATE = null, AGENCY = sys.Settings.DefaultAgency, }; context.CXLFEE.AddObject(cxlFee); } cxlFee.NTS_PRIOR = (short)ntsPrior; cxlFee.Description = null; cxlFee.NonRefundable = (ntsPrior == 999) || pctPenalty == 100; cxlFee.PCT_AMT = (float)pctPenalty; cxlFee.FLAT_FEE = null; cxlFee.NBR_NTS = null; cxlFee.TimeBasis = (short)Enumerations.FlexCancelFeeTimeBasis.flxCancelFeeTimeBasisBeforeArrival; cxlFee.TimeUnits = (short)Enumerations.FlexTimeUnits.flxTimeUnitsDays; MediaHelper.SetCxlfeeChgDate(context, cxlFee, _update, _sys.User.Name); }
public OperationsServiceListForm(ICoreSys sys) { InitializeComponent(); _sys = sys; textBoxRecipients.Text = Configurator.OperationsServiceList_Recipients; dateEditStart.Text = DateTime.Today.ToString(); dateEditEnd.Text = DateTime.Today.AddDays(Configurator.OperationsServiceList_FutureDays).ToString(); }
public HotelProductionReportForm(ICoreSys sys) { InitializeComponent(); _sys = sys; textBoxRecipients.Text = Configurator.HotelProductionReport_Recipients; dateEditStart.Text = DateTime.Today.AddDays(Configurator.HotelProductionReport_PastDays).ToString(); dateEditEnd.Text = DateTime.Today.ToString(); }
internal static string PutImageToBlob(ICoreSys sys, string type, string code, string supplier, string masterCity, string image, string tag, bool createThumbnail) { if (!string.IsNullOrEmpty(image) && Configurator.DownloadImages) { try { string relativePath = $@"{Configurator.PhotosPath}{type}\{masterCity}\{code}\"; Uri uri = new Uri(image); string filename = $"{code}_{supplier}_{tag}{Path.GetFileName(uri.AbsolutePath)}"; //TODO: this works for some CDNs which provide image paths with no extensions, eg https://cdn.filestackcontent.com/jqj2VclEQ3KB1oXqOJk0 //That assumes that the file is a jpeg, which it is for FareHabor, but might not always be so FileInfo file = new FileInfo(filename); if (string.IsNullOrEmpty(file.Extension)) { filename += ".jpg"; } CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Configurator.AzureStorageConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); CloudBlobContainer container = blobClient.GetContainerReference("images"); //CloudBlobContainer container = blobClient.GetContainerReference(sys.Settings.ImagesContainer); CloudBlockBlob blockBlob = container.GetBlockBlobReference(relativePath + filename); //Don't download or upload the images if they already exist if (Configurator.OverwriteImages || !blockBlob.Exists()) { Console.WriteLine($" Downloading image {filename}"); using (WebClient webClient = new WebClient()) { byte[] data = webClient.DownloadData(uri); if (createThumbnail) { Console.WriteLine($" Creating thumbnail"); ImageConverter converter = new ImageConverter(); Image fullSize = (Bitmap)converter.ConvertFrom(data); Image thumb = CreateThumbnail(fullSize); data = (byte[])converter.ConvertTo(thumb, typeof(byte[])); } //Use MemoryStream because it abstracts the process of having to loop through buffers of byte data using (MemoryStream memoryStream = new MemoryStream(data)) { blockBlob.UploadFromStream(memoryStream); } } } return(relativePath + filename); } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, image); return(null); } } else { return(null); } }
internal static string GetOrPutImage(ICoreSys sys, string type, string code, string supplier, string masterCity, string image, string tag, bool createThumbnail) { if (string.IsNullOrEmpty(Configurator.AzureStorageConnectionString)) { return(GetImage(sys, type, code, supplier, masterCity, image, tag, createThumbnail)); } else { return(PutImageToBlob(sys, type, code, supplier, masterCity, image, tag, createThumbnail)); } }
public OTAReferenceListForm(ICoreSys sys) { InitializeComponent(); _sys = sys; textBoxRecipients.Text = Configurator.OperationsServiceList_Recipients; //Get the date period of the prior month DateTime priorMonth = DateTime.Today.AddMonths(-1); DateTime startDate = new DateTime(priorMonth.Year, priorMonth.Month, 1); dateEditStart.Text = startDate.ToString(); DateTime endDate = startDate.AddMonths(1).AddDays(-1); dateEditEnd.Text = endDate.ToString(); }
internal static string GetImage(ICoreSys sys, string type, string code, string supplier, string masterCity, string image, string tag, bool createThumbnail) { if (!string.IsNullOrEmpty(image) && Configurator.DownloadImages) { try { string relativePath = $@"{Configurator.PhotosPath}{type}\{masterCity}\{code}\"; string fullPath = sys.Settings.ImagesRoot + relativePath; Directory.CreateDirectory(fullPath); Uri uri = new Uri(image); string filename = $"{code}_{supplier}_{tag}{Path.GetFileName(uri.AbsolutePath)}"; //TODO: this works for some CDNs which provide image paths with no extensions, eg https://cdn.filestackcontent.com/jqj2VclEQ3KB1oXqOJk0 //That assumes that the file is a jpeg, which it is for FareHabor, but might not always be so FileInfo file = new FileInfo(filename); if (string.IsNullOrEmpty(file.Extension)) { filename += ".jpg"; } //Don't download the images if they already exist if (Configurator.OverwriteImages || !File.Exists(fullPath + filename)) { Console.WriteLine($" Downloading image {filename}"); using (WebClient webClient = new WebClient()) { if (createThumbnail) { byte[] data = webClient.DownloadData(uri); Console.WriteLine($" Creating thumbnail"); ImageConverter converter = new ImageConverter(); Image fullSize = (Bitmap)converter.ConvertFrom(data); Image thumb = CreateThumbnail(fullSize); thumb.Save(fullPath + filename); } else { webClient.DownloadFile(uri, fullPath + filename); } } } return(relativePath + filename); } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, image); return(null); } } else { return(null); } }
public ProductListForm(ICoreSys sys) { InitializeComponent(); _sys = sys; ImageComboBoxEditLang.Properties.Items.Add(new ImageComboBoxItem() { Description = "", Value = null }); using (var context = new FlextourEntities(sys.Settings.EFConnectionString)) { foreach (var lang in context.LANGUAGE.OrderBy(l => l.CODE)) { ImageComboBoxEditLang.Properties.Items.Add(new ImageComboBoxItem { Description = $"{lang.NAME} ({lang.CODE})", Value = lang.CODE }); } } ImageComboBoxEditLang.EditValue = _sys.Settings.DefaultLanguage; textBoxRecipients.Text = Configurator.ProductList_Recipients; dateEditStart.Text = DateTime.Today.ToString(); dateEditEnd.Text = DateTime.Today.AddYears(1).ToString(); }
private void Connect(FlexInterfaces.Core.ICoreSys sys) { Connection.EFConnectionString = sys.Settings.EFConnectionString; _context = new FlextourEntities(sys.Settings.EFConnectionString); _sys = sys; }