コード例 #1
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
 /// <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.
     ServerDataModel.ObjectDataTable objectTable = ServerDataModel.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.
     ServerDataModel.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
     rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.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;
 }
コード例 #2
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
 /// <summary>Initializes the static elements of an Object.</summary>
 static Object()
 {
     // The table must be locked before the indices can be read into an accelerator array.
     ServerDataModel.ObjectLock.AcquireReaderLock(System.Threading.Timeout.Infinite);
     // Accessor for the Object Table.
     ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
     // This does an indirect lookup operation using the views created for the ExternalId columns.  Take the index of the user
     // identifier column calcualted above and use it to find a record containing the external identifier.
     Object.externalKeyArray = new DataView[] {
             objectTable.UKObjectExternalId0,
             objectTable.UKObjectExternalId1,
             objectTable.UKObjectExternalId2,
             objectTable.UKObjectExternalId3,
             objectTable.UKObjectExternalId4,
             objectTable.UKObjectExternalId5,
             objectTable.UKObjectExternalId6,
             objectTable.UKObjectExternalId7};
     // The table must be released after the array is constructed.
     ServerDataModel.ObjectLock.ReleaseReaderLock();
 }
コード例 #3
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
 /// <summary>Finds a a Object record using a configuration and an external identifier.</summary>
 /// <param name="configurationId">Specified which mappings (user id columns) to use when looking up external identifiers.</param>
 /// <param name="parameterId">The name of the parameter as specified in the configuration table.</param>
 /// <param name="externalId">The external (user supplied) identifier for the record.</param>
 public static int FindKey(object configurationId, string parameterId, object externalId)
 {
     // A missing key will never match a column.
     if ((externalId == null))
     {
         return int.MinValue;
     }
     // Accessor for the Object Table.
     ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
     // Look for the record using the external identifier.  The configuration selected the key to use, which effectively
     // selected the external id column to use for the search.  If a record is found in the view, a translation still needs
     // to be made back to the original table before an index to the record can be returned to the caller.
     int externalKeyIndex = Object.GetExternalKeyIndex(configurationId, parameterId);
     System.Data.DataView externalKeyView = Object.externalKeyArray[externalKeyIndex];
     int recordIndex = externalKeyView.Find(new object[] {
                 externalId});
     if ((recordIndex == -1))
     {
         return int.MinValue;
     }
     return ((int)(externalKeyView[recordIndex].Row[objectTable.ObjectIdColumn]));
 }
コード例 #4
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
 /// <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.
     ServerDataModel.ObjectDataTable objectTable = ServerDataModel.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.
     ServerDataModel.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
     rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Quasar.Core.Object.Archive(adoTransaction, sqlTransaction, rowVersion, objectId);
 }
コード例 #5
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
        /// <summary>Inserts a Object record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</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="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 int Insert(
            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,
            string name,
            object owner,
            object ownerPermission,
            object readOnly,
            object typeCode,
            object worldPermission)
        {
            // Accessor for the Object Table.
            ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
            // Apply Defaults
            if ((description == null))
            {
                description = System.DBNull.Value;
            }
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            if ((externalId1 == null))
            {
                externalId1 = System.DBNull.Value;
            }
            if ((externalId2 == null))
            {
                externalId2 = System.DBNull.Value;
            }
            if ((externalId3 == null))
            {
                externalId3 = System.DBNull.Value;
            }
            if ((externalId4 == null))
            {
                externalId4 = System.DBNull.Value;
            }
            if ((externalId5 == null))
            {
                externalId5 = System.DBNull.Value;
            }
            if ((externalId6 == null))
            {
                externalId6 = System.DBNull.Value;
            }
            if ((externalId7 == null))
            {
                externalId7 = System.DBNull.Value;
            }
            if ((groupPermission == null))
            {
                groupPermission = 0;
            }
            if ((hidden == null))
            {
                hidden = false;
            }
            if ((owner == null))
            {
                owner = 0;
            }
            if ((ownerPermission == null))
            {
                ownerPermission = 0;
            }
            if ((readOnly == null))
            {
                readOnly = false;
            }
            if ((typeCode == null))
            {
                typeCode = "Object";
            }
            if ((worldPermission == null))
            {
                worldPermission = 0;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.ObjectRow objectRow = objectTable.NewObjectRow();
            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;
            objectTable.AddObjectRow(objectRow);
            adoTransaction.DataRows.Add(objectRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Object"" (""rowVersion"",""Description"",""ExternalId0"",""ExternalId1"",""ExternalId2"",""ExternalId3"",""ExternalId4"",""ExternalId5"",""ExternalId6"",""ExternalId7"",""GroupPermission"",""Hidden"",""Name"",""ObjectId"",""Owner"",""OwnerPermission"",""ReadOnly"",""TypeCode"",""WorldPermission"") values (@rowVersion,@description,@externalId0,@externalId1,@externalId2,@externalId3,@externalId4,@externalId5,@externalId6,@externalId7,@groupPermission,@hidden,@name,@objectId,@owner,@ownerPermission,@readOnly,@typeCode,@worldPermission)");

            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, objectRow[objectTable.ObjectIdColumn]));
            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));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(objectRow.ObjectId);
        }
