예제 #1
0
        private static async Task <Customer> SimpleGraphQLClientDemo()
        {
            var customerRequest = new GraphQLRequest
            {
                Query     = @"query Sample($customerId :Int, $portfolioId: Int, $present: Boolean!)
                            {
                              customer:customer(id:$customerId)
                              {
                                id  @include(if: $present)
                                address
                                 ...custFragment
                              }  
                            }
                            fragment custFragment on CustomerType
                            {
                              name
                              portfolio(id:$portfolioId)
                              {
                                name
                                id
                              }
                            }",
                Variables = new { portfolioId = 1, customerId = 2, present = false }
            };

            var graphQLClient   = new GraphQL.Client.GraphQLClient(GraphQlServerUrl);
            var graphQLResponse = await graphQLClient.PostAsync(customerRequest);

            var customer = graphQLResponse.GetDataFieldAs <Customer>("customer");

            return(customer);
        }
        public async Task <List <DataEvent> > GetDataData()
        {
            var query = new GraphQLRequest
            {
                Query = @"query
						    { eventMany {
                                routing {
                                    action
                                    entityId
                                }
                            }
                        }"
            };
            var token = "eyJhbGciOiJSUzI1NiIsImtpZCI6ImZaTXdEZ2JDUllpbktDbWdDZjdZUFRPSHpScyIsInR5cCI6IkpXVCIsIng1dCI6ImZaTXdEZ2JDUllpbktDbWdDZjdZUFRPSHpScyJ9.eyJuYmYiOjE1ODkxODg2NjcsImV4cCI6MTU4OTE5MDQ2NywiaXNzIjoiaHR0cHM6Ly9pZG0uZGV2ZWxvcG1lbnQub3BhbDIuY29uZXh1cy5uZXQiLCJhdWQiOlsiaHR0cHM6Ly9pZG0uZGV2ZWxvcG1lbnQub3BhbDIuY29uZXh1cy5uZXQvcmVzb3VyY2VzIiwiY3hEb21haW5JbnRlcm5hbEFwaSJdLCJjbGllbnRfaWQiOiJPcGFsMldlYkFwcCIsImNsaWVudF9wb2xpY3lfaWQiOiJqd3QiLCJzdWIiOiIyMjgxRjFBMi04NDZDLTQyRDYtODQ1QS1FREUxMDdGRkVGQ0MiLCJhdXRoX3RpbWUiOjE1ODkxODg2NjYsImlkcCI6ImxvY2FsIiwiZ2l2ZW5fbmFtZSI6InN5cy1hZG1pbi0wMiIsImVtYWlsIjoic3lzLWFkbWluLTAyQHlvcG1haWwuY29tIiwicm9sZSI6WyJNT0VIUSBDb250ZW50IEFwcHJvdmluZyBPZmZpY2VyIiwiQ291cnNlIFBsYW5uaW5nIENvb3JkaW5hdG9yIiwiQ291cnNlIEFwcHJvdmluZyBPZmZpY2VyIiwiQ29udGVudCBDcmVhdG9yIiwiU3lzdGVtIEFkbWluaXN0cmF0b3IiLCJVc2VyIEFjY291bnQgQWRtaW5pc3RyYXRvciIsIkNvdXJzZSBBZG1pbmlzdHJhdG9yIiwiU2Nob29sIENvbnRlbnQgQXBwcm92aW5nIE9mZmljZXIiLCJXZWIgUGFnZSBFZGl0b3IiLCJDb3Vyc2UgQ29udGVudCBDcmVhdG9yIiwiT1BKIEFwcHJvdmluZyBPZmZpY2VyIiwiTGVhcm5lciIsIlNjaG9vbCBTdGFmZiBEZXZlbG9wZXIiLCJDb3Vyc2UgRmFjaWxpdGF0b3IiXSwic2NvcGUiOlsib3BlbmlkIiwicHJvZmlsZSIsImN4cHJvZmlsZSIsImN4RG9tYWluSW50ZXJuYWxBcGkiXSwiYW1yIjpbInB3ZCJdfQ.JibqF61ro1aMfU9Q66X5hKkIhHpqBT3VHp6pZxIxehx5j-Xz8qBGjo9hO30VX0sKGXqou96heDtWpo1XfztyTxFpv9BQ2LoDU3o-wrs3COXMXA7RGhz_YUYPlIMBwp44wHT0bkZ-lgRiYQdVrux3Xzox3P7L_rxJIrKJmjKqa682CBDoyqQbG0nmkWdy-VKu2wmzhwHIfPQNi5CTsWsVT7k--QeMiXnJPSqaY11jvgkia6f8oGR4fdAPikOAGmqd3JJrEV-1gFQxuE-IYNlz55WWpKbH6SxpBiCc25g3KIXg6U7n6iQcbCKszoSk7hTlqK7iiq1i57olf7di5Iv8Bg";

            _client.DefaultRequestHeaders.Add("Authorization", $"bearer {token}");
            var response = await _client.PostAsync(query);

            if (response.Data == null)
            {
                return(null);
            }

            return(response.GetDataFieldAs <List <DataEvent> >("eventMany"));
        }
