예제 #1
0
        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();
            }
        }