public static void ClearInputValues(int maxgen)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                IQueryable <MetricValue> metricValue =
                    from mv in dc.MetricValue
                    join m in dc.Metric on
                    new { mv.InstanceId, mv.MetricID } equals
                new { m.InstanceId, m.MetricID }
                where
                mv.Status == true &&
                mv.IsCalc == true &&
                m.Generation == maxgen
                select mv;

                foreach (MetricValue mv in metricValue)
                {
                    mv.InProcess = true;
                    mv.IsCalc    = false;
                }
                dc.SubmitChanges();

                IQueryable <MetricValue> _metricValue =
                    from mv in dc.MetricValue
                    where
                    mv.InProcess == true
                    select mv;

                foreach (MetricValue mv in _metricValue)
                {
                    mv.InProcess = false;
                }
                dc.SubmitChanges();
            }
        }
Exemple #2
0
        public static void InsertOrUpdate(Extend MetricFilter, bool InsertMode)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                if (!InsertMode)
                {
                    IQueryable <MetricFilterOrgLocation> OldMetricFilterOrgLocation
                        = from drol in dc.MetricFilterOrgLocation
                          where drol.InstanceId == LinqMicajahDataContext.InstanceId && drol.MetricFilterID == MetricFilter.MetricFilterID
                          select drol;

                    IQueryable <MetricFilterPerformanceIndicator> OldMetricFilterPerformanceIndicator
                        = from drpi in dc.MetricFilterPerformanceIndicator
                          where drpi.InstanceId == LinqMicajahDataContext.InstanceId && drpi.MetricFilterID == MetricFilter.MetricFilterID
                          select drpi;
                    IQueryable <MetricFilterMetric> OldMetricFilterMetric
                        = from drm in dc.MetricFilterMetric
                          where drm.InstanceId == LinqMicajahDataContext.InstanceId && drm.MetricFilterID == MetricFilter.MetricFilterID
                          select drm;
                    dc.MetricFilterOrgLocation.DeleteAllOnSubmit(OldMetricFilterOrgLocation);
                    dc.MetricFilterPerformanceIndicator.DeleteAllOnSubmit(OldMetricFilterPerformanceIndicator);
                    dc.MetricFilterMetric.DeleteAllOnSubmit(OldMetricFilterMetric);
                    dc.SubmitChanges();
                }
                foreach (Guid?NewOrgLocationID in MetricFilter.FilterOrgLocation)
                {
                    MetricFilterOrgLocation NewOrgLocation = new MetricFilterOrgLocation();
                    NewOrgLocation.InstanceId                = LinqMicajahDataContext.InstanceId;
                    NewOrgLocation.MetricFilterID            = MetricFilter.MetricFilterID;
                    NewOrgLocation.OrgLocationID             = (Guid)NewOrgLocationID;
                    NewOrgLocation.MetricFilterOrgLocationID = Guid.NewGuid();
                    dc.MetricFilterOrgLocation.InsertOnSubmit(NewOrgLocation);
                }
                foreach (Guid?NewPIID in MetricFilter.FilterPI)
                {
                    MetricFilterPerformanceIndicator NewPI = new MetricFilterPerformanceIndicator();
                    NewPI.InstanceId                         = LinqMicajahDataContext.InstanceId;
                    NewPI.MetricFilterID                     = MetricFilter.MetricFilterID;
                    NewPI.PerformanceIndicatorID             = (Guid)NewPIID;
                    NewPI.MetricFilterPerformanceIndicatorID = Guid.NewGuid();
                    dc.MetricFilterPerformanceIndicator.InsertOnSubmit(NewPI);
                }
                foreach (Guid?NewMetricID in MetricFilter.FilterMetric)
                {
                    MetricFilterMetric NewMetric = new MetricFilterMetric();
                    NewMetric.InstanceId           = LinqMicajahDataContext.InstanceId;
                    NewMetric.MetricFilterID       = MetricFilter.MetricFilterID;
                    NewMetric.MetricID             = (Guid)NewMetricID;
                    NewMetric.MetricFilterMetricID = Guid.NewGuid();
                    dc.MetricFilterMetric.InsertOnSubmit(NewMetric);
                }
                dc.SubmitChanges();
            }
            return;
        }
        public static void MakeFormulaRelatedInputsDirty(Guid OldMetricFormulaID, Guid NewFormulaID)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                List <MetricValue> InputMetricValue =
                    (from m in dc.Metric
                     join mr in dc.MetricRelation
                     on new { m.InstanceId, m.MetricID } equals new { mr.InstanceId, mr.MetricID }
                     join mv in dc.MetricValue
                     on new { m.InstanceId, m.MetricID } equals new { mv.InstanceId, mv.MetricID }
                     where

                     /*m.MetricTypeID == 1
                      * &&*/
                     m.MetricDataTypeID == 1
                     &&
                     mv.Status == true
                     &&
                     (mr.MetricFormulaID == OldMetricFormulaID || mr.MetricFormulaID == NewFormulaID)
                     select mv).ToList();
                foreach (MetricValue mv in InputMetricValue)
                {
                    mv.IsCalc    = true;
                    mv.InProcess = false;
                }
                try
                {
                    dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                }
                catch (ChangeConflictException)
                {
                    foreach (ObjectChangeConflict conflict in dc.ChangeConflicts)
                    {
                        foreach (MemberChangeConflict memberConflict in conflict.MemberConflicts)
                        {
                            if (memberConflict.Member.Name.Equals("IsCalc") || memberConflict.Member.Name.Equals("InProcess"))
                            {
                                memberConflict.Resolve(RefreshMode.KeepCurrentValues);
                            }
                            else
                            {
                                memberConflict.Resolve(RefreshMode.OverwriteCurrentValues);
                            }
                        }
                    }
                    dc.SubmitChanges(ConflictMode.ContinueOnConflict);
                }
            }
        }
