예제 #1
0
 public ExportManager()
 {
     _excelStyle   = new EStyleManager();
     _tableCounter = 0;
 }
예제 #2
0
 public ExportManager()
 {
     _excelStyle = new EStyleManager();
     _tableCounter = 0;
 }
예제 #3
0
파일: FormMain.cs 프로젝트: ruslanlyalko/DA
        private void ExportProfile(object o)
        {
            var profile = o as Profile;
            var finalDictionary = new EDataTableDictionary();

            if (profile != null)
                foreach (var query in profile.Queries)
                {

                    var table = QueryBuilder.GetDataTable(query);
                    if(table.Rows.Count == 0)
                        continue;

                    table.TableName = query.QueryName;
                    var periods = query.TimeSlice.ExtractedPeriods;

                    var tdays = from items in query.TimeSlice.SelectedDays
                                where items.Value
                                select items.Key;

                    var queryId = query.QueryId;

                    var tfinalBuilder = new EDataTableBuilder(table, queryId);
                    var selectedColumns = query.SelectedCols;
                    var dtype = query.TimeFrame == "Tick" ? EDataTableBuilder.DataType.Tick : EDataTableBuilder.DataType.Bar;
                    tfinalBuilder.CreateTimeSliceTables(tdays.ToList(), periods.ToList(), dtype,selectedColumns);

                    foreach(var tableTs in tfinalBuilder.GetTimeSliceTable())
                    {
                        CustomFormulaManager.Initialize(query, tableTs,
                                                        new EDataTable(1, true, false),
                                                        table);

                        CustomFormulaManager.CalculateTimeSliceTable();

                        finalDictionary.AddRange(tfinalBuilder.ETableDictionary);
                    }

                    var sdays = from items in query.SnapShoot.SelectedDays
                                where items.Value
                                select items.Key;
                    var stimeFrames = from items in query.SnapShoot.ExtrTimes
                                      select TimeSpan.Parse(items);
                    tfinalBuilder.CreateSnapShotTables(sdays.ToList(), stimeFrames.ToList());
                    foreach (var tableSS in tfinalBuilder.GetSnapShotTable())
                    {
                        CustomFormulaManager.Initialize(query, tableSS,
                                                        tableSS,
                                                        table);
                        CustomFormulaManager.CalculateSnapShootTable();

                        finalDictionary.AddRange(tfinalBuilder.ETableDictionary);
                    }
                    finalDictionary.AddRange(tfinalBuilder.ETableDictionary);

                }
            var oldThread = Thread.CurrentThread.CurrentCulture;
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            var excel = new ExportManager();
            var formatStyle = new EStyleManager();
            excel.ExcelFormattingStyle = formatStyle;
            finalDictionary.Normalize();
            excel.ExportRowProgress += ExportProgress;
            CheckDictionaryForEmptyData(finalDictionary);

               if(CheckDictionaryForEmptyData(finalDictionary))
               {
               Invoke((Action) delegate
                                   {
                                       ui_Exprot_button.Enabled = false;
                                   });

               if (profile != null)
                   excel.ExportDataToExcel(finalDictionary, ExportStyle.ColumnWise,profile.Parameters.ProfileName);
               }
               else
               {
               Invoke((Action)delegate
               {
                   ToastNotification.Show(this, @"The profile's queries are not found any data.", 2000, eToastPosition.MiddleCenter);
               });
               }

            Thread.CurrentThread.CurrentCulture = oldThread;

            if(Thread.CurrentThread.IsAlive)
                Thread.CurrentThread.Abort();
        }