示例#1
0
 private void ForEachOperation(DataAccessModel daLayer, OperationGenerator opGen, TextWriter tw)
 {
     foreach (ServiceLayerModel model in m_Arch.ServiceLayers)
       {
     foreach (ServiceModel model2 in model.Services)
     {
       foreach (OperationModel model3 in model2.Operations)
       {
     if ((daLayer == null) || (model3.DataLayer == daLayer))
     {
       if (model3 is TableOperation)
       {
         if (((TableOperation) (model3)).m_Table.m_generate)
         {
           opGen(model3, tw);
         }
       }
       else
       {
         opGen(model3, tw);
       }
     }
       }
     }
       }
 }
示例#2
0
 public static string GetSpName(DataAccessModel daLayer, AssocModel asc, AssocOperationType opType)
 {
     return string.Format("{0}{1}{2}", daLayer.Prefix, asc.Name, opType);
 }
示例#3
0
 public static string GetSpName(DataAccessModel daLayer, DataEntityModel de, TableOperationType opType)
 {
     return string.Format("{0}{1}{2}", daLayer.Prefix, de.MappingName, opType);
 }
示例#4
0
 private void GenerateSpsPartial(DataAccessModel daLayer, SqlSpInfo info2, CSharpTypeDef typeDef)
 {
     if (info2.Name.Substring(0, 3) != "dt_")
       {
     string prefix = daLayer.Prefix;
     if ((prefix == string.Empty) || (prefix == info2.Name.Substring(0, prefix.Length)))
     {
       bool returnsDataSet = (info2.ResultColumns != null) ||
                         ((Sql2000DataAccessModel) daLayer).IsInDynamicSp(info2.Name);
       TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", info2.Name));
       GenerateSpMethod(typeDef, info2, true, returnsDataSet);
       GenerateSpMethod(typeDef, info2, false, returnsDataSet);
     }
       }
 }
示例#5
0
        private CSharpTypeDef GetTypeDef(DataAccessModel daLayer, string id )
        {
            CSharpFile file = CSharpFilePool.Obtain(Path.Combine(daLayer.FullPath, GenerationHelper.GetDataContextName(id)));
              file.NameSpace = daLayer.NameSpace;
              file.Description = "Class implementing data access methods.";

              file.Usings.Add("System.Data");
              file.Usings.Add("System.Data.SqlClient");
              file.Usings.Add("Grepton.Runtime");
              file.Usings.Add("Grepton.Runtime.DBTypes");
              file.Usings.Add("Grepton.Runtime.SqlServer");
              file.Usings.Add("Grepton.Runtime.BusinessHosting");
              file.Usings.Add("Grepton.Diagnostics.EventSchema");
              file.Usings.Add("Grepton.Diagnostics.Pmc");
              file.Usings.Add(m_Arch.UtilityLayer.NameSpace);
              CSharpTypeDef typeDef = new CSharpTypeDef();
              file.InnerTypes.Add(typeDef);
              typeDef.Attributes.Add("ImplicitPmc");
              typeDef.Comment.Summary = file.Description;
              typeDef.HeaderLine = string.Format("public class {0}: Base{0}", daLayer.DataContextName);
              CSharpMethodDef def2 = new CSharpMethodDef();
              typeDef.Ctors.Add(def2);
              def2.Comment.Summary =
            "This constructor creates a stored procedure interface that uses the database connection as specified in the application configuration file.";
              def2.HeaderLine = string.Format("public {0}", daLayer.DataContextName);
              def2.HeaderTrailer = ": base()";
              CSharpMethodDef def3 = new CSharpMethodDef();
              typeDef.Ctors.Add(def3);
              def3.Comment.Summary =
            "This constructor creates a stored procedure interface that uses tha database connection as specified in the constructor parameter.";
              def3.HeaderLine = string.Format("public {0}", daLayer.DataContextName);
              def3.AddParam("sqlConn", "SqlConnection", "SQL Server connection to use.");
              def3.HeaderTrailer = ": base(sqlConn)";
              file = CSharpFilePool.Obtain(Path.Combine(daLayer.FullPath, GenerationHelper.GetBaseDataContextName(id)));
              file.NameSpace = daLayer.NameSpace;
              file.Description = "Class implementing data access methods.";
              file.Usings.Add("System.Data");
              file.Usings.Add("System.Data.SqlClient");
              file.Usings.Add("Grepton.Runtime");
              file.Usings.Add("Grepton.Runtime.DBTypes");
              file.Usings.Add("Grepton.Runtime.SqlServer");
              file.Usings.Add("Grepton.Runtime.BusinessHosting");
              file.Usings.Add("Grepton.Diagnostics.EventSchema");
              file.Usings.Add("Grepton.Diagnostics.Pmc");
              file.Usings.Add(m_Arch.UtilityLayer.NameSpace);
              typeDef = new CSharpTypeDef();
              file.InnerTypes.Add(typeDef);
              typeDef.Attributes.Add("ImplicitPmc");
              typeDef.Comment.Summary = file.Description;
              typeDef.HeaderLine = string.Format("public partial class Base{0}: SqlDataContextBase", daLayer.DataContextName);
              def2 = new CSharpMethodDef();
              typeDef.Ctors.Add(def2);
              def2.Comment.Summary =
            "This constructor creates a stored procedure interface that uses the database connection as specified in the application configuration file.";
              def2.HeaderLine = string.Format("public Base{0}", daLayer.DataContextName);
              def2.Writer.WriteLine("m_Connection = Configuration.{0}Connection;", daLayer.ConfigKeyName);
              def3 = new CSharpMethodDef();
              typeDef.Ctors.Add(def3);
              def3.Comment.Summary =
            "This constructor creates a stored procedure interface that uses tha database connection as specified in the constructor parameter.";
              def3.HeaderLine = string.Format("public Base{0}", daLayer.DataContextName);
              def3.AddParam("sqlConn", "SqlConnection", "SQL Server connection to use.");
              def3.HeaderTrailer = ": base(sqlConn)";
              return typeDef;
        }