Exemple #4
0
        // ==========================================

        // === PerformanceIndicatorForm Edit - Main Methods for PIFEdit page
        public static void AddPerformanceIndicatorsToForm(Guid PIFID, Guid[] PerfomanceIndicators)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                foreach (Guid pi in PerfomanceIndicators)
                {
                    PerformanceIndicatorFormPerformanceIndicatorJunc ret =
                        (from pifj in dc.PerformanceIndicatorFormPerformanceIndicatorJunc
                         where (pifj.InstanceId == LinqMicajahDataContext.InstanceId) && (pifj.PerformanceIndicatorFormID == PIFID) && (pifj.PerformanceIndicatorID == pi)
                         select pifj).FirstOrNull();
                    if (ret != null)
                    {
                        ret.Status = true;
                    }
                    else
                    {
                        PerformanceIndicatorFormPerformanceIndicatorJunc newPIFJ = new PerformanceIndicatorFormPerformanceIndicatorJunc();
                        newPIFJ.InstanceId = LinqMicajahDataContext.InstanceId;
                        newPIFJ.PerformanceIndicatorFormID = PIFID;
                        newPIFJ.PerformanceIndicatorID     = pi;
                        dc.PerformanceIndicatorFormPerformanceIndicatorJunc.InsertOnSubmit(newPIFJ);
                    }
                }
                dc.SubmitChanges();
            }
        }
Exemple #5
0
        public override void OnDeleting(LinqMicajahDataContext c, ref bool Cancel)
        {
            base.OnDeleting(c, ref Cancel);
            Cancel = true;

            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                IQueryable rets =
                    from pifpij in dc.PerformanceIndicatorFormPerformanceIndicatorJunc
                    where (pifpij.InstanceId == LinqMicajahDataContext.InstanceId)
                    &&
                    (pifpij.PerformanceIndicatorFormID == PerformanceIndicatorFormID)
                    &&
                    (pifpij.Status == true)
                    select pifpij;

                foreach (PerformanceIndicatorFormPerformanceIndicatorJunc pifpij in rets)
                {
                    if (pifpij != null)
                    {
                        pifpij.Status = false;
                    }
                }

                PerformanceIndicatorForm ret =
                    (from pif in dc.PerformanceIndicatorForm
                     where (pif.InstanceId == LinqMicajahDataContext.InstanceId) && (pif.PerformanceIndicatorFormID == PerformanceIndicatorFormID)
                     select pif).FirstOrNull();
                if (ret != null)
                {
                    ret.Status = false;
                }
                dc.SubmitChanges();
            }
        }
