示例#1
0
        public override void CreateEntities(PxMetaModel.PcAxisMetabaseEntities context)
        {
            //Create the valueset
            PxMetaModel.ValueSet vs = new PxMetaModel.ValueSet();
            vs.ValueSet1 = Valueset;
            vs.PresText = PresText;
            vs.Description = PresText;
            vs.Elimination = Elimination;
            vs.ValuePool = ValuePool;
            vs.ValuePres = ValuePres;
            vs.SortCodeExists = "Y";
            vs.Footnote = "S";
            vs.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            vs.LogDate = DateTime.Now;

            context.AddToValueSets(vs);

            PxMetaModel.ValueSet_Eng vsEng = new PxMetaModel.ValueSet_Eng();
            vsEng.ValueSet1 = vs;
            vsEng.PresText = PresTextEnglish;
            vsEng.Description = PresTextEnglish;
            vsEng.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            vsEng.LogDate = DateTime.Now;

            context.AddToValueSet_Eng(vsEng);

            int sortCode = 0;
            foreach (var v in Values)
            {
                sortCode++;
                if (v.IsNew)
                {
                    v.ValuePool = ValuePool;
                    v.Footnote = "N";
                    v.CreateEntities(context);
                }

                //Create vs value
                PxMetaModel.VSValue vsValue = new PxMetaModel.VSValue();
                vsValue.ValueSet1 = vs;
                vsValue.ValuePool = ValuePool;
                vsValue.ValueCode = v.ValueCode;
                int lengthOfCountValues = Values.Count.ToString().Length;
                string stringSortCode = "";
                for (int i = 0; i < lengthOfCountValues - sortCode.ToString().Length; i++)
                {
                    stringSortCode += "0";
                }
                stringSortCode += sortCode.ToString();
                vsValue.SortCode = stringSortCode;
                vsValue.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                vsValue.LogDate = DateTime.Now;

                context.AddToVSValues(vsValue);

                //Create vs value eng
                PxMetaModel.VSValue_Eng vsValueEng = new PxMetaModel.VSValue_Eng();
                vsValueEng.ValueSet1 = vs;
                vsValueEng.ValuePool = ValuePool;
                vsValueEng.ValueCode = v.ValueCode;
                vsValueEng.SortCode = sortCode.ToString();
                vsValueEng.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                vsValueEng.LogDate = DateTime.Now;

                context.AddToVSValue_Eng(vsValueEng);
            }
        }