Esempio n. 1
0
 public void ReturnToHomepage()
 {
     Google.SearchForItem("selenium automation");
     Google.GoToHomePage();
     Assert.IsFalse(Browser.WaitUntil(() => Harness.SearchResultsDiv.Displayed),
                    "Search results displayed when they were not expected");
 }
Esempio n. 2
0
        public static FullVideo Create(Google.YouTube.Video ytVideo = null)
        {
            if (ytVideo == null) {
                throw new Exception("Invalid link");
            }
            CurtDevDataContext db = new CurtDevDataContext();
            Video new_video = new Video {
                embed_link = ytVideo.VideoId,
                title = ytVideo.Title,
                screenshot = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[2].Url : "/Content/img/noimage.jpg",
                description = ytVideo.Description,
                watchpage = ytVideo.WatchPage.ToString(),
                youtubeID = ytVideo.VideoId,
                dateAdded = DateTime.Now,
                sort = (db.Videos.Count() == 0) ? 1 : db.Videos.OrderByDescending(x => x.sort).Select(x => x.sort).First() + 1
            };
            db.Videos.InsertOnSubmit(new_video);
            db.SubmitChanges();

            FullVideo fullvideo = new FullVideo {
                videoID = new_video.videoID,
                embed_link = new_video.embed_link,
                dateAdded = new_video.dateAdded,
                sort = new_video.sort,
                videoTitle = new_video.title,
                thumb = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[0].Url : "/Content/img/noimage.jpg"
            };

            return fullvideo;
        }
Esempio n. 3
0
 public void SearchForSeleniumOnGoogle()
 {
     Assert.IsTrue(Google.SearchForItem("selenium browser automation"),
                   "No search results displayed when they were expected");
     Assert.IsTrue(Google.FindSearchResultItem("SeleniumHQ Browser Automation"),
                   "Did not find a specific search result for Selenium - Web Browser Automation");
 }
 public AnalyticsService(Google.Apis.Services.BaseClientService.Initializer initializer)
     : base(initializer)
 {
     this._management = new ManagementResource(this, Authenticator);
     this._data = new DataResource(this, Authenticator);
     this.InitParameters();
 }
Esempio n. 5
0
 public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action<bnet.protocol.NoData> done)
 {
     Logger.Trace("Subscribe()" + request.EntityId.GetHighIdType());
                             
     var builder = bnet.protocol.NoData.CreateBuilder();
     done(builder.Build());
 }
Esempio n. 6
0
 public void Google()
 {
     Google google = new Google(driver);
     google.goToSite();
     google.sendWord();
     google.headersToListFirstPage();
 }
        public List<dynamic> GetFacebookContactSuggestion(Google.GData.Extensions.Name gName)
        {
            var list = GetFacebookContacts();
            var suggestions = new List<dynamic>();

            // Try to find on both parts
            foreach (dynamic user in list)
            {
                var name = (user.name as string);
                if (name == null)
                    continue;

                if (name.IndexOf(gName.GivenName, StringComparison.Ordinal) > -1 && name.IndexOf(gName.FamilyName, StringComparison.Ordinal) > -1)
                    suggestions.Add(user);
            }

            // If nothing found try more general search
            if(suggestions.Count <= 0)
            {
                suggestions.Clear();
                foreach (dynamic user in list)
                {
                    var name = (user.name as string);
                    if (name == null)
                        continue;

                    if ((gName.FamilyName != null && name.IndexOf(gName.FamilyName, StringComparison.Ordinal) > -1) || name.IndexOf(gName.GivenName, StringComparison.Ordinal) > -1)
                        suggestions.Add(user);
                }
            }

            return suggestions;
        }
        public static void IMPAbstractFactory()
        {
            //Google
            IMobilePhone googleMobilePhone = new Google();
            MobileClient googleClient      = new MobileClient(googleMobilePhone);

            Console.WriteLine("******* Google **********");
            Console.WriteLine(googleClient.GetSmartPhoneModelDetails());
            Console.WriteLine(googleClient.GetNormalPhoneModelDetails());

            //NOKIA
            IMobilePhone nokiaMobilePhone = new Nokia();
            MobileClient nokiaClient      = new MobileClient(nokiaMobilePhone);

            Console.WriteLine("********* NOKIA **********");
            Console.WriteLine(nokiaClient.GetSmartPhoneModelDetails());
            Console.WriteLine(nokiaClient.GetNormalPhoneModelDetails());



            //SAMSUNG
            IMobilePhone samsungMobilePhone = new Samsung();
            MobileClient samsungClient      = new MobileClient(samsungMobilePhone);

            Console.WriteLine("******* SAMSUNG **********");
            Console.WriteLine(samsungClient.GetSmartPhoneModelDetails());
            Console.WriteLine(samsungClient.GetNormalPhoneModelDetails());
        }
