Exemplo n.º 1
0
 static public void InitLogging(CCBConfig mainConf)
 {
     m_logfilepath = mainConf.MakeLogFilePath(DateTime.Now.Ticks);
     m_logger      = new CCBLogger(m_logfilepath, mainConf.LogLevel);
     m_logger.LogTime("Ceebeetle Start of log\n-------------------------------------------");
     m_nulllogger = new CCBLogger();
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void LoadGames(object sender, DoWorkEventArgs evtArgs)
        {
            BackgroundWorker wSender = (BackgroundWorker)sender;
            CCBConfig        config  = (CCBConfig)evtArgs.Argument;
            string           docPath;

            if (null != wSender)
            {
                try
                {
                    wSender.ReportProgress(1);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write("ReportProgress: " + ex.ToString());
                }
            }
            if (null == config)
            {
                System.Diagnostics.Debug.Write("No config found. Not loading games.");
                evtArgs.Result = TStatusUpdate.tsuFileNothingLoaded;
                return;
            }
            else
            {
                docPath = config.DocPath;
                if (!System.IO.File.Exists(docPath))
                {
                    docPath = config.GetLoadFile();
                    if (!System.IO.File.Exists(docPath))
                    {
                        System.Diagnostics.Debug.Write("Load file does not exist. Not loading games.");
                        evtArgs.Result = TStatusUpdate.tsuFileNothingLoaded;
                        return;
                    }
                }
            }
            System.Diagnostics.Debug.Write("Loading:" + docPath);
            evtArgs.Result = LoadGamesSafe(docPath);
        }
Exemplo n.º 4
0
 public MainWindow()
 {
     m_config                       = new CCBConfig();
     m_games                        = new CCBGameData();
     m_templates                    = new List <CCBGameTemplate>();
     m_storeManager                 = new CCBStoreManager();
     m_deleteEnabled                = false;
     m_deleteUsed                   = false;
     m_onCharacterListUpdateD       = new DOnCharacterListUpdate(OnCharacterListUpdate);
     m_onAddingNewEntityModeD       = new DOnAddingNewEntityMode(OnAddingNewEntityMode);
     m_onCreateNewGameD             = new DOnCreateNewGame(OnCreateNewGame);
     m_onCreateNewTemplateD         = new DOnCreateNewTemplate(OnCreateNewTemplate);
     m_gameAdderEntry               = new CCBTreeViewGameAdder();
     m_worker                       = new BackgroundWorker();
     m_worker.WorkerReportsProgress = true;
     m_timer                        = new Timer(133337);
     m_timer.Elapsed               += new ElapsedEventHandler(OnTimer);
     m_timer.Start();
     m_chatWnd = null;
     InitializeComponent();
     try
     {
         m_config.Initialize();
         CCBLogConfig.InitLogging(m_config);
         tbStatus.Text = System.String.Format("{0} [v{1}]", m_config.DocPath, System.Environment.Version.ToString());
     }
     catch (System.Reflection.TargetInvocationException ex)
     {
         System.Diagnostics.Debug.WriteLine("Error caught in Main.");
         System.Diagnostics.Debug.WriteLine(ex.ToString());
     }
     m_worker.ProgressChanged    += new ProgressChangedEventHandler(Worker_OnProgressChanged);
     m_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Worker_OnPersistenceCompleted);
     m_loaderD        = new DoWorkEventHandler(Worker_Load);
     m_worker.DoWork += m_loaderD;
     m_worker.RunWorkerAsync(m_config);
     SetDefaultView();
     AddOrMoveAdder();
 }
Exemplo n.º 5
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);
        }