Пример #1
0
        public bool GetBranchIdData(string repository, string branchFullName, out string repId, out int branchId)
        {
            repId    = null;
            branchId = -1;

            if (branchFullName.StartsWith("/"))
            {
                branchFullName = branchFullName.Substring(1);
            }

            Uri endpoint = ApiUris.GetFullUri(
                mBaseUri, ApiEndpoints.GetBranch, repository, branchFullName);

            string actionDescription = string.Format(
                "get info of branch br:{0}@{1}", branchFullName, repository);

            BranchResponse response = Internal.MakeApiRequest <BranchResponse>(
                endpoint, HttpMethod.Get, actionDescription, mPlasticBotUserToken);

            if (response == null)
            {
                return(false);
            }

            repId    = response.RepositoryId;
            branchId = response.Id;

            return(true);
        }
Пример #2
0
        public static async Task <HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, TraceWriter log)
        {
            log.Info($"{nameof(GithubBranchDetailTigger)} : C# HTTP trigger function processed a request.");

            var token = req.Headers.Where(x => x.Key == tokenHeader)
                        .SelectMany(x => x.Value)
                        .FirstOrDefault();

            if (string.IsNullOrEmpty(token))
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest, $"Missing AccessToken from Header : {tokenHeader}"));
            }

            var json = await req.Content.ReadAsStringAsync();

            var request = JsonConvert.DeserializeObject <GithubBranchDetailRequest>(json);

            // Validation
            if (string.IsNullOrEmpty(token))
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest, $"{nameof(token)} query element must be included."));
            }
            if (string.IsNullOrEmpty(request.Owner))
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest, $"{nameof(request.Owner)} posted json element must be included."));
            }
            if (string.IsNullOrEmpty(request.Repository))
            {
                return(req.CreateResponse(HttpStatusCode.BadRequest, $"{nameof(request.Repository)} posted json element must be included."));
            }

            try
            {
                // Execute
                var sweeper = new GithubMergedBranchSweeper(request.Owner, token, request.Repository)
                {
                    ExcludeBranches = request.ExcludeBranches,
                };
                var branches = await sweeper.GetBranchesAsync();

                var results = await sweeper.GetBranchDetailsAsync(branches);

                // Response
                var response = new BranchResponse()
                {
                    Count = results.Length, Owner = request.Owner, Repository = request.Repository, Value = results
                };
                var responseJson = JsonConvert.SerializeObject(response);
                return(req.CreateResponse(HttpStatusCode.OK, responseJson));
            }
            catch (Exception ex)
            {
                log.Error($"{ex.Message} {ex.GetType().FullName} {ex.StackTrace}");
                return(req.CreateResponse(HttpStatusCode.InternalServerError, $"Error when running sweep. {ex.GetType()} {ex.Message}"));
            }
        }
Пример #3
0
        //Branch
        public BranchResponse ExecuteBranch(BranchRequest request)
        {
            var response = new BranchResponse();

            Type type = request.GetType();

            if (type.FullName == "BOA.Types.Banking.BranchRequest")
            {
                var pr = new BOA.Process.Banking.Branch();

                if (request.MethodName == "GetBranches")
                {
                    response = pr.GetBranches((BranchRequest)request);
                }
            }
            return(response);
        }
Пример #4
0
        public async Task <BranchResponse> GetMemberDetailsById()
        {
            BranchResponse         branchResponse = new BranchResponse();
            IEnumerable <BranchVM> branchVM;
            BranchVM v = new BranchVM();

            try
            {
                object a;
                a = await _memberRepository.GetDetails(1);

                branchVM = a as IEnumerable <BranchVM>;
                branchResponse.branchVM = branchVM;
            }
            catch (Exception ex)
            {
            }
            return(branchResponse);
        }