查询实体树中的实体以参照形式展示

by 勾成图 2012.3.30 15:11

注:脚本执行有风险,对于客户正式环境请在研发指导下执行。

参考代码

\\vm97\CCViews2.5_Int\U9UICode\U9.VOB.PD.MFG.V2.5\MO\Code\DiscreteMOUI\Action\DiscreteMOBListUIModelActionExtend.cs

获取CaseModle后,调整CaseModel中CaseDefine,使得实体以参照形式呈现
CaseModel caseModel = beQryStrategyImpl.GetQryModel();
 // 自定义caseModel
SetCase(caseModel);//大家可以参考这个方法的写法来做自己的业务

        /// <summary>
        /// 设置参照属性
        /// </summary>
        /// <param name="caseModel"></param>
        /// <param name="filterDefName"></param>
        /// <param name="CodeField"></param>
        /// <param name="NameField"></param>
        /// <param name="ContainerID"></param>
        /// <param name="EntityID"></param>
        /// <param name="customInParams"></param>
        private static void SetRefDefine(CaseModel caseModel,
            string filterDefName,
            string CodeField,
            string NameField,
            Guid ContainerID,
            Guid EntityID,
            string customInParams)
        {
            FilterDefine filterDef = caseModel.CaseDefine.FilterDefines.GetObjectByName(filterDefName);
            if (filterDef == null)
            {
                filterDef = caseModel.Case.FilterDefines.GetObjectByName(filterDefName);
            }
            if (filterDef == null) { return; }
            QryService.ModifyReference(caseModel,new RefElements(EntityID,ContainerID,filterDef.Name,  NameField, CodeField),  FilterDataType.Number);
            filterDef.Reference.ReferenceObject.ReturnValueField = "ID";
            filterDef.Reference.ReferenceObject.ValueField = CodeField;
            filterDef.Expression = filterDefName.Replace("_", ".") + ".ID";

            RefCondition refCondition = new RefCondition();
            RefConditions refConditionS = new RefConditions();
            if (!string.IsNullOrEmpty(customInParams))
            {
                refCondition.IsFixed = true;
                refCondition.ParameterName = "OperatorType";
                // 从上下文中获取当前的雇佣组织
                refCondition.ParameterValue = "3";
                // 确定传来的Ref_Value是常量还是参数名称
                refCondition.IsFixed = true;
                refConditionS.Add(refCondition);
                // refCondition.CustomInParams = customInParams;
                filterDef.Reference.ReferenceObject.RefCondCollection.Clear();
                filterDef.Reference.ReferenceObject.RefCondCollection = refConditionS;
            }
        }

 

 

