/// <summary> /// 停止服务 /// </summary> public void StopServer() { try { #region BSP自动出票 if (BSPTh != null && BSPTh.IsAlive) { BSPTh.Abort(); BSPTh = null; } #endregion #region 取消编码 try { XePNR.XeLog = null; XePNR.m_XePNRInfo.EndFlag = true; XePNR.StopServer(); } catch (Exception ex) { //记录错误日志 Log.Record("XePnrError.log", ex, "停止服务按钮"); } #endregion //B2B自动出票 if (B2BAuto != null) { B2BAuto.Close(); } //抢票 if (robTicket != null) { robTicket.StopScan(); } } catch (Exception ex) { PnrAnalysis.LogText.LogWrite("停止自动出票服务:" + ex.Message, "AutoBSP"); } finally { if (SelGYList != null && SelGYList.Count > 0) { btnAutoStart.Enabled = true; btnAutoStop.Enabled = false; } } }
/// <summary> /// 开始服务 /// </summary> public void StartServer() { try { InitData(); if (SelGYList.Count == 0) { MessageBox.Show("请选择落地运营商!"); return; } #region BSP自动出票 if (BSPTh != null && BSPTh.IsAlive) { BSPTh.Abort(); BSPTh = null; } int.TryParse(txtBSPMinute.Text.Trim(), out BSPSecond); int.TryParse(txtBSPCount.Text.Trim(), out BSPCount); BSPAutoTicket.BSPShowLog bspLog = new BSPAutoTicket.BSPShowLog(ShowLog); try { if (BSPTh != null && BSPTh.IsAlive) { BSPTh.Abort(); } } catch (Exception) { } BSPTh = new Thread(new ThreadStart(delegate() { new BSPAutoTicket().BSPStart(SelGYList, SelGYTextList, BSPSecond, BSPCount, bspLog); })); //开启BSP if (BSPIsOpen) { BSPTh.Start(); } #endregion #region B2B自动出票 B2BAutoTicketStartCheck(SelGYList, SelGYTextList); #endregion #region 取消编码 try { #region 赋值相关参数设置信息 XePNR.m_XePNRInfo.EndFlag = false; XePNR.LPList = SelGYTextList; int ReTryCount = 0, InterMinutes = 1, day = 2; //失败尝试次数 if (int.TryParse(txtXePnrReTryCount.Text.Trim(), out ReTryCount)) { XePNR.m_XePNRInfo.ReTryCount = ReTryCount; } //遍历时间间隔 if (int.TryParse(txt_InterMinutes.Text.Trim(), out InterMinutes)) { XePNR.m_XePNRInfo.InterMinutes = InterMinutes; } if (int.TryParse(txtDay.Text.Trim(), out day)) { XePNR.m_XePNRInfo.day = day; } XePNR.XeLog = new XePNR.XePnrShowLog(ShowLog); XePNR.m_XePNRInfo.CompanyNoList = SelGYList;// string.Join(",", SelGYList.ToArray()); XePNR.m_XePNRInfo.XEMinutes = int.Parse(txt_XEMinutes.Text); #endregion 赋值相关参数设置信息 if (IsOpenXePnr) { XePNR.StartServer(); } } catch (Exception ex) { //记录错误日志 Log.Record("XePnrError.log", ex, "开始服务按钮"); } #endregion #region 抢票程序 robTicket = new RobTicket(); //扫描时间间隔 默认3分钟 int robTime = 180; int.TryParse(txt_RobScanTime.Text.Trim(), out robTime); robTicket.m_ScanTime = robTime; //扫描几分钟之类的订单 默认1小时 int robInnerTime = 60; int.TryParse(txtInnerTime.Text.Trim(), out robInnerTime); robTicket.m_InnerScanTime = robInnerTime; //扫描次数 int m_ScanCount = 1; int.TryParse(txtScanCount.Text.Trim(), out m_ScanCount); robTicket.m_ScanCount = m_ScanCount; //记录扫描日志 robTicket.m_Log = new RobTicket.RobShowLog(ShowLog); //落地运营商公司信息 robTicket.lstCpyNo = SelGYList; robTicket.SelGYTextList = SelGYTextList; if (IsOpenRobTicket) { robTicket.StartScan(); } #endregion } catch (Exception ex) { PnrAnalysis.LogText.LogWrite("开始自动出票服务:" + ex.Message, "AutoBSP"); } finally { if (SelGYList != null && SelGYList.Count > 0) { btnAutoStart.Enabled = false; btnAutoStop.Enabled = true; } } }