/// <summary>
        /// Generates a property that gets the lock for the data model.
        /// </summary>
        public TenantTargetProperty(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Gets the current transaction.
            //		/// </summary>
            //		[global::System.ComponentModel.BrowsableAttribute(false)]
            //		public static TenantDataModel TenantDataModel
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Gets the tenant's data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Type       = new CodeTypeReference(String.Format("Tenant{0}", dataModelSchema.Name));
            this.Name       = String.Format("Tenant{0}", dataModelSchema.Name);

            //			get
            //			{
            //				global::Teraque.OrganizationPrincipal e8116 = ((Teraque.OrganizationPrincipal)(global::System.Threading.Thread.CurrentPrincipal));
            //				return DataModel.tenantMap[e8116.Tenant];
            CodeVariableReferenceExpression organizationPrincipal = new CodeRandomVariableReferenceExpression();

            this.GetStatements.Add(new CodeOrganizationPrincipalExpression(organizationPrincipal));
            CodeVariableReferenceExpression targetDataSet = new CodeRandomVariableReferenceExpression();

            this.GetStatements.Add(
                new CodeMethodReturnStatement(
                    new CodeIndexerExpression(
                        new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "tenantMap"),
                        new CodePropertyReferenceExpression(organizationPrincipal, "Organization"))));

            //			}
            //		}
        }
示例#2
0
 /// <summary>
 /// Creates a field that holds the locks used in a transaction.
 /// </summary>
 public TenantTargetField(DataModelSchema dataModelSchema)
 {
     //				private TenantTarget tenantDataSet;
     this.Attributes = MemberAttributes.Assembly;
     this.Type       = new CodeTypeReference(String.Format("Tenant{0}", dataModelSchema.Name));
     this.Name       = "tenantDataSet";
 }
        /// <summary>
        /// Creates a method to read an XML file.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public ReadXmlMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Reads an XML file into the data model.
            //		/// </summary>
            //		/// <param name="fileName">The name of the file to read.</param>
            //		public static void ReadXml(string fileName)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Reads an XML file into the data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"fileName\">The name of the file to read.</param>", true));
            this.Name       = "ReadXml";
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(String)), "fileName"));

            //			DataModel.dataSet.ReadXml(fileName);
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodePropertyReferenceExpression(
                        new CodeTypeReferenceExpression(dataModelSchema.Name),
                        String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                    "ReadXml",
                    new CodeArgumentReferenceExpression("fileName")));

            //		}
        }
        /// <summary>
        /// Creates a property that gets the collection of relationship between tables in the data model.
        /// </summary>
        /// <param name="dataModelSchema">The data model schema.</param>
        public RelationsProperty(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Gets the collection of relations that link tables and allow navigation between parent tables and child tables.
            //		/// </summary>
            //		[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            //		[global::System.ComponentModel.BrowsableAttribute(false)]
            //		public static global::System.Data.DataRelationCollection Relations
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Gets the collection of relations that link tables and allow navigation between parent tables and child tables.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(DebuggerNonUserCodeAttribute))));
            this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(BrowsableAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(false))));
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Type       = new CodeGlobalTypeReference(typeof(DataRelationCollection));
            this.Name       = "Relations";

            //			get
            //			{
            //				global::Teraque.OrganizationPrincipal n222 = ((Teraque.OrganizationPrincipal)(global::System.Threading.Thread.CurrentPrincipal));
            //				DataModelDataSet q223 = DataModel.tenantMap[n222.Tenant];
            //				return q223.Relations;
            CodeVariableReferenceExpression organizationPrincipal = new CodeRandomVariableReferenceExpression();

            this.GetStatements.Add(new CodeOrganizationPrincipalExpression(organizationPrincipal));
            CodeVariableReferenceExpression targetDataSet = new CodeRandomVariableReferenceExpression();

            this.GetStatements.Add(new CodeTargetDataModelStatement(dataModelSchema, targetDataSet, organizationPrincipal));
            this.GetStatements.Add(new CodeMethodReturnStatement(new CodePropertyReferenceExpression(targetDataSet, "Relations")));

            //			}
            //		}
        }
        /// <summary>
        /// Generates a property that gets the lock for the data model.
        /// </summary>
        public DataLockProperty(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Gets the lock for the data model.
            //		/// </summary>
            //		[global::System.ComponentModel.BrowsableAttribute(false)]
            //		public static global::System.Threading.ReaderWriterLockSlim DataLock
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Gets the lock for the data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Type       = new CodeGlobalTypeReference(typeof(ReaderWriterLockSlim));
            this.Name       = "DataLock";

            //			get
            //			{
            //				global::Teraque.OrganizationPrincipal d220 = ((Teraque.OrganizationPrincipal)(global::System.Threading.Thread.CurrentPrincipal));
            //				DataModelDataSet p221 = DataModel.tenantMap[d220.Tenant];
            //				return p221.dataLock;
            //			}
            CodeVariableReferenceExpression organizationPrincipal = new CodeRandomVariableReferenceExpression();

            this.GetStatements.Add(new CodeOrganizationPrincipalExpression(organizationPrincipal));
            CodeVariableReferenceExpression targetDataSet = new CodeRandomVariableReferenceExpression();

            this.GetStatements.Add(new CodeTargetDataModelStatement(dataModelSchema, targetDataSet, organizationPrincipal));
            this.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(targetDataSet, "dataLock")));

            //		}
        }
 /// <summary>
 /// Creates a property for getting or setting the time a record lock is held.
 /// </summary>
 /// <param name="schema">The description of the data model.</param>
 public LockTimeoutProperty(DataModelSchema dataModelSchema)
 {
     //        /// <summary>
     //        /// Gets or sets the timeout value for locking operations.
     //        /// </summary>
     //        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     //        [global::System.ComponentModel.BrowsableAttribute(false)]
     //        public static global::System.TimeSpan LockTimeout {
     //            get {
     //                return FluidTrade.UnitTest.Server.DataModel.lockTimeout;
     //            }
     //            set {
     //                FluidTrade.UnitTest.Server.DataModel.lockTimeout = value;
     //            }
     //        }
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement("Gets or sets the timeout value for locking operations.", true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
     this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
     this.Type       = new CodeGlobalTypeReference(typeof(System.TimeSpan));
     this.Name       = "LockTimeout";
     this.GetStatements.Add(new CodeMethodReturnStatement(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "lockTimeout")));
     this.SetStatements.Add(new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "lockTimeout"), new CodeVariableReferenceExpression("value")));
 }
