Esempio n. 1
0
        public bool SaveStores(CCBConfig conf)
        {
            XmlWriter xmlWriter = null;
            CCBLogger logger    = CCBLogConfig.GetLogger();

            lock (this)
            {
                try
                {
                    DataContractSerializer dsWriter = new DataContractSerializer(typeof(CCBStoreManager));

                    conf.MaybeBackup(conf.GetStoreTmpFilePath());
                    xmlWriter = XmlWriter.Create(conf.GetStoreTmpFilePath());
                    dsWriter.WriteObject(xmlWriter, this);
                    xmlWriter.Flush();
                    xmlWriter.Close();
                    m_dirty = false;
                    try
                    {
                        System.IO.File.Copy(conf.GetStoreTmpFilePath(), conf.GetStoreFilePath(), true);
                    }
                    catch (System.IO.IOException ioex)
                    {
                        logger.Error("Error copying file: " + ioex.ToString());
                    }
                    return(true);
                }
                catch (IOException ioex)
                {
                    logger.Error("IO Exception saving store definitions: " + ioex.ToString());
                }
                catch (XmlException xmlex)
                {
                    logger.Error("XML Exception saving store definitions: " + xmlex.ToString());
                }
                catch (Exception ex)
                {
                    logger.Error("Exception saving store definitions: " + ex.ToString());
                }
            }
            if (null != xmlWriter)
            {
                xmlWriter.Close();
            }
            return(false);
        }
Esempio n. 2
0
 private void Worker_Load(object sender, DoWorkEventArgs evtArgs)
 {
     m_storeManager.LoadStores(m_config.GetStoreFilePath());
     m_games.LoadGames(sender, evtArgs);
 }