Esempio n. 9
0
        public override void SubscribeToUserManager(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.user_manager.SubscribeToUserManagerRequest request, System.Action<bnet.protocol.user_manager.SubscribeToUserManagerResponse> done)
        {
            Logger.Trace("Subscribe() {0}", this.Client);

            // temp hack: send him all online players on server where he should be normally get list of player he met in his last few games /raist.

            var builder = bnet.protocol.user_manager.SubscribeToUserManagerResponse.CreateBuilder();
            uint i = 0;
            foreach (var client in PlayerManager.OnlinePlayers)
            {
                if (client == this.Client) continue; // Don't add the requester to the list                
                if (client.Account.CurrentGameAccount.CurrentToon == null) continue;

                Logger.Debug("RecentPlayer => " + client.Account.CurrentGameAccount.CurrentToon);
                var recentPlayer = bnet.protocol.user_manager.RecentPlayer.CreateBuilder()
                    .SetEntity(client.Account.BnetEntityId)
                    .SetProgramId("D3")
                    .AddAttributes(bnet.protocol.attribute.Attribute.CreateBuilder()
                        .SetName("GameAccountEntityId")
                        .SetValue(bnet.protocol.attribute.Variant.CreateBuilder()
                            .SetMessageValue(client.Account.CurrentGameAccount.D3GameAccountId.ToByteString())
                            .Build())
                        .Build())
                    .SetId(i++)
                    .Build();
                builder.AddRecentPlayers(recentPlayer);
            }

            done(builder.Build());
        }
Esempio n. 10
0
 private void butAuthGoogle_Click(object sender, EventArgs e)
 {
     try {
         string url = Google.GetGoogleAuthorizationUrl(textUsername.Text);
         Process.Start(url);
         InputBox inputbox = new InputBox("Please enter the authorization code from your browser");
         inputbox.setTitle("Google Account Authorization");
         inputbox.ShowDialog();
         if (inputbox.DialogResult != DialogResult.OK)
         {
             return;
         }
         if (string.IsNullOrWhiteSpace(inputbox.textResult.Text))
         {
             throw new ODException(Lan.g(this, "There was no authorization code entered."));
         }
         string      authCode = inputbox.textResult.Text;
         GoogleToken tokens   = Google.MakeAccessTokenRequest(authCode);
         if (tokens.ErrorMessage != "")
         {
             throw new Exception(tokens.ErrorMessage);
         }
         textAccessToken.Text         = tokens.AccessToken;
         textRefreshToken.Text        = tokens.RefreshToken;
         groupAuthentication.Location = new Point(_groupAuthLocationXAuthorized, groupAuthentication.Location.Y);
         groupGoogleAuth.Visible      = true;
     }
     catch (ODException ae) {
         MsgBox.Show(ae.Message);
     }
     catch (Exception ex) {
         MsgBox.Show("Error: " + ex.Message);
     }
 }
 public void FirstTest()
 {
     using (IWebDriver dr = new ChromeDriver(Directory.GetCurrentDirectory()))
     {
         var google = new Google(dr);
         google.FullScreen();
         Thread.Sleep(2000);
         google.MoveToGoogle();
         Thread.Sleep(2000);
         google.Search(Rozetka.Url);
         Thread.Sleep(2000);
         google.Click();
         Thread.Sleep(2000);
         var rozetka = Google.MoveNext();
         Thread.Sleep(2000);
         rozetka.MoveToRozetka();
         Thread.Sleep(2000);
         rozetka.FindLepTop();
         Thread.Sleep(2000);
         rozetka.FindApple();
         Thread.Sleep(2000);
         rozetka.MoveToAppleLepTop();
         Thread.Sleep(2000);
         rozetka.BuyLepTop();
         Thread.Sleep(2000);
         //google.MoveNext();
     }
 }
Esempio n. 12
0
        /// <summary>Example: GoogleUserId.TryParseIdToken("google.jwt.here", new[]{"YOUR_APP_ID_HERE.apps.googleusercontent.com"});</summary>
        /// <example>GoogleUserId.TryParseIdToken("google.jwt.here", new[]{"YOUR_APP_ID_HERE.apps.googleusercontent.com"});</example>
        /// <param name="idToken"    >A google idToken JWT</param>
        /// <param name="validAppIds">An array of 1 or more valid google app IDs (of which 1 is expected to be the audience of this JWT)</param>
        /// <returns>A valid GoogleUserId if and only if idToken validates - otherwise null.</returns>
        /// <exception cref="ArgumentNullException" >validAppIds is null</exception>
        /// <exception cref="ArgumentException"     >validAppIds does not list at least 1 valid app id</exception>
        public static GoogleUserId TryParseIdToken(string idToken, string[] validAppIds)
        {
            if (validAppIds == null)
            {
                throw new ArgumentNullException(nameof(validAppIds), "validAppIds cannot be null");
            }
            if (validAppIds.Length < 1)
            {
                throw new ArgumentException("validAppIds must contain at least one valid app ID", nameof(validAppIds));
            }
            if (validAppIds.Any(id => id == null))
            {
                throw new ArgumentException("validAppIds cannot contain null app IDs", nameof(validAppIds));
            }
            if (idToken == null)
            {
                return(new GoogleUserId(null));
            }
            if (idToken == "")
            {
                return(new GoogleUserId(null));
            }

            try {
                var jwt = Google.ValidateIdToken(idToken, validAppIds);
                if (jwt == null)
                {
                    return(new GoogleUserId(null));
                }
                return(new GoogleUserId(jwt.Subject));
            }
            catch (SecurityTokenException) { return(new GoogleUserId(null)); }            // e.g. idToken is malformed, expired, missigned, has the wrong audience, etc.
            catch (WebException)           { return(new GoogleUserId(null)); }            // e.g. https://www.googleapis.com/oauth2/v1/certs failed to respond and could not be satisfied by a cached result
        }
