Exemplo n.º 1
0
        private static void CopyMC(LinqMicajahDataContext dc, Guid SourceID, Guid DestID)
        {
            MetricCategory SourceMC =
                (from mc in dc.MetricCategory
                 where
                 (mc.InstanceId == LinqMicajahDataContext.InstanceId)
                 &&
                 (mc.MetricCategoryID == SourceID)
                 &&
                 (mc.Status == true)
                 select mc).FirstOrNull();

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

                IQueryable <MetricCategory> SourceMCs =
                    from mc in dc.MetricCategory
                    where
                    (mc.InstanceId == LinqMicajahDataContext.InstanceId)
                    &&
                    (mc.ParentId == SourceID)
                    &&
                    (mc.Status == true)
                    select mc;
                foreach (MetricCategory mc in SourceMCs)
                {
                    CopyMC(dc, mc.MetricCategoryID, cSource.MetricCategoryID);
                }
            }
        }
Exemplo n.º 2
0
 protected void rtvMetricCategory_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.MetricCategory MetricCategory = new Bll.MetricCategory();
         MetricCategory.ParentId   = ParentID;
         MetricCategory.Name       = e.Text;
         MetricCategory.InstanceId = Bll.LinqMicajahDataContext.InstanceId;
         Guid _InsertedItemID = Bll.MetricCategory.Insert(MetricCategory);
         e.Node.Expanded = true;
     }
     else
     {
         if (!String.IsNullOrEmpty(e.Node.Value) && e.Node.Value != "0")
         {
             Guid ID = new Guid(e.Node.Value);
             Bll.MetricCategory.Update(ID, e.Text);
         }
     }
     GenerateTreeView();
 }
Exemplo n.º 3
0
 public static Guid Insert(MetricCategory newMetricCategory)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         dc.MetricCategory.InsertOnSubmit(newMetricCategory);
         dc.SubmitChanges();
         return(newMetricCategory.MetricCategoryID);
     }
 }
Exemplo n.º 4
0
        private static void MergeMC(LinqMicajahDataContext dc, Guid SourceID, Guid DestID)
        {
            IQueryable <GuidPair> Pairs =
                from mc1 in dc.MetricCategory
                join mc2 in dc.MetricCategory
                on mc1.Name equals mc2.Name
                where
                (mc1.InstanceId == LinqMicajahDataContext.InstanceId)
                &&
                (mc2.InstanceId == LinqMicajahDataContext.InstanceId)
                &&
                (mc1.ParentId == SourceID)
                &&
                (mc2.ParentId == DestID)
                &&
                mc1.Status == true
                &&
                mc2.Status == true
                select new GuidPair
            {
                SourceGuid = mc1.MetricCategoryID,
                DestGuid   = mc2.MetricCategoryID
            };

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

            // main merge
            IQueryable <MetricCategory> SourceMCs =
                from mc in dc.MetricCategory
                where
                (mc.InstanceId == LinqMicajahDataContext.InstanceId) && (mc.ParentId == SourceID)
                select mc;

            foreach (MetricCategory _mc in SourceMCs)
            {
                _mc.ParentId = DestID;
            }

            ChangeMetricsCategory(dc, SourceID, DestID);

            MetricCategory SourceMC =
                (from mc in dc.MetricCategory
                 where
                 (mc.InstanceId == LinqMicajahDataContext.InstanceId) && (mc.MetricCategoryID == SourceID)
                 select mc).FirstOrNull();

            if (SourceMC != null)
            {
                SourceMC.Status = false;
            }
            dc.SubmitChanges();
        }
Exemplo n.º 5
0
 public static void Move(Guid SourceID, Guid DestID)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         GuidPair Pair =
             (from mc1 in dc.MetricCategory
              join mc2 in dc.MetricCategory
              on mc1.Name equals mc2.Name
              where
              (mc1.InstanceId == LinqMicajahDataContext.InstanceId)
              &&
              (mc2.InstanceId == LinqMicajahDataContext.InstanceId)
              &&
              (mc1.MetricCategoryID == SourceID)
              &&
              (mc2.ParentId == DestID)
              &&
              mc1.Status == true
              &&
              mc2.Status == true
              select new GuidPair
         {
             SourceGuid = mc1.MetricCategoryID,
             DestGuid = mc2.MetricCategoryID
         }).FirstOrNull();
         if (Pair == null)
         {
             // move
             MetricCategory SourceMC =
                 (from mc in dc.MetricCategory
                  where
                  (mc.InstanceId == LinqMicajahDataContext.InstanceId)
                  &&
                  (mc.MetricCategoryID == SourceID)
                  select mc).FirstOrNull();
             if (SourceMC != null)
             {
                 SourceMC.ParentId = DestID;
             }
             dc.SubmitChanges();
         }
         else
         if (SourceID != Pair.DestGuid)
         {
             MergeMC(dc, SourceID, Pair.DestGuid);    // merge
         }
     }
 }
Exemplo n.º 6
0
 public static void Delete(Guid itemID)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         MetricCategory ret =
             (from _MetricCategory in dc.MetricCategory
              where (_MetricCategory.InstanceId == LinqMicajahDataContext.InstanceId) && (_MetricCategory.MetricCategoryID == itemID)
              select _MetricCategory).FirstOrNull();
         if (ret != null)
         {
             ret.Status = false;
             DeleteChildItems(dc, itemID);
             dc.SubmitChanges();
         }
     }
 }
Exemplo n.º 7
0
        public static void Update(Guid itemID, string text)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                MetricCategory ret =
                    (from _MetricCategory in dc.MetricCategory
                     orderby _MetricCategory.Name
                     where (_MetricCategory.InstanceId == LinqMicajahDataContext.InstanceId) && (_MetricCategory.MetricCategoryID == itemID)
                     select _MetricCategory).FirstOrNull();

                if (ret != null)
                {
                    ret.Name = text;
                    dc.SubmitChanges();
                }
            }
        }