コード例 #1
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public abstract void DropScript(AssocModel assoc, TextWriter sw);
コード例 #2
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static string GetAssignmentSpName(AssocModel leftAssoc)
 {
     return string.Format("{0}{1}Assign", leftAssoc.Parent.Parent.Prefix, leftAssoc.ParentRole);
 }
コード例 #3
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static void SelectAssignmentSp(AssocModel leftAssoc, AssocModel rightAssoc, TextWriter sw)
 {
     DataEntityModel parent = leftAssoc.Parent;
       DataEntityModel child = leftAssoc.Child;
       DataEntityModel model3 = child.ChildAssocs[rightAssoc.Name].Parent;
       string assignmentSpName = GetAssignmentSpName(leftAssoc);
       TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", assignmentSpName));
       HeadingComment(sw, assignmentSpName,                     string.Format("Selects the specified {0} records by '{1}' association.", model3.MappingName,                                   leftAssoc.ParentRole));
       ProcHead(sw, assignmentSpName);
       FieldList(sw, "  @{0} {1}", parent.PKFields);
       sw.WriteLine("as");
       sw.WriteLine("  select");
       FieldList(sw, "    [rightTbl].[{0}]", model3.Fields);
       sw.WriteLine(string.Format("  from [{0}] as assocTbl", child.MappingName));
       //sw.WriteLine(string.Format("  from [{0}] as assocTbl with (nolock)", child.MappingName));
       sw.WriteLine(string.Format("    inner join [{0}] as rightTbl with (nolock) on", model3.MappingName));
       //sw.WriteLine(string.Format("    inner join [{0}] as rightTbl on", model3.MappingName));
       for (int i = 0; i < model3.PKFields.Count; i++)
       {
     if (i > 0)
     {
       sw.WriteLine(" and");
     }
     sw.Write(string.Format("      assocTbl.[{0}] = rightTbl.[{1}]", rightAssoc.ForeignFields[i].Name,                               model3.PKFields[i].Name));
       }
       sw.WriteLine();
       sw.WriteLine("  where");
       for (int j = 0; j < parent.PKFields.Count; j++)
       {
     if (j > 0)
     {
       sw.WriteLine(" and");
     }
     sw.Write(string.Format("    assocTbl.[{0}] = @{1}", leftAssoc.ForeignFields[j].Name, parent.PKFields[j].Name));
       }
       sw.WriteLine();
       sw.WriteLine();
       sw.WriteLine("  return @@rowcount");
       sw.WriteLine("GO");
       sw.WriteLine();
 }
コード例 #4
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void CreationScript(AssocModel asc, TextWriter sw)
 {
     sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("-- Add foreign key [FK{0}] ", asc.Name));
       sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("alter table [dbo].[{0}] add", asc.Child.Name));
       sw.WriteLine(string.Format("constraint [FK{0}] foreign key", asc.Name));
       sw.WriteLine("(");
       int num = 0;
       foreach (DataFieldModel model in asc.ForeignFields)
       {
     if (num++ > 0)
     {
       sw.WriteLine(",");
     }
     sw.Write(string.Format("  [{0}]", model.Name));
       }
       sw.WriteLine();
       sw.WriteLine(")");
       sw.WriteLine(string.Format("references [dbo].[{0}]", asc.Parent.Name));
       sw.WriteLine("(");
       num = 0;
       foreach (DataFieldModel model2 in asc.Parent.PKFields)
       {
     if (num++ > 0)
     {
       sw.WriteLine(",");
     }
     sw.Write(string.Format("  [{0}]", model2.Name));
       }
       sw.WriteLine();
       sw.Write(") ");
       if (!asc.IsForReplication)
       {
     sw.Write("not for replication ");
       }
       if (asc.CascadeUpdate)
       {
     sw.Write("on update cascade ");
       }
       if (asc.CascadeDelete)
       {
     sw.Write("on delete cascade ");
       }
       sw.WriteLine();
       sw.WriteLine("GO");
       sw.WriteLine();
       if (!asc.EnforceRelation)
       {
     sw.WriteLine(string.Format("alter table [dbo].[{0}] nocheck constraint [FK{1}]", asc.Child.Name, asc.Name));
     sw.WriteLine("GO");
     sw.WriteLine();
       }
 }
コード例 #5
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void GenerateSelectBySp(AssocModel asc, TextWriter sw)
 {
     Sql2000SpGenerator.SelectBySp(asc, sw);
 }
コード例 #6
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static string GetOpName(AssocOperationType type, AssocModel asc)
 {
     return (type + asc.Name);
 }
