예제 #1
0
파일: Lookup.cs 프로젝트: sajens/MAIME
 public Lookup(Graph graph) : base(graph)
 {
     Database = new DatabaseTuple();
     Table    = new TableTuple();
     Joins    = new List <JoinTuple>();
     Output   = new List <OutputTuple>
     {
         new OutputTuple(),
         new OutputTuple()
     };
 }
예제 #2
0
 public OLEDBDestination(Graph graph) : base(graph)
 {
     Database = new DatabaseTuple();
     Table    = new TableTuple();
 }
예제 #3
0
 public OLEDBSource(Graph graph) : base(graph)
 {
     Database = new DatabaseTuple();
     Table    = new TableTuple();
 }
예제 #4
0
        public static void CopyToConsumerPanelExcel(Excel.Application app, List <ConsumerPanel> panelList, string dirName)
        {
            if (!Directory.Exists(dirName))
            {
                throw new Exception("Dir " + dirName + " not exists");
            }
            string[] entries = Directory.GetFileSystemEntries(dirName);
            foreach (string entry in entries)
            {
                string filename = Path.GetFileName(entry);
                char[] delims   = { '.', '-' };
                string city     = filename.Split(delims)[2];
                if (!KAO.cityTable.TryGetValue(city.ToLower(), out city))
                {
                    throw new Exception("Can not determine city :" + filename);
                }

                ConsumerPanel curPanel = null;
                foreach (ConsumerPanel p in panelList)
                {
                    if (p.city == city)
                    {
                        curPanel = p;
                    }
                }
                if (curPanel == null)
                {
                    throw new Exception("Cannot find panel of city " + city);
                }

                Excel.Workbook book = app.Workbooks.Open(entry, ReadOnly: false);
                if (curPanel.tableDataList.Count != book.Sheets.Count)
                {
                    throw new Exception("Panel table List count not equal to sheets count");
                }

                int idx = 0;
                foreach (Excel.Worksheet curSheet in book.Sheets)
                {
                    Trace.TraceInformation("Copying to {0}:{1}", book.Name, curSheet.Name);
                    TableTuple  curTuple       = curPanel.tableDataList[idx++];
                    Excel.Range startYearRange = curSheet.UsedRange.Find(curTuple.Item1.ToString(),
                                                                         Type.Missing, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlPart,
                                                                         Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext,
                                                                         false, Type.Missing, Type.Missing);
                    string startYearStr = startYearRange.Value.ToString();
                    int    startYear;
                    if (!int.TryParse(startYearStr, out startYear) || startYear != curTuple.Item1)
                    {
                        throw new Exception("Can not find a place to paste with year " + startYearStr);
                    }

                    Excel.Range startCell  = startYearRange.End[Excel.XlDirection.xlDown];
                    Excel.Range endCell    = startCell.Offset[curTuple.Item2.Rows.Count, curTuple.Item2.Columns.Count];
                    Excel.Range pasteRange = curSheet.Range[startCell, endCell];
                    Excel.Range copyRange  = curTuple.Item2;

                    copyRange.Copy(Type.Missing);
                    pasteRange.PasteSpecial(Excel.XlPasteType.xlPasteValues);
                }
            }
        }