Exemple #1
0
        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();
            }
        }
Exemple #2
0
 private void FormButton_FormClosing(object sender, FormClosingEventArgs e)
 {
     watchDog                = null;
     lastRequestBarcode      = null;
     manuelModeTimer         = null;
     manuelBarcodePostTimer  = null;
     manuelBarcodeCleanTimer = null;
 }
Exemple #3
0
        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();
            }
        }
Exemple #4
0
        public RequestBarcode CreatRetailRequest(List <string> barcods)
        {
            try
            {
                RequestPharmacySection pharmacySection = new RequestPharmacySection();
                #region pharmacySection
                pharmacySection.TransactionID = new Guid().ToString();
                pharmacySection.FarmakodeID   = Settings.Default.PharmacyID;
                pharmacySection.IPAddress     = Common.GetPublicIp(Settings.Default.IPAddressServer);
                pharmacySection.PCNO          = Settings.Default.PharmacyPCNO;
                pharmacySection.TokenKey      = Settings.Default.PharmacyID;
                #endregion

                RequestHeaderSection headerSection = new RequestHeaderSection();
                #region headerSection
                headerSection.ReceteNo = DateTime.Now.ToString("yyyyMMdd_HHmm_") + "Perakende";
                #endregion

                List <RequestDrugSection> drugSection = new List <RequestDrugSection>();
                #region drugSection

                for (int i = 0; i < barcods.Count; i++)
                {
                    RequestDrugSection item = new RequestDrugSection();
                    item.Id     = i + 1;
                    item.Barkod = barcods[i];
                    drugSection.Add(item);
                }
                #endregion

                RequestBarcode requestBarcode = new RequestBarcode();
                requestBarcode.DrugSection     = drugSection;
                requestBarcode.PharmacySection = pharmacySection;
                requestBarcode.HeaderSection   = headerSection;


                return(requestBarcode);
            }
            catch (Exception ex)
            {
                string message = "Requerst modeli oluşturulamadı";
                Logger.GetInstance().Error(message, ex);
                throw new Exception(message, ex);
            }
        }
Exemple #5
0
        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();
        }
Exemple #6
0
        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();
        }
Exemple #7
0
        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ı");
            }
        }
