Ejemplo n.º 1
0
        /// <summary>
        /// 打开写入的目标流
        /// </summary>
        /// <returns></returns>
        protected virtual Stream GetWriteStream()
        {
            Stream stream = null;

            try
            {
                var e = new GeneralEventArgs <Stream>(null);
                OnOpenWriteStream(e);

                stream = e.Data;
            }
            catch (Exception ex)
            {
                AsyncData.Exception = ex;
                CompleteCallback();
            }

            if (stream == null && !Success)
            {
                AsyncData.Exception = new Exception("Open target stream failed.");
                CompleteCallback();
            }

            return(stream);
        }
Ejemplo n.º 2
0
        void Session_RequestShowPanel(object sender, GeneralEventArgs <PanelIndex> e)
        {
            var p = e.Data;

            switch (p)
            {
            case PanelIndex.QueryPanel:
                st.SelectedTab = stQueryManage;
                break;

            case PanelIndex.NotComplete:
                st.SelectedTab = stOrderManage;
                break;

            case PanelIndex.Orders:
                st.SelectedTab = stOrderManage;
                break;

            case PanelIndex.PassengerManage:
                st.SelectedTab = stPasManage;
                break;

            case PanelIndex.HbOrder:
                st.SelectedTab = stBackupOrder;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 3
0
        protected virtual void OnOpenWriteStream(GeneralEventArgs <Stream> e)
        {
            OpenWriteStream?.Invoke(this, e);

            if (e.Data == null)
            {
                System.IO.Directory.CreateDirectory(Path.GetDirectoryName(FilePath));

                var fileinfo = new FileInfo(FilePath);
                if (fileinfo.Exists)
                {
                    if (Context.Response.Status != HttpStatusCode.PartialContent)
                    {
                        EnableRestartProcess = false;
                    }
                    if (Context.Response.Status == HttpStatusCode.RequestedRangeNotSatisfiable)
                    {
                        //ok
                        Success = true;
                        return;
                    }
                }

                e.Data = new System.IO.FileStream(FilePath, EnableRestartProcess ? FileMode.Append : FileMode.Create, FileAccess.Write, FileShare.None);
                if (!EnableRestartProcess)
                {
                    PreDownloadDataLength = 0;
                }
            }
        }
Ejemplo n.º 4
0
 void _payOrderWorker_RequireDirectResign(object sender, GeneralEventArgs <bool> e)
 {
     AppContext.HostForm.Invoke(() =>
     {
         e.Data = this.Question("改签无需支付,确认即可改签。确定要改签吗?", true);
     });
 }
Ejemplo n.º 5
0
 private void OnChnnelIOError(MyEvent evt)
 {
     if (isConnecting)
     {
         GeneralEventArgs gevt    = evt as GeneralEventArgs;
         string           message = gevt.Parame as string;
         this.HandleConnectionProblem(gevt);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 引发 <see cref="ForceLogout" /> 事件
        /// </summary>
        public static void OnForceLogout(object sender, GeneralEventArgs <bool> ea)
        {
            var handler = ForceLogout;

            if (handler != null)
            {
                handler(sender, ea);
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 引发 <see cref="RequireLoadFileContent" /> 事件
        /// </summary>
        /// <param name="sender">引发此事件的源对象</param>
        /// <param name="ea">包含此事件的参数</param>
        internal static void OnRequireLoadFileContent([CanBeNull] object sender, [NotNull] GeneralEventArgs <ResourceLocation, string, string> ea)
        {
            if (ea == null)
            {
                throw new ArgumentNullException("ea", "ea is null.");
            }

            RequireLoadFileContent?.Invoke(sender, ea);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 引发 <see cref="RequestLoad" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnRequestLoad(GeneralEventArgs <Action <Action> > ea)
        {
            var handler = RequestLoad;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 引发 <see cref="SelectedQueryChanged" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnSelectedQueryChanged(GeneralEventArgs <QueryParam> ea)
        {
            var handler = SelectedQueryChanged;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
        /// <summary>
        /// 引发 <see cref="InitPopup" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnInitPopup(GeneralEventArgs <Popup> ea)
        {
            var handler = InitPopup;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
        /// <summary>
        /// 引发 <see cref="NotificationCreated" /> 事件
        /// </summary>
        /// <param name="sender">引发此事件的源对象</param>
        /// <param name="ea">包含此事件的参数</param>
        static void OnNotificationCreated(object sender, GeneralEventArgs <string> ea)
        {
            var handler = NotificationCreated;

            if (handler != null)
            {
                handler(sender, ea);
            }
        }
Ejemplo n.º 12
0
        private void ExecuteDisconnection(string reason)
        {
            GeneralEventArgs evt = new GeneralEventArgs(ClientEvent.DISCONNECT);

            evt.Parame = reason;
            base.Dispatch(evt);
            base.OnChannelDisconnect(channel);
            ReleaseResources();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 引发 <see cref="RequestAddCode" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnRequestAddCode(GeneralEventArgs <string> ea)
        {
            var handler = RequestAddCode;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 引发 <see cref="GenerateOptionsTabs" /> 事件
        /// </summary>
        /// <param name="sender">引发此事件的源对象</param>
        /// <param name="ea">包含此事件的参数</param>
        public static void OnGenerateOptionsTabs(object sender, GeneralEventArgs <List <OptionConfigForm.AbstractOptionConfigUI> > ea)
        {
            var handler = GenerateOptionsTabs;

            if (handler != null)
            {
                handler(sender, ea);
            }
        }
        void DirectResign()
        {
            var confirmEventArg = new GeneralEventArgs <bool>(false);

            DirectResignCancelled = false;
            OnRequireDirectResign(confirmEventArg);
            if (!confirmEventArg.Data)
            {
                DirectResignCancelled = true;
                return;
            }

            //确认直接改签
            var resignResult = Session.NetClient.Create <string>(HttpMethod.Post, "pay/payConfirm" + ParamData.GetValue("pay_mode"), "payOrder/init", new
            {
                parOrderDTOJson  = ParamData.GetValue("parOrderDTOJson"),
                oldTicketDTOJson = ParamData.GetValue("oldTicketDTOJson"),
                sequence_no      = ParamData.GetValue("sequence_no"),
                batch_no         = ParamData.GetValue("batch_no"),
                _json_att        = Session.Attributes ?? ""
            }).Send();

            if (!resignResult.IsValid())
            {
                Error = "无效的服务器响应";
                return;
            }

            try
            {
                var resignData = JsonConvert.DeserializeAnonymousType(resignResult.Result, new
                {
                    status = true,
                    data   = new
                    {
                        resignStatus = false,
                        errorMessage = ""
                    },
                    messages = new string[0]
                });
                if (!resignData.status || resignData.data == null)
                {
                    Error = "服务器返回操作失败: " + resignData.messages.JoinAsString("").DefaultForEmpty(resignResult.Result);
                    return;
                }
                if (!resignData.data.resignStatus)
                {
                    Error = "无法完成改签: " + resignData.data.errorMessage.DefaultForEmpty("未知错误");
                    return;
                }
            }
            catch (Exception)
            {
                Error = "无法解析服务器响应: " + resignResult.Result;
                return;
            }
        }
        /// <summary>
        /// 引发 <see cref="RequireDirectResign" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnRequireDirectResign(GeneralEventArgs <bool> ea)
        {
            var handler = RequireDirectResign;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 引发 <see cref="RequestSubmitOrder" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnRequestSubmitOrder(GeneralEventArgs <QueryResultItem, char> ea)
        {
            var handler = RequestSubmitOrder;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Ejemplo n.º 18
0
        internal virtual void OnChannelError(string errorInfo, SocketError error)
        {
            GeneralEventArgs evt     = new GeneralEventArgs(ClientEvent.IO_ERROR);
            string           message = errorInfo + " : " + error.ToString();

            evt.ErrorDes = message;
            evt.Parame   = message;
            base.Dispatch(evt);
        }
        /// <summary>
        /// 引发 <see cref="OccourTimesExceed" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnOccourTimesExceed(GeneralEventArgs <object> ea)
        {
            var handler = OccourTimesExceed;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 引发 <see cref="RequestSelectSeat" /> 事件
        /// </summary>
        /// <param name="ea">包含此事件的参数</param>
        protected virtual void OnRequestSelectSeat(GeneralEventArgs <char> ea)
        {
            var handler = RequestSelectSeat;

            if (handler != null)
            {
                handler(this, ea);
            }
        }
Ejemplo n.º 21
0
        private void OnChnnelDisconnect(MyEvent evt)
        {
            GeneralEventArgs gevt   = evt as GeneralEventArgs;
            string           reason = gevt.GetParame <string>();

            if (string.IsNullOrEmpty(reason))
            {
                reason = ClientDisconnectionReason.UNKNOWN;
            }
            this.Dispatch(new UnityClientEvent(UnityClientEvent.CONNECTION_LOST, reason));
        }
Ejemplo n.º 22
0
        internal virtual void OnChannelConnect(Channel ch)
        {
            StartSendThread();
            GeneralEventArgs evt = new GeneralEventArgs(ClientEvent.CONNECT);

            evt.Success = true;
            DateTime now  = DateTime.Now;
            TimeSpan span = (TimeSpan)(now - lastConnectTime);

            log.Info("Connect Time Distance:" + span.TotalMilliseconds);
            base.Dispatch(evt);
        }
Ejemplo n.º 23
0
        private void HandleConnectionProblem(MyEvent evt)
        {
            GeneralEventArgs event2 = evt as GeneralEventArgs;
            UnityClientEvent ucevt  = new UnityClientEvent(UnityClientEvent.CONNECTION);

            ucevt.Success  = false;
            ucevt.ErrorDes = event2.ErrorDes;
            ucevt.Parame   = event2.Parame;
            this.Dispatch(ucevt);
            this.isConnecting = false;
            this.client.Destroy();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 引发 <see cref="RequireSaveFileContent" /> 事件
        /// </summary>
        /// <param name="sender">引发此事件的源对象</param>
        /// <param name="ea">包含此事件的参数</param>
        internal static void OnRequireSaveFileContent([CanBeNull] object sender, [NotNull] GeneralEventArgs <ResourceLocation, string, string> ea)
        {
            if (ea == null)
            {
                throw new ArgumentNullException("ea", "ea is null.");
            }
            var handler = RequireSaveFileContent;

            if (handler != null)
            {
                handler(sender, ea);
            }
        }
Ejemplo n.º 25
0
 private void Close(string reason)
 {
     if (this.IsConnected)
     {
         GeneralEventArgs gevt = new GeneralEventArgs(ClientEvent.KICK_CLIENT, reason);
         this.HandleKickClient(gevt);
     }
     else
     {
         string[] messages = new string[] { "You are not connected" };
         this.log.Info(messages);
     }
 }
Ejemplo n.º 26
0
 public void HandleQueueDone(object sender, GeneralEventArgs eventData)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new QueueDoneHandler(HandleQueueDone), new object[] { sender, eventData });
     }
     else
     {
         string msg = String.Format("Queue Done received on {0} element {1} at time {2}",
                                    eventData.Subsystem, eventData.Subsystem.Element,
                                    eventData.DateTime.ToString("T"));
         statusBarPanel.Text = msg;
     }
 }
Ejemplo n.º 27
0
        private void HandleKickClient(MyEvent evt)
        {
            GeneralEventArgs geva   = evt as GeneralEventArgs;
            string           reason = geva.Parame as string;

            this.client.ReconnectionSeconds = 0;
            if (this.client.IsConnected)
            {
                this.client.Close(reason);
            }
            if (reason != null)
            {
                this.Dispatch(new UnityClientEvent(UnityClientEvent.CONNECTION_LOST, reason));
            }
        }
Ejemplo n.º 28
0
 internal virtual void OnChannelData(Channel ch, byte[] msg)
 {
     try
     {
         ByteArray data = new ByteArray(msg);
         codecFactory.Decode.Decode(ch, data);
     }
     catch (Exception e)
     {
         string[] messages = new string[] { "## ChannelDataError: " + e.Message };
         this.log.Error(messages);
         GeneralEventArgs evt = new GeneralEventArgs(ClientEvent.DATA_ERROR);
         evt.ErrorDes = e.ToString();
         evt.Parame   = evt.ErrorDes;
         base.Dispatch(evt);
     }
 }
Ejemplo n.º 29
0
        public async Task <bool> BeenForceLogout()
        {
            var ea = new GeneralEventArgs <bool>(false);

            OnForceLogout(this, ea);
            if (!ea.Data)
            {
                var service = ServiceContainer.Resolve <ISessionReloginService>();
                ea.Data = await service.ReloginAsync().ConfigureAwait(true);
            }

            if (!ea.Data)
            {
                OnLogout(this, LogoutReason.AccoutKicked);
            }

            return(ea.Data);
        }
Ejemplo n.º 30
0
        public ConfigCenter()
        {
            InitializeComponent();

            var isPro = RunTime.IsInProfessonalMode;

            AddOption(new GenericOption());
            AddOption(new ThemeConfig());
            AddOption(new UIConfig());
            AddOption(new MediaOption());

            if (isPro)
            {
                AddOption(new QueryConfig());
                AddOption(new QueryView());
                AddOption(new SubmitOrderConfig());
                AddOption(new SubmitAutoResumeConfig());
            }
            AddOption(new NetworkConfig());
            AddOption(new FuncOption());
            AddOption(new MailConfig());

            if (isPro)
            {
                AddOption(new WebNotificationConfig());
            }
            //AddOption(new PromotionOption());
            AddOption(new VcConfig());

            var ce = new GeneralEventArgs <List <AbstractOptionConfigUI> >(new List <AbstractOptionConfigUI>());

            UiEvents.OnGenerateOptionsTabs(this, ce);
            ce.Data.ForEach(AddOption);

            cbMode.SelectedIndex         = (int)ProgramConfiguration.Instance.Mode;
            cbMode.SelectedIndexChanged += (_1, _2) =>
            {
                var mode = (RunningMode)cbMode.SelectedIndex;
                ConfigurationPresets.Apply(mode);

                lblModeChanged.Visible = true;
            };
        }
Ejemplo n.º 31
0
 private void HandleQueueStopped(object sender, GeneralEventArgs eventData)
 {
   Log(String.Format("Queue Stopped received on subsystem {0}",
       eventData.Subsystem));
 }
Ejemplo n.º 32
0
 private void HandleQueueDone(object sender, GeneralEventArgs eventData)
 {
   m_ainSS.Stop();
   Log(String.Format("Queue Done received on {0}",
       eventData.Subsystem));
 }
Ejemplo n.º 33
0
 protected override void DoEventTriggered(GeneralEventArgs args)
 {
     base.DoEventTriggered(args);
     PPEmissionFunctionality.HandleEmissionEvent(_particles, _emissionEvent);
 }
Ejemplo n.º 34
0
 protected virtual void DoEventTriggered(GeneralEventArgs args) { }
 protected override void DoEventTriggered(GeneralEventArgs args)
 {
     base.DoEventTriggered(args);
     GameMainReferences.Instance.PlayerCharacter.UnlockSpell(_spell, _quietUnlock);
 }