Beispiel #1
0
        public FlowLayoutPanel GetFlowLayoutPanel(RequestParameter requestParameter)
        {
            if (requestParameter != null && !string.IsNullOrEmpty(requestParameter.CommaValue))
            {
                var flp = new FlowLayoutPanel();
                flp.Name = requestParameter.Name;

                var vals = requestParameter.CommaValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
                vals.Insert(0, "All");

                for (int i = 0; i < vals.Count; i++)
                {
                    CheckBox chk = new CheckBox();
                    chk.AutoSize = true;
                    chk.Name     = vals[i];
                    chk.Text     = vals[i];
                    if (chk.Name == "All")
                    {
                        chk.Text = requestParameter.Name + "(All)";
                    }
                    chk.CheckedChanged += Chk_CheckedChanged;

                    flp.Controls.Add(chk);
                }

                flp.AutoSize = true;
                return(flp);
            }

            return(null);
        }
Beispiel #2
0
        public Task <IEnumerable <ITrack> > GetTracks()
        {
            if (TracklistInternal != null)
            {
                return(Task.Run(() =>
                {
                    List <ITrack> tracks = new List <ITrack>();

                    foreach (Track t in TracklistInternal.Items)
                    {
                        t.Deserialize(Client);
                        tracks.Add(t);
                    }

                    return tracks as IEnumerable <ITrack>;
                }, Client.CancellationToken));
            }


            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("id", Id)
            };

            return(Client.Get <Track>("album/{id}/tracks", parms)
                   .ContinueWith <IEnumerable <ITrack> >(task => Client.Transform <Track, ITrack>(task.Result),
                                                         Client.CancellationToken,
                                                         TaskContinuationOptions.NotOnCanceled,
                                                         TaskScheduler.Default));
        }
Beispiel #3
0
 public void AddParameter(RequestParameter parameter, object value)
 {
     if (value is Array)
         parameters.Add(parameter.GetStringValue(), string.Join(",", (long[])value));
     else
         parameters.Add(parameter.GetStringValue(), value.ToString());
 }
        public async Task <PagedResponse <IEnumerable <GetAllProductsViewModel> > > Handle(GetAllProductsQuery request, CancellationToken cancellationToken)
        {
            var pageSize     = request.PageSize < 1 ? _paginationSettings.PageSize : request.PageSize;
            int totalRecords = await _productRepository.CountAsync();

            var validRequest = new RequestParameter(request.PageNumber, pageSize);

            if (request.PageNumber == 0) // get All
            {
                validRequest = new RequestParameter(1, totalRecords);
                //var data = await _productRepository.GetAllAsync();
                var data = await _productRepository.GetAllIncludingAsync(x => x.ProductCategory);

                var allProductViewModel = _mapper.Map <IEnumerable <GetAllProductsViewModel> >(data);
                return(new PagedResponse <IEnumerable <GetAllProductsViewModel> >(allProductViewModel, validRequest, totalRecords));
            }

            //var products =  _productRepository.GetAllIncluding(x=>x.ProductCategory);
            //var dataPaged = products.Skip((validRequest.PageNumber - 1) * pageSize)
            //    .Take(pageSize);
            var dataPaged = await _productRepository.GetPagedResponseAsync(validRequest.PageNumber, validRequest.PageSize, "ProductCategory");

            var productsViewModel = _mapper.Map <IEnumerable <GetAllProductsViewModel> >(dataPaged);

            return(new PagedResponse <IEnumerable <GetAllProductsViewModel> >(productsViewModel, validRequest, totalRecords));
        }
Beispiel #5
0
        private IRestResponse ExecuteAPI(string action, object postBody, Dictionary <string, string> headerParameters = null, Method method = Method.PUT)
        {
            var           node     = GetLastNode();
            IRestResponse response = null;

            if (postBody != null)
            {
                node.Info("Create request body");
                node.Info(postBody.ToString().MarkupJsonString());
            }

            RequestParameter requestParameter = new RequestParameter
            {
                Method           = method,
                OperationPath    = action,
                HeaderParameters = headerParameters,
                PostBody         = postBody
            };

            response = SendHttpCall(requestParameter);

            node.LogRestResponseInfo(response);

            return(response);
        }
 public async Task <IActionResult> Get([FromQuery] RequestParameter filter)
 {
     return(Ok(await _mediator.Send(new GetAllArticlesQuery()
     {
         PageSize = filter.PageSize, PageNumber = filter.PageNumber
     })));
 }