示例#7
0
        /// <summary>
        /// Creates a strongly typed DataSet from a schema description.
        /// </summary>
        /// <param name="dataSetNamespace">The CodeDOM namespace Teraque.DataModelGenerator.TargetClientClass contains this strongly typed DataSet.</param>
        public TargetClientClass(DataModelSchema dataModelSchema)
        {
            //	[System.Diagnostics.DebuggerStepThroughAttribute()]
            //	public partial class DataModelClient : System.ServiceModel.ClientBase<IDataModel>, IDataModel
            //	{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement(String.Format("Client interface to a shared {0}.", dataModelSchema.Name), true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.IsPartial      = true;
            this.TypeAttributes = TypeAttributes.Public | TypeAttributes.Class;
            this.Name           = String.Format("{0}Client", dataModelSchema.Name);
            this.BaseTypes.Add(new CodeTypeReference(String.Format("global::System.ServiceModel.ClientBase<I{0}>", dataModelSchema.Name)));
            this.BaseTypes.Add(new CodeTypeReference(String.Format("I{0}", dataModelSchema.Name)));

            // Constructors
            this.Members.Add(new VoidConstructor(dataModelSchema));
            this.Members.Add(new StringConstructor(dataModelSchema));

            // Methods
            List <CodeMemberMethod> methodList = new List <CodeMemberMethod>();

            methodList.Add(new ReadMethod(dataModelSchema));
            foreach (KeyValuePair <string, TableSchema> tablePair in dataModelSchema.Tables)
            {
                methodList.Add(new CreateMethod(tablePair.Value));
                methodList.Add(new UpdateMethod(tablePair.Value));
                methodList.Add(new DestroyMethod(tablePair.Value));
                methodList.Add(new StoreMethod(tablePair.Value));
            }
            methodList.Sort(delegate(CodeMemberMethod firstMethod, CodeMemberMethod secondMethod) { return(firstMethod.Name.CompareTo(secondMethod.Name)); });
            foreach (CodeMemberMethod codeMemberMethod in methodList)
            {
                this.Members.Add(codeMemberMethod);
            }
        }
 /// <summary>
 /// Creates a property that gets the collection of relationship between tables in the data model.
 /// </summary>
 /// <param name="dataModelSchema">The data model schema.</param>
 public RelationsProperty(DataModelSchema dataModelSchema)
 {
     //        /// <summary>
     //        /// Gets the collection of relations that link tables and allow navigation between parent tables and child tables.
     //        /// </summary>
     //        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     //        [global::System.ComponentModel.BrowsableAttribute(false)]
     //        public static global::System.Data.DataRelationCollection Relations {
     //            get {
     //                return FluidTrade.UnitTest.Server.DataModel.dataSet.Relations;
     //            }
     //        }
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement("Gets the collection of relations that link tables and allow navigation between parent tables and child tables.", true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     // HACK - Put this line back in for official releases
     //this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(System.Diagnostics.DebuggerNonUserCodeAttribute))));
     this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(System.ComponentModel.BrowsableAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(false))));
     this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
     this.Type       = new CodeGlobalTypeReference(typeof(System.Data.DataRelationCollection));
     this.Name       = "Relations";
     this.GetStatements.Add(
         new CodeMethodReturnStatement(
             new CodePropertyReferenceExpression(
                 new CodePropertyReferenceExpression(
                     new CodeTypeReferenceExpression(dataModelSchema.Name),
                     String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                 "Relations")));
 }
 /// <summary>
 /// Creates a middle tier context for an operation.
 /// </summary>
 /// <param name="tableSchema"></param>
 public CodeCreateMiddleTierContextStatement(DataModelSchema dataModelSchema, CodeVariableReferenceExpression transactionExpression)
 {
     //                    global::FluidTrade.Core.MiddleTierContext middleTierTransaction = global::FluidTrade.Core.MiddleTierContext.Current;
     this.Type           = new CodeTypeReference(string.Format("{0}Transaction", dataModelSchema.Name));
     this.Name           = transactionExpression.VariableName;
     this.InitExpression = new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(this.Type), "Current");
 }