Esempio n. 13
0
        // operator== and operator!= are defined in terms of the implicit conversion operator.
        // Avoid defining our own:  doing so would cause the implicit generation of e.g. operator==(GoogleUserId?,GoogleUserId?) which causes id == null checks to fail!

        /// <summary>Example: GoogleUserId.FromIdToken("google.jwt.here", new[]{"YOUR_APP_ID_HERE.apps.googleusercontent.com"});</summary>
        /// <example>GoogleUserId.FromIdToken("google.jwt.here", new[]{"YOUR_APP_ID_HERE.apps.googleusercontent.com"});</example>
        /// <param name="idToken"    >A google idToken JWT</param>
        /// <param name="validAppIds">An array of 1 or more valid google app IDs (of which 1 is expected to be the audience of this JWT)</param>
        /// <returns>A valid GoogleUserId if and only if idToken validates - otherwise an exception will be thrown.  Never null.</returns>
        /// <exception cref="ArgumentNullException" >idToken is null</exception>
        /// <exception cref="ArgumentNullException" >validAppIds is null</exception>
        /// <exception cref="ArgumentException"     >idToken is not a valid JWT</exception>
        /// <exception cref="ArgumentException"     >validAppIds does not list at least 1 valid app id</exception>
        /// <exception cref="SecurityTokenException">idToken is not a valid JWT, has expired, is malformed, is missigned, has the wrong issuer, has the wrong audience, ...</exception>
        /// <exception cref="WebException"          >Certificates cannot be downloaded to validate idToken or are misformed (may be temporary)</exception>
        public static GoogleUserId FromIdToken(string idToken, string[] validAppIds)
        {
            if (idToken == null)
            {
                throw new ArgumentNullException(nameof(idToken), "idToken cannot be null");
            }
            if (validAppIds == null)
            {
                throw new ArgumentNullException(nameof(validAppIds), "validAppIds cannot be null");
            }
            if (validAppIds.Length < 1)
            {
                throw new ArgumentException("validAppIds must contain at least one valid app ID", nameof(validAppIds));
            }
            if (validAppIds.Any(id => id == null))
            {
                throw new ArgumentException("validAppIds cannot contain null app IDs", nameof(validAppIds));
            }
            if (idToken == "")
            {
                throw new SecurityTokenException("idToken cannot be empty");
            }

            var jwt = Google.ValidateIdToken(idToken, validAppIds);

            if (jwt == null)
            {
                throw new SecurityTokenException("Google.ValidateIdToken failed to return a valid token");
            }
            return(new GoogleUserId(jwt.Subject));
        }
Esempio n. 14
0
		public override void Logon(Google.ProtocolBuffers.IRpcController controller, LogonRequest request, Action<LogonResponse> done) {
			/*var client_auth = client.GetImportedService<bnet.protocol.authentication.AuthenticationClient>();
			var mod_load_req = ModuleLoadRequest.CreateBuilder();
			var mod_handle = ContentHandle.CreateBuilder();
			mod_handle.SetRegion(0x00005553);
			mod_handle.SetUsage(0x61757468);
			var password_hash = new byte[] { 0x8f, 0x52, 0x90, 0x6a, 0x2c, 0x85, 0xb4, 0x16, 0xa5, 0x95, 0x70, 0x22, 0x51, 0x57, 0xf, 0x96, 0xd3, 0x52, 0x2f, 0x39, 0x23, 0x76, 0x3, 0x11, 0x5f, 0x2f, 0x1a, 0xb2, 0x49, 0x62, 0x4, 0x3c };
			mod_handle.SetHash(ByteString.CopyFrom(password_hash));
			mod_load_req.SetModuleHandle(mod_handle);

			client_auth.ModuleLoad(null, mod_load_req.Build(), res => {
				Console.WriteLine(res);
			});*/


			var response = LogonResponse.CreateBuilder();
			var account = bnet.protocol.EntityId.CreateBuilder();
			var game_account = bnet.protocol.EntityId.CreateBuilder();

			account.SetHigh(0x100000000000000).SetLow(1234);

			game_account.SetHigh(0x200006200004433).SetLow(1234);

			response.SetAccount(account).SetGameAccount(game_account);

			done(response.Build());
		}
Esempio n. 15
0
        public override void Update(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UpdateRequest request, System.Action<bnet.protocol.NoData> done)
        {            
            //Logger.Warn("request:\n{0}", request.ToString());
            // This "UpdateRequest" is not, as it may seem, a request to update the client on the state of an object,
            // but instead the *client* requesting to change fields on an object that it has subscribed to.
            // Check docs/rpc/presence.txt in branch wip-docs (or master)

            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistantID(request.EntityId.Low);
                    Logger.Trace("Update:Account: {0} {1}", request.EntityId.GetHighIdType(), request.EntityId.Low);
                    break;
                case EntityIdHelper.HighIdType.ToonId:
                    var toon = ToonManager.GetToonByLowID(request.EntityId.Low);
                    Logger.Trace("Update:Toon: {0}", toon);
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Update request with type {0}", request.EntityId.GetHighIdType());
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 16
0
        public override void DeclineInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.invitation.GenericRequest request, Action<bnet.protocol.NoData> done)
        {
            var respone = bnet.protocol.NoData.CreateBuilder();
            done(respone.Build());

            this._invitationManager.HandleDecline(this.Client, request);
        }
Esempio n. 17
0
        public override void RevokeInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel_invitation.RevokeInvitationRequest request, Action<bnet.protocol.NoData> done)
        {
            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());

            this._invitationManager.Revoke(this.Client, request);
        }
