Пример #1
0
        /// <summary>
        /// Compares the Process Id against the RowForm's Participant Id. If they are the same, it means this row should be saved to this FrostDb Process.
        /// </summary>
        /// <param name="row">The rowForm to validate</param>
        /// <param name="process">The FrostDb Process</param>
        /// <returns>True if the row participant and the FrostDb process are the same, otherwise false</returns>
        public static bool IsLocal(this RowForm2 row, Process process)
        {
            if (row == null)
            {
                throw new ArgumentNullException(nameof(row));
            }

            if (row.Participant == null)
            {
                throw new InvalidOperationException("Participant is null");
            }

            return(row.Participant.Id == process.Id);
        }
Пример #2
0
        /// <summary>
        /// Adds a row to this FrostDb instance
        /// </summary>
        /// <param name="rowForm">The row data to add</param>
        /// <returns>True if successful, otherwise false</returns>
        private bool AddRowLocally(RowForm2 rowForm)
        {
            RowInsert rowToInsert = new RowInsert(rowForm.Values, this.Schema, rowForm.Participant.Id, !rowForm.IsLocal(_process), rowForm.Address);

            if (_storage.RecordTransactionInLog(rowToInsert))
            {
                if (_cache.InsertRow(rowToInsert))
                {
                    if (_storage.UpdateIndexes(rowToInsert))
                    {
                        _cache.SyncTreeToDisk(rowToInsert.Address);
                        _storage.MarkTransactionAsReconciledInLog(rowToInsert);
                    }
                }
            }

            //throw new NotImplementedException();
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Adds a row to the table based on the information in the passed in form.
        /// </summary>
        /// <param name="rowForm">A row form.</param>
        /// <returns></returns>
        public bool AddRow(RowForm2 rowForm)
        {
            bool isSuccessful;

            if (rowForm is null)
            {
                throw new ArgumentNullException(nameof(rowForm));
            }

            if (rowForm.IsLocal(_process))
            {
                isSuccessful = AddRowLocally(rowForm);
            }
            else
            {
                isSuccessful = AddRowRemotely(rowForm);
            }

            return(isSuccessful);
        }
Пример #4
0
 /// <summary>
 /// Adds a row to a remote FrostDb instance
 /// </summary>
 /// <param name="rowForm">The row data to add</param>
 /// <returns>True if successful, otherwise false</returns>
 private bool AddRowRemotely(RowForm2 rowForm)
 {
     throw new NotImplementedException();
 }