private static void Main(string[] args)
        {
            var    appSettings = ConfigurationManager.AppSettings;
            string hostUrl     = appSettings["hostUrl"];
            string userName    = appSettings["userName"];
            string password    = appSettings["password"];
            string acctId      = appSettings["dataCenterId"];

            UserServiceProxy proxy     = new UserServiceProxy();
            LoginInfo        loginInfo = new LoginInfo
            {
                Username  = userName,
                Password  = password,
                Lcid      = 2052,
                AcctID    = acctId,
                LoginType = LoginType.NormalERPLogin
            };

            proxy.HostURL = hostUrl;
            proxy.ValidateUser(
                hostUrl,
                loginInfo,
                result =>
            {
                Console.WriteLine(result.IsSuccessByAPI ? "登录成功" : throw new Exception("登录失败" + result.Message));
            });
            Thread.Sleep(2000);

            MetadataServiceProxy metadataService = new MetadataServiceProxy {
                HostURL = hostUrl
            };
            string objectId;
            bool   isExist;

            do
            {
                Console.WriteLine("输入业务对象标识并回车");

                objectId = Console.ReadLine();

                isExist = metadataService.IsExistMetaObjectType(objectId);
                if (!isExist)
                {
                    Console.WriteLine($"标识为{objectId}的业务对象不存在,请重新输入");
                }
            }while (!isExist);

            FormMetadata formMetadata = metadataService.GetFormMetadata(objectId);
            string       outputPath   = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, formMetadata.SubSystemId + Path.DirectorySeparatorChar);

            Console.WriteLine($"开始生成业务对象{formMetadata.Name}的实体类");
            ClassFileGenerator.GenerateClassFiles(formMetadata, outputPath);
            Console.WriteLine($"生成结束,文件路径:{outputPath}");
            Console.ReadKey();
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //登录系统
                userServiceProxy.HostURL = txtServer.Text;
                var loginInfo = new Kingdee.BOS.Authentication.LoginInfo();
                loginInfo.AcctID   = txtDbId.Text;
                loginInfo.Lcid     = 2052;
                loginInfo.Username = txtUser.Text;
                loginInfo.Password = txtPassword.Text;
                var res = userServiceProxy.ValidateUser(txtServer.Text, loginInfo);
                if (res.LoginResultType == LoginResultType.Success)
                {
                    metaServiceProxy.HostURL = txtServer.Text;
                    //据业务对象Id 取得元数据
                    FormMetadata meta = metaServiceProxy.GetFormMetadata("PAEZ_Phone");
                    BusinessInfo info = meta.BusinessInfo;
                    //创建手机数据包
                    DynamicObject row = new DynamicObject(info.GetDynamicObjectType());
                    row["F_PAEZ_Brand"] = txtBrand.Text;
                    row["F_PAEZ_Model"] = txtModel.Text;

                    //保存至数据库
                    dataServiceProxy.HostURL = txtServer.Text;
                    var oResult = dataServiceProxy.SaveData(info, row);
                    if (oResult.IsSuccess)
                    {
                        MessageBox.Show("保存成功!");
                    }
                    else
                    {
                        MessageBox.Show("保存失败!");
                    }
                }
                else
                {
                    MessageBox.Show(string.Format("登录失败!{0}", res.Message));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("保存失败!{0}", ex.Message));
            }
        }