Esempio n. 1
0
 protected static void FieldList(TextWriter sw, string formatString, DataFieldContainer fields)
 {
     int num = 0;
       foreach (DataFieldModel model in fields)
       {
     if (num > 0)
     {
       sw.WriteLine(",");
     }
     sw.Write(string.Format(formatString, model.Name, model.TypeString));
     num++;
       }
       sw.WriteLine();
 }
Esempio n. 2
0
 protected static void FieldList(TextWriter sw, string formatString, DataFieldContainer fields,                                    bool isRefCursorNeeded, bool isReturnValueNeeded)
 {
     if (fields != null)
       {
     int num = 0;
     foreach (DataFieldModel model in fields)
     {
       if (num > 0)
       {
     sw.WriteLine(",");
       }
       sw.Write(string.Format(formatString, model.Name, MapTypesSqlToOracle(model.TypeString, false)));
       num++;
     }
     if ((fields.Count > 0) && (isReturnValueNeeded || isRefCursorNeeded))
     {
       sw.WriteLine(",");
     }
     else
     {
       sw.WriteLine();
     }
       }
       if (isRefCursorNeeded)
       {
     sw.Write("  oresult out refcursor");
     if (isReturnValueNeeded)
     {
       sw.WriteLine(",");
     }
       }
       if (isReturnValueNeeded)
       {
     sw.WriteLine("  returnValue OUT NUMBER");
       }
 }
Esempio n. 3
0
 private static void ProcHead(TextWriter sw, string spName, DataFieldContainer fields, bool isRefCursorNeeded,                                 bool isReturnValueNeeded)
 {
     sw.WriteLine(string.Format("PROCEDURE {0}", spName));
       sw.WriteLine("(");
       FieldList(sw, "  i{0} IN {1}", fields, isRefCursorNeeded, isReturnValueNeeded);
       sw.WriteLine(")");
 }
Esempio n. 4
0
 protected static void FieldList(TextWriter sw, string formatString, DataFieldContainer fields)
 {
     if (fields.Count > 0)
       {
     int num = 0;
     foreach (DataFieldModel model in fields)
     {
       if (num > 0)
       {
     sw.WriteLine(",");
       }
       sw.Write(string.Format(formatString, model.Name, MapTypesSqlToOracle(model.TypeString, false)));
       num++;
     }
     sw.WriteLine();
       }
 }
