Exemple #1
0
 /// <summary>Updates a Object record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Update(ParameterList parameters)
 {
     // Accessor for the Object Table.
     ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     object name = parameters["name"].Value;
     string externalObjectId = ((string)(parameters["objectId"]));
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int objectId = Object.FindRequiredKey(configurationId, "objectId", externalObjectId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     // While the optimistic concurrency checking is disabled for the external methods, the internal methods
     // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
     // will bypass the coused when the internal method is called.
     ServerMarketData.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
     rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Object.Update(adoTransaction, sqlTransaction, ref rowVersion, description, null, null, null, null, null, null, null, null, groupPermission, hidden, name, objectId, owner, ownerPermission, readOnly, typeCode, worldPermission);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #2
0
 /// <summary>Archives a Object record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Archive(ParameterList parameters)
 {
     // Accessor for the Object Table.
     ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalObjectId = parameters["objectId"];
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Find the internal identifier using the primar key elements.
     // identifier is used to determine if a record exists with the same key.
     int objectId = Object.FindRequiredKey(configurationId, "objectId", externalObjectId);
     // While the optimistic concurrency checking is disabled for the external methods, the internal methods
     // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
     // will bypass the coused when the internal method is called.
     ServerMarketData.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
     rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Object.Archive(adoTransaction, sqlTransaction, rowVersion, objectId);
 }
Exemple #3
0
        /// <summary>Archives a Object record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="RowVersion">The version number of this row.</param>
        /// <param name="objectId">The value for the ObjectId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int objectId)
        {
            // Accessor for the Object Table.
            ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
            if ((objectRow == null))
            {
                throw new Exception(string.Format("The Object table does not have an element identified by {0}", objectId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((objectRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < objectRow.GetAccountBaseRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountBaseRow childAccountBaseRow = objectRow.GetAccountBaseRows()[index];
                AccountBase.ArchiveChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId);
            }
            for (int index = 0; (index < objectRow.GetBlotterRows().Length); index = (index + 1))
            {
                ServerMarketData.BlotterRow childBlotterRow = objectRow.GetBlotterRows()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < objectRow.GetFolderRows().Length); index = (index + 1))
            {
                ServerMarketData.FolderRow childFolderRow = objectRow.GetFolderRows()[index];
                Folder.ArchiveChildren(adoTransaction, sqlTransaction, childFolderRow.RowVersion, childFolderRow.FolderId);
            }
            for (int index = 0; (index < objectRow.GetIssuerRows().Length); index = (index + 1))
            {
                ServerMarketData.IssuerRow childIssuerRow = objectRow.GetIssuerRows()[index];
                Issuer.ArchiveChildren(adoTransaction, sqlTransaction, childIssuerRow.RowVersion, childIssuerRow.IssuerId);
            }
            for (int index = 0; (index < objectRow.GetObjectTreeRowsByObjectObjectTreeChildId().Length); index = (index + 1))
            {
                ServerMarketData.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByObjectObjectTreeChildId()[index];
                ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ObjectTreeId);
            }
            for (int index = 0; (index < objectRow.GetObjectTreeRowsByObjectObjectTreeParentId().Length); index = (index + 1))
            {
                ServerMarketData.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByObjectObjectTreeParentId()[index];
                ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ObjectTreeId);
            }
            for (int index = 0; (index < objectRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerMarketData.SecurityRow childSecurityRow = objectRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            for (int index = 0; (index < objectRow.GetUserRows().Length); index = (index + 1))
            {
                ServerMarketData.UserRow childUserRow = objectRow.GetUserRows()[index];
                User.ArchiveChildren(adoTransaction, sqlTransaction, childUserRow.RowVersion, childUserRow.UserId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            objectRow[objectTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(objectRow);
            objectRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Object\" set \"IsArchived\" = 1 where \"ObjectId\"=@objectId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@objectId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, objectId));
            sqlCommand.ExecuteNonQuery();
        }
Exemple #4
0
 /// <summary>Loads a Object record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Load(ParameterList parameters)
 {
     // Accessor for the Object Table.
     ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object description = parameters["description"].Value;
     object externalId0 = parameters["externalId0"].Value;
     object externalId1 = parameters["externalId1"].Value;
     object externalId2 = parameters["externalId2"].Value;
     object externalId3 = parameters["externalId3"].Value;
     object externalId4 = parameters["externalId4"].Value;
     object externalId5 = parameters["externalId5"].Value;
     object externalId6 = parameters["externalId6"].Value;
     object externalId7 = parameters["externalId7"].Value;
     object groupPermission = parameters["groupPermission"].Value;
     object hidden = parameters["hidden"].Value;
     string name = parameters["name"];
     object externalObjectId = parameters["objectId"].Value;
     object owner = parameters["owner"].Value;
     object ownerPermission = parameters["ownerPermission"].Value;
     object readOnly = parameters["readOnly"].Value;
     object externalTypeCode = parameters["typeCode"].Value;
     object worldPermission = parameters["worldPermission"].Value;
     // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
     // event it's needed for operations within the batch.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     int objectId = Object.FindKey(configurationId, "objectId", externalObjectId);
     object typeCode = Type.FindOptionalKey(configurationId, "typeCode", externalTypeCode);
     // The load operation will create a record if it doesn't exist, or update an existing record.  The external
     // identifier is used to determine if a record exists with the same key.
     if ((objectId == int.MinValue))
     {
         // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
         // external method is called with the same 'configurationId' parameter.
         int externalKeyIndex = Object.GetExternalKeyIndex(configurationId, "objectId");
         object[] externalIdArray = new object[8];
         externalIdArray[externalKeyIndex] = externalObjectId;
         externalId0 = externalIdArray[0];
         externalId1 = externalIdArray[1];
         externalId2 = externalIdArray[2];
         externalId3 = externalIdArray[3];
         externalId4 = externalIdArray[4];
         externalId5 = externalIdArray[5];
         externalId6 = externalIdArray[6];
         externalId7 = externalIdArray[7];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Object.Insert(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, owner, ownerPermission, readOnly, typeCode, worldPermission);
     }
     else
     {
         // While the optimistic concurrency checking is disabled for the external methods, the internal methods
         // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
         // will bypass the coused when the internal method is called.
         ServerMarketData.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
         rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.Object.Update(adoTransaction, sqlTransaction, ref rowVersion, description, externalId0, externalId1, externalId2, externalId3, externalId4, externalId5, externalId6, externalId7, groupPermission, hidden, name, objectId, owner, ownerPermission, readOnly, typeCode, worldPermission);
     }
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Exemple #5
0
        /// <summary>Updates a Object record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="rowVersion">The version number of the row</param>
        /// <param name="description">The value for the Description column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="externalId1">The value for the ExternalId1 column.</param>
        /// <param name="externalId2">The value for the ExternalId2 column.</param>
        /// <param name="externalId3">The value for the ExternalId3 column.</param>
        /// <param name="externalId4">The value for the ExternalId4 column.</param>
        /// <param name="externalId5">The value for the ExternalId5 column.</param>
        /// <param name="externalId6">The value for the ExternalId6 column.</param>
        /// <param name="externalId7">The value for the ExternalId7 column.</param>
        /// <param name="groupPermission">The value for the GroupPermission column.</param>
        /// <param name="hidden">The value for the Hidden column.</param>
        /// <param name="name">The value for the Name column.</param>
        /// <param name="objectId">The value for the ObjectId column.</param>
        /// <param name="owner">The value for the Owner column.</param>
        /// <param name="ownerPermission">The value for the OwnerPermission column.</param>
        /// <param name="readOnly">The value for the ReadOnly column.</param>
        /// <param name="typeCode">The value for the TypeCode column.</param>
        /// <param name="worldPermission">The value for the WorldPermission column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object description,
            object externalId0,
            object externalId1,
            object externalId2,
            object externalId3,
            object externalId4,
            object externalId5,
            object externalId6,
            object externalId7,
            object groupPermission,
            object hidden,
            object name,
            int objectId,
            object owner,
            object ownerPermission,
            object readOnly,
            object typeCode,
            object worldPermission)
        {
            // Accessor for the Object Table.
            ServerMarketData.ObjectDataTable objectTable = ServerMarketData.Object;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
            if ((objectRow == null))
            {
                throw new Exception(string.Format("The Object table does not have an element identified by {0}", objectId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((objectRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((description == null))
            {
                description = objectRow[objectTable.DescriptionColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = objectRow[objectTable.ExternalId0Column];
            }
            if ((externalId1 == null))
            {
                externalId1 = objectRow[objectTable.ExternalId1Column];
            }
            if ((externalId2 == null))
            {
                externalId2 = objectRow[objectTable.ExternalId2Column];
            }
            if ((externalId3 == null))
            {
                externalId3 = objectRow[objectTable.ExternalId3Column];
            }
            if ((externalId4 == null))
            {
                externalId4 = objectRow[objectTable.ExternalId4Column];
            }
            if ((externalId5 == null))
            {
                externalId5 = objectRow[objectTable.ExternalId5Column];
            }
            if ((externalId6 == null))
            {
                externalId6 = objectRow[objectTable.ExternalId6Column];
            }
            if ((externalId7 == null))
            {
                externalId7 = objectRow[objectTable.ExternalId7Column];
            }
            if ((groupPermission == null))
            {
                groupPermission = objectRow[objectTable.GroupPermissionColumn];
            }
            if ((hidden == null))
            {
                hidden = objectRow[objectTable.HiddenColumn];
            }
            if ((name == null))
            {
                name = objectRow[objectTable.NameColumn];
            }
            if ((owner == null))
            {
                owner = objectRow[objectTable.OwnerColumn];
            }
            if ((ownerPermission == null))
            {
                ownerPermission = objectRow[objectTable.OwnerPermissionColumn];
            }
            if ((readOnly == null))
            {
                readOnly = objectRow[objectTable.ReadOnlyColumn];
            }
            if ((typeCode == null))
            {
                typeCode = objectRow[objectTable.TypeCodeColumn];
            }
            if ((worldPermission == null))
            {
                worldPermission = objectRow[objectTable.WorldPermissionColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            objectRow[objectTable.RowVersionColumn]      = rowVersion;
            objectRow[objectTable.DescriptionColumn]     = description;
            objectRow[objectTable.ExternalId0Column]     = externalId0;
            objectRow[objectTable.ExternalId1Column]     = externalId1;
            objectRow[objectTable.ExternalId2Column]     = externalId2;
            objectRow[objectTable.ExternalId3Column]     = externalId3;
            objectRow[objectTable.ExternalId4Column]     = externalId4;
            objectRow[objectTable.ExternalId5Column]     = externalId5;
            objectRow[objectTable.ExternalId6Column]     = externalId6;
            objectRow[objectTable.ExternalId7Column]     = externalId7;
            objectRow[objectTable.GroupPermissionColumn] = groupPermission;
            objectRow[objectTable.HiddenColumn]          = hidden;
            objectRow[objectTable.NameColumn]            = name;
            objectRow[objectTable.OwnerColumn]           = owner;
            objectRow[objectTable.OwnerPermissionColumn] = ownerPermission;
            objectRow[objectTable.ReadOnlyColumn]        = readOnly;
            objectRow[objectTable.TypeCodeColumn]        = typeCode;
            objectRow[objectTable.WorldPermissionColumn] = worldPermission;
            adoTransaction.DataRows.Add(objectRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Object"" set ""RowVersion""=@rowVersion,""Description""=@description,""ExternalId0""=@externalId0,""ExternalId1""=@externalId1,""ExternalId2""=@externalId2,""ExternalId3""=@externalId3,""ExternalId4""=@externalId4,""ExternalId5""=@externalId5,""ExternalId6""=@externalId6,""ExternalId7""=@externalId7,""GroupPermission""=@groupPermission,""Hidden""=@hidden,""Name""=@name,""Owner""=@owner,""OwnerPermission""=@ownerPermission,""ReadOnly""=@readOnly,""TypeCode""=@typeCode,""WorldPermission""=@worldPermission where ""ObjectId""=@objectId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@description", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, description));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId1", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId1));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId2", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId2));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId3", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId3));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId4", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId4));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId5", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId5));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId6", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId6));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId7", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId7));
            sqlCommand.Parameters.Add(new SqlParameter("@groupPermission", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, groupPermission));
            sqlCommand.Parameters.Add(new SqlParameter("@hidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, hidden));
            sqlCommand.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, name));
            sqlCommand.Parameters.Add(new SqlParameter("@objectId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, objectId));
            sqlCommand.Parameters.Add(new SqlParameter("@owner", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, owner));
            sqlCommand.Parameters.Add(new SqlParameter("@ownerPermission", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, ownerPermission));
            sqlCommand.Parameters.Add(new SqlParameter("@readOnly", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, readOnly));
            sqlCommand.Parameters.Add(new SqlParameter("@typeCode", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, typeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@worldPermission", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, worldPermission));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }