Exemplo n.º 1
0
        public static List <string> RemoteGet(List <string> FileDaElaborare)
        {
            DirectoryInfo local = new DirectoryInfo(ConfigFile.LOCAL_DIR_FULL);

            if (local.Exists)
            {
                DirOps.TraverseDirectory(local);
            }

            Logger.PrintLC("## Starting elaboration of remote/local file structure.", 2, ConfigFile.INFO);
            try
            {
                string[]      listSQL          = DirOps.GetFilesToProcess(ConfigFile.ROOT, "*.sql");
                List <string> listSQLdaCopiare = listSQL.ToList();
                DirOps.Copy(ConfigFile.ROOT, ConfigFile.LOCAL_DIR_FULL, FileDaElaborare);
                DirOps.Copy(ConfigFile.ROOT, ConfigFile.LOCAL_DIR_FULL, listSQLdaCopiare);
            }
            catch
            {
                Logger.PrintLC("Error while copying remote structure to local temporary structure.", 2, ConfigFile.ERROR);
                return(new List <string>());
            }
            // SEZIONE AGGIORNAMENTO PATH CARTELLE DI SISTEMA
            ConfigFile.TEMP_REMOTE_ROOT          = ConfigFile.ROOT;
            ConfigFile.FOLDERDESTINATION_GENERAL = Path.Combine(ConfigFile.LOCAL_DIR_FULL, ConfigFile.DEST_FOLD_NAME);
            ConfigFile.FOLDERDESTINATION         = Path.Combine(ConfigFile.FOLDERDESTINATION_GENERAL, ConfigFile.TIMESTAMPFOLDER);
            //###############################################
            if (ConfigFile.LOCAL_DIR_FULL.Substring(ConfigFile.LOCAL_DIR_FULL.Length - 1) != @"\")
            {
                ConfigFile.ROOT = ConfigFile.LOCAL_DIR_FULL + @"\";
            }
            else
            {
                ConfigFile.ROOT = ConfigFile.LOCAL_DIR_FULL;
            }

            //FileDaElaborareRemoto = FileDaElaborare;
            string[]      elencoLocale = DirOps.GetFilesToProcess(ConfigFile.ROOT, "*.xls|.xlsx");
            List <string> FileDaElaborareCompletoLocale = FileOps.GetTrueFilesToProcess(elencoLocale);

            FileDaElaborare = Parser.ParseListOfFileNames(FileDaElaborareCompletoLocale);
            Logger.PrintLC("## Finished elaboration of remote/local file structure.", 2, ConfigFile.INFO);
            return(FileDaElaborare);
        }
Exemplo n.º 2
0
        /// <summary>
        /// MAIN process
        /// </summary>
        /// <returns></returns>
        public static int StartProcess()
        {
            try
            {
                string[]      ElencoExcel = DirOps.GetFilesToProcess(ConfigFile.ROOT, "*.xls|.xlsx");
                List <string> gg          = FileOps.GetTrueFilesToProcess(ElencoExcel);
                //####################################
                //Ciclo MAIN
                foreach (var file in gg)
                {
                    string TemplateFile = null;
                    if (ExcelOps.FileValidation(file))
                    {
                        FileT  fileT      = Parser.ParseFileName(file);
                        string destERFile = null;
                        if (fileT != null)
                        {
                            switch (fileT.TipoDBMS)
                            {
                            case ConfigFile.DB2_NAME:
                                TemplateFile = ConfigFile.ERWIN_TEMPLATE_DB2;
                                break;

                            case ConfigFile.ORACLE:
                                TemplateFile = ConfigFile.ERWIN_TEMPLATE_ORACLE;
                                break;

                            default:
                                TemplateFile = ConfigFile.ERWIN_TEMPLATE_DB2;
                                break;
                            }
                            FileInfo origin   = new FileInfo(file);
                            string   fileName = Path.GetFileNameWithoutExtension(file);
                            destERFile = Path.Combine(ConfigFile.FOLDERDESTINATION, fileName + Path.GetExtension(TemplateFile));
                            if (!FileOps.CopyFile(TemplateFile, destERFile))
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                        //Apertura connessione per il file attuale
                        ConnMng connessione = new ConnMng();
                        if (!connessione.openModelConnection(destERFile))
                        {
                            continue;
                        }
                        //Aggiornamento della struttura dati per il file attuale
                        if (!connessione.SetRootObject())
                        {
                            continue;
                        }
                        if (!connessione.SetRootCollection())
                        {
                            continue;
                        }

                        FileInfo       fInfo    = new FileInfo(file);
                        List <EntityT> DatiFile = ExcelOps.ReadXFileEntity(fInfo, fileT.TipoDBMS);
                        foreach (var dati in DatiFile)
                        {
                            connessione.CreateEntity(dati, TemplateFile);
                        }
                        fInfo = new FileInfo(Path.Combine(ConfigFile.FOLDERDESTINATION, Path.GetFileNameWithoutExtension(file) + ".xlsx"));
                        List <AttributeT> AttrFile = null;
                        if (File.Exists(fInfo.FullName))
                        {
                            AttrFile = ExcelOps.ReadXFileAttribute(fInfo, fileT.TipoDBMS);
                        }
                        //ATTRIBUTI - PASSAGGIO UNO
                        //Aggiornamento dati struttura
                        if (!connessione.SetRootObject())
                        {
                            continue;
                        }
                        if (!connessione.SetRootCollection())
                        {
                            continue;
                        }
                        //############################
                        foreach (var dati in AttrFile)
                        {
                            connessione.CreateAttributePassOne(dati, TemplateFile);
                        }

                        //ATTRIBUTI - PASSAGGIO DUE
                        //Aggiornamento dati struttura
                        if (!connessione.SetRootObject())
                        {
                            continue;
                        }
                        if (!connessione.SetRootCollection())
                        {
                            continue;
                        }
                        //############################
                        foreach (var dati in AttrFile)
                        {
                            connessione.CreateAttributePassTwo(dati, TemplateFile);
                        }

                        //Chiusura connessione per il file attuale.
                        connessione.CloseModelConnection();
                    }
                }
                return(0);
            }
            catch (Exception exp)
            {
                //return exp.HResult;
                return(6);
            }
            return(6);
        }