예제 #3
0
        private static async Task <Customer> SimpleMutationClientDemo()
        {
            var customerRequest = new GraphQLRequest
            {
                Query     = @"mutation ($customer:CustomerInput!) 
                            {
                                    createCustomer(customer: $customer) 
                                    {
                                    id
                                    name
                                    city
                                }
                      }",
                Variables = new
                {
                    customer = new
                    {
                        name = "me", address = "1234 anywhere", city = "buffalo grove"
                    }
                }
            };

            var graphQLClient   = new GraphQL.Client.GraphQLClient(GraphQlServerUrl);
            var graphQLResponse = await graphQLClient.PostAsync(customerRequest);

            var customer = graphQLResponse.GetDataFieldAs <Customer>("createCustomer");

            return(customer);
        }
예제 #4
0
        public async Task <Owner> GetOwner(int id)
        {
            var query = new GraphQLRequest
            {
                Query     = @"
                query ownerQuery($ownerID: Int!) {
                  owner(id: $ownerID) {
                    id
                    name
                    age
                    location                   
                  }
                }",
                Variables = new { ownerID = id }
            };

            var response = await _client.PostAsync(query);

            return(response.GetDataFieldAs <Owner>("owner"));
        }
예제 #5
0
        public async Task <List <Owner> > GetAllOwners()
        {
            var query = new GraphQLRequest
            {
                Query = @"
                query ownersQuery{
                  owners {
                    id
                    name
                    address
                    accounts {
                      id
                      type
                      description
                    }
                  }
                }"
            };

            var response = await _client.PostAsync(query);

            return(response.GetDataFieldAs <List <Owner> >("owners"));
        }
예제 #6
0
        public string EfetuarLogin(Login login)
        {
            var request = new GraphQLRequest();

            request.Query = @"mutation ($email:String!,$password:String!){
                              login(input: {
                                    email: $email,
                                    password: $password
                                }) {
                                user {
                                  apiKey
                                }
                              }
                            }";


            request.Variables = new
            {
                email    = login.Email,
                password = login.Password
            };

            var graphQLClient = new  GraphQL.Client.GraphQLClient("https://staging.loggi.com/graphql");

            // graphQLClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
            graphQLClient.DefaultRequestHeaders.Add("Authorization", "ApiKey email:api_key");

            var            response      = graphQLClient.PostAsync(request).GetAwaiter().GetResult();
            IList <string> mensagemError = new List <string>();

            if (response.Errors?.Count() > 0)
            {
                foreach (var error in response.Errors)
                {
                    mensagemError.Add(error.Message);
                }

                return(mensagemError.Select(_ => _).FirstOrDefault());
            }

            var apiKey = response.Data["login"]["user"]["apiKey"];

            if (apiKey == null)
            {
                return("Syntax Error GraphQL");
            }

            return(apiKey);
        }
예제 #7
0
        public async Task <List <UserSearchModel> > GetAllItems()
        {
            var query = new GraphQLRequest
            {
                Query = @"
                query UserSearchViewQuery{
                  userSearchViewList {
                    emailAddress
                }
                }"
            };

            var response = await _client.PostAsync(query);

            return(response.GetDataFieldAs <List <UserSearchModel> >("UserSearchViewList"));
        }
예제 #8
0
        public async Task <List <TodoItem> > GetAllToDos()
        {
            var query = new GraphQLRequest
            {
                Query = @"
                        query todosQuery{
                        todos {
                            id
                            title
                        }
                        }"
            };

            var response = await _client.PostAsync(query);

            return(response.GetDataFieldAs <List <TodoItem> >("todos"));
        }
예제 #9
0
        public async Task <IEnumerable <GetBookengByCustomerNumberResponse> > GetBookingsByCustomerNumber(string customerNumber)
        {
            var query = new GraphQLRequest
            {
                Query = $@"query searchByCustomerNumber 
                            {{searchByCustomerNumber(request: 
                                {{ customerNumber: ""{customerNumber}"" }}) 
                            {{ recordLocator,
                               origin,
                               destination
                            }}}}",
            };
            var response = await _client.PostAsync(query);

            return(response.GetDataFieldAs <IEnumerable <GetBookengByCustomerNumberResponse> >("searchByCustomerNumber"));
        }