//下面代码是甚至具体的Entity为参照形式
private void SetCase(CaseModel caseModel)
{
           SetRefDefine(caseModel,
                "ItemMaster",
                "Code",
                "Name",
                new Guid("73819e01-cb6c-4290-b117-d91acbf09148"),
                new Guid("636D3E47-48AA-47FC-ACA4-E6322BCE775B"),
                ItemMasterRefParams);
            // 单据类型 id="81afd993-c6a3-4769-b791-e4a192d60038"
            // name="MODocType4MORef"
            // displayName="生产订单单据类型"
            SetRefDefine(caseModel,
                "MODocType",
                "Code",
                "Name",
                new Guid("81AFD993-C6A3-4769-B791-E4A192D60038"),
                new Guid("EFCFE968-0CEB-4ADA-A8DD-67322F2D8708"),
                string.Empty);
            // 单位 id="0a5acc31-5e32-4a1d-a634-1f45344a64fd"
            // name="UOM4MFGRef"
            // displayName="计量单位"
            SetRefDefine(caseModel,
                new List<string>(new string[] {          
                  "ProductUOM",
                    "ProductBaseUOM",         
                    "CostBaseUOM",
                    "CostUOM",          
                    "StoreBaseUOM",
                    "RcvUOM",}),
                    "Code",
                    "Name",
                    new Guid("0A5ACC31-5E32-4A1D-A634-1F45344A64FD"),
                    new Guid("EFCFE968-0CEB-4ADA-A8DD-67322F2D8708"),
                    string.Empty);
            // 存储地点
            SetRefDefine(caseModel,
                "CompleteWh",
                "Code",
                "Name",
                // dbo.UBF_MD_UIReference表中的Container
                new Guid("1dc5d0ff-a06e-4dd8-a056-f1b266104b57"),
                // dbo.UBF_MD_UIReference表中的RefEntityId
                new Guid("0FAC5C83-2AB0-428F-BF82-C363857B37BE"),
                string.Empty);
            // 成本域 id="977c3d31-bb7f-4564-bdf8-a1b61ab282e9"
            // name="CostField4MFGRef"
            // displayName="成本域"           
            SetRefDefine(caseModel,
                "CostField",
                "Code",
                "Name",
                // dbo.UBF_MD_UIReference表中的Container
                new Guid("977C3D31-BB7F-4564-BDF8-A1B61AB282E9"),
                // dbo.UBF_MD_UIReference表中的RefEntityId          
                new Guid("633A12E7-2981-47A2-8F40-4BA5F8DDF3FA"),
                string.Empty);

            // 备料料品
            SetRefDefine(caseModel,
                "MOPickLists_ItemMaster",
                "Code",
                "Name",
                new Guid("73819e01-cb6c-4290-b117-d91acbf09148"),
                new Guid("636D3E47-48AA-47FC-ACA4-E6322BCE775B"),
                string.Empty);

            // 工序工作中心
            SetRefDefine(caseModel,
                "MOOperations_WorkCenter",
                "Code",
                "Name",
                new Guid("0C19BDC0-4812-4EEC-9B4C-C04C161201BF"),
                new Guid("03924B47-266C-4CDF-88B7-FB498A39ACA4"),
                string.Empty);

            // 资源
            SetRefDefine(caseModel,
                "MOResources_Res",
                "Code",
                "Name",
                new Guid("0A5F45A7-34D1-4DD1-A4F7-9E56D466CD78"),
                new Guid("64E543A0-ACCB-4B18-8D69-2822D180A803"),
                string.Empty);

            // 资源工作中心
            SetRefDefine(caseModel,
                "MOResources_WorkCenter",
                "Code",
                "Name",
                new Guid("0C19BDC0-4812-4EEC-9B4C-C04C161201BF"),
                new Guid("03924B47-266C-4CDF-88B7-FB498A39ACA4"),
                string.Empty);

            // 母单
            SetRefDefine(caseModel,
                "ParentMO",
                "DocNo",
                "DocNo",
                new Guid("5A8B3BCC-1250-477F-AC50-7777D6C85251"),
                new Guid("D81BF969-9BA9-423C-9FF2-C88537164C41"),
                string.Empty);

            // 母单
            SetRefDefine(caseModel,
                "ParentMO",
                "DocNo",
                "DocNo",
                new Guid("5A8B3BCC-1250-477F-AC50-7777D6C85251"),
                new Guid("D81BF969-9BA9-423C-9FF2-C88537164C41"),
                string.Empty);

            // 作业计划领料单单据类型
            SetRefDefine(caseModel,
                "MOTaskPlan_IssueDoc_IssueDocType",
                "Code",
                "Name",
                // ReferenceComponent id
                new Guid("864f0324-3677-45c9-8d18-65756426c5ec"),
                // refEntityId
                new Guid("41fbd32a-08b3-45ea-a203-a4cffee84083"),
                string.Empty);
}

Tags:

评论 (19) -

weight loss meals 美国 wrote at 2017/4/9 2:40:48 #

What's up to every one, for the reason that I am genuinely eager of reading this blog's post to be updated daily. It carries good information.

formuladrugs.com 美国 wrote at 2019/6/11 23:06:01 #

I visit every day a few blogs and information sites to read posts, but this weblog provides quality based content.