Exemple #6
0
        public static void SavePeriod(string PeriodType1, string PeriodType2, DateTime?Begin1, DateTime?End1, DateTime?Begin2, DateTime?End2)
        {
            if (LinqMicajahDataContext.LogedUserId == null)
            {
                return;
            }
            int?Id1 = GepPeriodTypeId(PeriodType1);
            int?Id2 = GepPeriodTypeId(PeriodType2);

            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                var  cp    = dc.ScoreCardCompPeriod.Where(p => p.UserId == (Guid)LinqMicajahDataContext.LogedUserId).FirstOrNull();
                bool IsNew = cp == null;
                if (IsNew)
                {
                    cp = new ScoreCardCompPeriod();
                    cp.ScoreCardCompPeriodId = Guid.NewGuid();
                }

                cp.UserId      = (Guid)LinqMicajahDataContext.LogedUserId;
                cp.PeriodType1 = Id1;
                cp.PeriodType2 = Id2;
                cp.Begin1      = Begin1;
                cp.End1        = End1;
                cp.Begin2      = Begin2;
                cp.End2        = End2;

                if (IsNew)
                {
                    dc.ScoreCardCompPeriod.InsertOnSubmit(cp);
                }
                dc.SubmitChanges();
            }
        }
Exemple #7
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);
                }
            }
        }
Exemple #8
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);
                }
            }
        }
Exemple #9
0
        public static void FillPeriodDate()
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                dc.ExecuteCommand("delete from D_PeriodDate");
                for (int FrequencyID = 1; FrequencyID <= 11; FrequencyID++)
                {
                    DateTime b = new DateTime(2000, 1, 1);
                    b = GetNormalizedDate(FrequencyID, b);
                    DateTime dt;
                    DateTime EndDt        = new DateTime(2075, 1, 1);
                    int      PeriodNumber = 0;

                    do
                    {
                        dt = AddPeriod(b, FrequencyID, PeriodNumber);
                        D_PeriodDate r = new D_PeriodDate()
                        {
                            FrequencyID  = FrequencyID,
                            Date         = dt,
                            PeriodNumber = PeriodNumber,
                            ShortName    = GetPeriodName(dt, FrequencyID, true),
                            LongName     = GetPeriodName(dt, FrequencyID, false)
                        };
                        dc.D_PeriodDate.InsertOnSubmit(r);
                        dc.SubmitChanges();
                        PeriodNumber++;
                    }while (dt <= EndDt);
                }
            }
        }
Exemple #10
0
        public static void SaveColumns(Guid DataViewTypeID, List <string> TableColumns, int DataViewColumnListTypeID, Guid DataViewListID)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                var NeedDelColumns = dc.DataViewColumn.Where(c => c.DataViewColumnListTypeID == DataViewColumnListTypeID && c.Status == true && c.InstanceId == LinqMicajahDataContext.InstanceId && c.DataViewListID == DataViewListID).ToList();
                dc.DataViewColumn.DeleteAllOnSubmit(NeedDelColumns);

                for (int i = 0; i < TableColumns.Count; i++)
                {
                    string         NeedInsertColumn = TableColumns[i];
                    string []      ss = NeedInsertColumn.Split(',');
                    DataViewColumn c  = new DataViewColumn()
                    {
                        TableName                = ss[0],
                        ColumnName               = ss[1],
                        DataViewListID           = DataViewListID,
                        DataViewColumnListTypeID = DataViewColumnListTypeID,
                        OrderNumber              = i
                    };
                    dc.DataViewColumn.InsertOnSubmit(c);
                }

                dc.SubmitChanges();
            }
        }
Exemple #11
0
        public static void Delete(Guid MetricID)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                /*var M = (from m in dc.Metric where m.MetricID == MetricID select m).FirstOrNull();
                 * if (M != null)
                 * {
                 *  dc.Metric.DeleteOnSubmit(M);
                 *  dc.SubmitChanges();
                 * }*/
                var PIMecricJuncs = from j in dc.PerformanceIndicatorMetricJunc
                                    where j.MetricID == MetricID && j.Status == true &&
                                    j.InstanceId == LinqMicajahDataContext.InstanceId
                                    select j;

                foreach (PerformanceIndicatorMetricJunc j in PIMecricJuncs)
                {
                    j.Status = false;
                }

                Metric ret =
                    (from m in dc.Metric
                     where (m.InstanceId == LinqMicajahDataContext.InstanceId) && (m.MetricID == MetricID)
                     select m).FirstOrNull();
                if (ret != null)
                {
                    ret.Status = false;
                }
                dc.SubmitChanges();
            }
        }