示例#6
0
 public ServiceLayerModel(ArchitectureModel aModel, string slName, string slFolder, DataAccessModel daLayer)
     : base(aModel)
 {
     m_Services = new ServiceContainer();
       base.LayerName = slName;
       base.LayerFolder = slFolder;
       DataAccessLayer = daLayer;
       aModel.ServiceLayers.Add(this);
 }
示例#7
0
 public void GenerateDataContext(DataAccessModel daLayer)
 {
     CSharpTypeDef typeDef = GetTypeDef(daLayer, "0");
       SqlMetaInfo info = new SqlMetaInfo((SqlConnection) daLayer.Connection);
       int counter = 0;
       int filenum = 0;
       foreach (SqlSpInfo info2 in info.StoredProcs)
       {
     counter++;
     if ((counter % 200) == 0)
     {
       filenum++;
       typeDef = GetTypeDef(daLayer, filenum.ToString());
     }
     GenerateSpsPartial(daLayer, info2, typeDef);
       }
 }
示例#8
0
 // Methods
 public ServiceLayerModel(ArchitectureModel aModel, string slName, DataAccessModel daLayer)
     : this(aModel, slName, string.Empty, daLayer)
 {
 }
示例#9
0
 public static string GetSpName(DataAccessModel daLayer, DataEntityModel de, string opType)
 {
     string str = CapitalizeFirstLetter(daLayer.NormalizeTableName(de.MappingName));
       return string.Format("{0}{1}{2}", daLayer.Prefix, str, opType);
 }