コード例 #6
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
        /// <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.
            ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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.GetFolderRows().Length); index = (index + 1))
            {
                ServerDataModel.FolderRow childFolderRow = objectRow.GetFolderRows()[index];
                Folder.ArchiveChildren(adoTransaction, sqlTransaction, childFolderRow.RowVersion, childFolderRow.FolderId);
            }
            for (int index = 0; (index < objectRow.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = objectRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < objectRow.GetBlotterRows().Length); index = (index + 1))
            {
                ServerDataModel.BlotterRow childBlotterRow = objectRow.GetBlotterRows()[index];
                Blotter.ArchiveChildren(adoTransaction, sqlTransaction, childBlotterRow.RowVersion, childBlotterRow.BlotterId);
            }
            for (int index = 0; (index < objectRow.GetBrokerRows().Length); index = (index + 1))
            {
                ServerDataModel.BrokerRow childBrokerRow = objectRow.GetBrokerRows()[index];
                Broker.ArchiveChildren(adoTransaction, sqlTransaction, childBrokerRow.RowVersion, childBrokerRow.BrokerId);
            }
            for (int index = 0; (index < objectRow.GetIssuerRows().Length); index = (index + 1))
            {
                ServerDataModel.IssuerRow childIssuerRow = objectRow.GetIssuerRows()[index];
                Issuer.ArchiveChildren(adoTransaction, sqlTransaction, childIssuerRow.RowVersion, childIssuerRow.IssuerId);
            }
            for (int index = 0; (index < objectRow.GetUserRows().Length); index = (index + 1))
            {
                ServerDataModel.UserRow childUserRow = objectRow.GetUserRows()[index];
                User.ArchiveChildren(adoTransaction, sqlTransaction, childUserRow.RowVersion, childUserRow.UserId);
            }
            for (int index = 0; (index < objectRow.GetModelRows().Length); index = (index + 1))
            {
                ServerDataModel.ModelRow childModelRow = objectRow.GetModelRows()[index];
                Model.ArchiveChildren(adoTransaction, sqlTransaction, childModelRow.RowVersion, childModelRow.ModelId);
            }
            for (int index = 0; (index < objectRow.GetObjectTreeRowsByFKObjectObjectTreeChildId().Length); index = (index + 1))
            {
                ServerDataModel.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByFKObjectObjectTreeChildId()[index];
                ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ParentId, childObjectTreeRow.ChildId);
            }
            for (int index = 0; (index < objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId().Length); index = (index + 1))
            {
                ServerDataModel.ObjectTreeRow childObjectTreeRow = objectRow.GetObjectTreeRowsByFKObjectObjectTreeParentId()[index];
                ObjectTree.Archive(adoTransaction, sqlTransaction, childObjectTreeRow.RowVersion, childObjectTreeRow.ParentId, childObjectTreeRow.ChildId);
            }
            for (int index = 0; (index < objectRow.GetSchemeRows().Length); index = (index + 1))
            {
                ServerDataModel.SchemeRow childSchemeRow = objectRow.GetSchemeRows()[index];
                Scheme.ArchiveChildren(adoTransaction, sqlTransaction, childSchemeRow.RowVersion, childSchemeRow.SchemeId);
            }
            for (int index = 0; (index < objectRow.GetSectorRows().Length); index = (index + 1))
            {
                ServerDataModel.SectorRow childSectorRow = objectRow.GetSectorRows()[index];
                Sector.ArchiveChildren(adoTransaction, sqlTransaction, childSectorRow.RowVersion, childSectorRow.SectorId);
            }
            for (int index = 0; (index < objectRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerDataModel.SecurityRow childSecurityRow = objectRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.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();
        }
コード例 #7
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
        /// <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.
            ServerDataModel.ObjectDataTable objectTable = ServerDataModel.Object;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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 = ServerDataModel.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();
        }
コード例 #8
0
ファイル: Object.cs プロジェクト: DonaldAirey/quasar
 /// <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.
     ServerDataModel.ObjectDataTable objectTable = ServerDataModel.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.Quasar.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.
         ServerDataModel.ObjectRow objectRow = objectTable.FindByObjectId(objectId);
         rowVersion = ((long)(objectRow[objectTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Quasar.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;
 }