Пример #1
0
        public void LoadBizObjectLanguageDescList(string bizObjectType, int?bizObjectSysNo, string bizObjectID, EventHandler <RestClientEventArgs <List <BizObjecLanguageDescVM> > > callback)
        {
            BizObjecLanguageDescVM vm = new BizObjecLanguageDescVM();
            string relativeUrl        = string.Empty;

            if (bizObjectSysNo.HasValue && bizObjectSysNo.Value > 0)
            {
                relativeUrl = string.Format("/CommonService/BizObject/GetBySysNo/{0}/{1}", bizObjectType, bizObjectSysNo.Value);
            }
            else
            {
                relativeUrl = string.Format("/CommonService/BizObject/Get/{0}/{1}/{2}", bizObjectType, bizObjectSysNo.HasValue ? bizObjectSysNo : 0, bizObjectID);
            }

            //restClient.Query<List<BizObjectLanguageDesc>>(relativeUrl, callback);
            restClient.Query <List <BizObjectLanguageDesc> >(relativeUrl, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                List <BizObjecLanguageDescVM> list = new List <BizObjecLanguageDescVM>();
                if (args.Result != null && args.Result.Count > 0)
                {
                    foreach (BizObjectLanguageDesc item in args.Result)
                    {
                        vm = item.Convert <BizObjectLanguageDesc, BizObjecLanguageDescVM>();
                        list.Add(vm);
                    }
                }

                callback(obj, new RestClientEventArgs <List <BizObjecLanguageDescVM> >(list, restClient.Page));
            });
        }
Пример #2
0
        public UCLanguagesDescription(string BizObjectType, string BizObjectSysNo)
        {
            listvm           = new List <BizObjecLanguageDescVM>();
            codeNamePairList = new List <CodeNamePair>();
            vm            = new BizObjecLanguageDescVM();
            bizObjectType = BizObjectType;
            bizObjectNo   = BizObjectSysNo;

            InitializeComponent();
            Loaded += UCLanguagesDescription_Loaded;
        }
Пример #3
0
        public void Update(BizObjecLanguageDescVM item, Action <bool> callback)
        {
            BizObjectLanguageDesc entity = EntityConverter <BizObjecLanguageDescVM, BizObjectLanguageDesc> .Convert(item);

            string url = "/CommonService/BizObject/Update";

            restClient.Update <bool>(url, entity, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                callback(args.Result);
            });
        }
Пример #4
0
        public void Create(BizObjecLanguageDescVM item, EventHandler <RestClientEventArgs <bool> > callback)
        {
            BizObjectLanguageDesc entity = EntityConverter <BizObjecLanguageDescVM, BizObjectLanguageDesc> .Convert(item);

            string url = "/CommonService/BizObject/Create";

            restClient.Create <bool>(url, entity, (obj, args) =>
            {
                if (args.FaultsHandle())
                {
                    return;
                }
                callback(obj, args);
            });
        }
Пример #5
0
        void UCLanguagesDescription_Loaded(object sender, RoutedEventArgs e)
        {
            //LanguageOptions=ConfigurationManager

            facade = new Facade(CPApplication.Current.CurrentPage);
            //获取业务对象类型
            CodeNamePairHelper.GetList(ConstValue.DomainName_Common, ConstValue.Key_BizObjectType, (o, p) =>
            {
                codeNamePairList = p.Result;

                CodeNamePair CodeName = codeNamePairList.Where(s => s.Code == bizObjectType).SingleOrDefault();
                vm.BizObjectType      = CodeName.Code;
                if (vm.BizObjectType == "Product")
                {
                    vm.BizObjectId = bizObjectNo;
                }

                if (vm.BizObjectType == "Merchant")
                {
                    vm.BizObjectSysNo = int.Parse(bizObjectNo);
                }

                vm.ShowBizObjectTypeName = CodeName.Name;
                List <KeyValuePair <string, string> > languageList = GetLanguageList();
                facade.LoadBizObjectLanguageDescList(vm.BizObjectType, vm.BizObjectSysNo, vm.BizObjectId, (obj, args) =>
                {
                    listvm = args.Result;
                    if (listvm != null && listvm.Count > 0)
                    {
                        for (int i = 0; i < listvm.Count; i++)
                        {
                            listvm[i].BizObjectSysNo         = vm.BizObjectSysNo;
                            listvm[i].BizObjectType          = vm.BizObjectType;
                            listvm[i].BizObjectId            = vm.BizObjectId;
                            listvm[i].ShowLanguageTypeName   = languageList.Where(s => s.Key == listvm[i].LanguageCode).SingleOrDefault().Value;
                            UCLanguageDescripttionSetting uc = new UCLanguageDescripttionSetting();
                            uc.DataContext = listvm[i];
                            Containner.Children.Add(uc);
                            languageList.Remove(languageList.Where(k => k.Key == listvm[i].LanguageCode).SingleOrDefault());
                        }
                    }

                    if (languageList != null && languageList.Count > 0)
                    {
                        for (int i = 0; i < languageList.Count; i++)
                        {
                            if (listvm == null || !listvm.Any(l => l.LanguageCode == languageList[i].Key))
                            {
                                BizObjecLanguageDescVM view      = new BizObjecLanguageDescVM();
                                view.BizObjectSysNo              = vm.BizObjectSysNo;
                                view.BizObjectType               = vm.BizObjectType;
                                view.BizObjectId                 = vm.BizObjectId;
                                view.LanguageCode                = languageList[i].Key;
                                view.ShowLanguageTypeName        = languageList[i].Value;
                                UCLanguageDescripttionSetting uc = new UCLanguageDescripttionSetting();
                                uc.DataContext = view;
                                Containner.Children.Add(uc);
                            }
                        }
                    }
                });
                this.DataContext = vm;
            });


            this.Loaded -= UCLanguagesDescription_Loaded;
        }