Ejemplo n.º 1
0
        /// <summary>
        /// 主方法:【订位】指令返回结果解析
        /// </summary>
        /// <param name="request">请求对象</param>
        /// <returns>解析结果</returns>
        public override CommandResult <JetermEntity.Response.Booking> BusinessDispose(JetermEntity.Request.Booking request)
        {
            _booking = new JetermEntity.Parser.Booking(this.config, this.OfficeNo);

            try
            {
                this.Cmd = _booking.ParseCmd(request);
                if (string.IsNullOrEmpty(this.Cmd))
                {
                    return(_booking.Response);
                }

                ExcuteCmd();

                _booking.ParseCmdResult(this.CmdResult);
                if (_booking.Response.state)
                {
                    GetBigPnr(_booking.Response.result.Pnr);
                }
            }
            catch (Exception e)
            {
                _booking.Response.error = new Error(EtermCommand.ERROR.PARSE_FAIL);
                _booking.Response.error.CmdResultBag = this.CmdResult;
                _booking.Response.state = false;
                LogWrite.WriteLog(e);
            }

            return(_booking.Response);
        }
Ejemplo n.º 2
0
        protected internal override void ExcuteCmd()
        {
            this.Cmd = this.Cmd.Replace(Environment.NewLine, "[RN]");

            //取缓存,防止重复订位
            string cmd = new Regex("TKTL\\d{4}/\\d{2}[A-Z]{3}").Replace(this.Cmd, "");
            string key = string.Format("140106_140110_{0}", MD5Helper.GetMD5(cmd));

            LogWrite.WriteLog(string.Format("{0}\r\n{1}", this.Cmd, key));
            string bookCache = RedisHelper.stringGet(key);

            if (!string.IsNullOrEmpty(bookCache))
            {
                LogWrite.WriteLog("从Redis中获取到订位信息:\r\n" + bookCache);

                string pnr = string.Empty;
                ParserHelper.GetNewPnr(bookCache, ref pnr);
                if (!string.IsNullOrEmpty(pnr))
                {
                    string rtdata = system(string.Format("RT {0}", pnr));
                    if (rtdata.IndexOf("CANCELLED") == -1)
                    {
                        //取PNR缓存
                        _key = string.Format("{0}_{1}", key, pnr);
                        string pnrCache = RedisHelper.stringGet(_key);

                        LogWrite.WriteLog("从Redis中获取到RT信息:\r\n" + pnrCache);

                        this.CmdResult = bookCache;
                        if (!string.IsNullOrEmpty(pnrCache))
                        {
                            _booking.Response.result.RTResultBag = pnrCache;
                        }
                        return;
                    }
                    else
                    {
                        LogWrite.WriteLog("此编码位置已取消:\r\n" + rtdata);
                        RedisHelper.delString(key);
                    }
                }
                else
                {
                    RedisHelper.delString(key);
                }
            }

            string iResult = string.Empty;
            int    i       = 0;

            do
            {
                iResult = system("i");
                ++i;
            }while (string.IsNullOrWhiteSpace(iResult) && i < 4);

            this.CmdResult = system(this.Cmd);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Eterm代理方法
        /// </summary>
        /// <param name="url">请求url</param>
        /// <returns>返回结果</returns>
        public string InvokeEterm(IntPtr hwnd, IntPtr handle, string strPost, string strParam)
        {
            string sret = string.Empty;

            try
            {
                EtermRequest ereq = JsonConvert.DeserializeObject <EtermRequest>(strPost);

                if (ereq != null)
                {
                    Type bllType = Type.GetType(string.Format("EtermProxy.BLL.{0}", ereq.ClassName));
                    Type reqType = Type.GetType(string.Format("JetermEntity.Request.{0},JetermEntity", ereq.ClassName));

                    object reqObj = JsonConvert.DeserializeObject(strParam, reqType);
                    if (bllType != null && reqObj != null)
                    {
                        object obj = Activator.CreateInstance(bllType, new object[] { hwnd, handle, ereq.Config, ereq.OfficeNo });

                        if (obj != null)
                        {
                            MethodInfo   info   = bllType.GetMethod("BusinessDispose");
                            BindingFlags flag   = BindingFlags.Public | BindingFlags.Instance;
                            object       objret = null;
                            try
                            {
                                objret = info.Invoke(obj, flag, Type.DefaultBinder, new object[] { reqObj }, null);
                            }
                            catch (TargetInvocationException targetEx)
                            {
                                LogWrite.WriteLog(targetEx);
                            }
                            if (objret != null)
                            {
                                sret = Newtonsoft.Json.JsonConvert.SerializeObject(objret);
                            }
                        }
                    }
                }
                return(sret);
            }
            catch (Exception ex)
            {
                LogWrite.WriteLog(ex);
            }
            return(sret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 设置Eterm数据
        /// </summary>
        /// <param name="hwnd"></param>
        /// <param name="data"></param>
        public void SetEtermData(string config, string guid, string cmd, string data)
        {
            EtermHelper.EtermData[config + guid + cmd] = data;

            LogWrite.WriteLog(string.Format("config={0} guid={1} cmd={2}\r\ndata={3}", config, guid, cmd, data));
        }