コード例 #1
0
        ///////////////////////////////////////////////////
        //save memory quotations to database
        ///////////////////////////////////////////////////
        public bool SaveMemoryToDatabase()
        {
            try
            {
                //AppDebug.LogEvent("QuotationServer", string.Format("begin QuotationFileCache.SaveMemoryToDatabase, Queue.Count={0}", this._Queue.Count), EventLogEntryType.Information);
                lock (this._QueueLock)
                {
                    while (this._Queue.Count > 0)
                    {
                        MemoryBatch memoryBatch = this._Queue.Peek();
                        DatabaseBatch databaseBatch = new DatabaseBatch(memoryBatch);

                        if (this.SaveDatabaseBatch(databaseBatch))
                        {
                            databaseBatch.Clear();
                            this._Queue.Dequeue();
                        }

                        if (this._Queue.Count == 0 && this._ActiveMemoryBatch != null)
                        {
                            this._ActiveMemoryBatch = null;
                        }
                    }
                }
                //AppDebug.LogEvent("QuotationServer", string.Format("end QuotationFileCache.SaveMemoryToDatabase, Queue.Count={0}", this._Queue.Count), EventLogEntryType.Information);
                return true;
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("QuotationServer", string.Format("QuotationFileCache.SaveMemoryToDatabase error: {0}", exception), EventLogEntryType.Error);
                return false;
            }
        }