Beispiel #1
0
        public void Execute(AggregateStore store, string LookupValue, string Shard)
        {
            using (SqlConnection conn = new SqlConnection(NoSQLServerConnectionString.Value))
            using (SqlCommand command = conn.CreateCommand())
            {
                command.Connection.Open();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = string.Format(Constants.STORED_PROC_STRING, Shard, this.GetType().Name);

                SqlParameter pData = new SqlParameter(Constants.PARAM_DATA, SqlDbType.VarBinary, int.MaxValue);
                SqlParameter pAggregateID = new SqlParameter(Constants.PARAM_AGGREGATE_ID, SqlDbType.BigInt);
                SqlParameter pLookupValue = new SqlParameter(Constants.PARAM_LOOKUP_VALUE, SqlDbType.VarChar, 36);
                pAggregateID.Value = 0;
                pData.Value = "";
                pLookupValue.Value = "";

                command.Parameters.Add(pLookupValue);
                command.Parameters.Add(pAggregateID);
                command.Parameters.Add(pData);
                command.Parameters[Constants.PARAM_AGGREGATE_ID].Value = store.AggregateID;
                command.Parameters[Constants.PARAM_DATA].Value = store.Data;
                command.Parameters[Constants.PARAM_LOOKUP_VALUE].Value = LookupValue;
                command.ExecuteNonQuery();
            }
        }
        public void Execute(AggregateStore aggregate, string ColumnNames, string DataValues, string Shard)
        {
            using (SqlConnection conn = new SqlConnection(NoSQLServerConnectionString.Value))
            using (SqlCommand command = conn.CreateCommand())
            {
                command.Connection.Open();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = string.Format(Constants.STORED_PROC_STRING, Shard, this.GetType().Name);

                SqlParameter pAggregateTypeID = new SqlParameter(Constants.PARAM_AGGREGATE_TYPE_ID, SqlDbType.BigInt);
                SqlParameter pDataValues = new SqlParameter(Constants.PARAM_DATA_VALUES, SqlDbType.VarChar, 40);
                SqlParameter pAggregateID = new SqlParameter(Constants.PARAM_AGGREGATE_ID, SqlDbType.BigInt);
                SqlParameter pColumnNames = new SqlParameter(Constants.PARAM_COLUMN_NAMES, SqlDbType.VarChar, 40);

                command.Parameters.Add(pAggregateID);
                command.Parameters.Add(pAggregateTypeID);
                command.Parameters.Add(pDataValues);
                command.Parameters.Add(pColumnNames);
                command.Prepare();

                command.Parameters[Constants.PARAM_AGGREGATE_TYPE_ID].Value = aggregate.AggregateTypeID;
                command.Parameters[Constants.PARAM_AGGREGATE_ID].Value = aggregate.AggregateID;
                command.Parameters[Constants.PARAM_COLUMN_NAMES].Value = ColumnNames;
                command.Parameters[Constants.PARAM_DATA_VALUES].Value = DataValues;
                command.ExecuteNonQuery();
            }
        }
        public void Execute(AggregateStore aggregate, string Shard)
        {
            using (SqlConnection conn = new SqlConnection(NoSQLServerConnectionString.Value))
            using (SqlCommand command = conn.CreateCommand())
            {

                command.Connection.Open();

                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = string.Format(Constants.STORED_PROC_STRING, Shard, this.GetType().Name);

                SqlParameter AggregateTypeID = new SqlParameter(Constants.PARAM_AGGREGATE_TYPE_ID, SqlDbType.BigInt);
                SqlParameter AggregateID = new SqlParameter(Constants.PARAM_AGGREGATE_ID, SqlDbType.BigInt);

                AggregateTypeID.Value = 0;
                AggregateTypeID.Value = 0;

                command.Parameters.Add(AggregateID);
                command.Parameters.Add(AggregateTypeID);

                command.Parameters[Constants.PARAM_AGGREGATE_ID].Value = aggregate.AggregateID;
                command.Parameters[Constants.PARAM_AGGREGATE_TYPE_ID].Value = aggregate.AggregateTypeID;
                command.ExecuteNonQuery();

            }
        }
Beispiel #4
0
 public AggregateInfo(AggregateStore store)
 {
     using (SqlConnection conn = new SqlConnection(NoSQLServerConnectionString.Value))
     {
         conn.Open();
         using (SqlCommand cmd = conn.CreateCommand())
         {
             cmd.CommandText = string.Format(fetch, AggregateTypeID);
             this.AggregateID = store.AggregateID;
             this.AggregateTypeID = store.AggregateTypeID;
             this.VersionNumber = store.VersionNumber;
             this.LookupValue = store.LookupValue;
         }
        }
 }
