示例#1
0
        public static EditServiceJson CreateFrom(NCDescriptorViewModel model, JsonTemplateNames partName)
        {
            var serviceJson = new EditServiceJson
            {
                ServiceDescriptor = JsonConvert.SerializeObject(model),
                CurrentPath       = "",
                CurrentName       = partName
            };

            switch (partName)
            {
            case JsonTemplateNames.NCParameter:
                serviceJson.CurrentJson = JsonConvert.SerializeObject(model.ParameterBody);
                break;

            case JsonTemplateNames.NCReturn:
                serviceJson.CurrentJson = JsonConvert.SerializeObject(model.ReturnBody);
                break;

            default:
                throw new Exception("传入了非NC系统Web服务类型的部位参数" + partName.ToString());
            }

            return(serviceJson);
        }
示例#2
0
        /// <summary>
        /// 假定uiViewModel参数是来自用户视图的数据控件绑定模型,
        /// 而当前实例是一个从数据库或视图状态中恢复出来的老模型,
        /// 那么,应当运行本方法完成用户可能发生的输入更改。
        /// 注意:本方法仅更新那些绑定到了视图上的form control的值。
        /// </summary>
        /// <param name="uiViewModel"></param>
        public void UpdateFromUI(IServiceDescriptorViewModel uiViewModel)
        {
            NCDescriptorViewModel viewModel = (NCDescriptorViewModel)uiViewModel;

            this.ActiveStatus  = viewModel.ActiveStatus;
            this.EndPoint      = viewModel.EndPoint;
            this.ServiceName   = viewModel.ServiceName;
            this.WebServiceUrl = viewModel.WebServiceUrl;
        }
示例#3
0
        /// <summary>
        /// 从一个EsbService定义中创建一个视图模型并返回。
        /// </summary>
        /// <param name="service"></param>
        /// <returns></returns>
        public static NCDescriptorViewModel CreateFrom(EsbService service)
        {
            if (service.Type != ServiceType.NCWebService)
            {
                throw new Exception("服务不是用友NC系统Web服务类型的。");
            }

            var model = JsonConvert.DeserializeObject <NCDescriptorViewModel>(service.ServiceDescriptor);

            if (model == null)
            {
                model = new NCDescriptorViewModel();
            }
            model.ServiceID    = service.ID;
            model.ServiceName  = service.Name;
            model.ActiveStatus = service.ActiveStatus == 1;

            return(model);
        }
示例#4
0
 public static EditServiceJson CreateFrom(EsbService service, JsonTemplateNames partName)
 {
     if (service.Type == ServiceType.SimpleRESTful)
     {
         return(EditServiceJson.CreateFrom(SimpleRestfulDescriptorViewModel.CreateFrom(service), partName));
     }
     else if (service.Type == ServiceType.NCWebService)
     {
         return(EditServiceJson.CreateFrom(NCDescriptorViewModel.CreateFrom(service), partName));
     }
     else if (service.Type == ServiceType.PrimetonService)
     {
         return(EditServiceJson.CreateFrom(PrimetonDescriptorViewModel.CreateFrom(service), partName));
     }
     else
     {
         throw new Exception("not impleted service type");
     }
 }