private void LoadXML()
        {
            try
            {
                var  _filePath   = Path.Combine(this.ConnectionString.HandleEnvironmentToken(), "Templates.config");
                bool _fileExists = System.IO.File.Exists(_filePath);

                Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_TryRead_ConfigFile, _filePath);

                if (_fileExists)
                {
                    XDocument _doc = XDocument.Load(_filePath);
                    this._data = XmlSerializerManager.Deserialize <XMLSiteTemplateData>(_doc);
                    Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_Loaded_ConfigFile, _filePath);
                }
                else
                {
                    _filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.ConnectionString, "Templates.config");
                    Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_TryRead_ConfigFile, _filePath);
                    _fileExists = System.IO.File.Exists(_filePath);
                    if (_fileExists)
                    {
                        Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_File_Found, _filePath);
                        XDocument _doc = XDocument.Load(_filePath);
                        this._data = XmlSerializerManager.Deserialize <XMLSiteTemplateData>(_doc);
                        Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_Loaded_ConfigFile, _filePath);
                    }
                    else
                    {
                        var _message = string.Format(PCResources.Exception_MasterTemplateNotFound, _filePath);
                        Log.Error("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", _message);
                        throw new DataStoreException(_message);
                    }
                }
            }
            catch (Exception _ex)
            {
                Log.Error("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager", PCResources.XMLTemplateManager_Error, _ex.Message, _ex.StackTrace);
                throw;
            }
        }
Ejemplo n.º 2
0
        private void LoadXML()
        {
            try
            {
                var _filePath = Path.Combine(this.ConnectionString.HandleEnvironmentToken(), "Templates.config");
                bool _fileExists = System.IO.File.Exists(_filePath);
               
                Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_TryRead_ConfigFile, _filePath);

                if(_fileExists)
                {
                    XDocument _doc = XDocument.Load(_filePath);
                    this._data = XmlSerializerHelper.Deserialize<XMLSiteTemplateData>(_doc);
                    Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_Loaded_ConfigFile, _filePath);
                }
                else
                {
                    _filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.ConnectionString, "Templates.config");
                    Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_TryRead_ConfigFile, _filePath);
                    _fileExists = System.IO.File.Exists(_filePath);
                    if (_fileExists)
                    {
                        Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_File_Found, _filePath);
                        XDocument _doc = XDocument.Load(_filePath);
                        this._data = XmlSerializerHelper.Deserialize<XMLSiteTemplateData>(_doc);
                        Log.Info("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", PCResources.XMLTemplateManager_Loaded_ConfigFile, _filePath);
                    }
                    else
                    {
                        var _message = string.Format(PCResources.Exception_MasterTemplateNotFound, _filePath);
                        Log.Fatal("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager.LoadXML", _message);
                        throw new DataStoreException(_message);
                    }
                }
            }
            catch (Exception _ex)
            {
                Log.Fatal("Provisioning.Common.Data.Templates.Impl.XMLSiteTemplateManager", PCResources.XMLTemplateManager_Error, _ex.Message, _ex.StackTrace);
                throw;
            }

        }