Beispiel #1
0
        private static void CopyGCA(LinqMicajahDataContext dc, Guid SourceID, Guid DestID)
        {
            GroupCategoryAspect SourceGCA =
                (from gca in dc.GroupCategoryAspect
                 where
                 (gca.InstanceId == LinqMicajahDataContext.InstanceId)
                 &&
                 (gca.GroupCategoryAspectID == SourceID)
                 &&
                 (gca.Status == true)
                 select gca).FirstOrNull();

            if (SourceGCA != null)
            {
                GroupCategoryAspect cSource = new GroupCategoryAspect();
                cSource.CopyFrom(SourceGCA);
                cSource.ParentId = DestID;
                dc.GroupCategoryAspect.InsertOnSubmit(cSource);
                dc.SubmitChanges();

                IQueryable <GroupCategoryAspect> SourceGCAs =
                    from gca in dc.GroupCategoryAspect
                    where
                    (gca.InstanceId == LinqMicajahDataContext.InstanceId)
                    &&
                    (gca.ParentId == SourceID)
                    &&
                    (gca.Status == true)
                    select gca;
                foreach (GroupCategoryAspect gca in SourceGCAs)
                {
                    CopyGCA(dc, gca.GroupCategoryAspectID, cSource.GroupCategoryAspectID);
                }
            }
        }
Beispiel #2
0
 protected void rtvGCA_NodeEdit(object sender, RadTreeNodeEditEventArgs e)
 {
     if (string.IsNullOrEmpty(e.Node.Value))
     {
         Guid?ParentID = null;
         if (e.Node.ParentNode.Value != "0")
         {
             ParentID = new Guid(e.Node.ParentNode.Value);
         }
         Bll.GroupCategoryAspect gca = new Bll.GroupCategoryAspect();
         gca.ParentId = ParentID;
         gca.Name     = e.Text;
         Guid _InsertedItemID = MetricTrac.Bll.GroupCategoryAspect.Insert(gca);
         e.Node.Expanded = true;
     }
     else
     {
         if (!String.IsNullOrEmpty(e.Node.Value) && e.Node.Value != "0")
         {
             Guid ID = new Guid(e.Node.Value);
             Bll.GroupCategoryAspect.Update(ID, e.Text);
         }
     }
     GenerateTreeView();
 }
Beispiel #3
0
        private static void MergeGCA(LinqMicajahDataContext dc, Guid SourceID, Guid DestID)
        {
            IQueryable <GuidPair> Pairs =
                from gca1 in dc.GroupCategoryAspect
                join gca2 in dc.GroupCategoryAspect
                on new { gca1.InstanceId, gca1.Name }
            equals new { gca2.InstanceId, gca2.Name }
            where
            (gca1.InstanceId == LinqMicajahDataContext.InstanceId)
            &&
            (gca2.InstanceId == LinqMicajahDataContext.InstanceId)
            &&
            (gca1.ParentId == SourceID)
            &&
            (gca2.ParentId == DestID)
            &&
            gca1.Status == true
            &&
            gca2.Status == true
            select new GuidPair
            {
                SourceGuid = gca1.GroupCategoryAspectID,
                DestGuid   = gca2.GroupCategoryAspectID
            };

            foreach (GuidPair gp in Pairs)
            {
                MergeGCA(dc, gp.SourceGuid, gp.DestGuid);
            }

            // main merge
            IQueryable <GroupCategoryAspect> SourceGCAs =
                from gca in dc.GroupCategoryAspect
                where
                (gca.InstanceId == LinqMicajahDataContext.InstanceId)
                &&
                (gca.ParentId == SourceID)
                select gca;

            foreach (GroupCategoryAspect _gca in SourceGCAs)
            {
                _gca.ParentId = DestID;
            }

            GroupCategoryAspect SourceGCA =
                (from gca in dc.GroupCategoryAspect
                 where
                 (gca.InstanceId == LinqMicajahDataContext.InstanceId)
                 &&
                 (gca.GroupCategoryAspectID == SourceID)
                 select gca).FirstOrNull();

            if (SourceGCA != null)
            {
                SourceGCA.Status = false;
            }
            dc.SubmitChanges();
        }
Beispiel #4
0
        /*public static IQueryable<D_GroupCategoryAspect> D_SelectAll()
         * {
         *  LinqMicajahDataContext dc = new LinqMicajahDataContext();
         *  IQueryable<D_GroupCategoryAspect> ret =
         *      from groupCategoryAspect in dc.D_GroupCategoryAspect
         *      where groupCategoryAspect.InstanceId == LinqMicajahDataContext.InstanceId
         *      select groupCategoryAspect;
         *  return ret;
         * }*/

        public static Guid Insert(GroupCategoryAspect newGCA)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                dc.GroupCategoryAspect.InsertOnSubmit(newGCA);
                dc.SubmitChanges();
                return(newGCA.GroupCategoryAspectID);
            }
        }
Beispiel #5
0
 public static void Move(Guid SourceID, Guid DestID)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         GuidPair Pair =
             (from gca1 in dc.GroupCategoryAspect
              join gca2 in dc.GroupCategoryAspect
              on new { gca1.InstanceId, gca1.Name }
              equals new { gca2.InstanceId, gca2.Name }
              where
              (gca1.InstanceId == LinqMicajahDataContext.InstanceId)
              &&
              (gca2.InstanceId == LinqMicajahDataContext.InstanceId)
              &&
              (gca1.GroupCategoryAspectID == SourceID)
              &&
              (gca2.ParentId == DestID)
              &&
              gca1.Status == true
              &&
              gca2.Status == true
              select new GuidPair
         {
             SourceGuid = gca1.GroupCategoryAspectID,
             DestGuid = gca2.GroupCategoryAspectID
         }).FirstOrNull();
         if (Pair == null)
         {
             GroupCategoryAspect SourceGCA =
                 (from gca in dc.GroupCategoryAspect
                  where
                  (gca.InstanceId == LinqMicajahDataContext.InstanceId)
                  &&
                  (gca.GroupCategoryAspectID == SourceID)
                  select gca).FirstOrNull();
             if (SourceGCA != null)
             {
                 SourceGCA.ParentId = DestID;
             }
             dc.SubmitChanges();
         }
         else
         if (SourceID != Pair.DestGuid)
         {
             MergeGCA(dc, SourceID, Pair.DestGuid);    // merge
         }
     }
 }
Beispiel #6
0
        public static void Update(Guid itemID, string text)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                GroupCategoryAspect ret =
                    (from groupCategoryAspect in dc.GroupCategoryAspect
                     orderby groupCategoryAspect.Name
                     where (groupCategoryAspect.InstanceId == LinqMicajahDataContext.InstanceId) && (groupCategoryAspect.GroupCategoryAspectID == itemID)
                     select groupCategoryAspect).FirstOrNull();

                if (ret != null)
                {
                    ret.Name = text;
                    dc.SubmitChanges();
                }
            }
        }
Beispiel #7
0
 public static void Delete(Guid itemID)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         GroupCategoryAspect ret =
             (from groupCategoryAspect in dc.GroupCategoryAspect
              orderby groupCategoryAspect.Name
              where (groupCategoryAspect.InstanceId == LinqMicajahDataContext.InstanceId) && (groupCategoryAspect.GroupCategoryAspectID == itemID)
              select groupCategoryAspect).FirstOrNull();
         if (ret != null)
         {
             ret.Status = false;
             DeleteChildItems(dc, itemID);
             dc.SubmitChanges();
         }
     }
 }