Esempio n. 18
0
        public override void AcceptInvitation(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel_invitation.AcceptInvitationRequest request, Action<bnet.protocol.channel_invitation.AcceptInvitationResponse> done)
        {
            var response = bnet.protocol.channel_invitation.AcceptInvitationResponse.CreateBuilder().SetObjectId(this._invitationManager.DynamicId).Build();
            done(response);

            this._invitationManager.HandleAccept(this.Client, request);
        }
Esempio n. 19
0
 static void FunctionTest()
 {
     //Test1.Test();
     //MSAA.Test();
     //Baidu.Test();
     Google.Test();
     //Other.Test();
     //Qidian.Test();
     //CSDN.Test();
     // QQ.Test();
     //FCKEditor.Test();
     //Netyi.Test();
     //gougou.Test();
     // Mitbbs.Test();
     // Xjflcp.Test();
     //Marry5.Test();
     //Maxthon.Test();
     //EventTest.Test();
     //Xunlei.Test();
     //SP.Test();
     //Calculator.Test();
     // YY365.Test();
     //TimeFairy.Test();
     //Alipay.Test();
     //KaiXin.Test();
 }
Esempio n. 20
0
        private async Task ImportOrgUnits(CancellationToken cancellationToken)
        {
            await foreach (var googleOrgUnit in Google.GetOrgUnitsAsync(cancellationToken))
            {
                if (IgnoreOrgUnitPaths.Contains(googleOrgUnit.OrgUnitPath))
                {
                    Logger.LogDebug("Skipping organization unit {OrgUnitPath}.", googleOrgUnit.OrgUnitPath);
                    continue;
                }

                var orgUnit = await Context.OrganizationUnits.FirstOrDefaultAsync(x => x.Path.Equals(googleOrgUnit.OrgUnitPath), cancellationToken);

                if (orgUnit is null)
                {
                    orgUnit = new OrganizationUnit
                    {
                        Path = googleOrgUnit.OrgUnitPath
                    };

                    await Context.OrganizationUnits.AddAsync(orgUnit, cancellationToken);
                }

                orgUnit.Name       = googleOrgUnit.Name.TrimStart('_');
                orgUnit.ParentPath = googleOrgUnit.ParentOrgUnitPath;
            }

            var count = await Context.SaveChangesAsync(cancellationToken);

            Logger.LogInformation("Imported {OrgUnitCount} org units from Google.", count);
        }
Esempio n. 21
0
        public async void GoogleScrapper_ReturnsNotEmptyResult()
        {
            var googleScrapper = new Google();
            var result         = await googleScrapper.Scrap("go language learning");

            result.Should().NotBeNullOrEmpty();
        }
Esempio n. 22
0
        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action<bnet.protocol.NoData> done)
        {
            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (account != null)
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, account);
                        account.AddSubscriber(this.Client, request.ObjectId);
                    }
                    break;
                case EntityIdHelper.HighIdType.ToonId:
                    var toon = ToonManager.GetToonByLowID(request.EntityId.Low);                    
                    if (toon != null) 
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, toon);
                        toon.AddSubscriber(this.Client, request.ObjectId); // The client will send us a Subscribe with ToonId of 0 the first time it tries to create a toon with a name that already exists. Let's handle that here.
                    }
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Subscribe request with type {0}", request.EntityId.GetHighIdType());
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 23
0
        /// <summary>
        /// Load all the placemark objects that are within the specified area.
        /// </summary>
        /// <param name="google">The Google helper class that does the database leg-work.</param>
        /// <returns>A collection of Placemark objects inside the radius.</returns>
        public override List <Placemark> LoadPlacemarks(Google google)
        {
            List <Placemark> items = new List <Placemark>();


            if (PopulateWith == PopulationType.Individuals)
            {
                foreach (Placemark p in google.PersonPlacemarksInArea(AreaID, 0, Int32.MaxValue))
                {
                    items.Add(p);
                }
            }
            else if (PopulateWith == PopulationType.Families)
            {
                foreach (Placemark p in google.FamilyPlacemarksInArea(AreaID, 0, Int32.MaxValue))
                {
                    items.Add(p);
                }
            }
            else if (PopulateWith == PopulationType.SmallGroups)
            {
                foreach (Placemark p in google.SmallGroupPlacemarksInArea(AreaID, 0, Int32.MaxValue))
                {
                    items.Add(p);
                }
            }

            return(items);
        }
