/// <summary> /// 检查Session /// </summary> /// <returns></returns> private SmcErr CheckSession() { NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log); SmcErr err = new CgwError(); CGWSession CgwSession = null; if (OperationContext.Current != null) { string strSessionId = OperationContext.Current.SessionId; err = SessionManage.Instance().GetSessionsBySessionId(strSessionId, out CgwSession); if (err.IsSuccess() == false || CgwSession == null) { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_SESSION_NULL); } else { //更新Session最后访问时间 CgwSession.LastVisitedTime = DateTime.Now; logEx.Trace("Current SessionId is:{0}, LastVisitedTime is :{1}", strSessionId, CgwSession.LastVisitedTime.ToLongTimeString()); } } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CURRENTSESSION_NULL); } return(err); }
/// <summary> /// 连接融合网关 /// </summary> /// <param name="password">连接字符串</param> /// <returns></returns> public SmcErr Connect(string password) { SmcErr err = new CgwError(); NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log); if (false == string.IsNullOrEmpty(password)) { //获取后台密码字符串 string s = CommonFunction.GetAppSetting("PassWord"); //进行SHA256加密 string newPassword = CommonFunction.SHA256Encrypt(s); //保存当前会话 if (newPassword == password) { //获取SessionManage中Session个数 if (SessionManage.Instance().GetSessionsCount() == 0) { Guid sessionGuid = Guid.NewGuid(); //保存至CGW的session管理中 CGWSession CgwSession = new CGWSession(sessionGuid, OperationContext.Current.SessionId); logEx.Trace("Connect Successful,Current.SessionId is : ", OperationContext.Current.SessionId); } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_SESSION_COUNT_MAX); logEx.Warn("Session Count is Top Of Max number !"); } } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_PASSWORD_INCORRECT); logEx.Error("Connect Password is Incorrect !"); } } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_PASSWORD_NULL); logEx.Error("Connect Password is null !"); } return(err); }
/// <summary> /// 连接融合网关 /// </summary> /// <param name="password">连接字符串</param> /// <returns></returns> public SmcErr Connect(string password) { SmcErr err = new CgwError(); NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log); if (false == string.IsNullOrEmpty(password)) { //获取后台密码字符串 string s = CommonFunction.GetAppSetting("PassWord"); //进行SHA256加密 string newPassword = CommonFunction.SHA256Encrypt(s); //保存当前会话 if (newPassword == password) { //获取SessionManage中Session个数 if (SessionManage.Instance().GetSessionsCount() == 0) { Guid sessionGuid = Guid.NewGuid(); //保存至CGW的session管理中 CGWSession CgwSession = new CGWSession(sessionGuid, OperationContext.Current.SessionId); logEx.Trace("Connect Successful,Current.SessionId is : ", OperationContext.Current.SessionId); } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_SESSION_COUNT_MAX); logEx.Warn("Session Count is Top Of Max number !"); } } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_PASSWORD_INCORRECT); logEx.Error("Connect Password is Incorrect !"); } } else { err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_PASSWORD_NULL); logEx.Error("Connect Password is null !"); } return err; }