using System; using System.Collections.Generic; namespace SiriIntents.Server { /// /// 接口类的返回信息 /// public class IMessageCommon { /// /// 接口类的返回信息 /// private static IMessageCommon m_Current = null; /// /// 接口类的返回信息 /// public static IMessageCommon Current { get { if (m_Current == null) { m_Current = new IMessageCommon(); } return m_Current; } } /// /// 是否在获取token /// public bool isGetingToken; /// /// 无视错误(访问云端时,此操作将不会弹出错误) /// public bool IgnoreError = false; ///// ///// 全部信息 ///// //private Dictionary> dicMsg = null; /// /// 通用错误码 /// private Dictionary stateCodeDic = null; /// /// 根据接口的状态码,翻译返回信息 /// /// 接口 /// 云端返回的数据 /// 请求参数 /// public string GetMsgByRequestName(string statuCode) { if (IgnoreError == true) { //无视错误 return null; } //共通码 if (stateCodeDic.ContainsKey(statuCode) == true) { return "-1";// Language.StringByID(stateCodeDic[statuCode]); } //if (dicMsg.ContainsKey(requestName) == true && dicMsg[requestName].ContainsKey(statuCode) == true) //{ // //在册的Msg // return Language.StringByID(dicMsg[requestName][statuCode]); //} return "-1";//Language.StringByID(StringId.FailedRequestServer) + "\n(" + statuCode + ")"; } /// /// StartRefreshToken /// public void StartRefreshToken() { if (isGetingToken) return; new System.Threading.Thread(() => { isGetingToken = true; try { var success = new HttpServerRequest().RefreshToken(); } catch { } finally { isGetingToken = false; } }) { IsBackground = true }.Start(); } } /// /// 常用状态码管理 /// public class StateCode { /// /// 网络请求异常 /// APP自定义错误码 /// public const string NETWORK_ERROR = "-1"; /// /// 数据解析错误 /// APP自定义错误码 /// public const string DATA_EXCEPTION = "-2"; /// /// 请求成功的状态码 /// public const string SUCCESS = "0"; /// /// 验证码校验失败 /// public const string VERIFICATION_CODE_WRONG = "14"; /// /// 会话超时,请更新token /// public const string TOKEN_EXPIRED = "10001"; /// /// 账号不存在的错误码 /// public const string ACCOUNT_NOT_EXIST = "10010"; /// /// 登录锁定,密码错误次数过多 /// 密码输入错误超过10次,请30分钟后重试! /// public const string AccountLoginLock = "10019"; } }