Esempio n. 24
0
        public override void SubscribeToFollowers(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.followers.SubscribeToFollowersRequest request, System.Action<bnet.protocol.followers.SubscribeToFollowersResponse> done)
        {
            Logger.Trace("Subscribe() {0}", this.Client);

            var builder = bnet.protocol.followers.SubscribeToFollowersResponse.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 25
0
        public override void Execute(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.storage.ExecuteRequest request, System.Action<bnet.protocol.storage.ExecuteResponse> done)
        {
            Logger.Trace("Execute() {0}", this.Client);
            bnet.protocol.storage.ExecuteResponse response = null;
            switch (request.QueryName)
            {
                case "GetGameAccountSettings":
                    response = GameAccountSettings(request);
                    break;
                case "LoadAccountDigest":
                    response = LoadAccountDigest(Client, request);
                    break;
                case "GetHeroDigests":
                    response = GetHeroDigest(Client, request);
                    break;
                case "GetToonSettings":
                    response = GetToonSettings(request);
                    break;
                default:
                    Logger.Warn("Unhandled query: {0}", request.QueryName);
                    response = bnet.protocol.storage.ExecuteResponse.CreateBuilder().Build();
                    break;
            }

            done(response);
        }
Esempio n. 26
0
        public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action<bnet.protocol.NoData> done)
        {

            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    // The client will probably make sure it doesn't unsubscribe to a null ID, but just to make sure..
                    if (account != null)
                    {
                        account.RemoveSubscriber(this.Client);
                        Logger.Trace("Unsubscribe() {0} {1}", this.Client, account);
                    }
                    break;
                case EntityIdHelper.HighIdType.GameAccountId:
                    var gameaccount = GameAccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (gameaccount != null)
                    {
                        gameaccount.RemoveSubscriber(this.Client);
                        Logger.Trace("Unsubscribe() {0} {1}", this.Client, gameaccount);
                    }
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Unsubscribe request with type {0} (0x{1})", request.EntityId.GetHighIdType(), request.EntityId.High.ToString("X16"));
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 27
0
        private static async System.Threading.Tasks.Task MainAsync()
        {
            var TransEngine = new Google(@"C:\test\test.docx");
            await TransEngine.AsynWdProcess();

            var iii = 1;
        }
Esempio n. 28
0
    public async Task <GoogleStaticMaps> Load(string search, string size, int zoom)
    {
        var    key    = "AIzaSyCdNJl4Lm98QbzuYKdbcn9gCYawkmc_tlk";
        var    url    = $"https://maps.googleapis.com/maps/api/geocode/json?address={search}&key={key}";
        Google result = await googleApi.GetData <Google>(url);

        double lat    = result.results.ElementAt(0).geometry.location.lat;   //not sure we need this bit yet.
        double lng    = result.results.ElementAt(0).geometry.location.lng;
        String LatLng = (lat.ToString() + "," + lng.ToString());

        GoogleStaticMaps GSmaps = new GoogleStaticMaps();

        GSmaps.imageUrl   = $"https://maps.googleapis.com/maps/api/staticmap?zoom={zoom}&size={size}&maptype=roadmap&markers=color:red|label:X|{LatLng}";
        GSmaps.timestamp  = DateTime.Now.ToString();
        GSmaps.searchTerm = search;                     //ViewBag add 32
        GSmaps.zoomLevel  = zoom;
        GSmaps.size       = new Size {
            width  = Int32.Parse(size.Split(new char[] { 'x' })[0]),
            height = Int32.Parse(size.Split(new char[] { 'x' })[1])
        };
        GSmaps.markers = new List <Marker> {
            new Marker {
                color    = "red",
                label    = "X",
                location = new GoogleStaticMapsX.Location {
                    lat = lat,
                    lng = lng
                }
            }
        };

        return(GSmaps);
    }
Esempio n. 29
0
        public async void Must_Not_Find_Any_Page()
        {
            MockGoogleWebClient webClient = new MockGoogleWebClient();

            webClient.SuccessPages = new int[] { };
            webClient.UrlToScan    = "www.infotrack.com.au";

            MockProcessingQueue queu = new MockProcessingQueue();

            queu.EnQueueLimit = 100;
            MockSearchResponseRepository responseRepository = new MockSearchResponseRepository();

            Google googleEngineService = new Google(queu, responseRepository, webClient);
            await googleEngineService.SearchEngineForRequest(
                new InfoTrackTest.Models.SearchEngineRequest()
            {
                SearchPhrase = "online title search",
                SiteURL      = "www.infotrack.com.au"
            });

            var results = responseRepository.GetResults(response => response.Found)
                          .Select(response => response.Request.Page).ToArray();

            Assert.NotNull(results);
            Assert.Equal(0, results.Length);
        }
Esempio n. 30
0
        public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
        {
            Logger.Trace("SendNotification()");
            //Logger.Debug("notification:\n{0}", request.ToString());

            switch (request.GetNotificationType())
            {
                case NotificationTypeHelper.NotificationType.Whisper:
                    
                    // NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
                    // Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).

                    Logger.Trace(string.Format("NotificationRequest by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));

                    var account = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
                    if (account.LoggedInClient == null) return;

                    var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
                        .SetSenderId(this.Client.CurrentToon.BnetEntityID)
                        .Build();

                    var method = bnet.protocol.notification.NotificationListener.Descriptor.FindMethodByName("OnNotificationReceived");
                    account.LoggedInClient.CallMethod(method, notification);
                    break;
                default:
                    Logger.Warn("Unhandled notification type: {0}", request.Type);
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 31
0
        public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
        {
            switch (request.GetNotificationType())
            {
                case NotificationTypeHelper.NotificationType.Whisper:
                    
                    // NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
                    // Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).

                    Logger.Trace(string.Format("NotificationRequest.Whisper by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));

                    var account = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
                    if (account.LoggedInClient == null) return;

                    if (account is CommandHandlerAccount) // hackish way to enable server commands for players that are not in party.
                        CommandHandlerAccount.Instance.ParseCommand(request, this.Client);
                    else
                    {
                        var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
                            .SetSenderId(this.Client.CurrentToon.BnetEntityID)
                            .Build();

                        account.LoggedInClient.MakeRPC(() => bnet.protocol.notification.NotificationListener.CreateStub(account.LoggedInClient).
                                      OnNotificationReceived(controller, notification, callback => { }));
                    }
                    break;
                default:
                    Logger.Warn("Unhandled notification type: {0}", request.Type);
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 32
0
        public override void Logon(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.authentication.LogonRequest request, Action<bnet.protocol.authentication.LogonResponse> done)
        {
            Logger.Trace("LogonRequest(); Email={0}", request.Email);

            // we should be also checking here version, program, locale and similar stuff /raist.

            AuthManager.StartAuthentication(this.Client, request);

            var authenticationThread = new Thread(() =>
            {
                this.Client.AuthenticationCompleteSignal.WaitOne(); // wait the signal;

                if(this.Client.AuthenticationErrorCode != MooNetClient.AuthenticationErrorCodes.None)
                {
                    Logger.Info("Authentication failed for {0} because of invalid credentals.", request.Email);
                    done(bnet.protocol.authentication.LogonResponse.DefaultInstance);
                    return;
                }

                Logger.Info("User {0} authenticated successfuly.", request.Email);
                var builder = bnet.protocol.authentication.LogonResponse.
                    CreateBuilder()
                    .SetAccount(Client.Account.BnetAccountID)
                    .SetGameAccount(Client.Account.BnetGameAccountID);

                done(builder.Build());

                PlayerManager.PlayerConnected(this.Client);

            }) { IsBackground = true, CurrentCulture = CultureInfo.InvariantCulture }; ;

            authenticationThread.Start();
        }
Esempio n. 33
0
 public void FindConsist()
 {
     Google google = new Google(driver);
     google.goToSite();
     google.sendWord();
     google.headersToListAllPages();
 }
Esempio n. 34
0
        public void TestGoogle()
        {
            StkPortfolio stkPortfolio = new Google();

            stkPortfolio.stkVal();
            stkPortfolio.RandStkVal(.01, .05);
            stkPortfolio.ShowDayChange(250.00);
            stkPortfolio.ShowTtlChange(250.00);
            Assert.AreEqual(250.00, stkPortfolio.stkVal());
            Assert.IsTrue(stkPortfolio.RandStkVal(.01, .05) <= .05);
            Assert.IsTrue(stkPortfolio.RandStkVal(.01, .05) >= .01);
            double change = stkPortfolio.ShowDayChange(250.00)[0];
            double value  = stkPortfolio.ShowDayChange(250.00)[1];

            Assert.IsTrue(change <= 12.50);
            Assert.IsTrue(change >= -12.50);
            Assert.IsTrue(value <= 262.50);
            Assert.IsTrue(value >= 238.50);
            double ttlChange = stkPortfolio.ShowTtlChange(250.00)[0];
            double ttlValue  = stkPortfolio.ShowTtlChange(250.00)[1];

            Assert.IsTrue(ttlChange <= 12.50);
            Assert.IsTrue(ttlChange >= -12.50);
            Assert.IsTrue(ttlValue <= 262.50);
            Assert.IsTrue(ttlValue >= 238.50);
        }
Esempio n. 35
0
        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.SubscribeRequest request, System.Action<bnet.protocol.NoData> done)
        {
            switch (request.EntityId.GetHighIdType())
            {
                case EntityIdHelper.HighIdType.AccountId:
                    var account = AccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (account != null)
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, account);
                        account.AddSubscriber(this.Client, request.ObjectId);
                    }
                    break;
                case EntityIdHelper.HighIdType.GameAccountId:
                    var gameaccount = GameAccountManager.GetAccountByPersistentID(request.EntityId.Low);
                    if (gameaccount != null)
                    {
                        Logger.Trace("Subscribe() {0} {1}", this.Client, gameaccount);
                        gameaccount.AddSubscriber(this.Client, request.ObjectId);
                    }
                    break;
                default:
                    Logger.Warn("Recieved an unhandled Presence.Subscribe request with type {0} (0x{1})", request.EntityId.GetHighIdType(), request.EntityId.High.ToString("X16"));
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 36
0
        public override void FindChannel(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel.FindChannelRequest request, System.Action<bnet.protocol.channel.FindChannelResponse> done)
        {
            Logger.Trace("FindChannel(): Filter={0}", request.Filter);
            var builder = bnet.protocol.channel.FindChannelResponse.CreateBuilder();

            done(builder.Build());
        }
Esempio n. 37
0
        public override void Bind(Google.ProtocolBuffers.IRpcController controller, BindRequest request, Action<BindResponse> done)
        {
            var requestedServiceIDs = new List<uint>();
            foreach (var serviceHash in request.ImportedServiceHashList)
            {
                var serviceID = Service.GetByHash(serviceHash);
                Logger.Trace("Bind() {0} [export] Hash: 0x{1} Id: 0x{2} Service: {3} ", this.Client, serviceHash.ToString("X8"), serviceID.ToString("X2"),

                Service.GetByID(serviceID) != null ? Service.GetByID(serviceID).GetType().Name : "N/A");
                requestedServiceIDs.Add(serviceID);
            }

            // read services supplied by client..
            foreach (var service in request.ExportedServiceList.Where(service => !Client.Services.ContainsValue(service.Id)))
            {
                if (Client.Services.ContainsKey(service.Hash)) continue;
                Client.Services.Add(service.Hash, service.Id);
                Logger.Trace(string.Format("Bind() {0} [import] Hash: 0x{1} Id: 0x{2}", this.Client, service.Hash.ToString("X8"), service.Id.ToString("X2")));
            }

            var builder = BindResponse.CreateBuilder();
            foreach (var serviceId in requestedServiceIDs) builder.AddImportedServiceId(serviceId);
            
            done(builder.Build());
        }
Esempio n. 38
0
        public override void SendNotification(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.notification.Notification request, Action<bnet.protocol.NoData> done)
        {
            switch (request.GetNotificationType())
            {
                case NotificationTypeHelper.NotificationType.Whisper:

                    // NOTE: Real implementation doesn't even handle the situation where neither client knows about the other.
                    // Client requires prior knowledge of sender and target (and even then it cannot whisper by using the /whisper command).

                    Logger.Trace(string.Format("NotificationRequest.Whisper by {0} to {1}", this.Client.CurrentToon, ToonManager.GetToonByLowID(request.TargetId.Low)));

                    var targetAccount = ToonManager.GetOwnerAccountByToonLowId(request.TargetId.Low);
                    if (targetAccount.LoggedInClient == null) return;

                    if (targetAccount == this.Client.Account) // check if whisper targets the account itself.
                        CommandManager.TryParse(request.AttributeList[0].Value.StringValue, this.Client); // try parsing it as a command and respond it if so.
                    else
                    {
                        var notification = bnet.protocol.notification.Notification.CreateBuilder(request)
                            .SetSenderId(this.Client.CurrentToon.BnetEntityID)
                            .Build();

                        targetAccount.LoggedInClient.MakeRPC(() => 
                            bnet.protocol.notification.NotificationListener.CreateStub(targetAccount.LoggedInClient).OnNotificationReceived(controller, notification, callback => { }));
                    }
                    break;
                default:
                    Logger.Warn("Unhandled notification type: {0}", request.Type);
                    break;
            }

            var builder = bnet.protocol.NoData.CreateBuilder();
            done(builder.Build());
        }
        private Expander CreateUITasklist(TaskList list, Google.Apis.Tasks.v1.Data.Tasks tasks)
        {
            var expander = new Expander();

            // Add a bold title.
            expander.Header = list.Title;
            expander.FontWeight = FontWeights.Bold;

            // Add the taskItems (if applicable).
            if (tasks.Items != null)
            {
                var container = new StackPanel();
                foreach (CheckBox box in tasks.Items.Select(CreateUITask))
                {
                    container.Children.Add(box);
                }
                expander.Content = container;
            }
            else
            {
                expander.Content = "There are no tasks in this list.";
            }

            return expander;
        }
Esempio n. 40
0
 public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action<bnet.protocol.NoData> done)
 {
     Logger.Trace("Unsubscribe()");
     Logger.Debug("request:\n{0}", request.ToString());
     
     switch (request.EntityId.GetHighIdType())
     {
         case EntityIdHelper.HighIdType.AccountId:
             var account = AccountManager.GetAccountByEntityID(request.EntityId);
             // The client will probably make sure it doesn't unsubscribe to a null ID, but just to make sure..
             if (account != null)
                 account.RemoveSubscriber((MooNetClient)this.Client);
             break;
         case EntityIdHelper.HighIdType.ToonId:
             var toon = ToonManager.GetToonByLowID(request.EntityId.Low);
             if (toon != null)
                 toon.RemoveSubscriber((MooNetClient)this.Client);
             break;
         default:
             Logger.Warn("Recieved an unhandled Presence.Unsubscribe request with type {0}", request.EntityId.GetHighIdType());
             break;
     }
     
     var builder = bnet.protocol.NoData.CreateBuilder();
     done(builder.Build());
 }
Esempio n. 41
0
    public static bool PromtForDownload(Google.Apis.Drive.v2.Data.File file, bool askUser)
    {
        bool needToDownload = false;
        if (askUser)
        {
            Console.WriteLine(file.Title + " ([y]/n)");
            String answer = Console.ReadLine().ToLower();

            if (answer == "y" || answer == "yes")
            {
                needToDownload = true;
            }
        }
        else
        {
            needToDownload = true;
        }

        if (needToDownload)
        {
            Console.WriteLine("Downloading " + file.Title);

            if (mClient.DownloadFile(file))
            {
                Console.WriteLine("Stored as " + file.Title);

                if (mDbObject.IsConnectionActive())
                {
                    mDbObject.DbInsertRequest(file.Title, DateTime.Now.Date);
                }
            }
        }

        return needToDownload;
    }
Esempio n. 42
0
                public void Search()
                {
                    Google.Open();

                    Google.Search("selenide");
                    Google.Results[0].Should(Have.Text("Selenide: concise UI tests in Java"));
                }
Esempio n. 43
0
        public override void JoinChannel(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel.JoinChannelRequest request, System.Action<bnet.protocol.channel.JoinChannelResponse> done)
        {
            Logger.Trace("JoinChannel()");

            var builder = bnet.protocol.channel.JoinChannelResponse.CreateBuilder().SetObjectId(67122); // should be fixed with the actual joined channel object id.
            done(builder.Build());
        }
Esempio n. 44
0
        public override void Logon(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.authentication.LogonRequest request, Action<bnet.protocol.NoData> done)
        {
            Logger.Trace("LogonRequest(): Email={0}", request.Email);

            if (!VersionChecker.Check(this.Client, request)) // if the client trying to connect doesn't match required version, disconnect him.
            {
                Logger.Error("Client [{0}] doesn't match required version {1}, disconnecting..", request.Email, VersionInfo.MooNet.RequiredClientVersion);

                // create the disconnection reason.
                var reason = bnet.protocol.connection.DisconnectNotification.CreateBuilder()
                    .SetErrorCode(3018).Build();

                // Error 3018 => A new patch for Diablo III is available. The game will now close and apply the patch automatically. You will be able to continue playing after the patch has been applied.

                // FIXME: D3 client somehow doesn't show the correct error message yet, and in debug output we only miss a message like [ Recv ] service_id: 254 token: 6 status: 28 
                // when I compare mooege's output. That could be the reason. /raist.

                // force disconnect the client as it does not satisfy required version. /raist.
                this.Client.MakeRPC(() => bnet.protocol.connection.ConnectionService.CreateStub(this.Client).ForceDisconnect(null, reason, callback => { }));
                this.Client.Connection.Disconnect();

                return;
            }

            done(bnet.protocol.NoData.CreateBuilder().Build());

            AuthManager.StartAuthentication(this.Client, request);
        }
Esempio n. 45
0
 public override void Unsubscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.presence.UnsubscribeRequest request, System.Action<bnet.protocol.NoData> done)
 {
     Logger.Trace("Unsubscribe()");
     //Logger.Debug("request:\n{0}", request.ToString());
     var builder = bnet.protocol.NoData.CreateBuilder();
     done(builder.Build());
 }
Esempio n. 46
0
        public void TestRandStkVal()
        {
            StkPortfolio stkPortfolio = new Google();

            stkPortfolio.RandStkVal(.01, .05);
            Assert.IsTrue(stkPortfolio.RandStkVal(.01, .05) <= .05);
            Assert.IsTrue(stkPortfolio.RandStkVal(.01, .05) >= .01);
        }
Esempio n. 47
0
        public void Google()
        {
            Google google = new Google(driver);

            google.GoToSite();
            google.SendWord();
            google.HeadersToListAllPages();
        }
Esempio n. 48
0
        public void Thow_Exception_When_Keyword_Is_Empty_And_Search_Count_Is_Less_Than_One()
        {
            //Arrange
            ISearchEngine google = new Google();

            //Act
            google.Search(string.Empty, -1);
        }
Esempio n. 49
0
        public void TestRandVal()
        {
            StkPortfolio stkPortfolio = new Google();

            stkPortfolio.RandVal();
            Assert.IsTrue(stkPortfolio.RandVal() <= 1);
            Assert.IsTrue(stkPortfolio.RandVal() >= 0);
        }
Esempio n. 50
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Player"/> class.
        /// </summary>
        internal Player()
        {
            this.Time = new Time();

            this.Facebook   = new Facebook(this);
            this.Google     = new Google(this);
            this.Gamecenter = new Gamecenter(this);
        }
Esempio n. 51
0
        public override void SubscribeToUserManager(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.user_manager.SubscribeToUserManagerRequest request, System.Action<bnet.protocol.user_manager.SubscribeToUserManagerResponse> done)
        {
            //TODO: Sending this packet crashes my client. This may be a local issue as I haven't heard anyone else mention it.     -Ethos
            //var builder = bnet.protocol.user_manager.SubscribeToUserManagerResponse.CreateBuilder();
            //done(builder.Build());

            throw new NotImplementedException();
        }
Esempio n. 52
0
        public void Throw_Exception_When_Keyword_Is_Null()
        {
            //Arrange
            ISearchEngine google = new Google();

            //Act
            google.Search(null, 100);
        }
Esempio n. 53
0
		public override void ToonList(Google.ProtocolBuffers.IRpcController controller, ToonListRequest request, Action<ToonListResponse> done) {
			var response = ToonListResponse.CreateBuilder();
			response.AddToons(new EntityId.Builder {
				High = 0x300016200004433,
				Low = 2
			});
			done(response.Build());
		}
Esempio n. 54
0
        public override void Subscribe(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel_invitation.SubscribeRequest request, Action<bnet.protocol.channel_invitation.SubscribeResponse> done)
        {
            Logger.Trace("Subscribe() {0}", this.Client);

            this._invitationManager.AddSubscriber(this.Client, request.ObjectId);
            var builder = bnet.protocol.channel_invitation.SubscribeResponse.CreateBuilder();
            done(builder.Build());
        }
Esempio n. 55
0
        public void Throw_Exception_When_Keyword_Is_Empty()
        {
            //Arrange
            ISearchEngine google = new Google();

            //Act
            google.Search(string.Empty, 100);
        }
Esempio n. 56
0
                public void FollowLink()
                {
                    Google.Open();
                    Google.Search("selenide");

                    Google.FollowLink(0);
                    wait.Until(UrlToBe("http://selenide.org/"));
                }
Esempio n. 57
0
        public void Throw_Exception_When_Search_Count_Is_Zero()
        {
            //Arrange
            ISearchEngine google = new Google();

            //Act
            google.Search("conveyancing software", 0);
        }
Esempio n. 58
0
        public void Thow_Exception_When_Search_Count_Is_Less_Than_One()
        {
            //Arrange
            ISearchEngine google = new Google();

            //Act
            google.Search("conveyancing software", -1);
        }
        public void MinDaysBloomTest(int[] roses, int k, int n, int expected)
        {
            // Act
            int result = Google.MinDaysBloom(roses, k, n);

            // Assert
            Assert.AreEqual(expected, result);
        }
Esempio n. 60
0
        public void ShouldReturnErrorCodeInCaseOfException()
        {
            var             erraticService          = new ErraticService();
            IErraticService erraticServiceTest      = new Google(erraticService);
            ServiceResponse serviceResponse         = erraticServiceTest.Search("test");
            var             serviceRequestException = erraticService.LastThrownException();

            Assert.AreEqual(serviceResponse.ErrorCode, serviceRequestException.ServiceError.ErrorCode);
        }