示例#1
0
        /// <summary>
        /// Load configuration values from the config.xml file.
        /// If no exist config.xml file the constructor will be creating with default values.
        /// </summary>
        /// <param name="strFilename">Configuration file with full path</param>
        private static void LoadConfig(string strFilename)
        {
            m_oPiConfig = new SSGConfig();

            // Checking exists the configuration file and create default configuration if not found.
            if (!File.Exists(strFilename))
            {
                // Set the default values.
                m_oPiConfig.TexDirectory           = Environment.CurrentDirectory + "\\tex";
                m_oPiConfig.PdfDirectory           = Environment.CurrentDirectory + "\\pdf";
                m_oPiConfig.LogDirectory           = Environment.CurrentDirectory + "\\log";
                m_oPiConfig.Latex                  = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\MiKTeX 2.7\\miktex\\bin\\latex.exe";
                m_oPiConfig.PdfLatex               = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\MiKTeX 2.7\\miktex\\bin\\pdflatex.exe";
                m_oPiConfig.ConvertTimeout         = CONVERT_TIMEOUT;
                m_oPiConfig.MsmqQueueName          = Environment.MachineName + "\\private$\\PDFQueue";
                m_oPiConfig.MessageTimeOut         = MESSAGE_TIMEOUT;
                m_oPiConfig.ServicePollingInterval = SERVICE_POLLING_INTERVAL;
                m_oPiConfig.ServiceMaxThread       = SERVICE_MAXIMUM_THREAD;
                m_oPiConfig.DatabaseServer         = Environment.MachineName;
                m_oPiConfig.DatabaseName           = "PDFRequest";
                m_oPiConfig.IntegratedSecurity     = true;
                m_oPiConfig.DBUser                 = "******";
                m_oPiConfig.DBPassword             = "******";
                m_oPiConfig.SystemLog              = Environment.CurrentDirectory + DIRECTORY_SEPARATOR + AppDomain.CurrentDomain.FriendlyName + ".log";

                // Serialize the configuration object to file
                SSGConfig.Serialize(strFilename, m_oPiConfig);
            }
            else
            {
                // Read the configuration object from file
                m_oPiConfig = SSGConfig.Deserialize(strFilename);
            }
        }
示例#2
0
 /// <summary>
 /// Serialize the values of properties member into configuration files.
 /// The configuration file has stored in the xml format.
 /// </summary>
 /// <param name="strFilename">a string of file name for writing the configuration values</param>
 /// <param name="oConfig">an object instance has holding the configulation values</param>
 /// <seealso cref="SSG.Config.SSGConfig.Deserialize"/>
 public static void Serialize(string strFilename, SSGConfig oConfig)
 {
     try
     {
         // Serialize configuration values into a file.
         XmlSerializer oXmlSerializer = new XmlSerializer(typeof(SSGConfig));
         StreamWriter  oStmWriter     = File.CreateText(strFilename);
         oXmlSerializer.Serialize(oStmWriter, oConfig);
         oStmWriter.Flush();
         oStmWriter.Close();
     }
     catch (Exception)
     {
         // Ignored exception occuring.
     }
 }
示例#3
0
 /// <summary>
 /// Deserialize the values of properties member from configuration files.
 /// The configuration file has stored in the xml format.
 /// </summary>
 /// <param name="strFilename">a string of file name for reading the configuration values</param>
 /// <returns>an instance object of SSGConfig has contained the configuration value</returns>
 /// <seealso cref="SSG.Config.SSGConfig.Serialize"/>
 public static SSGConfig Deserialize(string strFilename)
 {
     try
     {
         // Deserialize configuration values from a file.
         XmlSerializer oXmlSerializer = new XmlSerializer(typeof(SSGConfig));
         StreamReader  oStmReader     = File.OpenText(strFilename);
         SSGConfig     c = (SSGConfig)oXmlSerializer.Deserialize(oStmReader);
         oStmReader.Close();
         return(c);
     }
     catch (Exception)
     {
         // Ignored exception occuring.
         return(null);
     }
 }