Esempio n. 5
0
 private void GenerateSpMethod(CSharpTypeDef dcClass, string spName, DataFieldContainer dataFields,                                  string packageName, bool hasRetVal, bool returnsDataSet)
 {
     CSharpMethodDef def = new CSharpMethodDef();
       dcClass.Methods.Add(def);
       def.Comment.Summary = string.Format("Calls stored procedure '{0}'", spName);
       def.Attributes.Add(string.Format("ImplicitPmc(\"{0}\")", spName));
       if (returnsDataSet)
       {
     def.HeaderLine = string.Format("public DataSet {0}", spName);
     def.Comment.Returns = "Resulting DataSet from the stored procedure.";
       }
       else
       {
     def.HeaderLine = string.Format("public void {0}", spName);
       }
       foreach (DataFieldModel model in dataFields)
       {
     int length = (model.TypeString.IndexOf("(") > 0) ? model.TypeString.IndexOf("(") : model.TypeString.Length;
     string index = model.TypeString.Substring(0, length).ToLower();
     def.AddParam(model.NormalizedName, OracleTypeMap.GetDBType(index),                     string.Format("{0} parameter.", model.MappingName));
       }
       if (hasRetVal)
       {
     CSharpMethodparamDef def2 = new CSharpMethodparamDef("retVal", "int");
     def2.Direction = MethodParamDir.Out;
     def.Params.Add(def2);
     def.Comment.AddParam("retVal", "SP return value.");
       }
       TextWriter writer = def.Writer;
       writer.WriteLine("TraceCallEnterEvent.Raise();");
       writer.WriteLine("OracleCommand oraComm = PrepareSPCall(\"{0}\");", packageName + "." + spName);
       writer.WriteLine();
       int num2 = 1;
       foreach (DataFieldModel model2 in dataFields)
       {
     int num3 = (model2.TypeString.IndexOf("(") > 0) ? model2.TypeString.IndexOf("(") : model2.TypeString.Length;
     string str2 = model2.TypeString.Substring(0, num3).ToLower();
     writer.WriteLine(string.Format("OracleParameter p{0} = oraComm.Parameters.Add(\"i{1}\", OracleType.{2});", num2,                                       model2.Name, OracleTypeMap.GetNetOracleTypeWithSize(str2, model2.MaxLength)));
     writer.WriteLine(string.Format("p{0}.Direction = ParameterDirection.Input;", num2));
     if (OracleTypeMap.GetDBType(str2).ToLower() == "bool")
     {
       writer.WriteLine(string.Format("p{0}.Value = {1};", num2, model2.NormalizedName));
     }
     else
     {
       writer.WriteLine(string.Format("p{0}.Value = {1}.Value;", num2, model2.NormalizedName));
     }
     num2++;
       }
       if (returnsDataSet)
       {
     writer.WriteLine(string.Format(
                    "OracleParameter p{0} = oraComm.Parameters.Add(\"oresult\", OracleType.Cursor);", num2));
     writer.WriteLine(string.Format("p{0}.Direction = ParameterDirection.Output;", num2));
       }
       if (hasRetVal)
       {
     writer.WriteLine("OracleParameter returnValue = oraComm.Parameters.Add(\"returnValue\", OracleType.Number);");
     writer.WriteLine("returnValue.Direction = ParameterDirection.Output;");
       }
       writer.WriteLine("//TraceDbCommandEvent.Raise(oraComm);");
       if (returnsDataSet)
       {
     writer.WriteLine("DataSet Result = new DataSet();");
       }
       writer.WriteLine("try");
       writer.WriteLine("{");
       if (returnsDataSet)
       {
     writer.WriteLine("  OracleDataAdapter oraAdapt = new OracleDataAdapter(oraComm);");
     writer.WriteLine("  oraAdapt.Fill(Result);");
     writer.WriteLine("  TraceCallReturnEvent.Raise();");
       }
       else
       {
     writer.WriteLine("  oraComm.ExecuteNonQuery();");
     writer.WriteLine("  TraceCallReturnEvent.Raise();");
       }
       writer.WriteLine("}");
       writer.WriteLine("catch (OracleException  e)");
       writer.WriteLine("{");
       writer.WriteLine("  TraceCallReturnEvent.Raise(false);");
       writer.WriteLine("  throw e;");
       writer.WriteLine("}");
       writer.WriteLine("finally");
       writer.WriteLine("{");
       writer.WriteLine("  FinishSPCall();");
       writer.WriteLine("}");
       num2 = 0;
       if (hasRetVal)
       {
     writer.WriteLine("retVal = Convert.ToInt32(returnValue.Value);");
     writer.WriteLine("TraceInfoEvent.Raise(\"RetVal: {0}\", retVal);");
       }
       if (returnsDataSet)
       {
     writer.WriteLine("return Result;");
       }
 }
Esempio n. 6
0
 public static void EnumerateParams(TextWriter tw, DataFieldContainer cont, string format)
 {
     int num = 0;
       foreach (DataFieldModel model in cont)
       {
     string str = (num == 0) ? format.TrimStart(new char[0]) : format;
     if (num > 0)
     {
       tw.Write(",");
       tw.WriteLine();
       tw.Write("  ");
     }
     tw.Write(string.Format(str, model.NormalizedName));
     num++;
       }
 }
Esempio n. 7
0
 public static void AddMethodParams(CSharpMethodDef method, DataFieldContainer cont)
 {
     foreach (DataFieldModel model in cont)
       {
     string name = string.Format("{0}Val", model.NormalizedName);
     string comment = string.Format("Value of '{0}' field", model.MappingName);
     method.AddParam(name, SqlTypeMap.GetDBTypeFromFullName(model.TypeString), comment);
       }
 }
Esempio n. 8
0
 private void AddAssoc(string assocName, string revAssocname, DataEntityModel table, bool mandatory, bool isInPK,                          params string[] fkFields)
 {
     AssocModel model = new AssocModel(assocName, table, this);
       model.ParentRole = assocName;
       model.ChildRole = (revAssocname == string.Empty) ? string.Format("ReverseOf{0}", assocName) : revAssocname;
       DataFieldContainer container = new DataFieldContainer();
       foreach (DataFieldModel model2 in table.PKFields)
       {
     container.Add(model2);
       }
       int index = 0;
       foreach (DataFieldModel model3 in container)
       {
     string name = (index >= fkFields.Length) ? model3.Name : fkFields[index];
     if (Fields[name] != null)
     {
       model.ForeignFields.Add(Fields[name]);
     }
     else
     {
       if (name == string.Empty)
       {
     name = model3.Name + "Parent";
     if (Fields[name] != null)
     {
       name = name + Fields.Count;
     }
       }
       DataFieldModel df = new DataFieldModel(name, model3.TypeString).Descr(model3.Description);
       if (isInPK)
       {
     df.PKOrder = 0;
       }
       df.AllowNull = !mandatory;
       Add(df);
       model.ForeignFields.Add(df);
     }
     index++;
       }
 }