Exemple #12
0
        public static void Insert(Guid PerformanceIndicatorID, Guid MetricID)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                PerformanceIndicatorMetricJunc PiMJ =
                    (
                        from j in dc.PerformanceIndicatorMetricJunc
                        where
                        j.InstanceId == LinqMicajahDataContext.InstanceId &&
                        j.PerformanceIndicatorID == PerformanceIndicatorID &&
                        j.MetricID == MetricID
                        select j
                    ).FirstOrNull();

                if (PiMJ == null)
                {
                    PiMJ = new PerformanceIndicatorMetricJunc();
                    PiMJ.PerformanceIndicatorID = PerformanceIndicatorID;
                    PiMJ.MetricID = MetricID;

                    dc.PerformanceIndicatorMetricJunc.InsertOnSubmit(PiMJ);
                }
                else
                {
                    PiMJ.Status = true;
                }

                dc.SubmitChanges();
            }
        }
Exemple #13
0
        public static void HideAllPublicScoreCards()
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                var r = from c in dc.ScoreCard
                        join _h in dc.ScoreCardHidden on new { c.InstanceId, c.ScoreCardID, CurrentUserId = LinqMicajahDataContext.LogedUserId } equals new { _h.InstanceId, _h.ScoreCardID, CurrentUserId = (Guid?)_h.UserId } into __h
                from h in __h.DefaultIfEmpty()
                where c.InstanceId == LinqMicajahDataContext.InstanceId && c.Status == true &&
                (c.IsPublic && h.ScoreCardHiddenID == null && (LinqMicajahDataContext.LogedUserId != c.UserId || c.UserId == null))
                select new Extend
                {
                    InstanceId  = c.InstanceId,
                    ScoreCardID = c.ScoreCardID
                };

                var l = r.ToList();

                foreach (Extend cs in l)
                {
                    ScoreCardHidden sch = new ScoreCardHidden();
                    sch.ScoreCardID = cs.ScoreCardID;
                    sch.UserId      = (Guid)LinqMicajahDataContext.LogedUserId;
                    sch.Created     = DateTime.Now;
                    dc.ScoreCardHidden.InsertOnSubmit(sch);
                }
                dc.SubmitChanges();
            }
        }
Exemple #14
0
 public static void InsertOrgLocationsClusterList(Guid RuleID, Guid?[] OrgLocationsID)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         DataRule FirstRule = (from r in dc.DataRule
                               where r.InstanceId == LinqMicajahDataContext.InstanceId && r.Status == true && r.DataRuleID == RuleID
                               select r).FirstOrNull();
         if (FirstRule != null && OrgLocationsID.Length > 1)
         {
             for (int i = 1; i < OrgLocationsID.Length; i++)
             {
                 DataRule OneMoreRule = new DataRule();
                 OneMoreRule.InstanceId                 = FirstRule.InstanceId;
                 OneMoreRule.DataRuleID                 = Guid.NewGuid();
                 OneMoreRule.DataRuleTypeID             = FirstRule.DataRuleTypeID;
                 OneMoreRule.OrderNumber                = FirstRule.OrderNumber;
                 OneMoreRule.OrgLocationID              = OrgLocationsID[i];
                 OneMoreRule.GroupCategoryAspectID      = FirstRule.GroupCategoryAspectID;
                 OneMoreRule.PerformanceIndicatorID     = FirstRule.PerformanceIndicatorID;
                 OneMoreRule.PerformanceIndicatorFormID = FirstRule.PerformanceIndicatorFormID;
                 OneMoreRule.MetricID      = FirstRule.MetricID;
                 OneMoreRule.UserId        = FirstRule.UserId;
                 OneMoreRule.GroupId       = FirstRule.GroupId;
                 OneMoreRule.Status        = FirstRule.Status;
                 OneMoreRule.Created       = FirstRule.Created;
                 OneMoreRule.Updated       = FirstRule.Updated;
                 OneMoreRule.Description   = FirstRule.Description;
                 OneMoreRule.RuleClusterID = FirstRule.RuleClusterID;
                 dc.DataRule.InsertOnSubmit(OneMoreRule);
             }
             dc.SubmitChanges();
         }
     }
 }