예제 #10
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL };
                //RequireCaptcha(Captchaval);
                GQLClient = new GraphQL.Client.GraphQLClient(URL);

                /*GraphQLRequest LoginReq = new GraphQLRequest
                 * {
                 *  Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                 * };
                 *
                 * GQLClient
                 * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 * if (Resp.Errors != null)
                 * {
                 *  if (Resp.Errors.Length > 0)
                 *  {
                 *      Parent.DumpLog(Resp.Errors[0].Message, -1);
                 *      Parent.updateStatus(Resp.Errors[0].Message);
                 *      finishedlogin(false);
                 *      return;
                 *  }
                 * }
                 * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/
                GQLClient.DefaultRequestHeaders.Add("x-access-token", Password);

                /*
                 * var subscriptionResult = GQLClient.SendSubscribeAsync(@"subscription { chatMessages(chatId: "14939265 - 52a4 - 404e-8a0c - 6e3e10d915b4") { id chat { id name isPublic } createdAt user { id name roles { name } } data { ... on ChatMessageDataBot { message } ... on ChatMessageDataText { message } ... on ChatMessageDataTip { tip { id amount currency sender: sendBy { id name } receiver: user { id name } } } } } } ").Result;
                 * subscriptionResult.OnReceive += (res) => { Console.WriteLine(res.Data.messageAdded.content); };
                 */


                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {game bets wins losses betAmount profit currency}}}"
                };
                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                pdUser          user = Resp.GetDataFieldAs <pdUser>("user");

                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower() && x.game == StatGameName)
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.betAmount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }
예제 #11
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
                //RequireCaptchaEventArgs Captchaval = new RequireCaptchaEventArgs { PublicKey = CaptchaKey, Domain=this.URL };
                //RequireCaptcha(Captchaval);
                GQLClient = new GraphQL.Client.GraphQLClient(URL);

                /*GraphQLRequest LoginReq = new GraphQLRequest
                 * {
                 *  Query = "mutation{loginUser(captcha:\""+Captchaval.ResponseValue+ "\" name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                 * };
                 *
                 * GQLClient
                 * GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                 * if (Resp.Errors != null)
                 * {
                 *  if (Resp.Errors.Length > 0)
                 *  {
                 *      Parent.DumpLog(Resp.Errors[0].Message, -1);
                 *      Parent.updateStatus(Resp.Errors[0].Message);
                 *      finishedlogin(false);
                 *      return;
                 *  }
                 * }
                 * pdUser user = Resp.GetDataFieldAs<pdUser>("loginUser");*/
                GQLClient.DefaultRequestHeaders.Add("x-access-token", Password);
                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "query{user {activeServerSeed { seedHash seed nonce} activeClientSeed{seed} id balances{available{currency amount}} statistic {bets wins losses amount profit currency}}}"
                };
                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                pdUser          user = Resp.GetDataFieldAs <pdUser>("user");

                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower())
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }
예제 #12
0
        public override void Login(string Username, string Password, string otp)
        {
            try
            {
                GQLClient = new GraphQL.Client.GraphQLClient(URL);
                GraphQLRequest LoginReq = new GraphQLRequest
                {
                    Query = "mutation{loginUser(name:\"" + Username + "\", password:\"" + Password + "\"" + (string.IsNullOrWhiteSpace(otp) ? "" : ",tfaToken:\"" + otp + "\"") + ") {activeServerSeed { seedHash seed nonce} activeClientSeed {seed} id statistic {bets wins losses amount profit currency} balances{available{currency amount}} }}"
                };
                Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

                GraphQLResponse Resp = GQLClient.PostAsync(LoginReq).Result;
                if (Resp.Errors != null)
                {
                    if (Resp.Errors.Length > 0)
                    {
                        Parent.DumpLog(Resp.Errors[0].Message, -1);
                        Parent.updateStatus(Resp.Errors[0].Message);
                        finishedlogin(false);
                        return;
                    }
                }
                pdUser user = Resp.GetDataFieldAs <pdUser>("loginUser");
                userid = user.id;
                if (string.IsNullOrWhiteSpace(userid))
                {
                    finishedlogin(false);
                }
                else
                {
                    foreach (Statistic x in user.statistic)
                    {
                        if (x.currency.ToLower() == Currency.ToLower())
                        {
                            this.bets    = (int)x.bets;
                            this.wins    = (int)x.wins;
                            this.losses  = (int)x.losses;
                            this.profit  = (decimal)x.profit;
                            this.wagered = (decimal)x.amount;
                            break;
                        }
                    }
                    foreach (Balance x in user.balances)
                    {
                        if (x.available.currency.ToLower() == Currency.ToLower())
                        {
                            balance = (decimal)x.available.amount;
                            break;
                        }
                    }

                    finishedlogin(true);
                    ispd = true;
                    Thread t = new Thread(GetBalanceThread);
                    t.Start();
                    return;
                }
            }
            catch (WebException e)
            {
                if (e.Response != null)
                {
                }
                finishedlogin(false);
            }
            catch (Exception e)
            {
                Parent.DumpLog(e.ToString(), -1);
                finishedlogin(false);
            }
        }
