예제 #1
0
        private void veriAktar(string veriyolu, string extension)
        {
            if (String.IsNullOrEmpty(veriyolu))
            {
                MessageBox.Show("Dosya Seçmediniz !!!");
                return;
            }
            List <CrossCatalogModel> uruns = new List <CrossCatalogModel>();
            FileStream streamTemp          = File.Open(veriyolu, FileMode.Open, FileAccess.Read);

            ExcelPackage.LicenseContext = LicenseContext.NonCommercial;

            using (var package = new ExcelPackage(streamTemp))
            {
                var currentSheet = package.Workbook.Worksheets;
                var workSheet    = currentSheet[0];//florists
                var noOfCol      = workSheet.Dimension.End.Column;
                var noOfRow      = workSheet.Dimension.End.Row;
                for (int rowIterator = 1; rowIterator <= noOfRow; rowIterator++)
                {
                    var urun = new CrossCatalogModel();
                    urun.AracTipi = workSheet.Cells[rowIterator, 1].Value != null ? workSheet.Cells[rowIterator, 1].Value.ToString() : string.Empty;
                    urun.Marka    = workSheet.Cells[rowIterator, 2].Value != null ? workSheet.Cells[rowIterator, 2].Value.ToString() : string.Empty;
                    urun.Code     = workSheet.Cells[rowIterator, 3].Value != null ? workSheet.Cells[rowIterator, 3].Value.ToString() : string.Empty;
                    urun.AltCode  = workSheet.Cells[rowIterator, 4].Value != null ? workSheet.Cells[rowIterator, 4].Value.ToString() : string.Empty;
                    urun.AltMarka = workSheet.Cells[rowIterator, 5].Value != null ? workSheet.Cells[rowIterator, 5].Value.ToString() : string.Empty;

                    urun.SearchCode    = urun.Code.ToLower().Replace(" ", "");
                    urun.SearchAltCode = urun.AltCode.ToLower().Replace(" ", "");
                    if (!(String.IsNullOrEmpty(urun.AracTipi)))
                    {
                        uruns.Add(urun);
                    }

                    progressBar1.Value = (progressBar1.Value >= 100) ? 0 : progressBar1.Value;
                    progressBar1.Value++;
                }
                GRPLoader.Text = "Veriler Okundu";
                int i = 0;

                if (i == 0)
                {
                    var mongoCrossManager = new MongoCrossManager();
                    mongoCrossManager.AddData(uruns);
                }
                progressBar1.Value = (progressBar1.Value >= 100) ? 0 : progressBar1.Value;
                progressBar1.Value++;
                GRPLoader.Text = "Veriler Dbye Yazılıyor.";
                i++;



                GRPLoader.Text    = "Veriler Dbye Yazıldı";
                GRPLoader.Visible = false;
                MessageBox.Show("Aktarım Tamamlandı");
            }
        }