Exemple #15
0
        public static void Move(Guid DataRuleID, bool Up, int DataRuleTypeID)
        {
            LinqMicajahDataContext dc = new LinqMicajahDataContext();
            MoveDataRule           mr;

            if (Up)
            {
                mr = (from r0 in dc.DataRule

                      where r0.DataRuleID == DataRuleID &&
                      r0.InstanceId == LinqMicajahDataContext.InstanceId &&
                      r0.Status == true && r0.DataRuleTypeID == DataRuleTypeID

                      select new MoveDataRule
                {
                    r0 = r0,
                    r1 = (from _r1 in dc.DataRule
                          orderby _r1.OrderNumber descending
                          where _r1.OrderNumber < r0.OrderNumber &&
                          _r1.InstanceId == LinqMicajahDataContext.InstanceId &&
                          _r1.Status == true && _r1.DataRuleTypeID == DataRuleTypeID
                          select _r1).FirstOrDefault()
                }).FirstOrDefault();
            }
            else
            {
                mr = (from r0 in dc.DataRule

                      where r0.DataRuleID == DataRuleID &&
                      r0.InstanceId == LinqMicajahDataContext.InstanceId &&
                      r0.Status == true && r0.DataRuleTypeID == DataRuleTypeID

                      select new MoveDataRule
                {
                    r0 = r0,
                    r1 = (from _r1 in dc.DataRule
                          orderby _r1.OrderNumber
                          where _r1.OrderNumber > r0.OrderNumber &&
                          _r1.InstanceId == LinqMicajahDataContext.InstanceId &&
                          _r1.Status == true && _r1.DataRuleTypeID == DataRuleTypeID
                          select _r1).FirstOrDefault()
                }).FirstOrDefault();
            }

            if (mr == null || mr.r0 == null || mr.r1 == null)
            {
                return;
            }

            int R0Number = mr.r0.OrderNumber;
            int R1Number = mr.r1.OrderNumber;

            mr.r0.OrderNumber = R1Number;
            mr.r1.OrderNumber = R0Number;

            dc.SubmitChanges();
            UpdateD_DataRule(dc);
        }
Exemple #16
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();
        }
Exemple #17
0
 public static Guid Insert(MetricCategory newMetricCategory)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         dc.MetricCategory.InsertOnSubmit(newMetricCategory);
         dc.SubmitChanges();
         return(newMetricCategory.MetricCategoryID);
     }
 }
Exemple #18
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);
            }
        }
Exemple #19
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();
        }
Exemple #20
0
 public static void ViewAllScoreCards()
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         IQueryable <ScoreCardHidden> hiddens = from sch in dc.ScoreCardHidden where sch.UserId == LinqMicajahDataContext.LogedUserId && sch.InstanceId == LinqMicajahDataContext.InstanceId select sch;
         foreach (ScoreCardHidden s in hiddens)
         {
             dc.ScoreCardHidden.DeleteOnSubmit(s);
         }
         dc.SubmitChanges();
     }
 }
Exemple #21
0
 // Hidden ScoreCards
 public static void HideScoreCard(Guid ScoreCardId)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         ScoreCardHidden sch = new ScoreCardHidden();
         sch.ScoreCardID = ScoreCardId;
         sch.UserId      = (Guid)LinqMicajahDataContext.LogedUserId;
         sch.Created     = DateTime.Now;
         dc.ScoreCardHidden.InsertOnSubmit(sch);
         dc.SubmitChanges();
     }
 }
