Esempio n. 1
0
        /* Заносим данные в List<AdvertisingProductsModel> */
        private void SetSponsoredProductsToList(IDataRecord record)
        {
            AdvertisingProductsModel adprModel = new AdvertisingProductsModel();

            advprodList.Add(adprModel);
            for (int i = 0; i < record.FieldCount; i++)
            {
                advprodList[advprodList.Count - 1].WriteData(i, record[i]);
            }
        }
Esempio n. 2
0
        /* Загружаем новые ключи из файла для Sponsored Products */
        public void OpenNewFileForSponsoredProducts(string _fileName)
        {
            advProductsList.Clear();

            try
            {
                FileInfo existingFile = new FileInfo(@_fileName);
                using (ExcelPackage package = new ExcelPackage(existingFile))
                {
                    //get the first worksheet in the workbook
                    ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                    int            colCount  = worksheet.Dimension.End.Column; //get Column Count
                    int            rowCount  = worksheet.Dimension.End.Row;    //get row count

                    for (int row = 2; row <= rowCount; row++)
                    {
                        AdvertisingProductsModel prModel = new AdvertisingProductsModel();
                        advProductsList.Add(prModel);

                        UpdateDate = worksheet.Cells[row, 1].GetValue <DateTime>();
                        datesList.Add(worksheet.Cells[row, 1].GetValue <DateTime>());
                        advProductsList[advProductsList.Count - 1].WriteData(0, UpdateDate);

                        advProductsList[advProductsList.Count - 1].WriteData(1, ChechForNull(worksheet, row, 3));             //[CurrencyCharCode]
                        advProductsList[advProductsList.Count - 1].WriteData(2, ChechForNull(worksheet, row, 4));             //[CampaignName]
                        advProductsList[advProductsList.Count - 1].WriteData(3, ChechForNull(worksheet, row, 5));             //[AdGroupName]
                        advProductsList[advProductsList.Count - 1].WriteData(4, ChechForNull(worksheet, row, 6));             //[Targeting]
                        advProductsList[advProductsList.Count - 1].WriteData(5, ChechForNull(worksheet, row, 7));             //[MatchType]
                        advProductsList[advProductsList.Count - 1].WriteData(6, ChechForNull(worksheet, row, 8));             //[Impressions]
                        advProductsList[advProductsList.Count - 1].WriteData(7, ChechForNull(worksheet, row, 9));             //[Clicks]
                        advProductsList[advProductsList.Count - 1].WriteData(8, ChechForNull(worksheet, row, 10));            //[CTR]
                        advProductsList[advProductsList.Count - 1].WriteData(9, ChechForNull(worksheet, row, 11));            //[CPC]
                        advProductsList[advProductsList.Count - 1].WriteData(10, ChechForNull(worksheet, row, 12));           //[Spend]
                        advProductsList[advProductsList.Count - 1].WriteData(11, ChechForNull(worksheet, row, 15));           //[Sales]
                        advProductsList[advProductsList.Count - 1].WriteData(12, ChechForNull(worksheet, row, 13));           //[ACoS]
                        advProductsList[advProductsList.Count - 1].WriteData(13, ChechForNull(worksheet, row, 14));           //[RoAS]
                        advProductsList[advProductsList.Count - 1].WriteData(14, ChechForNull(worksheet, row, 16));           //[Orders]
                        advProductsList[advProductsList.Count - 1].WriteData(15, ChechForNull(worksheet, row, 17));           //[Units]
                        advProductsList[advProductsList.Count - 1].WriteData(16, ChechForNull(worksheet, row, 18));           //[ConversionRate]
                        advProductsList[advProductsList.Count - 1].WriteData(17, ChechForNull(worksheet, row, 19));           //[AdvSKUUnits]
                        advProductsList[advProductsList.Count - 1].WriteData(18, ChechForNull(worksheet, row, 20));           //[OtherSKUUnits]
                        advProductsList[advProductsList.Count - 1].WriteData(19, ChechForNull(worksheet, row, 21));           //[AdvSKUSales]
                        advProductsList[advProductsList.Count - 1].WriteData(20, ChechForNull(worksheet, row, 22));           //[OtherSKUSales]
                    }
                }

                StartDate = datesList.Min();
                EndDate   = datesList.Max().AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            catch (Exception ex)
            {
                richTextBox2.Text = "Проблема при открытии файла. Убедитесь, что Вы выбрали файл с нужны расширением. Возможно, разметка файла не поддерживается программой.";
                advProductsList.Clear();
            }
        }
Esempio n. 3
0
        private void LoadManyFilesStepByStep_AP(string _filename)
        {
            advProductsList.Clear();

            try
            {
                FileInfo existingFile = new FileInfo(@_filename);
                using (ExcelPackage package = new ExcelPackage(existingFile))
                {
                    //get the first worksheet in the workbook
                    ExcelWorksheet worksheet = package.Workbook.Worksheets[1];
                    int            colCount  = worksheet.Dimension.End.Column; //get Column Count
                    int            rowCount  = worksheet.Dimension.End.Row;    //get row count

                    for (int row = 2; row <= rowCount; row++)
                    {
                        AdvertisingProductsModel prModel = new AdvertisingProductsModel();
                        advProductsList.Add(prModel);

                        advProductsList[advProductsList.Count - 1].WriteData(0, worksheet.Cells[row, 1].GetValue <DateTime>());

                        advProductsList[advProductsList.Count - 1].WriteData(1, ChechForNull(worksheet, row, 4));              //[CurrencyCharCode]
                        advProductsList[advProductsList.Count - 1].WriteData(2, ChechForNull(worksheet, row, 5));              //[CampaignName]
                        advProductsList[advProductsList.Count - 1].WriteData(3, ChechForNull(worksheet, row, 6));              //[AdGroupName]
                        advProductsList[advProductsList.Count - 1].WriteData(4, ChechForNull(worksheet, row, 7));              //[Targeting]
                        advProductsList[advProductsList.Count - 1].WriteData(5, ChechForNull(worksheet, row, 8));              //[MatchType]
                        advProductsList[advProductsList.Count - 1].WriteData(6, ChechForNull(worksheet, row, 9));              //[Impressions]
                        advProductsList[advProductsList.Count - 1].WriteData(7, ChechForNull(worksheet, row, 10));             //[Clicks]
                        advProductsList[advProductsList.Count - 1].WriteData(8, ChechForNull(worksheet, row, 11));             //[CTR]
                        advProductsList[advProductsList.Count - 1].WriteData(9, ChechForNull(worksheet, row, 12));             //[CPC]
                        advProductsList[advProductsList.Count - 1].WriteData(10, ChechForNull(worksheet, row, 13));            //[Spend]
                        advProductsList[advProductsList.Count - 1].WriteData(11, ChechForNull(worksheet, row, 16));            //[Sales]
                        advProductsList[advProductsList.Count - 1].WriteData(12, ChechForNull(worksheet, row, 14));            //[ACoS]
                        advProductsList[advProductsList.Count - 1].WriteData(13, ChechForNull(worksheet, row, 15));            //[RoAS]
                        advProductsList[advProductsList.Count - 1].WriteData(14, ChechForNull(worksheet, row, 17));            //[Orders]
                        advProductsList[advProductsList.Count - 1].WriteData(15, ChechForNull(worksheet, row, 18));            //[Units]
                        advProductsList[advProductsList.Count - 1].WriteData(16, ChechForNull(worksheet, row, 19));            //[ConversionRate]
                        advProductsList[advProductsList.Count - 1].WriteData(17, ChechForNull(worksheet, row, 20));            //[AdvSKUUnits]
                        advProductsList[advProductsList.Count - 1].WriteData(18, ChechForNull(worksheet, row, 21));            //[OtherSKUUnits]
                        advProductsList[advProductsList.Count - 1].WriteData(19, ChechForNull(worksheet, row, 22));            //[AdvSKUSales]
                        advProductsList[advProductsList.Count - 1].WriteData(20, ChechForNull(worksheet, row, 23));            //[OtherSKUSales]
                                                                                                                               //}
                    }
                }
            }
            catch (Exception ex) { }
        }
Esempio n. 4
0
 /* Public метод для занесения товаров, которые потом нужно будет обновить, из AdvertisingController */
 public void AddProductForUpdate(AdvertisingProductsModel _apm)
 {
     advProductsListForUpdate.Add(_apm);
 }