Beispiel #5
0
        public long Execute(AggregateStore aggregate, string Shard)
        {
            long ID = 0;

            using (SqlConnection connection = new SqlConnection(NoSQLServerConnectionString.Value))
            {
                connection.Open();
                using (SqlCommand command = connection.CreateCommand())
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = string.Format(Constants.STORED_PROC_STRING, Shard, this.GetType().Name);

                    SqlParameter AggregateTypeID = new SqlParameter(Constants.PARAM_AGGREGATE_TYPE_ID, SqlDbType.BigInt);
                    SqlParameter Data = new SqlParameter(Constants.PARAM_DATA, SqlDbType.VarBinary, int.MaxValue);
                    SqlParameter AggregateID = new SqlParameter(Constants.PARAM_AGGREGATE_ID, SqlDbType.BigInt);
                    SqlParameter LookupValue = new SqlParameter(Constants.PARAM_LOOKUP_VALUE, SqlDbType.VarChar, 36);
                    AggregateID.Direction = ParameterDirection.Output;

                    AggregateTypeID.Value = 0;
                    Data.Value = "";

                    command.Parameters.Add(AggregateID);
                    command.Parameters.Add(AggregateTypeID);
                    command.Parameters.Add(LookupValue);
                    command.Parameters.Add(Data);
                    command.Prepare();

                    command.Parameters[Constants.PARAM_AGGREGATE_TYPE_ID].Value = aggregate.AggregateTypeID;
                    command.Parameters[Constants.PARAM_DATA].Value = aggregate.Data;
                    command.Parameters[Constants.PARAM_LOOKUP_VALUE].Value = aggregate.LookupValue;

                    command.ExecuteNonQuery();

                    ID = (long)command.Parameters[Constants.PARAM_AGGREGATE_ID].Value;
                }
            }
            return ID;
        }
Beispiel #6
0
 public QueueWriter(AggregateBase aggregate, AggregateStore store, string Shard)
 {
     this.aggregate = aggregate;
     this.store = store;
     this.Shard = Shard;
 }
Beispiel #7
0
 private void Update(AggregateBase aggregate, AggregateStore store, string Shard)
 {
     try
     {
         writeRepo.GetUpdateAggregate().Execute(store, aggregate.GetUniqueKey(), Shard);
     }
     catch (Exception e)
     {
         throw new Exception("Failed in 'Update'", e);
     }
 }
Beispiel #8
0
 private void RebuildIndexes(AggregateBase aggregate, AggregateStore store, string Shard)
 {
     try
     {
         Dictionary<string, string> indexes = aggregate.GetIndexes();
         foreach (string key in indexes.Keys)
         {
             writeRepo.GetInsertAggregateIndex().Execute(store, key, indexes[key], Shard);
         }
     }
     catch (Exception e)
     {
         throw new Exception("Failed in 'RebuildIndexes'", e);
     }
 }
Beispiel #9
0
 private void ProcessCascadingUpdates(AggregateBase aggregate, AggregateStore store, string Shard)
 {
     //
     QueueWriter queueWriter = new QueueWriter(aggregate, store, Shard);
     queueWriter.Send();
     Thread t = new Thread(queueWriter.Send);
     t.Start();
 }
Beispiel #10
0
 private void DeleteIndexes(AggregateStore store, string Shard)
 {
     try
     {
         writeRepo.GetDeleteAggregateIndexes().Execute(store, Shard);
     }
     catch (Exception e)
     {
         throw new Exception("Failed in 'DeleteIndexes'", e);
     }
 }
Beispiel #11
0
 private long Add(AggregateStore store, string Shard)
 {
     try
     {
         return writeRepo.GetInsertAggregate().Execute(store, Shard);
     }
     catch (Exception e)
     {
         throw new Exception("Failed in 'Add'", e);
     }
 }
Beispiel #12
0
 public AggregateStore ToAggregateStore()
 {
     AggregateStore obj = new AggregateStore();
     obj.AggregateTypeID = AggregateTypeID;
     obj.AggregateID = AggregateID;
     BinaryFormatter formatter = new BinaryFormatter();
     using (MemoryStream stream = new MemoryStream())
     {
         formatter.Serialize(stream, this);
         obj.Data = stream.ToArray();
     }
     obj.LookupValue = GetUniqueKey();
     return obj;
 }