示例#10
0
        /// <summary>
        /// Creates a method to dispose of the resources used by the data model.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public WaitForUpdateMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Waits for an update to the data model.
            //		/// </summary>
            //		public static void WaitForUpdate()
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement(string.Format("Dispose of the managed resources allocated by this object.", dataModelSchema.Name), true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"disposing\">true to indicate managed resources should be relesaed.</param>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForMethods());
            this.Name       = "WaitForUpdate";
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;

            //			try
            //          {
            //              Monitor.Enter(DataModel.syncUpdate);
            //				Monitor.Wait(DataModel.syncUpdate);
            //          }
            //          finally
            //          {
            //              Monitor.Exit(DataModel.syncUpdate);
            //          }
            CodeTryCatchFinallyStatement tryLockUpdateEvent = new CodeTryCatchFinallyStatement();

            tryLockUpdateEvent.TryStatements.Add(new CodeMethodInvokeExpression(new CodeGlobalTypeReferenceExpression(typeof(System.Threading.Monitor)), "Enter", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "syncUpdate")));
            tryLockUpdateEvent.TryStatements.Add(new CodeMethodInvokeExpression(new CodeGlobalTypeReferenceExpression(typeof(System.Threading.Monitor)), "Wait", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "syncUpdate")));
            tryLockUpdateEvent.FinallyStatements.Add(new CodeMethodInvokeExpression(new CodeGlobalTypeReferenceExpression(typeof(System.Threading.Monitor)), "Exit", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "syncUpdate")));
            this.Statements.Add(tryLockUpdateEvent);

            //		}
        }
示例#11
0
        /// <summary>
        /// Creates a method to read an XML file.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public ExecuteMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Executes the SQL command asynchronously.
            //		/// </summary>
            //		/// <param name="sqlCommand">The command to be executed asynchronously.</param>
            //		internal void Execute(global::System.Data.SqlClient.SqlCommand sqlCommand)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("The command to be executed asynchronously.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"sqlCommand\">The command to be executed asynchronously.", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForMethods());
            this.Attributes = MemberAttributes.Assembly | MemberAttributes.Final;
            this.Name       = "Execute";
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(SqlCommand)), "sqlCommand"));

            //			this.countdownEvent.AddCount();
            this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "countdownEvent"), "AddCount"));

            //			sqlCommand.BeginExecuteNonQuery(this.HandleCallback, sqlCommand);
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeArgumentReferenceExpression("sqlCommand"),
                    "BeginExecuteNonQuery",
                    new CodeMethodReferenceExpression(new CodeThisReferenceExpression(), "HandleQueryCallback"),
                    new CodeArgumentReferenceExpression("sqlCommand")));

            //		}
        }
示例#12
0
        /// <summary>
        /// Provides a default handler for to get a Reader Context.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public IncrementRowVersionMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Increments and returns the master row version.
            //		/// </summary>
            //		private long IncrementRowVersion()
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Provides a default handler for to get a Reader Context.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            this.ReturnType = new CodeGlobalTypeReference(typeof(Int64));
            this.Name       = "IncrementRowVersion";

            //			return global::System.Threading.Interlocked.Increment(ref this.masterRowVersion);
            this.Statements.Add(
                new CodeMethodReturnStatement(
                    new CodeMethodInvokeExpression(
                        new CodeGlobalTypeReferenceExpression(typeof(Interlocked)),
                        "Increment",
                        new CodeDirectionExpression(
                            FieldDirection.Ref,
                            new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "rowVersion")))));

            //		}
        }
示例#13
0
        /// <summary>
        /// Creates a method to add a lock to the transaction.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public AddLockMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Adds a row lock to the list of locks that must be released at the end of a transaction.
            //		/// </summary>
            //		/// <param name="row">The row containing the lock.</param>
            //		public void AddLock(IRow iRow)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Adds a row lock to the list of locks that must be released at the end of a transaction.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"iRow\">The lock to be added to the transaction.</param>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForMethods());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            this.Name       = "AddLock";
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(IRow)), "iRow"));

            //			this.lockList.Add(iRow);
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "lockList"),
                    "Add",
                    new CodeArgumentReferenceExpression("iRow")));

            //		}
        }
        /// <summary>
        /// Creates a property to return a collection of the tables in the data model.
        /// </summary>
        /// <param name="dataModelSchema">The data model schema.</param>
        public TablesProperty(DataModelSchema dataModelSchema)
        {
            //        /// <summary>
            //        /// Gets the collection of tables contained in the DataModel.
            //        /// </summary>
            //        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            //        [global::System.ComponentModel.BrowsableAttribute(false)]
            //        [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)]
            //        public static global::System.Data.DataTableCollection Tables
            //		  {
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement(string.Format("Gets the collection of tables contained in the {0}.", dataModelSchema.Name), true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Type       = new CodeGlobalTypeReference(typeof(DataTableCollection));
            this.Name       = "Tables";

            //            get {
            //                return FluidTrade.UnitTest.Server.DataModel.dataSet.Tables;
            //            }
            this.GetStatements.Add(
                new CodeMethodReturnStatement(
                    new CodePropertyReferenceExpression(
                        new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "dataSet"),
                        "Tables")));

            //        }
        }
 /// <summary>
 /// Creates a field that provides a way to look up a transaction based on the local transaction identifier.
 /// </summary>
 public TransactionTableField(DataModelSchema dataModelSchema)
 {
     //		private static global::System.Collections.Generic.Dictionary<string, DataModelTransaction> transactionTable;
     this.Attributes = MemberAttributes.Private | MemberAttributes.Static;
     this.Type       = new CodeTypeReference(String.Format("global::System.Collections.Generic.Dictionary<string, {0}Transaction>", dataModelSchema.Name));
     this.Name       = "transactionTable";
 }
示例#16
0
 /// <summary>
 /// Creates a method to handle moving the deleted records from the active data model to the deleted data model.
 /// </summary>
 /// <param name="schema">The data model schema.</param>
 public IncrementRowVersionMethod(DataModelSchema schema)
 {
     //		/// <summary>
     //		/// Increments the row version on a column.
     //		/// </summary>
     //		public static long IncrementRowVersion()
     //		{
     //			// In order to reconcile the server data model to the client, the server maintains views on the data that are organized
     //			// by row version.  When a reconcile operating is trying to determine which rows should be returned to the client, it
     //			// is critical that the order of this table doesn't change.  A monitor on the 'RowVersionColumn' of the table acts as
     //			// the gatekeeper for the information used to sort the view.  This will prevent other threads from updating the row
     //			// version until the reconile operation can collect all the rows that need to be returned to the client.
     //			return Interlocked.Increment(ref DataModel.masterRowVersion);
     //		}
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement("Increments the row version on a column.", true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     this.Name       = "IncrementRowVersion";
     this.ReturnType = new CodeTypeReference(typeof(System.Int64));
     this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
     this.Statements.Add(new CodeCommentStatement("In order to reconcile the server data model to the client, the server maintains views on the data that are organized"));
     this.Statements.Add(new CodeCommentStatement("by row version.  When a reconcile operating is trying to determine which rows should be returned to the client, it"));
     this.Statements.Add(new CodeCommentStatement("is critical that the order of this table doesn't change.  A monitor on the 'RowVersionColumn' of the table acts as"));
     this.Statements.Add(new CodeCommentStatement("the gatekeeper for the information used to sort the view.  This will prevent other threads from updating the row"));
     this.Statements.Add(new CodeCommentStatement("version until the reconile operation can collect all the rows that need to be returned to the client."));
     this.Statements.Add(new CodeMethodReturnStatement(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(typeof(System.Threading.Interlocked)), "Increment", new CodeDirectionExpression(FieldDirection.Ref, new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(schema.Name), "masterRowVersion")))));
 }
示例#17
0
        /// <summary>
        /// Creates a method to handle moving the deleted records from the active data model to the deleted data model.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public AddTransactionMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Adds a transaction item to the log.
            //		/// </summary>
            //		/// <param name="iRow">The record to be added to the transaction log.</param>
            //		/// <param name="data">An array of updated fields.</param>
            //		[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            //		[global::System.ComponentModel.BrowsableAttribute(false)]
            //		internal static void AddTransaction(IRow iRow, object[] data)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Adds a transaction item to the log.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"iRow\">The record to be added to the transaction log.</param>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"data\">An array of updated fields.</param>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Name       = "AddTransaction";
            this.Attributes = MemberAttributes.Assembly | MemberAttributes.Static;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(FluidTrade.Core.IRow)), "iRow"));
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(Object[])), "data"));

            //			DataModel.dataModelDataSet.AddTransaction(iRow, data);
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeFieldReferenceExpression(
                        new CodeTypeReferenceExpression(dataModelSchema.Name),
                        String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                    "AddTransaction",
                    new CodeArgumentReferenceExpression("iRow"),
                    new CodeArgumentReferenceExpression("data")));

            //		}
        }
示例#18
0
        /// <summary>
        /// Creates a method to read an XML file.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public ReadXmlMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Reads an XML file into the data model.
            //		/// </summary>
            //		/// <param name="fileName">The name of the file to read.</param>
            //		public static void ReadXml(string fileName)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Reads an XML file into the data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"fileName\">The name of the file to read.</param>", true));
            this.Name       = "ReadXml";
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(String)), "fileName"));

            //			global::Teraque.OrganizationPrincipal q8561 = ((Teraque.OrganizationPrincipal)(global::System.Threading.Thread.CurrentPrincipal));
            //			DataModelDataSet i8562 = DataModel.tenantMap[q8561.Tenant];
            //			i8562.ReadXml(fileName);
            CodeVariableReferenceExpression organizationPrincipal = new CodeRandomVariableReferenceExpression();

            this.Statements.Add(new CodeOrganizationPrincipalExpression(organizationPrincipal));
            CodeVariableReferenceExpression targetDataSet = new CodeRandomVariableReferenceExpression();

            this.Statements.Add(new CodeTargetDataModelStatement(dataModelSchema, targetDataSet, organizationPrincipal));
            this.Statements.Add(
                new CodeMethodInvokeExpression(targetDataSet, "ReadXml", new CodeArgumentReferenceExpression("fileName")));

            //		}
        }
示例#19
0
        /// <summary>
        /// Generates a property that gets the lock for the data model.
        /// </summary>
        public DataLockProperty(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Gets the lock for the data model.
            //		/// </summary>
            //		public global::System.Threading.ReaderWriterLockSlim DataLock
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Gets the lock for the data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Type       = new CodeGlobalTypeReference(typeof(ReaderWriterLockSlim));
            this.Name       = "DataLock";

            //			get
            //			{
            //				return this.dataLock;
            //			}
            this.GetStatements.Add(
                new CodeMethodReturnStatement(
                    new CodeFieldReferenceExpression(
                        new CodeFieldReferenceExpression(
                            new CodeTypeReferenceExpression(dataModelSchema.Name),
                            String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                        "DataLock")));

            //		}
        }
示例#20
0
        /// <summary>
        /// Creates a strongly typed DataSet from a schema description.
        /// </summary>
        /// <param name="dataSetNamespace">The CodeDOM namespace Teraque.DataModelGenerator.TargetInterface contains this strongly typed DataSet.</param>
        public TargetInterface(DataModelSchema dataModelSchema)
        {
            //	/// <summary>
            //	/// Abstract interface to a thread-safe, multi-tiered DataModel.
            //	/// </summary>
            //	[System.ServiceModel.ServiceContractAttribute()]
            //	public interface IDataModel
            //	{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement(String.Format("Abstract interface to a thread-safe, multi-tiered {0}.", dataModelSchema.Name), true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(ServiceContractAttribute))));
            this.Name           = String.Format("I{0}", dataModelSchema.Name);
            this.TypeAttributes = TypeAttributes.Public | TypeAttributes.Interface;
            this.IsPartial      = true;

            // Methods
            List <CodeMemberMethod> methodList = new List <CodeMemberMethod>();

            methodList.Add(new ReadMethod(dataModelSchema));
            foreach (KeyValuePair <String, TableSchema> tablePair in dataModelSchema.Tables)
            {
                methodList.Add(new CreateMethod(tablePair.Value));
                methodList.Add(new DestroyMethod(tablePair.Value));
                methodList.Add(new StoreMethod(tablePair.Value));
                methodList.Add(new UpdateMethod(tablePair.Value));
            }
            methodList.Sort(delegate(CodeMemberMethod firstMethod, CodeMemberMethod secondMethod) { return(firstMethod.Name.CompareTo(secondMethod.Name)); });
            foreach (CodeMemberMethod codeMemberMethod in methodList)
            {
                this.Members.Add(codeMemberMethod);
            }
        }
示例#21
0
        /// <summary>
        /// Creates a method to read an XML file.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public PrepareMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Indicates that the transaction can be committed.
            //		/// </summary>
            //		/// <param name="preparingEnlistment">Facilitates communication bewtween an enlisted transaction participant and the
            //		/// transaction manager during the final phase of the transaction.</param>
            //		public void Prepare(global::System.Transactions.PreparingEnlistment preparingEnlistment)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Indicates that the transaction can be committed.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"preparingEnlistment\">Facilitates communication bewtween an enlisted transaction participant and the", true));
            this.Comments.Add(new CodeCommentStatement("transaction manager during the final phase of the transaction.</param>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForMethods());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Final;
            this.Name       = "Prepare";
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(PreparingEnlistment)), "preparingEnlistment"));

            //			this.countdownEvent.Signal();
            this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "countdownEvent"), "Signal"));

            //			this.countdownEvent.Wait();
            this.Statements.Add(new CodeMethodInvokeExpression(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "countdownEvent"), "Wait"));

            //			preparingEnlistment.Prepared();
            this.Statements.Add(new CodeMethodInvokeExpression(new CodeArgumentReferenceExpression("preparingEnlistment"), "Prepared"));

            //		}
        }
示例#22
0
 /// <summary>
 /// Creates a method to dispose of the resources used by the data model.
 /// </summary>
 /// <param name="schema">The data model schema.</param>
 public DisposeMethod(DataModelSchema schema)
 {
     //		/// <summary>
     //		/// Dispose of an instance of the DataModel.
     //		/// </summary>
     //		protected override void Dispose(bool disposing)
     //		{
     //			// This section disposes of the managed resources.
     //			if ((disposing == true))
     //			{
     //				// This controls the disposal of the static resources.  When the instance count reaches zero, then all static resources
     //				// should be released back to the operating system.
     //				DataModel.referenceCount = (DataModel.referenceCount - 1);
     //			}
     //			// Allow the base class to complete the disposal.
     //			base.Dispose(disposing);
     //		}
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement(string.Format("Dispose of an instance of the {0}.", schema.Name), true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     this.Name       = "Dispose";
     this.Attributes = MemberAttributes.Override | MemberAttributes.Family;
     this.Parameters.Add(new CodeParameterDeclarationExpression(typeof(System.Boolean), "disposing"));
     this.Statements.Add(new CodeCommentStatement("This section disposes of the managed resources."));
     CodeStatement[] disposeMethodTrue = new CodeStatement[]
     {
         new CodeCommentStatement("This controls the disposal of the static resources.  When the instance count reaches zero, then all static resources"),
         new CodeCommentStatement("should be released back to the operating system."),
         new CodeAssignStatement(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(schema.Name), "referenceCount"), new CodeBinaryOperatorExpression(new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(schema.Name), "referenceCount"), CodeBinaryOperatorType.Subtract, new CodePrimitiveExpression(1)))
     };
     this.Statements.Add(new CodeConditionStatement(new CodeBinaryOperatorExpression(new CodeArgumentReferenceExpression("disposing"), CodeBinaryOperatorType.IdentityEquality, new CodePrimitiveExpression(true)), disposeMethodTrue));
     this.Statements.Add(new CodeCommentStatement("Allow the base class to complete the disposal."));
     this.Statements.Add(new CodeMethodInvokeExpression(new CodeBaseReferenceExpression(), "Dispose", new CodeArgumentReferenceExpression("disposing")));
 }
