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(); }
public void TestMethod1() { UserServiceProxy proxy = new UserServiceProxy(); // 引用Kingdee.BOS.ServiceFacade.KDServiceClient.dll proxy.HostURL = @"http://127.0.0.1/K3cloud/"; //k/3cloud地址 LoginInfo loginInfo = new LoginInfo(); loginInfo.Username = "******"; loginInfo.Password = "******"; loginInfo.Lcid = 2052; loginInfo.AcctID = "5c42b8435b2962"; //Context ctx = proxy.ValidateUser("", "5c42b8435b2962", "scy", "666666", 2052).Context; Context ctx = proxy.ValidateUser("http://127.0.0.1/K3cloud/", loginInfo).Context; //List<long> salerIds = CRMServiceHelper.getSalerPersonids(ctx, 101789); }
public static Context getContext(string UserName, string PassWord, int ICID, string DBID, string ServerUrl) { UserServiceProxy proxy = new UserServiceProxy(); // 引用Kingdee.BOS.ServiceFacade.KDServiceClient.dll proxy.HostURL = @"http://localhost/K3Cloud/"; //k/3cloud地址 LoginInfo logininfo = new LoginInfo(); logininfo.Username = UserName; logininfo.Password = PassWord; logininfo.Lcid = ICID; logininfo.AcctID = DBID; Context ctx = proxy.ValidateUser("http://localhost/K3Cloud/", logininfo).Context;//guid为业务数据中心dbid,可以去管理中心数据库查询一下t_bas_datacenter_l表查找,后面需要用户名和密码 return(ctx); }
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)); } }