Ejemplo 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);
        }
Ejemplo n.º 2
0
        public bool SaveGames(object oConfig)
        {
            CCBConfig conf = (CCBConfig)oConfig;

            if (null != conf)
            {
                conf.MaybeBackup(conf.TmpPath);
                if (SaveGames(conf.TmpPath))
                {
                    try
                    {
                        System.IO.File.Copy(conf.TmpPath, conf.DocPath, true);
                        return(true);
                    }
                    catch (System.IO.IOException ioex)
                    {
                        System.Diagnostics.Debug.Write("Error copying file: " + ioex.ToString());
                    }
                }
            }
            return(false);
        }