예제 #13
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            const String c_collectionUri = "https://dev.azure.com/ankhokha";

            // Interactively ask the user for credentials, caching them so the user isn't constantly prompted

            VssCredentials creds = new VssBasicCredential(String.Empty, "");

            // Connect to Azure DevOps Services
            VssConnection connection = new VssConnection(new Uri(c_collectionUri), creds);

            // Get a GitHttpClient to talk to the Git endpoints
            GitHttpClient gitClient = connection.GetClient <GitHttpClient>();

            int              pullRequestId           = 1;
            IList <string>   fileList                = new List <string>();
            IList <File>     fileDetailsList         = new List <File>();
            List <FileInput> fileMutationDetailsList = new List <FileInput>();
            var              repository              = gitClient.GetRepositoryAsync("8ff8a410-814b-463b-8ecc-949c96fe2007").SyncResult();
            var              repoLink                = (repository.Links.Links["web"] as ReferenceLink).Href;
            var              uriBuilder              = new UriBuilder(repoLink);
            var              query = HttpUtility.ParseQueryString(uriBuilder.Query);

            while (true)
            {
                fileMutationDetailsList.Clear();
                Console.WriteLine(pullRequestId);
                // Get data about a specific repository
                IList <GitCommitRef> commitsList;
                try
                {
                    commitsList = gitClient.GetPullRequestCommitsAsync("8ff8a410-814b-463b-8ecc-949c96fe2007", pullRequestId).SyncResult();
                }
                catch (VssServiceException ex)
                {
                    Console.WriteLine(String.Format("Pull request with id {0} not found. Exiting...", pullRequestId));
                    break;
                }

                string email      = "";
                string authorName = "";

                foreach (var commit in commitsList)
                {
                    var commitId = commit.CommitId;
                    var result   = gitClient.GetChangesAsync(commitId, new Guid("8ff8a410-814b-463b-8ecc-949c96fe2007")).SyncResult <GitCommitChanges>();
                    var changes  = result.Changes.ToList();


                    foreach (var change in changes)
                    {
                        fileList.Add(change.Item.Path);
                        query["path"]    = change.Item.Path;
                        email            = commit.Author.Email;
                        authorName       = commit.Author.Name;
                        uriBuilder.Query = query.ToString();

                        var include = true;
                        foreach (var file in fileMutationDetailsList)
                        {
                            if (file.Path == change.Item.Path)
                            {
                                include = false;
                            }
                        }
                        if (include)
                        {
                            fileMutationDetailsList.Add(new FileInput(change.Item.Path, uriBuilder.ToString()));
                        }
                    }
                }

                string graphqlServer = "https://ganes-server.azurewebsites.net/graphql";

                var graphQlCLient = new GraphQL.Client.GraphQLClient(graphqlServer);

                var q = new GraphQL.Common.Request.GraphQLRequest();

                List <FileInput> a = new List <FileInput> ();

                q.Query = @"mutation Mutation1($files: [FileInput]!, $email: String!, $name: String!, $pullRequestId: String!)
                            {
                              IngestPullRequest(
                                pullRequest: {
                                  Files: $files,
                                  ModifiedBy:
                                        {
                                        email: $email,
                                        name: $name
                                  },
                                Properties:
                                        {
                                        Key: ""pullRequestId"",
                                        Value: $pullRequestId
                                    }
                                }
                              )
                              {
                                name
                                }
                            }";



                q.Variables = new {
                    files         = fileMutationDetailsList,
                    email         = email,
                    name          = authorName,
                    pullRequestId = pullRequestId.ToString()
                };

                var response = graphQlCLient.PostAsync(q).SyncResult();

                Thread.Sleep(2000);

                pullRequestId++;
            }
        }