Пример #1
0
        public bool TryLoadConfigurationSettings(IFilingProcessor processor)
        {
            filingProcessor = processor;

            myServerKey = ConfigurationManager.AppSettings["ServerKey"];
            myEndPoint = ConfigurationManager.AppSettings["EndPoint"];
            myDispatcherUri = ConfigurationManager.AppSettings["DispatcherUri"];

            string errorMsg;
            if (!filingProcessor.TryGetDependentFolderConfiguration(out filingsFolder, out processingFolder, out reportsFolder, out errorMsg))
            {
                WriteLogEntry("Unable to load folder configuration: " + errorMsg, EventLogEntryType.Error);
                return false;
            }

            //processingFolder should never be null, if it is then something went wrong.
            processingFolderInfo = new DirectoryInfo(processingFolder);

            if (!string.IsNullOrEmpty(reportsFolder))
            {
                reportsFolderInfo = new DirectoryInfo(reportsFolder);
            }
            if (!string.IsNullOrEmpty(filingsFolder))
            {
                filingsFolderInfo = new DirectoryInfo(filingsFolder);
            }

            string strPortNumber = ConfigurationManager.AppSettings["PortNum"];
            string strMaxThreads = ConfigurationManager.AppSettings["MaxBuilderThreads"] ?? "1";
            string strFrequency = ConfigurationManager.AppSettings["ProcessingFrequency"];

            //try
            //{
            //    myDBConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
            //}
            //catch { }

            #region validate config settins

            if (string.IsNullOrEmpty(myServerKey))
            {
                WriteLogEntry("Invalid value for configuration setting ServerKey.  This value can not be empty.", EventLogEntryType.Error);
                return false;
            }

            if (string.IsNullOrEmpty(myDispatcherUri))
            {
                WriteLogEntry("Invalid value for configuration setting DispatcherUri.  This value can not be empty.", EventLogEntryType.Error);
                return false;
            }

            if (string.IsNullOrEmpty(myEndPoint))
            {
                WriteLogEntry("Invalid value for configuration setting EndPoint.  This value can not be empty.", EventLogEntryType.Error);
                return false;
            }

            if (!Int32.TryParse(strPortNumber, out myPortNumber))
            {
                WriteLogEntry("Invalid value for configuration setting PortNum: " + strPortNumber + ".  This value must be a numeric value.", EventLogEntryType.Error);
                return false;
            }

            if( !Int32.TryParse( strMaxThreads, out maxBuilderThreads ) )
            {
                WriteLogEntry( "Invalid value for configuration setting MaxBuilderThreads: " + strMaxThreads + ".  This value must be a numeric value.  Defaulting to " + maxBuilderThreads.ToString() + ".", EventLogEntryType.Error );
                //return false;
            }

            if (!Int32.TryParse(strFrequency, out processingFrequency))
            {
                WriteLogEntry("Invalid value for configuration setting ProcessingFrequency: " + strFrequency + ".  This value must be a numeric value.", EventLogEntryType.Error);
                return false;
            }

            #endregion

            return true;
        }
Пример #2
0
        public bool TryLoadConfigurationSettings(IFilingProcessor processor)
        {
            filingProcessor = processor;

            myServerKey     = ConfigurationManager.AppSettings["ServerKey"];
            myEndPoint      = ConfigurationManager.AppSettings["EndPoint"];
            myDispatcherUri = ConfigurationManager.AppSettings["DispatcherUri"];

            string errorMsg;

            if (!filingProcessor.TryGetDependentFolderConfiguration(out filingsFolder, out processingFolder, out reportsFolder, out errorMsg))
            {
                WriteLogEntry("Unable to load folder configuration: " + errorMsg, EventLogEntryType.Error);
                return(false);
            }

            //processingFolder should never be null, if it is then something went wrong.
            processingFolderInfo = new DirectoryInfo(processingFolder);

            if (!string.IsNullOrEmpty(reportsFolder))
            {
                reportsFolderInfo = new DirectoryInfo(reportsFolder);
            }
            if (!string.IsNullOrEmpty(filingsFolder))
            {
                filingsFolderInfo = new DirectoryInfo(filingsFolder);
            }

            string strPortNumber = ConfigurationManager.AppSettings["PortNum"];
            string strMaxThreads = ConfigurationManager.AppSettings["MaxBuilderThreads"] ?? "1";
            string strFrequency  = ConfigurationManager.AppSettings["ProcessingFrequency"];

            //try
            //{
            //    myDBConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;
            //}
            //catch { }

            #region validate config settins

            if (string.IsNullOrEmpty(myServerKey))
            {
                WriteLogEntry("Invalid value for configuration setting ServerKey.  This value can not be empty.", EventLogEntryType.Error);
                return(false);
            }

            if (string.IsNullOrEmpty(myDispatcherUri))
            {
                WriteLogEntry("Invalid value for configuration setting DispatcherUri.  This value can not be empty.", EventLogEntryType.Error);
                return(false);
            }

            if (string.IsNullOrEmpty(myEndPoint))
            {
                WriteLogEntry("Invalid value for configuration setting EndPoint.  This value can not be empty.", EventLogEntryType.Error);
                return(false);
            }

            if (!Int32.TryParse(strPortNumber, out myPortNumber))
            {
                WriteLogEntry("Invalid value for configuration setting PortNum: " + strPortNumber + ".  This value must be a numeric value.", EventLogEntryType.Error);
                return(false);
            }

            if (!Int32.TryParse(strMaxThreads, out maxBuilderThreads))
            {
                WriteLogEntry("Invalid value for configuration setting MaxBuilderThreads: " + strMaxThreads + ".  This value must be a numeric value.  Defaulting to " + maxBuilderThreads.ToString() + ".", EventLogEntryType.Error);
                //return false;
            }

            if (!Int32.TryParse(strFrequency, out processingFrequency))
            {
                WriteLogEntry("Invalid value for configuration setting ProcessingFrequency: " + strFrequency + ".  This value must be a numeric value.", EventLogEntryType.Error);
                return(false);
            }


            #endregion

            return(true);
        }