/// <summary>
        /// Takes a GIS model and a file and writes the model to that file.
        /// </summary>
        /// <param name="model">
        /// The GisModel which is to be persisted.
        /// </param>
        /// <param name="fileName">
        /// The name of the file in which the model is to be persisted.
        /// </param>
        public void Persist(GisModel model, string fileName)
        {
            Initialize(model);
            PatternedPredicate[] predicates = GetPredicates();

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            using (mDataConnection = new SqliteConnection("Data Source=" + fileName + ";New=True;Compress=False;Synchronous=Off;UTF8Encoding=True;Version=3"))
            {
                mDataConnection.Open();
                mDataCommand = mDataConnection.CreateCommand();
                CreateDataStructures();

                using (mDataTransaction = mDataConnection.BeginTransaction())
                {
                    mDataCommand.Transaction = mDataTransaction;

                    CreateModel(model.CorrectionConstant, model.CorrectionParameter);
                    InsertOutcomes(model.GetOutcomeNames());
                    InsertPredicates(predicates);
                    InsertPredicateParameters(model.GetOutcomePatterns(), predicates);

                    mDataTransaction.Commit();
                }
                mDataConnection.Close();
            }
        }
        /// <summary>
        /// Takes a GIS model and a file and writes the model to that file.
        /// </summary>
        /// <param name="model">
        /// The GisModel which is to be persisted.
        /// </param>
        /// <param name="fileName">
        /// The name of the file in which the model is to be persisted.
        /// </param>
        public void Persist(GisModel model, string fileName)
        {
            Initialize(model);
            PatternedPredicate[] predicates = GetPredicates();

            if (	File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            using (mDataConnection = new SQLiteConnection("Data Source=" + fileName + ";New=True;Compress=False;Synchronous=Off;UTF8Encoding=True;Version=3"))
            {
                mDataConnection.Open();
                mDataCommand = mDataConnection.CreateCommand();
                CreateDataStructures();

                using (mDataTransaction = mDataConnection.BeginTransaction())
                {
                    mDataCommand.Transaction = mDataTransaction;

                    CreateModel(model.CorrectionConstant, model.CorrectionParameter);
                    InsertOutcomes(model.GetOutcomeNames());
                    InsertPredicates(predicates);
                    InsertPredicateParameters(model.GetOutcomePatterns(), predicates);

                    mDataTransaction.Commit();
                }
                mDataConnection.Close();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Writes the model to persistent storage, using the <code>writeX()</code> methods
 /// provided by extending classes.
 ///
 /// <p>This method delegates to worker methods for each part of this
 /// sequence.  If you are creating a writer that conforms largely to this
 /// sequence but varies at one or more points, override the relevant worker
 /// method(s) to achieve the required format.</p>
 ///
 /// <p>If you are creating a writer for a format which does not follow this
 /// sequence at all, override this method and ignore the
 /// other WriteX methods provided in this abstract class.</p>
 /// </summary>
 /// <param name="model">
 /// GIS model whose data is to be persisted.
 /// </param>
 protected void Persist(GisModel model)
 {
     Initialize(model);
     WriteModelType("GIS");
     WriteCorrectionConstant(model.CorrectionConstant);
     WriteCorrectionParameter(model.CorrectionParameter);
     WriteOutcomes(model.GetOutcomeNames());
     WritePredicates(model);
 }