예제 #1
0
        public static int OnMsg(int nNodeID, string strRequestString, MainForm mainForm, ref string strRespone)
        {
            int nErrorCode = (int)ENUM_OutTaskResponeError.eOutTaskRequest_UnknownFailed;

            // 检查请求合法性
            if (!IsValidOutTaskMsg(strRequestString, RSAKeyContainer.GetInstance.GetJavaPublicKey()))
            {
                // 消息检查未通过
                nErrorCode = (int)ENUM_OutTaskResponeError.eOutTaskRequest_UnvalidMsg;
                LOGGER.WARN($"Server out task request is not a invalid msg. \n Request = {strRequestString}");
            }
            else
            {
                SOutTaskInfo info = ParseStructFromRequest(strRequestString, RSAKeyContainer.GetInstance.GetCSharpPrivateKey());
                if (info.taskID <= 0)
                {
                    // 消息不正常
                    nErrorCode = (int)ENUM_OutTaskResponeError.eOutTaskRequest_UnvalidTaskId;
                    LOGGER.WARN($"Server out task request is not a invalid msg. \n Request = {strRequestString} \n TaskInfo = {info.ToLogString()}");
                }
                else
                {
                    // 消息解析成功,开始逻辑处理
                    {
                        // 实际处理
                        mainForm.AddOutTaskToWaitQueue(info);
                        nErrorCode = (int)ENUM_OutTaskResponeError.eOutTaskRequest_Successed;
                    }
                }
            }

            strRespone = ("{\"nodeID\":") + nNodeID + (",\"status\":") + nErrorCode + ("}");
            return(nErrorCode);
        }
예제 #2
0
        /// <summary>
        /// 处理流水查询任务
        /// </summary>
        private void HandleOutTask()
        {
            try
            {
                SOutTaskInfo info = m_OutTasksList.Peek();  // 取出消息,不删除

                LOGGER.INFO($"Handle a new out task:\n {info.ToLogString()} \n, still left {m_OutTasksList.Count - 1} tasks in queue.");

                SOutTaskResult dealResult = new SOutTaskResult();
                dealResult.taskID = info.taskID;
                dealResult.nodeID = GetCurCashierNodeID();

                // 记录当前在处理的任务ID
                SetCurTaskID(info.taskID);

                // 开始处理
                if (!AutomationOut(info, ref dealResult))
                {
                }

                LOGGER.WARN($"Auto out task is done. Now ready to send msg to server. TaskID = {info.taskID}.", info.taskID);
                // 通知服务器处理结果
                HttpSendResult sendResult = RequestSender.SendRequestToServer(dealResult);
                if (sendResult.IsSendSuccessed())
                {
                    SetLastTaskID(info.taskID);
                    SetCurTaskID(INVALID_TASK_ID);
                    LOGGER.INFO($"Send auto out task successed. TaskID = {info.taskID}. \n {sendResult.ToLogString()}");
                }
                else
                {
                    SetLastTaskID(INVALID_TASK_ID);
                    SetCurTaskID(INVALID_TASK_ID);
                    LOGGER.ERROR($"Send auto out task failed. TaskID = {info.taskID}. \n {sendResult.ToLogString()}", info.taskID);
                }
                LOGGER.WARN($"Out task deal over. TaskID = {info.taskID}.", info.taskID);
            }
            catch (Exception e)
            {
                LOGGER.ERROR($"Deal out task error occured. Error = {e.ToString()}");
            }
            finally
            {
                SetCurTaskID(INVALID_TASK_ID);
                m_OutTasksList.Dequeue();       // 无论如何,该任务必须删除
            }
            return;
        }
예제 #3
0
 /// <summary>
 /// 银行执行出账任务入口函数
 /// </summary>
 /// <param name="nTaskID">任务ID</param>
 /// <param name="info">信息详细情况:例如登录密码,收款人,金额等</param>
 /// <param name="result">过程中捕获的详细信息:例如余额,流水单号等</param>
 /// <returns></returns>
 public abstract bool AutoDo(int nTaskID, SOutTaskInfo info, ref SOutTaskResult result);
예제 #4
0
 /// <summary>
 /// 添加一个出款任务到等待队列
 /// </summary>
 /// <param name="info"></param>
 internal void AddOutTaskToWaitQueue(SOutTaskInfo info)
 {
     LOGGER.INFO($"Add a new out task to queue. TaskID = {info.taskID}");
     m_OutTasksList.Enqueue(info);
 }
예제 #5
0
 public S2CMessage_OutTaskRequest()
 {
     timestamp = 0;
     signature = "";
     info      = new SOutTaskInfo();
 }
예제 #6
0
 public override bool AutoDo(int nTaskID, SOutTaskInfo info, ref SOutTaskResult result)
 {
     throw new NotImplementedException();
 }
예제 #7
0
        /// <summary>
        /// 实际自动处理一次自动出款
        /// </summary>
        /// <param name="info"></param>
        /// <param name="result"></param>
        /// <returns></returns>
        private bool AutomationOut(SOutTaskInfo info, ref SOutTaskResult result)
        {
            // 检查是否支持该银行
            int nBankTypeID = GetOutBankTypeIDByName(info.fromBankCode);

            if (nBankTypeID <= 0)
            {
                result.status = (int)SOutTaskResult.ENUM_OutcomeActionStatus.eOutcomeActionStatus_UnsupportBankCode;
                return(false);
            }

            // 先进行清理
            // 为保持长期登录状态,现不进行清理 - added by Frankie.W 2017-07-19
            //{
            //    FKWebAutomatic.FKWebDriver.GetInstance.FKClose();
            //    ForceShutdownIE();
            //    Thread.Sleep(1000);
            //}

            DateTime startTime = DateTime.Now;

            bool            bSuccessed = false;
            BankAutoOutBase imp        = null;

            try
            {
                switch (nBankTypeID)
                {
                case 1:
                    imp = new CMBC_AutoOut();
                    break;

                default:
                    break;
                }

                if (imp == null)
                {
                    LOGGER.ERROR($"Auto out failed.");
                    result.status = (int)SOutTaskResult.ENUM_OutcomeActionStatus.eOutcomeActionStatus_UnknownError;
                    bSuccessed    = false;
                }
                else
                {
                    imp.Init();
                    bSuccessed = imp.AutoDo(info.taskID, info, ref result);
                    imp.Clear();
                }
            }
            catch (Exception e)
            {
                LOGGER.ERROR($"Auto do error occured. Error = {e.ToString()}");
                bSuccessed = false;
            }
            DateTime endTime = DateTime.Now;
            TimeSpan span    = endTime - startTime;

            if (!bSuccessed)
            {
                LOGGER.ERROR($"Auto do failed.");
                // 执行失败
                result.status = (int)SOutTaskResult.ENUM_OutcomeActionStatus.eOutcomeActionStatus_AutoProcessFailed;
            }

            // 无论成功与否,都要进行清理
            // 为保持长期登录状态,现不进行清理 - added by Frankie.W 2017-07-19
            //{
            //    FKWebAutomatic.FKWebDriver.GetInstance.FKClose();
            //    ForceShutdownIE();
            //}

            // 并记录到日志时间数据库,以便日志查询
            FKLog.FKSQLiteLogMgr.GetInstance.AddTaskTimeLog(info.taskID, DateTime.Now);

            return(bSuccessed);
        }