Ejemplo n.º 1
0
 public Template(string scriptContents, IImportParser importParser, IConfiguration configuration, IEnumerable <Assembly> referencedAssemblies)
 {
     _importParser         = importParser;
     _configuration        = configuration;
     _referencedAssemblies = referencedAssemblies;
     this.Initialize(scriptContents);
 }
Ejemplo n.º 2
0
        private static int ImportDirectory(string i_sFileType, string i_sFileName, bool i_bMerge)
        {
            int iExitCode = EXIT_CODE_SUCCESS;

            IImportParser importParser = null;

            switch (i_sFileType.ToLower())
            {
            case "csv":
                importParser = new CsvImportParser();
                break;

            case "allworx":
                importParser = new AllworxImportParser();
                break;

            case "shoretel":
                importParser = new ShoreTelImportParser();
                break;

            default:
                iExitCode = EXIT_CODE_ILLEGAL_ARGUMENT;
                Console.Error.WriteLine("ERROR: Invalid type specified {0} - valid types are: csv, allworx, shoretel", i_sFileType);
                break;
            }

            if (null != importParser)
            {
                byte[] importBytes = GetBytesFromImportFile(i_sFileName);

                if ((null != importBytes) && (importBytes.Length > 0))
                {
                    bool bContinueImport = true;

                    if (!i_bMerge)
                    {
                        bContinueImport = DeleteAllUsersExceptAdmin();
                    }

                    if (bContinueImport)
                    {
                        SBConfigStor.Directory sbcDir = new SBConfigStor.Directory();
                        SBConfigStor.Directory.eImportStatus importStatus = sbcDir.Persist(importBytes, importParser, GetNumberOfUsersThatCanBeAdded());

                        if (SBConfigStor.Directory.eImportStatus.eFailure == importStatus)
                        {
                            iExitCode = EXIT_CODE_IMPORT_ERROR;
                            Console.Error.WriteLine("ERROR: There was an error importing the file ('{0}', '{1}').", i_sFileType, i_sFileName);
                        }
                        else
                        {
                            if (SBConfigStor.Directory.eImportStatus.eIncomplete == importStatus)
                            {
                                iExitCode = EXIT_CODE_IMPORT_INCOMPLETE;
                                Console.Error.WriteLine("WARNING: Import incomplete since licensed number of Directory Entries exceeded.");
                            }

                            ConfigParams.SetVoicexmlDirty(true);
                        }
                    }
                    else
                    {
                        iExitCode = EXIT_CODE_IMPORT_ERROR;
                    }
                }
                else
                {
                    iExitCode = EXIT_CODE_IMPORT_ERROR;
                    Console.Error.WriteLine("ERROR: Import file was empty or doesn't exist {0}.", i_sFileName);
                }
            }

            return(iExitCode);
        }
 public SimpleTemplateFactory(IImportParser importParser, IConfiguration configuration, IEnumerable <Assembly> referencedAssemblies)
 {
     _importParser         = importParser;
     _configuration        = configuration;
     _referencedAssemblies = referencedAssemblies;
 }