Beispiel #7
0
 public CommitGetOptionalParameters(string branchOrTag     = "",
                                    List <string> includes = null,
                                    List <string> excludes = null)
 {
     if (branchOrTag == "")
     {
         _branchOrTag = null;
     }
     else
     {
         _branchOrTag = new RequestParameter <string>("branchOrTag", branchOrTag);
     }
     if (includes == null)
     {
         _includes = null;
     }
     else
     {
         _includes = new MultiValueRequestParameter <string>("include", includes);
     }
     if (excludes == null)
     {
         _excludes = null;
     }
     else
     {
         _excludes = new MultiValueRequestParameter <string>("exclude", excludes);
     }
 }
        public HttpResponseMessage Execute(RequestParameter requestParameter)
        {
            var handler1 = new HttpClientHandler
            {
                ClientCertificateOptions = ClientCertificateOption.Manual,
                ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => true
            };

            var client = new HttpClient(handler1);

            var buildUrl = new UriBuilder(requestParameter.BaseAddress)
            {
                Path = requestParameter.UriPath
            };

            var request = new HttpRequestMessage()
            {
                RequestUri = buildUrl.Uri,
                Method     = requestParameter.Method
            };

            foreach (var header in requestParameter.HeaderParameter.GetParameters())
            {
                client.DefaultRequestHeaders.Add(header.Key, header.Value);
            }

            if (requestParameter.RequestBody != null)
            {
                var json = JsonConvert.SerializeObject(requestParameter.RequestBody);
                request.Content = new StringContent(json, Encoding.UTF8, "application/json");
            }

            return(client.SendAsync(request).Result);
        }
Beispiel #9
0
        public async Task <PagedResponse <List <UserResponse> > > GetAllAsync(RequestParameter page)
        {
            List <UserResponse> list = new List <UserResponse>();

            List <ApplicationUser> user = await _userManager.Users.Skip <ApplicationUser>((page.PageNumber - 1) *page.PageSize)
                                          .Take(page.PageSize)
                                          .AsNoTracking()
                                          .ToListAsync();

            foreach (var item in user)
            {
                UserResponse obj = new UserResponse
                {
                    Id             = item.Id.ToString(),
                    Firstname      = item.FirstName,
                    LastName       = item.LastName,
                    Username       = item.UserName,
                    Email          = item.Email,
                    EmailConfirmed = item.EmailConfirmed,
                    Created        = item.Created,
                    LastModified   = item.LastModified,
                };

                list.Add(obj);
            }

            return(new PagedResponse <List <UserResponse> >(list, page.PageNumber, page.PageSize));
        }
Beispiel #10
0
        public async Task <string> TranslateAsync(string text, string targetLanguage)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentException(nameof(text));
            }
            if (string.IsNullOrEmpty(targetLanguage))
            {
                throw new ArgumentException(nameof(text));
            }

            try
            {
                var requestParameter = new RequestParameter()
                {
                    To = new[] { targetLanguage }
                };
                var result = await _translateClient.TranslateAsync(
                    new RequestContent(text), requestParameter);

                return(result.First().Translations.First().Text);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
            }

            return(text);
        }
Beispiel #11
0
        public void ToQueryString_WhenToIsInvalid_ExpectException(params string[] data)
        {
            var rp = new RequestParameter();

            rp.To = data;

            Assert.Throws <Exception>(() => rp.ToQueryString());
        }
 public IHttpActionResult Get(long requestId = 0)
 {
     return(execute(delegate()
     {
         RequestParameter obj = requestService.Get(requestId);
         result = Json(new { success = true, data = obj });
     }));
 }
        public async Task <IActionResult> Get([FromQuery] RequestParameter filter)
        {
            var permissions = await _typeOfPermissionRepository.GetPagedReponseAsync(filter.PageNumber, filter.PageSize, x => !x.IsDeleted);

            var permissionsViewModel = _mapper.Map <IEnumerable <TypeOfPermissionDto> >(permissions);

            return(Ok(new PagedResponse <IEnumerable <TypeOfPermissionDto> >(permissionsViewModel, filter.PageNumber, filter.PageSize)));
        }
Beispiel #14
0
            /// <summary>
            /// 定义事件需求与窗口中引发此事件的控件对象及对应的事件参数
            /// </summary>
            /// <param name="RequestId">具体的需求</param>
            /// <param name="e">Form中的事件所对应的事件参数</param>
            /// <param name="sender">引发Form事件控件对象</param>
            /// <remarks></remarks>
            public RequestParameter(Request RequestId, EventArgs e = null, object sender = null)
            {
                RequestParameter with_1 = this;

                with_1.F_sender = sender;
                with_1.F_e      = e;
                with_1.F_Id     = RequestId;
            }
Beispiel #15
0
        /// <summary>
        /// Параметры для создания новой заявки на основе существующей заявки
        /// </summary>
        public RequestParameter GetNewByRequestId(long requestId)
        {
            RequestParameter r = getCreateOrUpdateRequest(requestId);

            r.Id          = 0;
            r.ByRequestId = requestId;
            return(r);
        }
        internal string ToOrderedJson()
        {
            var res = RequestParameter.ToObjectDictionary();

            res.Add(_signature.Key, _signature.Value);
            _requestString = res.ToJson();
            return(_requestString);
        }
