예제 #1
0
        public List <MdxMember> ExtractMeasureMembers(ObjCalcScript cspt, ref List <Calculation> calcs)
        {
            List <MdxMember> cms = calcs
                                   .Where(x => x.calc_type == CalculationType.MdxMember)
                                   .Select(x => new CalcMember(x))
                                   .Select(x => new MdxMember
            {
                IsMeasure        = x.flag_ms,
                FullCode         = x.prop_ex,
                Name             = x.prop_nm,
                MeasureGroup     = x.prop_mg,
                DisplayFolder    = x.prop_df,
                NonEmptyBehavior = x.prop_ne,
                FormatString     = x.prop_fs,
                Caption          = x.prop_cp,
                Visible          = x.prop_vs,
                SolveOrder       = x.prop_so,
                DateCreated      = x.DateCreated,
                DateModified     = x.DateModified,
                ObjCalcScriptId  = cspt.Id
            })
                                   .ToList();

            calcs.RemoveAll(x => x.calc_type == CalculationType.MdxMember);

            return(cms);
        }
예제 #2
0
        public void AddMdxUnclassifiedCalcListToDB(ObjCalcScript cspt, List <MdxUnclassifiedCalc> muc)
        {
            dbc.MdxUnclassifiedCalc.RemoveRange(dbc.MdxUnclassifiedCalc.Where(s => s.ObjCalcScriptId == cspt.Id));

            muc.ForEach(x => dbc.MdxUnclassifiedCalc.Add(x));
            dbc.SaveChanges();
        }
예제 #3
0
        public void AddMdxSetListToDB(ObjCalcScript cspt, List <MdxSet> es)
        {
            dbc.MdxSet.RemoveRange(dbc.MdxSet.Where(s => s.ObjCalcScriptId == cspt.Id));

            es.ForEach(x => dbc.MdxSet.Add(x));
            dbc.SaveChanges();
        }
예제 #4
0
        public void AddMdxMemberMeasureListToDB(ObjCalcScript cspt, List <MdxMember> emm)
        {
            dbc.MdxMember.RemoveRange(dbc.MdxMember.Where(s => s.ObjCalcScriptId == cspt.Id));

            emm.ForEach(x => dbc.MdxMember.Add(x));
            dbc.SaveChanges();
        }
예제 #5
0
        public void AddMdxScopeListToDB(ObjCalcScript cspt, List <MdxScope> esc)
        {
            dbc.MdxScope.RemoveRange(dbc.MdxScope.Where(s => s.ObjCalcScriptId == cspt.Id));

            esc.ForEach(x => dbc.MdxScope.Add(x));
            dbc.SaveChanges();
        }
예제 #6
0
        public List <MdxScope> ExtractScopes(ObjCalcScript cspt, ref List <Calculation> calcs)
        {
            List <Tuple <int, int> > tpls   = new List <Tuple <int, int> >();
            List <MdxScope>          scopes = new List <MdxScope>();

            int state = 0;
            int start = 0;

            for (int i = 0; i < calcs.Count; i++)
            {
                switch (calcs[i].calc_type)
                {
                case CalculationType.MdxScopeBegin:
                {
                    state++;
                    if (state == 1)
                    {
                        start = i;
                    }
                    break;
                }

                case CalculationType.MdxScopeEnd:
                {
                    state--;
                    if (state == 0)
                    {
                        tpls.Add(new Tuple <int, int>(start, i));
                    }
                    break;
                }
                }
            }

            foreach (Tuple <int, int> t in tpls.OrderByDescending(o => o.Item1))
            {
                string s =
                    string.Join(Environment.NewLine,
                                calcs
                                .Skip(t.Item1)
                                .Take(t.Item2 - t.Item1 + 1)
                                .Select(x => x.fullcode + ";")
                                );
                scopes.Add(new MdxScope
                {
                    Code            = s,
                    ObjCalcScriptId = cspt.Id,
                    DateCreated     = DateTime.Now,
                    DateModified    = DateTime.Now
                });

                calcs.RemoveRange(t.Item1, t.Item2 - t.Item1 + 1);
            }

            return(scopes);
        }
예제 #7
0
        public List <Calculation> SplitToCalculations(ObjCalcScript cspt)
        {
            List <Calculation> calculations = prs
                                              .Divide(cspt.CalculationScriptText, breakPairs, ';', bracketPairs)
                                              .Select(x => new Calculation(x, SplitToProperties(x)))
                                              .ToList()
            ;

            return(calculations);
        }
예제 #8
0
        private void AddObjCalcScript(ObjCalcScript obj)
        {
            dbc.ObjCalcScript
            .Where(b => b.CubeId == obj.CubeId)
            .ToList()
            .ForEach(c => c.IsActive = 0);

            dbc.ObjCalcScript
            .Add(obj);

            dbc.SaveChanges();
        }
예제 #9
0
        public ObjCalcScript GetScript()
        {
            if (cb == null)
            {
                return(null);
            }
            ObjCalcScript cs = dbc.ObjCalcScript
                               .Where(b => b.Cube.Name == cb.Name &&
                                      b.Cube.Project.ProjectName == prj.ProjectName &&
                                      b.IsActive == 1)
                               .Single()
            ;

            return(cs);
        }
예제 #10
0
        public List <MdxSet> ExtractSets(ObjCalcScript cspt, ref List <Calculation> calcs)
        {
            List <MdxSet> cms = calcs
                                .Where(x => x.calc_type == CalculationType.MdxSet)
                                .Select(x => new CalcSet(x))
                                .Select(x => new MdxSet
            {
                Name            = x.prop_nm,
                FullCode        = x.prop_ex,
                Caption         = x.prop_cp,
                DisplayFolder   = x.prop_df,
                IsSession       = x.flag_is,
                IsDynamic       = x.flag_id,
                IsHidden        = x.flag_ih,
                DateCreated     = x.DateCreated,
                DateModified    = x.DateModified,
                ObjCalcScriptId = cspt.Id
            })
                                .ToList();

            calcs.RemoveAll(x => x.calc_type == CalculationType.MdxSet);
            return(cms);
        }
예제 #11
0
        public void SplitScript()
        {
            ObjCalcScript cs = dbc.GetScript();
            //  split
            List <Calculation> cspts = extractor.SplitToCalculations(cs);

            //  extract
            List <MdxScope>  esc = extractor.ExtractScopes(cs, ref cspts);
            List <MdxMember> emm = extractor.ExtractMeasureMembers(cs, ref cspts);
            List <MdxSet>    est = extractor.ExtractSets(cs, ref cspts);

            List <MdxUnclassifiedCalc> muc = cspts.Select(x => new MdxUnclassifiedCalc
            {
                FullCode        = x.fullcode,
                ObjCalcScriptId = cs.Id
            }).ToList();

            //  add to db
            dbc.AddMdxScopeListToDB(cs, esc);
            dbc.AddMdxMemberMeasureListToDB(cs, emm);
            dbc.AddMdxSetListToDB(cs, est);
            dbc.AddMdxUnclassifiedCalcListToDB(cs, muc);
        }