示例#10
0
 public void GenerateDataContext(DataAccessModel daLayer)
 {
     CSharpFile file = CSharpFilePool.Obtain(Path.Combine(daLayer.FullPath, GenerationHelper.GetDataContextName("")));
       file.NameSpace = daLayer.NameSpace;
       file.Description = "Class implementing data access methods.";
       file.Usings.Add("System.Data");
       file.Usings.Add("System.Data.OracleClient");
       file.Usings.Add("Grepton.Runtime");
       file.Usings.Add("Grepton.Runtime.DBTypes");
       file.Usings.Add("Grepton.Runtime.SqlServer");
       file.Usings.Add("Grepton.Runtime.BusinessHosting");
       file.Usings.Add("Grepton.Diagnostics.EventSchema");
       file.Usings.Add("Grepton.Diagnostics.Pmc");
       file.Usings.Add(m_Arch.UtilityLayer.NameSpace);
       CSharpTypeDef typeDef = new CSharpTypeDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Attributes.Add("ImplicitPmc");
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = string.Format("public class {0}: Base{0}", daLayer.DataContextName);
       CSharpMethodDef def2 = new CSharpMethodDef();
       typeDef.Ctors.Add(def2);
       def2.Comment.Summary =
     "This constructor creates a stored procedure interface that uses the database connection as specified in the application configuration file.";
       def2.HeaderLine = string.Format("public {0}", daLayer.DataContextName);
       def2.HeaderTrailer = ": base()";
       CSharpMethodDef def3 = new CSharpMethodDef();
       typeDef.Ctors.Add(def3);
       def3.Comment.Summary =
     "This constructor creates a stored procedure interface that uses the database connection as specified in the constructor parameter.";
       def3.HeaderLine = string.Format("public {0}", daLayer.DataContextName);
       def3.AddParam("oraConn", "OracleConnection", "Oracle connection to use.");
       def3.HeaderTrailer = ": base(oraConn)";
       file = CSharpFilePool.Obtain(Path.Combine(daLayer.FullPath, GenerationHelper.GetBaseDataContextName("")));
       file.NameSpace = daLayer.NameSpace;
       file.Description = "Class implementing data access methods.";
       file.Usings.Add("System.Data");
       file.Usings.Add("System.Data.OracleClient");
       file.Usings.Add("Grepton.Runtime");
       file.Usings.Add("Grepton.Runtime.DBTypes");
       file.Usings.Add("Grepton.Runtime.SqlServer");
       file.Usings.Add("Grepton.Runtime.BusinessHosting");
       file.Usings.Add("Grepton.Diagnostics.EventSchema");
       file.Usings.Add("Grepton.Diagnostics.Pmc");
       file.Usings.Add(m_Arch.UtilityLayer.NameSpace);
       typeDef = new CSharpTypeDef();
       file.InnerTypes.Add(typeDef);
       typeDef.Attributes.Add("ImplicitPmc");
       typeDef.Comment.Summary = file.Description;
       typeDef.HeaderLine = string.Format("public class Base{0}: Oracle8DataContextBase", daLayer.DataContextName);
       def2 = new CSharpMethodDef();
       typeDef.Ctors.Add(def2);
       def2.Comment.Summary =
     "This constructor creates a stored procedure interface that uses the database connection as specified in the application configuration file.";
       def2.HeaderLine = string.Format("public Base{0}", daLayer.DataContextName);
       def2.HeaderTrailer = ": base(Configuration.AppDatabaseConnection)";
       def3 = new CSharpMethodDef();
       typeDef.Ctors.Add(def3);
       def3.Comment.Summary =
     "This constructor creates a stored procedure interface that uses tha database connection as specified in the constructor parameter.";
       def3.HeaderLine = string.Format("public Base{0}", daLayer.DataContextName);
       def3.AddParam("oraConn", "OracleConnection", "Oracle Server connection to use.");
       def3.HeaderTrailer = ": base(oraConn)";
       foreach (DataEntityModel model in daLayer.Entities)
       {
     string packageName = ((Oracle8DataAccessModel) daLayer).PackageName;
     TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.DeleteSpName(model)));
     GenerateSpMethod(typeDef, daLayer.DeleteSpName(model), model.PKFields, packageName, false, false);
     TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.InsertSpName(model)));
     GenerateSpMethod(typeDef, daLayer.InsertSpName(model), model.InsertParamFields, packageName, false, false);
     TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.SelectAllSpName(model)));
     GenerateSpMethod(typeDef, daLayer.SelectAllSpName(model), new DataFieldContainer(), packageName, false, true);
     TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.SelectDispsetAllSpName(model)));
     GenerateSpMethod(typeDef, daLayer.SelectDispsetAllSpName(model), new DataFieldContainer(), packageName, false,                         true);
     TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.SelectSpName(model)));
     GenerateSpMethod(typeDef, daLayer.SelectSpName(model), model.PKFields, packageName, false, true);
     TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.UpdateSpName(model)));
     GenerateSpMethod(typeDef, daLayer.UpdateSpName(model), model.UpdateParamFields, packageName, true, false);
     GenerateSpMethod(typeDef, daLayer.UpdateSpName(model), model.UpdateParamFields, packageName, false, false);
     foreach (AssocModel model2 in model.ParentAssocs)
     {
       TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.DeleteBySpName(model2)));
       GenerateSpMethod(typeDef, daLayer.DeleteBySpName(model2), model2.ForeignFields, packageName, true, false);
       GenerateSpMethod(typeDef, daLayer.DeleteBySpName(model2), model2.ForeignFields, packageName, false, false);
       TraceInfoEvent.Raise(string.Format("Adding method for '{0}'", daLayer.SelectBySpName(model2)));
       GenerateSpMethod(typeDef, daLayer.SelectBySpName(model2), model2.ForeignFields, packageName, false, true);
     }
       }
 }
示例#11
0
 public void Remove(DataAccessModel daModel)
 {
     m_Items.Remove(daModel);
       TraceInfoEvent.Raise(string.Format("DataAccessModel '{0}' removed.", daModel.LayerName));
 }
示例#12
0
 public int Add(DataAccessModel daModel)
 {
     foreach (DataAccessModel model in m_Items)
       {
     if (model.LayerName.ToLower().Equals(daModel.LayerName.ToLower()))
     {
       throw new ArgumentException(
     string.Format("There is already a DataAccessModel item in the container with the name '{0}'.",                          daModel.LayerName));
     }
       }
       int num = m_Items.Add(daModel);
       TraceInfoEvent.Raise(string.Format("DataAccessModel '{0}' added.", daModel.LayerName));
       return num;
 }