public ConnectionCode Login(string userName, string password) { if (_isFirst) { _isFirst = false; _lastRetCode = LoginInternal(userName, password); } else if (_lastRetCode == ConnectionCode.ErrorFailStartService) { _lastRetCode = InitService(); } else { _lastRetCode = LoginInternal(userName, password); } if (_lastRetCode == ConnectionCode.Success) { StartMainForm(); } return(_lastRetCode); }
public void SetHostAddress() { connectCodeText.text = ConnectionCode.Encode(hostIPDropdown.captionText.text); }
public BLLResponse(ConnectionCode code, string message) { Code = code; Message = message; }
/// <summary> /// 异步调用UFX接口,完成调用之后,如果不出错,则注册回调信息 /// </summary> /// <typeparam name="T">A generic type defines the UFX request parameters.</typeparam> /// <param name="functionCode">An enum type defines the UFX interface number.</param> /// <param name="requests">A generic request list. NOTE: the caller MUST control the request count if the /// interface does not support many requests at a time. /// </param> /// <param name="callbacker">It is used to store the callback information.</param> /// <returns>It is used to define the call result.</returns> public ConnectionCode SubmitAsync <T>(UFXFunctionCode functionCode, List <T> requests, Callbacker callbacker) { FunctionItem functionItem = ConfigManager.Instance.GetFunctionConfig().GetFunctionItem(functionCode); if (functionItem == null || functionItem.RequestFields == null || functionItem.RequestFields.Count == 0) { string msg = string.Format("提交UFX请求号[{0}]未定义!", functionCode); logger.Error(msg); return(ConnectionCode.ErrorNoFunctionCode); } string userToken = LoginManager.Instance.LoginUser.Token; if (string.IsNullOrEmpty(userToken)) { string msg = string.Format("提交UFX请求[{0}]令牌失效!", functionCode); logger.Error(msg); return(ConnectionCode.ErrorLogin); } CT2BizMessage bizMessage = new CT2BizMessage(); //初始化 bizMessage.SetFunction((int)functionCode); bizMessage.SetPacketType(CT2tag_def.REQUEST_PACKET); //业务包 CT2Packer packer = new CT2Packer(2); packer.BeginPack(); foreach (FieldItem item in functionItem.RequestFields) { packer.AddField(item.Name, item.Type, item.Width, item.Scale); } var dataFieldMap = UFXDataBindingHelper.GetProperty <T>(); foreach (var request in requests) { foreach (FieldItem item in functionItem.RequestFields) { if (dataFieldMap.ContainsKey(item.Name)) { SetRequestField <T>(ref packer, request, item, dataFieldMap); } else { SetRequestDefaultField(ref packer, item, userToken); } } } packer.EndPack(); #if DEBUG OutputParam <T>(functionCode, requests); #endif unsafe { bizMessage.SetContent(packer.GetPackBuf(), packer.GetPackLen()); } ConnectionCode retCode = ConnectionCode.Success; int hSend = _t2SDKWrap.SendAsync(bizMessage); if (hSend < 0) { string msg = string.Format("提交UFX请求[{0}]失败, 返回值:[{1}]!", functionCode, hSend); logger.Error(msg); retCode = ConnectionCode.ErrorConn; } else { //注册UFX返回数据后,需要调用的回调 //此处存在假设,异步提交返回之前,不会触发回调 AddDataHandler(functionCode, hSend, callbacker); retCode = ConnectionCode.Success; } packer.Dispose(); bizMessage.Dispose(); return(retCode); }