Exemple #22
0
        public static void SaveWhere(Guid DataViewTypeID, List<Extend> WhereCriteria, string Condition, int DataViewColumnListTypeID, Guid DataViewListID)
        {
            using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
            {
                var wl = (from l in dc.DataViewList
                         where l.InstanceId == LinqMicajahDataContext.InstanceId && l.Status == true &&
                            l.DataViewListID == DataViewListID
                         select l).FirstOrNull();

                if (wl == null) return;
                wl.WhereCondition = Condition;

                var ColumnForDel = (from c in dc.DataViewColumn
                             where c.InstanceId == LinqMicajahDataContext.InstanceId && c.Status == true &&
                             c.DataViewColumnListTypeID == DataViewColumnListTypeID && c.DataViewListID == DataViewListID
                             select c).ToList();
                var ColumnForDelID = ColumnForDel.Select(c=>c.DataViewColumnID).ToList();
                var WhereForDel = from w in dc.DataViewWhere
                                  where w.InstanceId == LinqMicajahDataContext.InstanceId && w.Status == true &&
                                    w.DataViewListID == DataViewListID && w.Slave== (DataViewColumnListTypeID!=2)
                                  select w;
                dc.DataViewColumn.DeleteAllOnSubmit(ColumnForDel);
                dc.DataViewWhere.DeleteAllOnSubmit(WhereForDel);

                foreach (var w in WhereCriteria)
                {
                    DataViewColumn NewColumn = new DataViewColumn()
                    {
                        TableName = w.TableName,
                        ColumnName = w.ColumnName,
                        DataViewListID = DataViewListID,
                        DataViewColumnListTypeID = DataViewColumnListTypeID,
                        InstanceId = LinqMicajahDataContext.InstanceId,
                        OrderNumber = WhereCriteria.IndexOf(w),
                        DataViewColumnID = Guid.NewGuid()
                    };
                    dc.DataViewColumn.InsertOnSubmit(NewColumn);

                    DataViewWhere NewWhere = new DataViewWhere()
                    {
                        DataViewListID = DataViewListID,
                        DataViewColumnID = NewColumn.DataViewColumnID,
                        DataViewConditionTypeID = w.DataViewConditionTypeID,
                        CompareValue = w.CompareValue,
                        Slave = (DataViewColumnListTypeID!=2)
                    };
                    dc.DataViewWhere.InsertOnSubmit(NewWhere);
                }

                dc.SubmitChanges();
            }
        }
Exemple #23
0
 public static void LogAppMessage(string Code, string Message)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         ApplicationLog AppLog = new ApplicationLog();
         AppLog.ApplicationLogID = Guid.NewGuid();
         AppLog.Code             = Code;
         AppLog.Message          = Message;
         AppLog.Created          = DateTime.Now;
         dc.ApplicationLog.InsertOnSubmit(AppLog);
         dc.SubmitChanges();
     }
 }
Exemple #24
0
        public static void LogChange(LinqMicajahDataContext dc, Guid MetricValueID, MetricValueChangeTypeEnum Type, string OldValue, string NewValue, string ChangeMessage)
        {
            MetricValueChangeLog change = new MetricValueChangeLog();

            change.OldValue                = OldValue;
            change.NewValue                = NewValue;
            change.Event                   = ChangeMessage;
            change.MetricValueID           = MetricValueID;
            change.MetricValueChangeTypeID = (int)Type;
            change.CreatedTime             = DateTime.Now;
            change.UserId                  = Micajah.Common.Security.UserContext.Current.UserId;
            dc.MetricValueChangeLog.InsertOnSubmit(change);
            dc.SubmitChanges();
        }
Exemple #25
0
 public static void RemovePerformanceIndicator(Guid PIFID, Guid PerformanceIndicatorID)
 {
     using (LinqMicajahDataContext dc = new LinqMicajahDataContext())
     {
         PerformanceIndicatorFormPerformanceIndicatorJunc ret =
             (from pifj in dc.PerformanceIndicatorFormPerformanceIndicatorJunc
              where (pifj.InstanceId == LinqMicajahDataContext.InstanceId) && (pifj.PerformanceIndicatorFormID == PIFID) && (pifj.PerformanceIndicatorID == PerformanceIndicatorID)
              select pifj).FirstOrNull();
         if (ret != null)
         {
             ret.Status = false;
         }
         dc.SubmitChanges();
     }
 }
Exemple #26
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
         }
     }
 }
Exemple #27
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
         }
     }
 }
Exemple #28
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();
         }
     }
 }
Exemple #29
0
        private static void ChangeMetricsCategory(LinqMicajahDataContext dc, Guid SourceID, Guid DestID)
        {
            IQueryable <Metric> ms =
                from m in dc.Metric
                where
                (m.InstanceId == LinqMicajahDataContext.InstanceId) &&
                (m.MetricCategoryID == SourceID) &&
                (m.Status == true)
                select m;

            foreach (Metric m in ms)
            {
                m.MetricCategoryID = DestID;
            }
            dc.SubmitChanges();
        }
Exemple #30
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();
                }
            }
        }