예제 #1
0
파일: Main.cs 프로젝트: lulzzz/SS.Payment
        private object Service_ApiPost(object sender, ApiEventArgs args)
        {
            var request = args.Request;

            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiGet)))
            {
                return(StlPayment.ApiGet(request));
            }
            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiPay)))
            {
                return(StlPayment.ApiPay(request));
            }
            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiPaySuccess)))
            {
                return(StlPayment.ApiPaySuccess(request));
            }
            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiWeixinInterval)))
            {
                return(StlPayment.ApiWeixinInterval(request));
            }
            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiWeixinNotify)))
            {
                return(StlPayment.ApiWeixinNotify(request, args.Id));
            }
            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiRedirect)))
            {
                var successUrl = request.GetPostString("successUrl");
                StlPayment.ApiRedirect(successUrl);
            }

            return(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
예제 #2
0
 /// <summary>
 /// 获取 Session 时触发
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnGetSession(ApiEventArgs e)
 {
     if (e.Context.Session.IsNewSession)
     {
         OnNewSession(e);
     }
 }
예제 #3
0
        public WaitWindow(string datenbank,
                          string apiToken,
                          string idHersteller,
                          string idKategorie,
                          string idProdukt)
        {
            InitializeComponent();

            DataContext = this;

            WaitText             = "Die Informationen werden von " + datenbank + " abgerufen...";
            ResultHerstellerDto  = new ResponseHerstellerBaseDto();
            ResultKategorienList = new List <KategorienViewModel>();
            ResultList           = new List <DatenbankteilAuswahlViewModel>();
            ResultProduktString  = "";
            ResultProduktLink    = "";
            ErrorText            = string.Empty;

            _eventArgs = new ApiEventArgs
            {
                ApiToken     = apiToken,
                Datenbank    = datenbank,
                HerstellerId = idHersteller,
                KategorieId  = idKategorie,
                ProduktId    = idProdukt
            };

            _worker                     = new BackgroundWorker();
            _worker.DoWork             += _worker_DoWork;
            _worker.RunWorkerCompleted += _worker_RunWorkerCompleted;
        }
예제 #4
0
 protected void CallApi(object sender, ApiEventArgs <TApi> data)
 {
     if (ApiInvoke == null)
     {
         return;
     }
     ApiInvoke(sender, data);
 }
        private void OnGetEntriesEnded(int value)
        {
            ApiEventArgs args = new ApiEventArgs
            {
                Value = value
            };

            GetEntriesEnded?.Invoke(this, args);
        }
        private void OnGetEntriesIncremented()
        {
            ApiEventArgs args = new ApiEventArgs
            {
                Value = 1
            };

            GetEntriesIncremented?.Invoke(this, args);
        }
예제 #7
0
        private object Service_ApiGet(object sender, ApiEventArgs args)
        {
            if (Utils.EqualsIgnoreCase(args.Action, nameof(ApiUtils.Captcha)))
            {
                return(ApiUtils.Captcha(args.Request, args.Id));
            }

            throw new Exception("请求的资源不在服务器上");
        }
        //TODO: 考虑手工硬编码
        /// <exception cref="MobileException"></exception>
        /// <exception cref="DatabaseException"></exception>
        private async Task OnApiClientRequestingAsync(ApiRequest request, ApiEventArgs args)
        {
            if (args.RequestType == ApiRequestType.Add)
            {
                _addRequestClientIdDict[request.GetRequestId()] = new List <long>();
            }

            await ChangeIdAsync(request, args.RequestId, ChangeDirection.ToServer, args.RequestType).ConfigureAwait(false);
        }
예제 #9
0
        void OnApiChangeMessage(bool apiReady)
        {
            ApiEventArgs e = new ApiEventArgs(apiReady);

            Logger.WriteLine("Firing ApiReady event");
            if (apiChangedEvent != null)
            {
                apiChangedEvent.Invoke(this, e);
            }
        }
예제 #10
0
파일: Main.cs 프로젝트: lulzzz/SS.Payment
        private object Service_ApiGet(object sender, ApiEventArgs args)
        {
            var request = args.Request;

            if (Utils.EqualsIgnoreCase(args.Action, nameof(StlPayment.ApiQrCode)))
            {
                return(StlPayment.ApiQrCode(request));
            }

            return(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
예제 #11
0
        private object Service_ApiGet(object sender, ApiEventArgs args)
        {
            if (!string.IsNullOrEmpty(args.Action) && !string.IsNullOrEmpty(args.Id))
            {
                if (Utils.EqualsIgnoreCase(args.Action, nameof(ApiHttpGet.Captcha)))
                {
                    return(ApiHttpGet.Captcha(args.Id));
                }
            }

            throw new Exception("请求的资源不在服务器上");
        }
예제 #12
0
        private void ProgressIncremented(object sender, ApiEventArgs args)
        {
            currentProgress += args.Value;

            Invoke(new MethodInvoker(delegate
            {
                var progress = webBrowser.Document.GetElementsByTagName("progress");
                if (progress != null && progress.Count > 0)
                {
                    progress[0].SetAttribute("value", $"{currentProgress}");
                }
            }));
        }
        /// <exception cref="DatabaseException"></exception>
        /// <exception cref="MobileException"></exception>
        private async Task OnApiClientResponsedAsync(object?sender, ApiEventArgs args)
        {
            switch (args.RequestType)
            {
            case ApiRequestType.Add:

                if (sender is IEnumerable <long> servierIds)
                {
                    List <long> clientIds = _addRequestClientIdDict[args.RequestId];

                    await AddServerIdToClientIdAsync(servierIds, clientIds).ConfigureAwait(false);

                    _addRequestClientIdDict.Remove(args.RequestId);
                }

                break;

            case ApiRequestType.Update:
                break;

            case ApiRequestType.Delete:
                break;

            case ApiRequestType.Get:
                if (sender is IEnumerable enumerable)
                {
                    foreach (object obj in enumerable)
                    {
                        await ChangeIdAsync(obj, args.RequestId, ChangeDirection.FromServer, args.RequestType).ConfigureAwait(false);
                    }
                }
                break;

            case ApiRequestType.GetSingle:
                await ChangeIdAsync(sender, args.RequestId, ChangeDirection.FromServer, args.RequestType).ConfigureAwait(false);

                break;

            default:
                break;
            }
        }
예제 #14
0
 /// <summary>
 /// 准备返回数据时触发
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeginResponse(ApiEventArgs e)
 {
 }
예제 #15
0
 /// <summary>
 /// 出现 <see cref="ApiException"/> 时触发
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnApiException(ApiEventArgs e) => OnException(e);
예제 #16
0
 /// <summary>
 /// 默认情况下出现任何异常都触发,但重新<see cref="OnApiException"/> 或 <see cref="OnUnprocessException"/> 后不,对应的异常不会触发该事件
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnException(ApiEventArgs e)
 {
 }
예제 #17
0
 /// <summary>
 /// 准备调用API方法时触发
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeginInvokeMethod(ApiEventArgs e)
 {
 }
예제 #18
0
 /// <summary>
 /// 出现未处理的非 <seealso cref="ApiException"/> 异常时触发
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnUnprocessException(ApiEventArgs e) => OnException(e);
예제 #19
0
 /// <summary>
 /// 获取 Session 时,如果 IsNewSession = true 则触发, 重写 <see cref="OnGetSession"/> 后不触发该事件
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnNewSession(ApiEventArgs e)
 {
 }
예제 #20
0
 /// <summary>
 /// 数据解析完成时触发
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnApiDataParsed(ApiEventArgs e)
 {
 }
예제 #21
0
 /// <summary>
 /// 请求开始时触发,这是第一个被触发的事件
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnBeginRequest(ApiEventArgs e)
 {
 }
예제 #22
0
        private static object Service_ApiPost(object sender, ApiEventArgs args)
        {
            if (!string.IsNullOrEmpty(args.Action) && Utils.EqualsIgnoreCase(args.Action, "actions") && !string.IsNullOrEmpty(args.Id))
            {
                var request = args.Request;
                var id      = args.Id;

                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.LoadConfig)))
                {
                    return(ApiJsonActionsPost.LoadConfig(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.Login)))
                {
                    return(ApiJsonActionsPost.Login(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.Logout)))
                {
                    return(ApiJsonActionsPost.Logout(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.ResetPassword)))
                {
                    return(ApiJsonActionsPost.ResetPassword(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.ResetPasswordByToken)))
                {
                    return(ApiJsonActionsPost.ResetPasswordByToken(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.Edit)))
                {
                    return(ApiJsonActionsPost.Edit(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.GetLogs)))
                {
                    return(ApiJsonActionsPost.GetLogs(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.IsMobileExists)))
                {
                    return(ApiJsonActionsPost.IsMobileExists(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.IsPasswordCorrect)))
                {
                    return(ApiJsonActionsPost.IsPasswordCorrect(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.IsCodeCorrect)))
                {
                    return(ApiJsonActionsPost.IsCodeCorrect(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.SendSms)))
                {
                    return(ApiJsonActionsPost.SendSms(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.SendSmsOrRegister)))
                {
                    return(ApiJsonActionsPost.SendSmsOrRegister(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.RegisterWithCode)))
                {
                    return(ApiJsonActionsPost.RegisterWithCode(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.CreateContent)))
                {
                    return(ApiJsonActionsPost.CreateContent(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.DeleteContent)))
                {
                    return(ApiJsonActionsPost.DeleteContent(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.EditContent)))
                {
                    return(ApiJsonActionsPost.EditContent(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.GetContent)))
                {
                    return(ApiJsonActionsPost.GetContent(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.GetContents)))
                {
                    return(ApiJsonActionsPost.GetContents(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.GetChannels)))
                {
                    return(ApiJsonActionsPost.GetChannels(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.GetSites)))
                {
                    return(ApiJsonActionsPost.GetSites(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.GetTableColumns)))
                {
                    return(ApiJsonActionsPost.GetTableColumns(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiJsonActionsPost.UploadAvatarResize)))
                {
                    return(ApiJsonActionsPost.UploadAvatarResize(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiHttpActionsPost.UploadAvatar)))
                {
                    return(ApiHttpActionsPost.UploadAvatar(request));
                }
                if (Utils.EqualsIgnoreCase(id, nameof(ApiHttpActionsPost.UploadSiteFiles)))
                {
                    return(ApiHttpActionsPost.UploadSiteFiles(request));
                }
            }

            throw new Exception("请求的资源不在服务器上");
        }
예제 #23
0
 public virtual void Call(object sender, ApiEventArgs <TApi> data)
 {
     FilterCall(sender, data);
 }
예제 #24
0
 /// <summary>External Trigger</summary>
 public virtual void Call(ApiEventArgs <TApi> data)
 {
     Call(null, data);
 }
예제 #25
0
 public object OnApiPut(ApiEventArgs e)
 {
     return(ApiPut?.Invoke(this, e));
 }
예제 #26
0
 public object OnApiDelete(ApiEventArgs e)
 {
     return(ApiDelete?.Invoke(this, e));
 }
예제 #27
0
 /// <summary>
 /// 请求结束时触发,这是最后一个被触发的事件
 /// </summary>
 /// <param name="e"></param>
 protected virtual void OnEndRequest(ApiEventArgs e)
 {
 }
 public void TestSetup()
 {
     eventArgs = new ApiEventArgs();
 }
예제 #29
0
 /// <returns>true if OnApi handles the call</returns>
 protected virtual void OnApi(object sender, ApiEventArgs <TApi> args)
 {
 }