orderhcginjections.com 美国 wrote at 2019/6/15 15:01:51 #

I every time used to read post in news papers but now as I am a user of internet therefore from now I am using net for articles or reviews, thanks to web.

budesonide nasal spray 美国 wrote at 2019/7/6 14:13:20 #

great issues altogether, you just received a new reader. What could you recommend in regards to your put up that you just made a few days in the past? Any certain?

Summer 美国 wrote at 2019/8/9 21:11:15 #

Way cool! Some very valid points! I appreciate you penning this write-up and also the rest of the site is extremely good.

Caitlyn 美国 wrote at 2019/8/14 14:51:08 #

You could certainly see your skills within the work you write. The sector hopes for more passionate writers like you who aren't afraid to mention how they believe. All the time go after your heart.

North Carolina 美国 wrote at 2019/9/10 0:49:24 #

Excellent article. Keep posting such kind of information on your site. Im really impressed by your site. Hi there,  You have done a fantastic job. I will certainly digg it and in my view suggest to my friends. I am sure they will be benefited from this web site.

Missouri 美国 wrote at 2019/9/14 9:56:21 #

Your style is so unique compared to other folks I've read stuff from. Many thanks for posting when you've got the opportunity, Guess I will just bookmark this web site.

우리카지노 美国 wrote at 2019/9/23 17:31:24 #

It's wonderful that you are getting ideas from this paragraph as well as from our discussion made at this place.

우리카지노 美国 wrote at 2019/9/29 12:51:01 #

certainly like your web-site but you have to test the spelling on several of your posts. Many of them are rife with spelling issues and I in finding it very troublesome to inform the truth on the other hand I'll definitely come back again.

퍼스트카지노 美国 wrote at 2019/10/1 6:56:59 #

Wonderful site. Plenty of helpful information here. I am sending it to several pals ans also sharing in delicious. And naturally, thanks on your sweat!

카지노게임사이트 美国 wrote at 2019/10/1 21:51:23 #

Once more, Tim Ferriss is a masterful interviewer.

우리카지노 美国 wrote at 2019/10/2 22:31:02 #

It's great that you are getting thoughts from this piece of writing as well as from our discussion made at this time.

우리카지노 美国 wrote at 2019/10/3 18:09:24 #

Hi there just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Opera. I'm not sure if this is a format issue or something to do with internet browser compatibility but I thought I'd post to let you know. The layout look great though! Hope you get the issue resolved soon. Cheers

카지노게임 美国 wrote at 2019/10/5 14:37:13 #

Forgo greetings, pleases and thank yous?

우리카지노 美国 wrote at 2019/10/12 4:20:41 #

I read this paragraph fully on the topic of the resemblance of most recent and previous technologies, it's remarkable article.

우리카지노 美国 wrote at 2019/10/13 5:04:44 #

Hi there! This is kind of off topic but I need some help from an established blog. Is it difficult to set up your own blog? I'm not very techincal but I can figure things out pretty quick. I'm thinking about creating my own but I'm not sure where to start. Do you have any points or suggestions?  Cheers

Kelly 美国 wrote at 2019/10/15 17:39:48 #

Piece of writing writing is also a fun, if you know afterward you can write otherwise it is complex to write.

우리카지노 美国 wrote at 2019/10/16 8:43:19 #

Wonderful goods from you, man. I've understand your stuff previous to and you're just extremely magnificent. I really like what you've acquired here, certainly like what you are saying and the way in which you say it. You make it entertaining and you still take care of to keep it wise. I can not wait to read far more from you. This is really a wonderful site.

添加评论



biuquote
微笑得意调皮害羞酷大笑惊讶发呆喜欢可怜尴尬闭嘴噘嘴皱眉伤心抓狂呕吐坏笑漫骂发怒
Loading


RecentComments

评论 RSS

Statistics

989 篇文章
0 个单页
776080 条评论
11 次评分
1443852 次访问
访问统计开始于 2019年12月15日
平均日访问 6810 次
当前 105 人在线