Beispiel #17
0
        public Task <bool> AddRadioToFavourite(ulong radioId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("radio_id", radioId),
            };

            return(Client.Post("user/me/radios", parms, DeezerPermissions.ManageLibrary));
        }
        public void GetAccessTokenParamter()
        {
            var actual = RequestParameter.GetAccessTokenParamter("245bmueho57");

            Assert.IsNotNull(actual);
            Assert.AreEqual("access_token", actual.Id, "Id");
            Assert.AreEqual("245bmueho57", actual.Value, "Value");
            Assert.AreEqual(ParameterType.QueryString, actual.Type, "Type");
        }
        public void RequestParameterTest()
        {
            var parameter = new RequestParameter("苹果");

            parameter.Salt = "1";
            Assert.AreEqual("9425afeed2b7892b7ee31055f328f2bd", parameter.GetSign());
            //parameter.Secret
            //Assert.Fail();
        }
Beispiel #20
0
 public EOrderController(string eBusinessID, string appKey, string url)
 {
     _RequestParameter = new RequestParameter();
     this._RequestParameter.EBusinessID = eBusinessID;
     this._RequestParameter.DataType    = "2";
     this._RequestParameter.RequestType = "1007";
     this._ApiUrl = url;
     this._AppKey = appKey;
 }
Beispiel #21
0
        public Task <bool> AddTrackToFavourite(ulong trackId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("track_id", trackId),
            };

            return(Client.Post("user/me/tracks", parms, DeezerPermissions.ManageLibrary));
        }
Beispiel #22
0
        public Task <bool> RemovePlaylistFromFavourite(ulong playlistId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("playlist_id", playlistId),
            };

            return(Client.Delete("user/me/playlists", parms, DeezerPermissions.ManageLibrary | DeezerPermissions.DeleteLibrary));
        }
        public void GetNewUrlSegmentParamter()
        {
            var actual = RequestParameter.GetNewUrlSegmentParamter("user", new { ID = 10 });

            Assert.IsNotNull(actual);
            Assert.AreEqual("user", actual.Id, "Id");
            Assert.AreEqual(new { ID = 10 }, actual.Value, "Value");
            Assert.AreEqual(ParameterType.UrlSegment, actual.Type, "Type");
        }
Beispiel #24
0
        public Task <bool> SetSeen()
        {
            List <IRequestParameter> p = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("id", this.Id),
            };

            return(Client.Post("playlist/{id}/seen", p, DeezerPermissions.BasicAccess));
        }
        public void GetNewQueryStringParameter()
        {
            var actual = RequestParameter.GetNewQueryStringParameter("address", new { number = 2 });

            Assert.IsNotNull(actual);
            Assert.AreEqual("address", actual.Id, "Id");
            Assert.AreEqual(new { number = 2 }, actual.Value, "Value");
            Assert.AreEqual(ParameterType.QueryString, actual.Type, "Type");
        }
Beispiel #26
0
        public Task <bool> RemoveAlbumFromFavourite(ulong albumId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("album_id", albumId),
            };

            return(Client.Delete("user/me/albums", parms, DeezerPermissions.ManageLibrary | DeezerPermissions.DeleteLibrary));
        }
Beispiel #27
0
        public Task <bool> AddArtistToFavourite(ulong artistId)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewQueryStringParameter("artist_id", artistId),
            };

            return(Client.Post("user/me/artists", parms, DeezerPermissions.ManageLibrary));
        }
 public IHttpActionResult Save(RequestParameter dto)
 {
     return(execute(delegate()
     {
         long userId = User.Identity.GetUserId <long>();
         dto.UserId = userId;
         long requestId = requestService.Save(dto);
         result = Json(new { success = true, requestId = requestId });
     }));
 }
Beispiel #29
0
        public Task <bool> AddToPlaylist(uint playlistId, string songids)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("playlist_id", playlistId),
                RequestParameter.GetNewQueryStringParameter("songs", songids)
            };

            return(Client.Post("playlist/{playlist_id}/tracks", parms, DeezerPermissions.ManageLibrary));
        }
Beispiel #30
0
        public Task <uint> CreatePlaylist(string title)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("id", Id),
                RequestParameter.GetNewQueryStringParameter("title", title)
            };

            return(Client.PostForCreate("user/{id}/playlists", parms, DeezerPermissions.ManageLibrary).ContinueWith(t => t.Result.Id));
        }
Beispiel #31
0
        public Task <bool> RemoveTracks(string aTrackIds)
        {
            List <IRequestParameter> parms = new List <IRequestParameter>()
            {
                RequestParameter.GetNewUrlSegmentParamter("playlist_id", Id),
                RequestParameter.GetNewQueryStringParameter("songs", aTrackIds)
            };

            return(Client.Delete("playlist/{playlist_id}/tracks", parms, DeezerPermissions.ManageLibrary | DeezerPermissions.DeleteLibrary));
        }
 public AppController(IAppService appService, RequestParameter requestParameter)
 {
     _appService = appService;
     _requestParameter = requestParameter;
 }
 /// <summary>
 /// 注入参数及服务
 /// </summary>
 /// <param name="tenantService"></param>
 /// <param name="requestParameter"></param>
 public TenantController(ITenantService tenantService, RequestParameter requestParameter)
 {
     _tenantService = tenantService;
     _requestParameter = requestParameter;
 }