// Выводит объекты в Excel файл
        public void printAllToExcel()
        {
            ExcelDocumentManager manager_out = new ExcelDocumentManager();

            manager_out.setVisible(true);
            manager_out.CreateExcelApplication();
            manager_out.CreateWorkbook();
            manager_out.OpenSheet();
            manager_out.toFirstRow();

            // Выводим шапку
            FISGIAObject tempObj = new FISGIAObject();

            for (int i = 1; i <= tempObj.Fields().Length; i++)
            {
                manager_out.cell(i).Value = tempObj.Description(i);
            }
            manager_out.toNextRow();

            // Выводим объекты
            foreach (FISGIAObject obj in this.objects)
            {
                for (int i = 1; i <= obj.Fields().Length; i++)
                {
                    manager_out.cell(i).Value = obj.Get(i);
                }
                manager_out.toNextRow();
            }
        } //--//--
        // Загружает данные из файла
        public static List <FISGIAObject> Read(String[] files)
        {
            List <FISGIAObject> FisgiaObjects = new List <FISGIAObject>();

            ExcelDocumentManager manager = new ExcelDocumentManager();

            manager.setVisible(true);
            manager.CreateExcelApplication();

            foreach (String filename in files)
            {
                //=================================
                // Открытие новой книги
                //=================================
                manager.OpenWorkbook(filename);


                //=================================
                // Подсчет количества строк
                //=================================
                manager.toFirstRow();
                manager.toNextRow();
                manager.toNextRow();
                int count = 0;
                while (!manager.empty(1))
                {
                    manager.toNextRow();
                    count++;
                }
                //=================================

                // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                /*ExcelDocumentManager manager_out = new ExcelDocumentManager();
                 * FISGIAObject tempObj = new FISGIAObject();
                 * manager_out.setVisible(true);
                 * manager_out.CreateExcelApplication();
                 * manager_out.CreateWorkbook();
                 * manager_out.OpenSheet();
                 * manager_out.toFirstRow();
                 * for (int i = 1; i <= tempObj.Fields().Length; i++)
                 * {
                 *  manager_out.cell(i).Value = tempObj.Description(i);
                 * }
                 * manager_out.toNextRow();*/
                //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                //=================================
                // Прогресс
                //=================================
                Progressor progressor = new Progressor();
                progressor.SetCount(count);
                progressor.Show();
                progressor.Focus();
                //=================================

                manager.toFirstRow();
                manager.toNextRow(); //Проскакиваем меню
                manager.toNextRow();
                while (!manager.empty(1))
                {
                    FISGIAObject obj = new FISGIAObject();

                    for (int i = 1; i <= obj.Fields().Length; i++)
                    {
                        if (!manager.empty(i))
                        {
                            if (obj.Type(i) == ParentObjectFieldTypes.DATE)
                            {
                                try
                                {
                                    obj.Set(obj.Field(i), "'" + String.Format("{0:dd.MM.yyyy}", (DateTime)manager.cell(i).Value));
                                }
                                catch (Exception e)
                                {
                                    obj.Set(obj.Field(i), null);
                                }
                            }

                            if (obj.Type(i) == ParentObjectFieldTypes.NUM)
                            {
                                try
                                {
                                    obj.Set(obj.Field(i), "'" + (manager.cell(i).Value).ToString());
                                }
                                catch (Exception e)
                                {
                                    obj.Set(obj.Field(i), null);
                                }
                            }

                            if (obj.Type(i) == ParentObjectFieldTypes.TEXT)
                            {
                                try
                                {
                                    obj.Set(obj.Field(i), (String)manager.cell(i).Value);
                                }
                                catch (Exception e)
                                {
                                    obj.Set(obj.Field(i), null);
                                }
                            }
                        }
                        else
                        {
                            obj.Set(obj.Field(i), null);
                        }
                    }


                    FisgiaObjects.Add(obj);

                    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                    /*for (int i = 1; i <= obj.Fields().Length; i++)
                     * {
                     *  manager_out.cell(i).Value = obj.Get(i);
                     * }
                     * manager_out.toNextRow();*/
                    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                    manager.toNextRow();
                    progressor.Step();
                } // --//-- while (!manager.empty(1))

                progressor.Hide();
                progressor.Dispose();

                manager.CloseBook();
            } // --//-- foreach (String filename in files)

            manager.CloseApplication();

            return(FisgiaObjects);
        } // --//-- List<FISGIAObject> Read(String[] files)
Example #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            //Загружаем заявления студентов (FISGIA)
            FISGIAObjectManager manager = new FISGIAObjectManager();

            manager.LoadFiles();

            Logger.getInstance().log("Загружено студентов " + manager.getCount().ToString());

            /*List <ASURSOObject> list = manager.getAllArrived();
             * Logger.getInstance().log("Отобрано студентов " + list.Count.ToString());
             * (new LogForm(Logger.getInstance().getAllLogs())).ShowDialog();*/

            // Смотрим найденных студентов

            /*ExcelDocumentManager office = new ExcelDocumentManager();
             * office.setVisible(true);
             * office.CreateExcelApplication();
             * office.CreateWorkbook();
             * office.OpenSheet();
             *
             * office.toFirstRow();
             * office.cell(1).Value = "Найдены данные";
             * office.toNextRow();
             * int i = 1;
             * foreach(String name in (new ASURSOObject()).Descriptions())
             * {
             *  office.cell(i).Value = name;
             *  i++;
             * }
             * office.toNextRow();
             *
             * foreach(ASURSOObject obj in list)
             * {
             *  for(int j=1; j<= obj.Fields().Length; j++)
             *  {
             *      office.cell(j).Value = (obj.Field(j).Contains("Group") ? "'" : "")  + obj.Get(j);
             *  }
             *  office.toNextRow();
             * }*/


            // Смотрим, есть ли студенты, прошедшие по приказу (knowlege) но не найденные в заявлениях (FISGIA)
            ExcelDocumentManager office = new ExcelDocumentManager();

            office.setVisible(true);
            office.CreateExcelApplication();
            office.CreateWorkbook();
            office.OpenSheet();

            office.toFirstRow();
            office.cell(1).Value = "Не найдены данные";
            office.toNextRow();
            office.cell(1).Value = "Фамилия";
            office.cell(2).Value = "Имя";
            office.cell(3).Value = "Отчество";
            office.cell(4).Value = "Группа";
            office.toNextRow();


            List <ArrivedStudentObject> allArrived = new GIAToASURSOConverter.knowlege.ArrivedStudentsKnowlege().getAll();

            foreach (ArrivedStudentObject obj in allArrived)
            {
                bool found = false;

                //=====================================================================================
                // Поиск в найденных
                //foreach (ASURSOObject aobj in list)
                foreach (FISGIAObject aobj in manager.getAll())
                {
                    String family  = obj.Get("Family");
                    String name    = obj.Get("Name");
                    String sername = obj.Get("Sername");

                    String family2  = aobj.Get("Family");
                    String name2    = aobj.Get("Name");
                    String sername2 = aobj.Get("Sername");

                    if (CheckSimilaryFIO.Check(family, name, sername, family2, name2, sername2) == true)
                    {
                        found = true;
                    }
                } //===============================================================================================


                if (found == false)
                {
                    office.cell(1).Value = obj.Get("Family");
                    office.cell(2).Value = obj.Get("Name");
                    office.cell(3).Value = obj.Get("Sername");
                    office.cell(4).Value = "'" + obj.Get("Group");
                    office.toNextRow();
                }
            }
        }