コード例 #7
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static void DeleteBySp(AssocModel assocInfo, TextWriter sw)
 {
     string str = assocInfo.Parent.Parent.DeleteBySpName(assocInfo);
       TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str));
       HeadingComment(sw, str,                     string.Format("Deletes {0} records belonging to {1}.", assocInfo.Child.MappingName,                                   assocInfo.Parent.Name));
       ProcHead(sw, str, assocInfo.ForeignFields, false, true);
       sw.WriteLine("AS");
       sw.WriteLine("BEGIN");
       sw.WriteLine(string.Format("  DELETE FROM {0}", assocInfo.Child.Name));
       sw.WriteLine("  WHERE");
       ConditionList(sw, "    {0} = i{0}", assocInfo.ForeignFields);
       sw.WriteLine();
       sw.WriteLine("    returnValue := SQL%ROWCOUNT;");
       sw.WriteLine(string.Format("END {0};", str));
       sw.WriteLine();
 }
コード例 #8
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 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++;
       }
 }
コード例 #9
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 // Methods
 public DocumentRelationModel(AssocModel assoc, BusinessDocModel doc)
 {
     m_Assoc = assoc;
       m_Document = doc;
 }
コード例 #10
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public DataEntityModel AddParentAssoc(AssocModel asc)
 {
     m_ParentAssocs.Add(asc);
       TraceInfoEvent.Raise(string.Format("Parent association '{0}' added to '{1}'.", asc.Name, Name));
       return this;
 }
コード例 #11
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public DataEntityModel RemoveParentAssoc(AssocModel asc)
 {
     m_ParentAssocs.Remove(asc);
       TraceInfoEvent.Raise(string.Format("Parent association '{0}' removed from '{1}'.", asc.Name, Name));
       return this;
 }
コード例 #12
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public abstract string SelectBySpName(AssocModel asc);
コード例 #13
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public abstract void GenerateSelectBySp(AssocModel asc, TextWriter sw);
コード例 #14
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public virtual void GenerateSelectByHeader(AssocModel asc, TextWriter sw)
 {
 }
コード例 #15
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void GenerateDeleteBySp(AssocModel asc, TextWriter sw)
 {
     Oracle8SpGenerator.DeleteBySp(asc, sw);
 }
コード例 #16
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public int Add(AssocModel ascModel)
 {
     foreach (AssocModel model in m_Items)
       {
     if (model.Name.ToLower().Equals(ascModel.Name.ToLower()))
     {
       throw new ArgumentException("There is already an AssocModel item in the container with the same name.");
     }
       }
       return m_Items.Add(ascModel);
 }
コード例 #17
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void GenerateSelectByHeader(AssocModel asc, TextWriter sw)
 {
     string str = asc.Parent.Parent.SelectBySpName(asc);
       sw.Write(string.Format("PROCEDURE {0}(", str));
       Oracle8SpGenerator.PackageHeaderFieldList(sw, "i{0} IN {1}", asc.ForeignFields);
       sw.Write(", oresult OUT refCursor");
       sw.WriteLine(");");
 }
コード例 #18
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 // Methods
 public static AssocModel Assoc(string name, DataEntityModel parent, DataEntityModel child)
 {
     AssocModel model = new AssocModel(name, parent, child);
       parent += model;
       return model;
 }
コード例 #19
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override string SelectBySpName(AssocModel asc)
 {
     return Oracle8SpGenerator.GetSpName(asc.Parent.Parent, asc, "SelBy");
 }
コード例 #20
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public void Remove(AssocModel ascModel)
 {
     m_Items.Remove(ascModel);
 }
コード例 #21
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static void SelectBySp(AssocModel assocInfo, TextWriter sw)
 {
     string str = assocInfo.Parent.Parent.SelectBySpName(assocInfo);
       TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str));
       HeadingComment(sw, str,                     string.Format("Gets {0} records belonging to {1}.", assocInfo.Child.MappingName,                                   assocInfo.Parent.Name));
       ProcHead(sw, str, assocInfo.ForeignFields, true, false);
       sw.WriteLine("AS");
       sw.WriteLine("BEGIN");
       sw.WriteLine("  OPEN oresult FOR");
       sw.WriteLine("   SELECT");
       FieldList(sw, "      {0}", assocInfo.Child.Fields);
       sw.WriteLine(string.Format("    FROM {0}", assocInfo.Child.Name));
       sw.WriteLine("    WHERE");
       ConditionList(sw, "      {0} = i{0}", assocInfo.ForeignFields);
       sw.WriteLine();
       sw.WriteLine(string.Format("END {0};", str));
       sw.WriteLine();
 }
