コード例 #1
0
        public int Save(ISARelationshipDTO item)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                ISARelationship dbItem = null;
                if (item.ID == 0)
                {
                    dbItem = new ISARelationship();
                    projectContext.ISARelationship.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.ISARelationship.First(x => x.ID == item.ID);
                }

                dbItem.Name          = item.Name;
                dbItem.IsDisjoint    = item.IsDisjoint;
                dbItem.InternalTable = item.InternalTable == true;
                //dbItem.InternalTableColumnID = item.InternalTableColumnID == 0 ? (int?)null : item.InternalTableColumnID;
                dbItem.IsGeneralization     = item.IsGeneralization;
                dbItem.IsSpecialization     = !item.IsSpecialization;
                dbItem.IsTolatParticipation = item.IsTolatParticipation;
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
コード例 #2
0
        //public List<ISARelationshipDTO> GetISARelationships(int tableDrivedEntityID)
        //{
        //    List<ISARelationshipDTO> result = new List<ISARelationshipDTO>();
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        var list = projectContext.ISARelationship.Where(x => x.TableDrivedEntityID1 == tableDrivedEntityID || x.TableDrivedEntityID2 == tableDrivedEntityID);
        //        foreach (var item in list)
        //        {
        //            result.Add(ToISARelationshipDTO(item));
        //        }
        //    }
        //    return result;
        //}
        private ISARelationshipDTO ToISARelationshipDTO(DataAccess.ISARelationship item)
        {
            ISARelationshipDTO result = new ISARelationshipDTO();

            result.Name          = item.Name;
            result.ID            = item.ID;
            result.InternalTable = item.InternalTable == true;
            //result.InternalTableColumnID = item.InternalTableColumnID ?? 0;
            result.IsGeneralization     = item.IsGeneralization == true;
            result.IsTolatParticipation = item.IsTolatParticipation;
            result.IsDisjoint           = item.IsDisjoint;
            if (item.SuperToSubRelationshipType.Any())
            {
                result.SuperEntityID = item.SuperToSubRelationshipType.First().RelationshipType.Relationship.TableDrivedEntityID1;
            }
            result.SuperTypeEntities = "";
            foreach (var superType in item.SuperToSubRelationshipType)
            {
                if (!result.SuperTypeEntities.Contains(superType.RelationshipType.Relationship.TableDrivedEntity.Name))
                {
                    result.SuperTypeEntities += (result.SuperTypeEntities == "" ? "" : ",") + superType.RelationshipType.Relationship.TableDrivedEntity.Name;
                }
            }
            result.SubTypeEntities = "";
            foreach (var subType in item.SubToSuperRelationshipType)
            {
                result.SubTypeEntities += (result.SubTypeEntities == "" ? "" : ",") + subType.RelationshipType.Relationship.TableDrivedEntity.Name;
            }
            return(result);
        }
コード例 #3
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (txtName.Text == "")
            {
                MessageBox.Show("نام رابطه مشخص نشده است");
                return;
            }
            if (optIsDisjoint.IsChecked == false && optIsOverlap.IsChecked == false)
            {
                MessageBox.Show("نوع " + "Disjoint/IsOverlap" + "مشخص نشده است");
                return;
            }
            if (optIsTolatParticipation.IsChecked == false && optIsPartialParticipation.IsChecked == false)
            {
                MessageBox.Show("نوع " + "TolatParticipation/PartialParticipation" + "مشخص نشده است");
                return;
            }
            BizISARelationship biz = new BizISARelationship();
            var item = new ISARelationshipDTO();

            item.Name                 = txtName.Text;
            item.IsDisjoint           = optIsDisjoint.IsChecked == true;
            item.IsTolatParticipation = optIsTolatParticipation.IsChecked == true;
            item.IsGeneralization     = optIsGeneralization.IsChecked == true;
            item.ID = biz.Save(item);
            if (ISARelationshipSelected != null)
            {
                ISARelationshipSelected(this, new ISARelationshipSelectedArg()
                {
                    ISARelationship = item
                });
            }
            MyProjectManager.GetMyProjectManager.CloseDialog(this);
        }
コード例 #4
0
        public ISARelationshipDTO GetInternalTableISARelationships(int baseEntityID)
        {
            ISARelationshipDTO result = new ISARelationshipDTO();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var isaRelationship = projectContext.ISARelationship.FirstOrDefault(x => x.InternalTable == true && x.SuperToSubRelationshipType.Any(y => y.RelationshipType.Relationship.TableDrivedEntityID1 == baseEntityID));
                if (isaRelationship != null)
                {
                    return(ToISARelationshipDTO(isaRelationship));
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #5
0
 public void MergeISARelationships(string name, List <ISARelationshipDTO> relationships, ISARelationshipDTO selectedOne)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         int isaRelationID = 0;
         foreach (var relationship in relationships)
         {
             //if (relationship == selectedOne)
             //    isaRelationID = relationship.ID;
             //else
             //{
             var dbRelationship = projectContext.ISARelationship.First(x => x.ID == relationship.ID);
             foreach (var detail in dbRelationship.SuperToSubRelationshipType)
             {
                 detail.ISARelationshipID = selectedOne.ID;
             }
             foreach (var detail in dbRelationship.SubToSuperRelationshipType)
             {
                 detail.ISARelationshipID = selectedOne.ID;
             }
             //}
         }
         projectContext.SaveChanges();
     }
 }
コード例 #6
0
 void frm_ISARelationshipSelected(ISARelationshipDTO isaRelationshipDTO, RelationshipDTO relationship, Enum_RelationshipType targetRaltionshipType)
 {
     bizRelationship.ConvertRelationship(MyProjectManager.GetMyProjectManager.GetRequester(), relationship, targetRaltionshipType, isaRelationshipDTO.ID);
 }