Esempio n. 1
0
        /// <summary>
        /// Отображает грфик в EXEL, но не сохраняет его.
        /// </summary>
        /// <param name="xy">корневой массив-линий, листовой точек. Точки должны отличться на одну постоянноую величину</param>
//        static void Draw(int[][] xy)
//        {
//            Application application = new Application(){Visible = true};
//            var workbooks = application.Workbooks;
//            var wordBook = workbooks.Open(new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent.FullName+"/chart.xls");
//            var sheet = (_Worksheet) wordBook.ActiveSheet;
//var chart =(_Chart)wordBook.Charts.Add();
//            chart.Name = "sdfs";
//            Thread.CurrentThread.CurrentCulture=new CultureInfo("en-US");
//            sheet.ClearArrows();
//            for (int j = 0; j < xy.Length; j++)
//                for (int i = 0; i < xy[0].Length; i++)
//            {
//                {
//                    sheet.Cells[i + 1, j + 1] = xy[j][i].ToString(CultureInfo.InvariantCulture);
//                }
//            }

//            chart.ChartWizard(sheet.Range["A1", "G" + xy[0].Length], XlChartType.xlLine);
//            //System.Runtime.InteropServices.Marshal.ReleaseComObject(chart);
//            //System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);
//            //wordBook.Close(false);
//            //System.Runtime.InteropServices.Marshal.ReleaseComObject(wordBook);
//            //System.Runtime.InteropServices.Marshal.ReleaseComObject(workbooks);
//            //System.Runtime.InteropServices.Marshal.ReleaseComObject(application);
//        }



        private static void TestSearch(BTree cell, string name)
        {
            PxEntry found = cell.BinarySearch(pe =>
            {
                string s = (string)pe.Field(0).Get();
                return(String.Compare(name, s, StringComparison.Ordinal));
            });

            if (found.offset == long.MinValue)
            {
                Console.WriteLine("Имя {0} не найдено", name);
            }
            else
            {
                var res3 = found.GetValue();
                Console.WriteLine(res3.Type.Interpret(res3.Value));
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string path = @"..\..\..\Databases\";

            InitTypes();
            DateTime tt0 = DateTime.Now;

            // Проверка объекта
            object[] testdb = new object[] {
                new object[] { 1, new object[] { "a", "b", "c" } },
                new object[] { 1, new object[] { "a1", "b1", "c1" } },
                new object[] { 2, new object[] { "da", "db", "dc", "lang" } }
            };
            Console.WriteLine(seqtriplets.Interpret(testdb));

            // Создание ячейки плавающего формата
            string testpacfilename = path + "test.pac";

            if (System.IO.File.Exists(testpacfilename))
            {
                System.IO.File.Delete(testpacfilename);
            }
            PaCell cell = new PaCell(seqtriplets, testpacfilename, false); // false - чтобы заполнять

            // Заполнение ячейки данными из объекта
            cell.Fill(testdb);
            // Проверка того, что имеется в ячейке
            var cell_pvalue = cell.Root.GetValue();

            Console.WriteLine(cell_pvalue.Type.Interpret(cell_pvalue.Value));

            PTypeUnion tp_u = new PTypeUnion();

            tp_u.Variants = new[] {
                new NamedType("empty", new PType(PTypeEnumeration.none)),
                new NamedType("node", new PTypeRecord(
                                  new NamedType("f0", new PType(PTypeEnumeration.boolean)),
                                  new NamedType("f1", new PTypeSequence(tp_u))))
            };
            object[] vv = new object[] { 1,
                                         new object[] {
                                             true,
                                             new object[] {
                                                 new object[] { 1,
                                                                new object[] {
                                                                    false,
                                                                    new object[0]
                                                                } }
                                             }
                                         } };
            PxCell xcell = new PxCell(tp_u, path + "xcell.pxc", false);

            xcell.Fill(vv);
            PxEntry e1 = xcell.Root.UElement().Field(1);
            PxEntry e2 = e1.Element(0);
            var     v  = e2.GetValue();

            Console.WriteLine(v.Type.Interpret(v.Value));

            return;

            //cell.Clear();
            //cell.Fill(testtriplets); // проверка на то, что при неочищенной ячейке, записать в нее нельзя
            //cell.Close();
            //cell.Clear();
            //cell.Fill(testtriplets); // проверка на то, что при очищении, записать можно

            //// Проверка серийного буфера, в него загружаются данные из XML-файла, в ячейку ничего не помещается
            //// Этот тест, для начала, можно пропустить.
            //tt0 = DateTime.Now;
            //SerialBuffer buff = new SerialBuffer(new SerialFlowReceiverStub(seqtriplets));
            //TestSerialInput(buff, path);
            //Console.WriteLine("Число элементов в объекте:" + ((object[])buff.Result).LongLength);
            //Console.WriteLine("Forming buffer ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;

            // Проверка ввода из серийного скобочного потока для ячейки свободного формата
            // В данном случае, поток порождается при сканировании XML-документа
            tt0 = DateTime.Now;
            cell.Clear();
            TestSerialInput(cell, path);
            Console.WriteLine("Число элементов в объекте:" + cell.Root.Count());
            Console.WriteLine("Serial input ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
            cell.Close(); // Ячейка закрыта, теперь ее нельзя использовать

            // Проверка создания ячейки в режиме чтения
            PaCell cell2pac = new PaCell(seqtriplets, testpacfilename);
            long   cnt2     = cell2pac.Root.Count();
            var    pval2    = cell2pac.Root.Element(100000).GetValue();

            Console.WriteLine("cnt2=" + cnt2 + " Element(100000).Get()=" + pval2.Type.Interpret(pval2.Value));
            Console.WriteLine("ReadObly cell ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;

            // Создание ячейки фиксированного формата
            xcell.Clear();
            xcell = new PxCell(seqtriplets, path + "test.pxc", false);
            var pv = cell2pac.Root.Get();

            tt0 = DateTime.Now;
            xcell.Fill2(pv); // Плохой метод, заменю на хороший
            Console.WriteLine("xcell Fill ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;

            // Проверка наполнения
            PxEntry rxt = xcell.Root;
            var     ele = rxt.Element(400000).GetValue();

            Console.WriteLine(ele.Type.Interpret(ele.Value));
            Console.WriteLine("ok. duration=" + (DateTime.Now - tt0).Ticks / 10000L); tt0 = DateTime.Now;
        }