Exemple #8
0
        private void SaveRequest(string folder, RequestBarcode requestBarcode)
        {
            try
            {
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                #region Save Request

                string path        = Path.Combine(folder, requestBarcode.HeaderSection.ReceteNo + "_Request.json");
                string jsonContent = JsonConvert.SerializeObject(requestBarcode, 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 request i son işlemler klasörüne kayıt edildi");
            }
            catch (Exception ex)
            {
                string message = "Reçete request i son işlemler klasörüne yazılamadı";
                Logger.GetInstance().Error(message, ex);
                throw new Exception(message, ex);
            }
        }
Exemple #9
0
        public RequestBarcode CreateRequestModel(List <ParsedData> data)
        {
            try
            {
                RequestPharmacySection pharmacySection = new RequestPharmacySection();
                #region pharmacySection
                pharmacySection.TransactionID = new Guid().ToString();
                pharmacySection.FarmakodeID   = Settings.Default.PharmacyID;
                pharmacySection.IPAddress     = Common.GetPublicIp(Settings.Default.IPAddressServer);
                pharmacySection.PCNO          = Settings.Default.PharmacyPCNO;
                pharmacySection.TokenKey      = Settings.Default.PharmacyID;
                #endregion

                RequestHeaderSection headerSection = new RequestHeaderSection();
                #region headerSection
                headerSection.ReceteSahibiTC      = GetLongValue(data, nameof(headerSection.ReceteSahibiTC));
                headerSection.TeslimAlanTC        = GetLongValue(data, nameof(headerSection.TeslimAlanTC));
                headerSection.IlaciTeslimAlan     = GetStringValue(data, nameof(headerSection.IlaciTeslimAlan));
                headerSection.ReceteSahibiAd      = GetStringValue(data, nameof(headerSection.ReceteSahibiAd));
                headerSection.ReceteSahibiSoyad   = GetStringValue(data, nameof(headerSection.ReceteSahibiSoyad));
                headerSection.ReceteSahibiAdSoyad = headerSection.ReceteSahibiAd + " " + headerSection.ReceteSahibiSoyad;
                headerSection.TeslimAlanAd        = GetStringValue(data, nameof(headerSection.TeslimAlanAd));
                headerSection.TeslimAlanSoyad     = GetStringValue(data, nameof(headerSection.TeslimAlanSoyad));
                headerSection.ProvizyonTipi       = GetStringValue(data, nameof(headerSection.ProvizyonTipi));
                headerSection.ProtokolNo          = GetStringValue(data, nameof(headerSection.ProtokolNo));
                headerSection.TesisKodu           = GetStringValue(data, nameof(headerSection.TesisKodu));
                headerSection.ReceteTarihi        = GetStringValue(data, nameof(headerSection.ReceteTarihi));
                headerSection.ReceteNo            = GetStringValue(data, nameof(headerSection.ReceteNo));
                headerSection.KarekodDurumu       = GetStringValue(data, nameof(headerSection.KarekodDurumu));
                headerSection.Kapsam                = GetStringValue(data, nameof(headerSection.Kapsam));
                headerSection.IlacAlimTarihi        = GetStringValue(data, nameof(headerSection.IlacAlimTarihi));
                headerSection.EReceteNo             = GetStringValue(data, nameof(headerSection.EReceteNo));
                headerSection.ReceteTuru            = GetStringValue(data, nameof(headerSection.ReceteTuru));
                headerSection.ReceteAltTuru         = GetStringValue(data, nameof(headerSection.ReceteAltTuru));
                headerSection.HastaTuru             = GetStringValue(data, nameof(headerSection.HastaTuru));
                headerSection.DiplomaTescilNo       = GetStringValue(data, nameof(headerSection.DiplomaTescilNo));
                headerSection.DrDiplomaNo           = GetStringValue(data, nameof(headerSection.DrDiplomaNo));
                headerSection.DrAd                  = GetStringValue(data, nameof(headerSection.DrAd));
                headerSection.DrSoyad               = GetStringValue(data, nameof(headerSection.DrSoyad));
                headerSection.Brans                 = GetStringValue(data, nameof(headerSection.Brans));
                headerSection.Sertifika             = GetStringValue(data, nameof(headerSection.Sertifika));
                headerSection.Karekodlu             = GetBooleanValue(data, nameof(headerSection.Karekodlu));
                headerSection.SiraliDagitimRecetesi = GetBooleanValue(data, nameof(headerSection.SiraliDagitimRecetesi));
                #endregion

                List <RequestDrugSection> drugSection = new List <RequestDrugSection>();
                #region drugSection
                for (int i = 1; i < 11; i++)
                {
                    RequestDrugSection item = new RequestDrugSection();
                    item.Id     = i;
                    item.Barkod = GetStringValue(data, nameof(item.Barkod), i);
                    if (!string.IsNullOrEmpty(item.Barkod))
                    {
                        item.Adet         = GetIntValue(data, nameof(item.Adet), i);
                        item.PeriyodDeger = GetIntValue(data, nameof(item.PeriyodDeger), i);
                        item.PeriyodTipi  = GetStringValue(data, nameof(item.PeriyodTipi), i);
                        item.Doz          = GetIntValue(data, nameof(item.Doz), i);
                        item.DozMiktari   = GetDoubleValue(data, nameof(item.DozMiktari), i);
                        item.Adi          = GetStringValue(data, nameof(item.Adi), i);
                        item.Tutar        = GetDoubleValue(data, nameof(item.Tutar), i);
                        item.Fark         = GetDoubleValue(data, nameof(item.Fark), i);
                        item.Rapor        = GetStringValue(data, nameof(item.Rapor), i);
                        string _VerilecebilecegiTarih = GetStringValue(data, nameof(item.VerilecebilecegiTarih), i);
                        if (string.IsNullOrEmpty(_VerilecebilecegiTarih))
                        {
                            item.VerilecebilecegiTarih = DateTime.MinValue;
                        }
                        else
                        {
                            item.VerilecebilecegiTarih = DateTime.Parse(_VerilecebilecegiTarih);
                        }



                        item.Mesaj = GetStringValue(data, nameof(item.Mesaj), i);
                        drugSection.Add(item);
                    }
                }
                #endregion


                List <RequestICDSection> icdSection = new List <RequestICDSection>();
                #region icdSection
                for (int i = 1; i < 6; i++)
                {
                    RequestICDSection item = new RequestICDSection();
                    item.Kod  = GetStringValue(data, nameof(item.Kod), i);
                    item.Tani = GetStringValue(data, nameof(item.Tani), i);

                    if (!string.IsNullOrEmpty(item.Kod) && !string.IsNullOrEmpty(item.Tani))
                    {
                        icdSection.Add(item);
                    }
                }
                #endregion

                RequestPriceSection priceSection = new RequestPriceSection();
                #region priceSection
                priceSection.KatkiPayiElden        = GetDoubleValue(data, nameof(priceSection.KatkiPayiElden));
                priceSection.KatkiPayiMaastan      = GetDoubleValue(data, nameof(priceSection.KatkiPayiMaastan));
                priceSection.MuayeneKatkiPayi      = GetDoubleValue(data, nameof(priceSection.MuayeneKatkiPayi));
                priceSection.MuayeneKatkiMaastan   = GetDoubleValue(data, nameof(priceSection.MuayeneKatkiMaastan));
                priceSection.EczaneIndirimTutari   = 0;// GetDoubleValue(data, nameof(priceSection.EczaneIndirimTutari));
                priceSection.IlacKatkiPayiTutari   = GetDoubleValue(data, nameof(priceSection.IlacKatkiPayiTutari));
                priceSection.FiyatFarki            = GetDoubleValue(data, nameof(priceSection.FiyatFarki));
                priceSection.ToplamTutar           = GetDoubleValue(data, nameof(priceSection.ToplamTutar));
                priceSection.OdenecekTutar         = GetDoubleValue(data, nameof(priceSection.OdenecekTutar));
                priceSection.EczaneyeOdenecekTutar = GetDoubleValue(data, nameof(priceSection.EczaneyeOdenecekTutar));
                #endregion


                RequestBarcode requestBarcode = new RequestBarcode();
                requestBarcode.DrugSection     = drugSection;
                requestBarcode.HeaderSection   = headerSection;
                requestBarcode.ICDSection      = icdSection;
                requestBarcode.PharmacySection = pharmacySection;
                requestBarcode.PriceSection    = priceSection;


                return(requestBarcode);
            }
            catch (Exception ex)
            {
                string message = "Requerst modeli oluşturulamadı";
                Logger.GetInstance().Error(message, ex);
                throw new Exception(message, ex);
            }
        }
Exemple #10
0
 private void ManuelModeTimer_Tick(object sender, EventArgs e)
 {
     lastRequestBarcode = null;
 }