public async Task <IActionResult> GetFilesList([FromQuery] FileParams <Models.File> param)
        {
            var files = await _uow.FileRepository.Get("Daily,FileType",
                                                      x => x.OrderByDescending(f => f.Id),
                                                      filter => filter.Name.StartsWith (param.Name) || filter.FileNum55 == param.Name || filter.FileNum224 == param.Name);

            if (files == null)
            {
                return(NotFound());
            }

            var filePagedList = await PagedList <Models.File> .CreateAsync(files.AsQueryable(), param.PageNumber, param.PageSize);

            var empsToReturn = _mapper.Map <IEnumerable <FilesDTO> > (filePagedList);

            Response.AddPageination(filePagedList.CurrentPage, filePagedList.PageSize, filePagedList.TotalCount, filePagedList.TotalPages);
            return(Ok(empsToReturn));
        }
        public override StatementSyntax GetSyntax()
        {
            var paramArgList = new List <SyntaxNodeOrToken>();

            paramArgList.Add(GetLiteralArg("path", Path));
            paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));

            if (PathParams.Any())
            {
                paramArgList.Add(GetVariableArg("pathParams", "pathParams"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            if (QueryParams.Any())
            {
                paramArgList.Add(GetVariableArg("queryParams", "queryParams"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            if (FileParams.Any())
            {
                paramArgList.Add(GetVariableArg("fileParams", "fileParams"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            if (FormParams.Any())
            {
                paramArgList.Add(GetVariableArg("formParams", "formParams"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            if (BodyParams.Any(b => b.External != true))
            {
                paramArgList.Add(GetVariableArg("bodyParams", "bodyParams"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            if (BodyParams.Any(b => b.External == true && !b.Key.EndsWith("request")))
            {
                paramArgList.Add(GetVariableArg("externalBodyParams", "externalBodyParams"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            if (HasRequest)
            {
                paramArgList.Add(GetVariableArg("request", "objectToUnpack"));
                paramArgList.Add(SyntaxFactory.Token(SyntaxKind.CommaToken));
            }

            paramArgList.Add(GetMemberAccessArg("method", "HttpMethods", HttpMethod));

            var statementBody = SyntaxFactory.AwaitExpression(
                SyntaxFactory.InvocationExpression(
                    SyntaxFactory.MemberAccessExpression(
                        SyntaxKind.SimpleMemberAccessExpression,
                        SyntaxFactory.IdentifierName("Client"),
                        SyntaxFactory.GenericName(
                            SyntaxFactory.Identifier("CallApi"))
                        .WithTypeArgumentList(
                            SyntaxFactory.TypeArgumentList(
                                SyntaxFactory.SingletonSeparatedList <TypeSyntax>(
                                    SyntaxFactory.IdentifierName(Returns))))))
                .WithArgumentList(
                    SyntaxFactory.ArgumentList(
                        SyntaxFactory.SeparatedList <ArgumentSyntax>(
                            paramArgList.ToArray()
                            ))));

            if (IsVoidTask)
            {
                return(SyntaxFactory.ExpressionStatement(statementBody));
            }

            return(SyntaxFactory.ReturnStatement(statementBody));
        }
        protected List <StatementSyntax> GetMethodBodyParams(bool ignoreQuery = false)
        {
            var methodBody = new List <StatementSyntax>();

            if (PathParams.Any())
            {
                var pathDeclaration = new DictionaryParamaterLocalDeclarationSyntax
                {
                    Name     = "pathParams",
                    MyParams = PathParams,
                }.GetSyntax();

                methodBody.Add(pathDeclaration);
            }

            if (QueryParams.Any() && !ignoreQuery)
            {
                var queryParamDeclaration = new DictionaryParamaterLocalDeclarationSyntax
                {
                    Name     = "queryParams",
                    MyParams = QueryParams,
                }.GetSyntax();

                methodBody.Add(queryParamDeclaration);
            }

            if (FileParams.Any())
            {
                var fileParamDeclaration = new DictionaryParamaterLocalDeclarationSyntax
                {
                    Name     = "fileParams",
                    MyParams = FileParams,
                    VarType  = "Stream",
                }.GetSyntax();

                methodBody.Add(fileParamDeclaration);
            }

            if (FormParams.Any())
            {
                var formParamDeclaration = new DictionaryParamaterLocalDeclarationSyntax
                {
                    Name     = "formParams",
                    MyParams = FormParams,
                }.GetSyntax();

                methodBody.Add(formParamDeclaration);
            }

            if (BodyParams.Any(b => b.External != true))
            {
                var bodyParamDeclaration = new BodyParameterContainer
                {
                    Name       = "bodyParams",
                    BodyType   = UseAnnonBody ? "Annonymous" : Returns,
                    BodyParams = BodyParams.Where(b => b.External != true && !b.Key.EndsWith("request")).ToList(),
                }.GetSyntax();

                methodBody.Add(bodyParamDeclaration);
            }

            // add external body params
            if (BodyParams.Any(b => b.External == true && !b.Key.EndsWith("request")))
            {
                var bodyParamDeclaration = new BodyParameterContainer
                {
                    Name       = "externalBodyParams",
                    BodyType   = "Annonymous",
                    BodyParams = BodyParams.Where(b => b.External == true && !b.Key.EndsWith("request")).ToList(),
                }.GetSyntax();

                methodBody.Add(bodyParamDeclaration);
            }

            return(methodBody);
        }
예제 #4
0
        //private FileWrapper handleAddFileWithMultipartFile(string entityType, int entityId, MultipartFormDataContent multipartFile, string externalId, FileParams fileParams, bool v)
        //{

        //    Dictionary<string, string> uriVariables = restUriVariablesFactory.getUriVariablesForAddFile(BullhornEntityInfo.getTypesRestEntityName(type),
        //            entityId, externalId, fileParams);
        //    String url = restUrlFactory.assembleAddFileUrl(params);

        //    return this.handleAddFile(type, entityId, multiValueMap, url, uriVariables, multipartFile.getOriginalFilename(), deleteFile);
        //}


        private FileApiResponse handleAddFile(string entityType, int entityId, string base64encodedFile, FileParams fileParams)
        {
            StandardFileApiResponse fileApiResponse;
            string url = restUrlFactory.assembleFileAddUrl(entityType, entityId, base64encodedFile, restApiSession.GetBhRestToken());

            try
            {
                StandardFileWrapper wrapper = new StandardFileWrapper(base64encodedFile);

                HttpRequestMessage _httpRequest = new HttpRequestMessage();
                _httpRequest.RequestUri = new Uri(url);
                _httpRequest.Method     = HttpMethod.Put;
                _httpRequest.Content    = new StringContent(
                    JsonConvert.SerializeObject(
                        wrapper,
                        Formatting.Indented,
                        new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                }), Encoding.UTF8, "application/json");

                Console.WriteLine(JsonConvert.SerializeObject(
                                      wrapper,
                                      Formatting.Indented,
                                      new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    ContractResolver  = new CamelCasePropertyNamesContractResolver(),
                }));
                var response = httpClient.SendAsync(_httpRequest).Result.Content.ReadAsStringAsync().Result;
                fileApiResponse = JsonConvert.DeserializeObject <StandardFileApiResponse>(response);
            }
            catch (HttpException error)
            {
                fileApiResponse = null;
                //fileApiResponse = restErrorHandler.handleHttpFourAndFiveHundredErrors(new DeleteResponse(), error, entityId);
            }
            return(fileApiResponse);
        }
예제 #5
0
 public FileApiResponse addFile(string entityType, int entityId, string base64encodedfile, string externalId, FileParams fileParams)
 {
     return(this.handleAddFile(entityType, entityId, base64encodedfile, fileParams));
 }