コード例 #22
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void CreationScript(AssocModel asc, TextWriter sw)
 {
     sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("-- Add foreign key FK{0} ", asc.Name));
       sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("ALTER TABLE {0} ADD", asc.Child.Name));
       sw.WriteLine(string.Format("CONSTRAINT FK{0} FOREIGN KEY", asc.Name));
       sw.WriteLine("(");
       int num = 0;
       foreach (DataFieldModel model in asc.ForeignFields)
       {
     if (num++ > 0)
     {
       sw.WriteLine(",");
     }
     sw.Write(string.Format("  {0}", model.Name));
       }
       sw.WriteLine();
       sw.WriteLine(")");
       sw.WriteLine(string.Format("REFERENCES {0}", asc.Parent.Name));
       sw.WriteLine("(");
       num = 0;
       foreach (DataFieldModel model2 in asc.Parent.PKFields)
       {
     if (num++ > 0)
     {
       sw.WriteLine(",");
     }
     sw.Write(string.Format("  {0}", model2.Name));
       }
       sw.WriteLine();
       sw.Write("); ");
       if (asc.CascadeDelete)
       {
     sw.Write("ON DELETE CASCADE ");
       }
       sw.WriteLine();
       if (!asc.EnforceRelation)
       {
     sw.WriteLine(string.Format("ALTER TABLE {0} DISABLE CONSTRAINT FK{1};", asc.Child.Name, asc.Name));
     sw.WriteLine();
       }
 }
コード例 #23
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void DropScript(AssocModel assoc, TextWriter sw)
 {
     sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("-- Drop foreign key [FK{0}]", assoc.Name));
       sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine("if exists (select * from dbo.sysobjects ");
       sw.WriteLine(string.Format("where id = object_id(N'[dbo].[FK{0}]') and ", assoc.Name));
       sw.WriteLine("OBJECTPROPERTY(id, N'IsForeignKey') = 1)");
       sw.WriteLine(string.Format("alter table [dbo].[{0}] drop constraint [FK{1}]", assoc.Child.Name, assoc.Name));
       sw.WriteLine("GO");
       sw.WriteLine();
 }
コード例 #24
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 // Methods
 public AssocOperation(AssocOperationType type, AssocModel asc)
 {
     m_Type = type;
       m_Assoc = asc;
       base.m_DataLayer = asc.Parent.Parent;
 }
コード例 #25
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override string SelectBySpName(AssocModel asc)
 {
     return Sql2000SpGenerator.GetSpName(asc.Parent.Parent, asc, AssocOperationType.SelectBy);
 }
コード例 #26
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void DropScript(AssocModel assoc, TextWriter sw)
 {
     sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("-- Drop foreign key FK{0}", assoc.Name));
       sw.WriteLine("------------------------------------------------------------------");
       sw.WriteLine(string.Format("ALTER TABLE {0} DROP CONSTRAINT FK{1};", assoc.Child.Name, assoc.Name));
       sw.WriteLine();
 }
コード例 #27
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static string GetSpName(DataAccessModel daLayer, AssocModel asc, AssocOperationType opType)
 {
     return string.Format("{0}{1}{2}", daLayer.Prefix, asc.Name, opType);
 }
コード例 #28
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public override void GenerateDeleteByHeader(AssocModel asc, TextWriter sw)
 {
     string str = asc.Parent.Parent.DeleteBySpName(asc);
       sw.Write(string.Format("PROCEDURE {0}(", str));
       Oracle8SpGenerator.PackageHeaderFieldList(sw, "i{0} IN {1}", asc.ForeignFields);
       sw.Write(", returnValue OUT NUMBER");
       sw.WriteLine(");");
 }
コード例 #29
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public static void SelectBySp(AssocModel assocInfo, TextWriter sw)
 {
     string str = GetSpName(assocInfo.Parent.Parent, assocInfo, AssocOperationType.SelectBy);
       TraceInfoEvent.Raise(string.Format("Generating SP '{0}'.", str));
       HeadingComment(sw, str,                     string.Format("Gets {0} records belonging to {1}.", assocInfo.Child.MappingName,                                   assocInfo.Parent.MappingName));
       ProcHead(sw, str);
       FieldList(sw, "  @{0} {1}", assocInfo.ForeignFields);
       sw.WriteLine("as");
       sw.WriteLine("  select");
       FieldList(sw, "    [{0}]", assocInfo.Child.Fields);
       //sw.WriteLine(string.Format("  from [{0}] with (nolock)", assocInfo.Child.MappingName));
       sw.WriteLine(string.Format("  from [{0}]  with (nolock)", assocInfo.Child.MappingName));
       sw.WriteLine("  where");
       ConditionList(sw, "    {0} = @{0}", assocInfo.ForeignFields);
       sw.WriteLine();
       sw.WriteLine("  return @@rowcount");
       sw.WriteLine("GO");
       sw.WriteLine();
 }
コード例 #30
0
ファイル: all.cs プロジェクト: bmadarasz/ndihelpdesk
 public abstract string DeleteBySpName(AssocModel asc);