示例#23
0
        /// <summary>
        /// Creates a static constructor for the transaction.
        /// </summary>
        /// <param name="dataModelSchema">A description of the data model.</param>
        public Constructor(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Creates a collector of fields for the transaction log compression.
            //		/// </summary>
            //		/// <param name="linkedListNode">The node that is to be compressed.</param>
            //		/// <param name="fieldTable">A collection of transaction log fields.</param>
            //		private FieldCollector(global::System.Collections.Generic.LinkedListNode<TransactionLogItem> linkedListNode, global::System.Collections.Generic.Dictionary<int, object> fieldTable)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Creates a collector of fields for the transaction log compression.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"linkedListNode\">The node that is to be compressed.</param>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"fieldTable\">A collection of transaction log fields.</param>", true));
            this.Attributes = MemberAttributes.Assembly;
            this.Parameters.Add(
                new CodeParameterDeclarationExpression(
                    new CodeTypeReference("global::System.Collections.Generic.LinkedListNode<TransactionLogItem>"), "linkedListNode"));
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(Dictionary <Int32, Object>)), "fieldTable"));

            //			this.linkedListNode = linkedListNode;
            this.Statements.Add(
                new CodeAssignStatement(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "linkedListNode"), new CodeArgumentReferenceExpression("linkedListNode")));

            //			this.fieldTable = fieldTable;
            this.Statements.Add(
                new CodeAssignStatement(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "fieldTable"), new CodeArgumentReferenceExpression("fieldTable")));

            //		}
        }
 /// <summary>
 /// Creates a method to handle moving the deleted records from the active data model to the deleted data model.
 /// </summary>
 /// <param name="schema">The data model schema.</param>
 public OnEndMergeMethod(DataModelSchema dataModelSchema)
 {
     //		/// <summary>
     //		/// Broadcasts an event when the data model is has finished changing.
     //		/// </summary>
     //		/// <param name="sender">Object originating the event.</param>
     //		public static void OnEndMerge(object sender)
     //		{
     //
     //			// If a handler has been associated with this event, invoke it.
     //			if (DataModel.EndMerge != null)
     //				DataModel.EndMerge(sender, EventArgs.Empty);
     //
     //		}
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement("Broadcasts an event when the data model has finished changing.", true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     this.Comments.Add(new CodeCommentStatement("<param name=\"sender\">The object that originated the event.</param>", true));
     this.CustomAttributes.AddRange(new CodeCustomAttributesForMethods());
     this.Attributes = MemberAttributes.Final | MemberAttributes.Static | MemberAttributes.Public;
     this.Name       = "OnEndMerge";
     this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(System.Object)), "sender"));
     this.Statements.Add(new CodeCommentStatement("Broadcast the event to any listeners."));
     this.Statements.Add(new CodeConditionStatement(new CodeBinaryOperatorExpression(new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "EndMerge"), CodeBinaryOperatorType.IdentityInequality, new CodePrimitiveExpression(null)),
                                                    new CodeExpressionStatement(new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(dataModelSchema.Name), "EndMerge", new CodeArgumentReferenceExpression("sender"), new CodePropertyReferenceExpression(new CodeGlobalTypeReferenceExpression(typeof(EventArgs)), "Empty")))));
 }
示例#25
0
 /// <summary>
 /// Creates a private field to hold the generic DataSet.
 /// </summary>
 public DataSetField(DataModelSchema dataModelSchema)
 {
     //        // The generic data behind the strongly typed data model.
     //        private static global::System.Data.DataSet dataSet;
     this.Attributes = MemberAttributes.Assembly | MemberAttributes.Static;
     this.Type       = new CodeTypeReference(string.Format("{0}DataSet", dataModelSchema.Name));
     this.Name       = string.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name));
 }
