private void ManuelBarcodePostTimer_Tick(object sender, EventArgs e) { try { if (manuelBarcods.Count > 0) { Logger.GetInstance().Info("Web Servise gönderilen perakende barkodları" + string.Join("\n", manuelBarcods)); RequestBarcode requestBarcode = BL.CreatRetailRequest(manuelBarcods); ResponseBarcode responseBarcode = BL.PostRetailRequest(requestBarcode); responseBarcode.ReceteNo = requestBarcode.HeaderSection.ReceteNo; new FormNotification(responseBarcode).ShowDialog(); _barcode.Clear(); manuelBarcods.Clear(); } } catch (Exception ex) { _barcode.Clear(); manuelBarcods.Clear(); Logger.GetInstance().Error("Perakende işlemine ait barkod işlemi web servisten okunamadı", ex); new FormNotification("Perakende işlemine ait barkod işlemi web servisten okunamadı", NotificationType.Error).ShowDialog(); } }
public FormPostList(ResponseBarcode selectedResponseBarcode) { InitializeComponent(); initializeForm(); locationForm(); this.selectedResponseBarcode = selectedResponseBarcode; ShowResponseDetails(); }
private void ShowNotification(ResponseBarcode responseBarcode, bool isRetail = false) { FormNotification fn = new FormNotification(responseBarcode, isRetail); fn.TopLevel = true; fn.TopMost = true; fn.ShowDialog(); }
void initializeForm() { DirectoryInfo di = new DirectoryInfo(Path.Combine(Settings.Default.DestinationFolder, Settings.Default.LatestPostFolderName)); List <FileInfo> latestFiles = di.GetFiles("*_Response.json").ToList().OrderByDescending(p => p.LastWriteTime).ToList(); PostListItem postListItem = null; ResponseBarcode tmpParsedData = null; try { panel1.Controls.Clear(); int i = 1; JsonSerializerSettings serializerSettings = new JsonSerializerSettings(); serializerSettings.Culture = new System.Globalization.CultureInfo("tr-TR"); serializerSettings.DateFormatString = "dd.MM.YYYY"; foreach (var item in latestFiles) { try { tmpParsedData = ParserBL.GetInstance().GetObjectFromJsonFile <ResponseBarcode>(item.FullName, serializerSettings); if (tmpParsedData != null) { postListItem = new PostListItem(i, tmpParsedData); postListItem.Dock = DockStyle.Top; postListItem.Name = item.Name; postListItem.Height = 28; postListItem.Width = 315; postListItem.PostItemDetailClicked += PostListItem_PostItemDetailClicked; postListItem.PostItemPrint += PostListItem_PostItemPrint; panel1.Controls.Add(postListItem); } else { Logger.GetInstance().Info(item.FullName + " dosyası convert edilemedi"); } if (i >= Settings.Default.NotificationMaxCount) { break; } i++; } catch (Exception ex) { Logger.GetInstance().Error(item.FullName + " dosyası parse edilemedi", ex); } } } catch (Exception ex) { Logger.GetInstance().Error("Son işlem yapılan reçete dosyaları okunamadı", ex); new FormNotification("Son işlem yapılan reçete dosyaları okunamadı", NotificationType.Error).ShowDialog(); } }
private void PostListItem_PostItemDetailClicked(object sender, EventArgs e) { selectedResponseBarcode = sender as ResponseBarcode; if (selectedResponseBarcode.Data != null) { ShowResponseDetails(); } else { KryptonMessageBox.Show("Aradığınız ilaç için veriler henüz eklenmedi. En kısa sürede eklenecektir", "Uyarı"); } }
public FormNotification(ResponseBarcode responseBarcode, bool isRetail = false) { InitializeComponent(); btnGoruntule.Visible = true; btnYazdir.Visible = true; if (isRetail) { btnEnglish.Visible = responseBarcode.Data.Supported_multi_lang || false; btnMobil.Visible = responseBarcode.Data.Has_mobile_app || false; } selectedResponseBarcode = responseBarcode; TopMost = true; Opacity = 1; StartPosition = FormStartPosition.Manual; string fname; for (int i = 1; i < 10; i++) { fname = "alert" + i.ToString(); FormNotification frm = (FormNotification)Application.OpenForms[fname]; if (frm == null) { Name = fname; x = Screen.PrimaryScreen.WorkingArea.Width - Width + 15; y = Screen.PrimaryScreen.WorkingArea.Height - Height * i - 5 * i; Location = new Point(x, y); break; } } x = Screen.PrimaryScreen.WorkingArea.Width - base.Width - 5; string messsage = string.Format("{0} reçetesi hazır", responseBarcode.Data.Patient_name); if (isRetail) { messsage = responseBarcode.Title; } pictureBox1.Image = Resources.success; BackColor = Color.SeaGreen; lblMsg.Text = messsage; action = NotificationAction.start; timer1.Interval = 1; timer1.Start(); }
private void WatchDog_ParseFileEvent(object sender, ParseEventArgs e) { Logger.GetInstance().Info(e.FilePath + " dosyası okunacak"); try { if (File.Exists(e.FilePath)) { using (FileStream fs = new FileStream(e.FilePath, FileMode.Open, FileAccess.Read, FileShare.Read)) { using (StreamReader sr = new StreamReader(fs)) { string content = sr.ReadToEnd(); if (BL.IsValidHTML(content)) { List <ParsedData> parsedData = BL.Parse(content); RequestBarcode requestBarcode = BL.CreateRequestModel(parsedData); lastRequestBarcode = requestBarcode; if (!Settings.Default.IsManuelMode) { ResponseBarcode responseBarcode = BL.PostRequest(requestBarcode); if (responseBarcode.Data != null) { new Thread(() => ShowNotification(responseBarcode)).Start(); } else { new FormNotification("Aradığınız ilaç için veriler henüz eklenmedi. En kısa sürede eklenecektir", NotificationType.Warning).ShowDialog(); } } } else { Logger.GetInstance().Info(e.FilePath + " dosyasının içeriğinde \"" + Settings.Default.IsParseableKeyword + "\" geçemediği için ya da Recete No=0 olduğu için okunamadı"); } } fs.Close(); } } } catch (Exception ex) { Logger.GetInstance().Error("Dosya okunurken hata oluştu", ex); new FormNotification("FarmaKode hata. " + ex.Message, NotificationType.Error).ShowDialog(); } }
private void btnGonder_Click(object sender, EventArgs e) { List <string> selected = new List <string>(); foreach (var item in listBarcodes.SelectedItems) { selected.Add(item.ToString()); } Logger.GetInstance().Info("Web Servise gönderilen perakende barkodları" + string.Join("\n", selected)); RequestBarcode requestBarcode = BL.CreatRetailRequest(selected); ResponseBarcode responseBarcode = BL.PostRetailRequest(requestBarcode); responseBarcode.ReceteNo = requestBarcode.HeaderSection.ReceteNo; new FormNotification(responseBarcode).ShowDialog(); selected.Clear(); }
private void btnShowPostList_Click(object sender, EventArgs e) { //new FormPostList().ShowDialog(); List <string> barcodes = new List <string>(); barcodes.Add("8699522521456"); barcodes.Add("8699525590435"); barcodes.Add("8699717010093"); barcodes.Add("8699580510027"); RequestBarcode requestBarcode = BL.CreatRetailRequest(barcodes); ResponseBarcode responseBarcode = BL.PostRetailRequest(requestBarcode); responseBarcode.ReceteNo = requestBarcode.HeaderSection.ReceteNo; new Thread(() => ShowNotification(responseBarcode, true)).Start(); }
private void PostListItem_PostItemPrint(object sender, EventArgs e) { try { selectedResponseBarcode = sender as ResponseBarcode; if (selectedResponseBarcode.Data != null) { string tmpPDFPath = Printer.GetInstance().CreatePDF(selectedResponseBarcode); Printer.GetInstance().Print(tmpPDFPath); } else { KryptonMessageBox.Show("Aradığınız ilaç için veriler henüz eklenmedi. En kısa sürede eklenecektir", "Uyarı"); } } catch (Exception ex) { Logger.GetInstance().Error("Barkod yazdırılamadı", ex); } }
public ResponseBarcode PostRetailRequest(RequestBarcode requestBarcode) { try { var client = new RestClient(Settings.Default.PerakendeApiURL); string jsonContent = JsonConvert.SerializeObject(requestBarcode, Formatting.Indented); var request = new RestRequest(); request.RequestFormat = DataFormat.Json; request.AddJsonBody(requestBarcode); var response = client.Post(request); response.Content = response.Content.Replace("app_data", "data"); SaveRequest(Constants.LatestPostFolder, requestBarcode); if (response.IsSuccessful) { JsonSerializerSettings settings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }; settings.Culture = new System.Globalization.CultureInfo("tr-TR"); settings.DateFormatString = "dd.MM.yyyy"; ResponseBarcode responseBarcode = JsonConvert.DeserializeObject <ResponseBarcode>(response.Content, settings); responseBarcode.ReceteNo = requestBarcode.HeaderSection.ReceteNo; SaveResponse(Constants.LatestPostFolder, responseBarcode); return(responseBarcode); } else { SaveResponse(Constants.LatestPostFolder, requestBarcode.HeaderSection.ReceteNo, response.Content); throw new Exception("Web servisten reçete detayları alınamadı"); } } catch (Exception ex) { Logger.GetInstance().Error("Post metodu çalışırken hata oluştu", ex); throw new Exception("Web servisten reçete detayları alınamadı"); } }
private void SaveResponse(string folder, ResponseBarcode responseBarcode) { try { if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } #region Save Response string path = Path.Combine(folder, responseBarcode.ReceteNo + "_Response.json"); string jsonContent = JsonConvert.SerializeObject(responseBarcode, Formatting.Indented); //File.WriteAllText(path, jsonContent, Encoding.UTF8); using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.WriteLine(jsonContent); sw.Close(); } fs.Close(); } #endregion Logger.GetInstance().Info("Reçete response son işlemler kalsörüne kayıt edildi"); } catch (Exception ex) { string message = "Reçete response son işlemler klasörüne yazılamadı"; Logger.GetInstance().Error(message, ex); throw new Exception(message, ex); } }
public string CreatePDF(ResponseBarcode barcode) { try { byte[] pdf; var cssText = File.ReadAllText(Settings.Default.DestinationFolder + "\\ReportTemplate\\barcode.css"); var htmlTemplate = File.ReadAllText(Settings.Default.DestinationFolder + "\\ReportTemplate\\barcode.html"); StringBuilder sb = new StringBuilder(); foreach (var item in barcode.Data.Drugs) { if (item.IsPrint) { string content = string.Format(htmlTemplate, item.Drug_name, DateTime.Now.ToString("dd.MM.yyyy"), item.Diagnosis, item.Suggestions, item.Warnings, barcode.Data.Patient_name, item.Expiration_date.ToString("dd.MM.yyyy"), barcode.Data.Pharmacy_name, barcode.Data.Pharmacy_phone); sb.AppendLine(content); } } using (var memoryStream = new MemoryStream()) { Size paperSize = Common.GetBarcodePaperSize(); Margins paperMargins = Common.GetBarcodePaperMargins(); float width = (float)Math.Ceiling((float)paperSize.Width * 0.039370078740158 * 72); float height = (float)Math.Ceiling((float)paperSize.Height * 0.039370078740158 * 72); iTextSharp.text.Rectangle rectangle = new iTextSharp.text.Rectangle(width, height); var document = new Document(rectangle, paperMargins.Left, paperMargins.Right, paperMargins.Top, paperMargins.Bottom); var writer = PdfWriter.GetInstance(document, memoryStream); document.Open(); using (var cssMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(cssText))) { using (var htmlMemoryStream = new MemoryStream(Encoding.UTF8.GetBytes(sb.ToString()))) { XMLWorkerHelper.GetInstance().ParseXHtml(writer, document, htmlMemoryStream, cssMemoryStream); } } document.Close(); pdf = memoryStream.ToArray(); } string path = Settings.Default.DestinationFolder + "\\Barcods\\" + barcode.ReceteNo + "_Barcode.pdf"; FileStream fs = new FileStream(path, FileMode.Create); fs.Write(pdf, 0, pdf.Length); fs.Flush(); fs.Close(); return(path); } catch (Exception ex) { throw ex; } }
public PostListItem(int orderNo, ResponseBarcode Data) { InitializeComponent(); this.Data = Data; load(orderNo); }