示例#26
0
        public VoidConstructor(DataModelSchema dataModelSchema)
        {
            //		public DataModelClass()
            //		{
            this.Attributes = MemberAttributes.Public;

            //		}
        }
示例#27
0
 /// <summary>
 /// Creates a private field that maps an tenant to a data model.
 /// </summary>
 public TenantMapField(DataModelSchema dataModelSchema)
 {
     //			static global::System.Collections.Generic.Dictionary<string, DataModelDataSet> tenantMap = new System.Collections.Generic.Dictionary<string, DataModelDataSet>();
     this.Attributes     = MemberAttributes.Assembly | MemberAttributes.Static;
     this.Type           = new CodeTypeReference(string.Format("global::System.Collections.Generic.Dictionary<string, Tenant{0}>", dataModelSchema.Name));
     this.Name           = "tenantMap";
     this.InitExpression = new CodeObjectCreateExpression(this.Type);
 }
        /// <summary>
        /// Creates a method to read an XML file.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public AddTransactionMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Adds a transaction item to the log.
            //		/// </summary>
            //		/// <param name="iRow">The record to be added to the transaction log.</param>
            //		/// <param name="data">An array of updated fields.</param>
            //		[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            //		[global::System.ComponentModel.BrowsableAttribute(false)]
            //		internal void AddTransaction(IRow iRow, object[] data)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Adds a transaction item to the log.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"iRow\">The record to be added to the transaction log.</param>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"data\">An array of updated fields.</param>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Name       = "AddTransaction";
            this.Attributes = MemberAttributes.Assembly | MemberAttributes.Final;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(IRow)), "iRow"));
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(Object[])), "data"));

            //			ITable iTable = ((ITable)(iRow.Table));
            this.Statements.Add(
                new CodeVariableDeclarationStatement(
                    new CodeGlobalTypeReference(typeof(ITable)),
                    "iTable",
                    new CodeCastExpression(
                        new CodeGlobalTypeReference(typeof(ITable)),
                        new CodePropertyReferenceExpression(new CodeArgumentReferenceExpression("iRow"), "Table"))));

            //			this.transactionLog.AddLast(new TransactionLogItem(data, iTable.PrimaryKey.Length, this.sequence, global::System.DateTime.Now));
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "transactionLog"),
                    "AddLast",
                    new CodeObjectCreateExpression(
                        new CodeTypeReference("TransactionLogItem"),
                        new CodeArgumentReferenceExpression("data"),
                        new CodePropertyReferenceExpression(
                            new CodePropertyReferenceExpression(new CodeVariableReferenceExpression("iTable"), "PrimaryKey"),
                            "Length"),
                        new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "sequence"),
                        new CodePropertyReferenceExpression(new CodeGlobalTypeReferenceExpression(typeof(DateTime)), "Now"))));

            //			this.sequence = (this.sequence + 1);
            this.Statements.Add(
                new CodeAssignStatement(
                    new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "sequence"),
                    new CodeBinaryOperatorExpression(
                        new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), "sequence"),
                        CodeBinaryOperatorType.Add,
                        new CodePrimitiveExpression(1))));

            //		}
        }
示例#29
0
 /// <summary>
 /// A statement creating an tenant principal.
 /// </summary>
 /// <param name="organizationPrincipal">The organizationPrincipal variable.</param>
 public CodeTargetDataModelStatement(DataModelSchema dataModelSchema, CodeVariableReferenceExpression targetDataSet, CodeVariableReferenceExpression organizationPrincipal)
 {
     //			global::Teraque.OrganizationPrincipal l1651 = ((Teraque.OrganizationPrincipal)(global::System.Threading.Thread.CurrentPrincipal));
     this.Type           = new CodeTypeReference(String.Format("Tenant{0}", dataModelSchema.Name));
     this.Name           = targetDataSet.VariableName;
     this.InitExpression = new CodeIndexerExpression(
         new CodePropertyReferenceExpression(
             new CodeTypeReferenceExpression(dataModelSchema.Name), "tenantMap"),
         new CodePropertyReferenceExpression(organizationPrincipal, "Organization"));
 }
示例#30
0
        public StringConstructor(DataModelSchema dataModelSchema)
        {
            //		public DataModelClass()
            //		{
            this.Attributes = MemberAttributes.Public;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(String)), "endpointConfigurationName"));
            this.BaseConstructorArgs.Add(new CodeArgumentReferenceExpression("endpointConfigurationName"));

            //		}
        }