public static bool UploadVideoHash(IMLItem Item, string location, string imdbid, ConnectionResult connectionresult, bool FileServerIsOnline, bool IsUNC)
        {

            if (String.IsNullOrEmpty(imdbid))
            {
                Debugger.LogMessageToFile("[OSdb movie hash uploader] This video's IMDb ID is not available. Uploading of it's file hash cannot be performed.");
                return false;
            }

            if (!FileServerIsOnline && IsUNC)
            {
                Debugger.LogMessageToFile("[OSdb movie hash uploader] Your file server is offline. ");
                return false;
            }

            if (!File.Exists(location))
                return false;

            string moviehash = Helpers.GetTagValueFromItem(Item, "VideoHash");

            if (String.IsNullOrEmpty(moviehash))
                return false;

           
            #region get file info
            Debugger.LogMessageToFile("[OSdb movie hash uploader] Extracting file information for movie hash uploading...");
            FileInfo file = new FileInfo(location);
            long filesize = file.Length;
            string imdbidNumOnly = imdbid.Remove(0, 2);      
            #endregion

            return PerformUploading(Item, moviehash, connectionresult, filesize, imdbidNumOnly);
        
        }
        private static bool PerformUploading(IMLItem Item, string moviehash, ConnectionResult connectionresult, long filesize, string imdbidNumOnly)
        {
            try
            {
                MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress, "Updating video definitions database...");
                InsertVideoHash(Item, connectionresult.OsDbLoginResult.token, moviehash, filesize,
                                             imdbidNumOnly);
                return true;
            }
            catch
            {
                MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress,
                                               "Osdb database did not respond. Retrying...");
                Thread.Sleep(3000);
                try
                {
                    InsertVideoHash(Item, connectionresult.OsDbLoginResult.token, moviehash, filesize,
                                                 imdbidNumOnly);
                    return true;
                }
                catch
                {
                    Debugger.LogMessageToFile("Unable to communicate with OSdb. Video hash was not uploaded.");
                    MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress,
                                                   "Unable to communicate with OSdb. Video hash was not uploaded.");
                    return false;
                }

            }


        }//endof method
        internal static ConnectionResult ConnectToOsDb
            (ConnectionResult connectionResult)
        {

            if (!connectionResult.InternetConnectionAvailable
                &&
                Settings.ConnectionDiagnosticsEnabled)
            {
                connectionResult.OSDbIsOnline = false;
                return connectionResult;
            }



            if (!Settings.EnableVideoHasher &&
                !Settings.EnableSubtitleDownloader &&
                !Settings.WantOSdbDetails)
            {
                connectionResult.OSDbIsOnline = false;
                return connectionResult;
            }



            OSoperations osDbOperations = new OSoperations();

            connectionResult = 
                TryConnection(osDbOperations, connectionResult);


            return connectionResult;


        }
        internal static ConnectionResult OsDbConnectionRetry(OSoperations osDbOperations,
            ConnectionResult connectionResult)
        {
            MainImportingEngine.ThisProgress.Progress
                (MainImportingEngine.CurrentProgress,
                 "OSdb did not respond. Retrying... ");

            Thread.Sleep(2000);

            try
            {
                connectionResult.OsDbLoginResult =
                    osDbOperations.SiteLogin();

                MainImportingEngine.ThisProgress.Progress
                    (MainImportingEngine.CurrentProgress,
                     "login status: " +
                     connectionResult.OsDbLoginResult.Status);

                Thread.Sleep(3000);

                connectionResult.OsDbIsOnline = true;

            }
            catch (Exception)
            {
                connectionResult =
                    DisableOsDbConnection(connectionResult);
            }

            return connectionResult;
        }
Пример #5
0
        public void OnConnectionFailed (ConnectionResult result)
        {
            Log.Debug (TAG, "onConnectionFailed:" + result);

            if (!mIsResolving && mShouldResolve)
            {
                if (result.HasResolution)
                {
                    try
                    {
                        result.StartResolutionForResult (Activity, RC_SIGN_IN);
                        mIsResolving = true;
                    }
                    catch (IntentSender.SendIntentException e)
                    {
                        Log.Error (TAG, "Could not resolve ConnectionResult.", e);
                        mIsResolving = false;
                        mGoogleApiClient.Connect ();
                    }
                }
                else {
                    ShowErrorDialog (result);
                }
            }
            else {
                UpdateUI (false);
            }
        }
        internal static string IdentifyMovieByVideoFingerprint(IMLItem item, ConnectionResult connectionresult, bool FileServerIsOnline, bool IsUNC, string location, string parent )
        {

            #region function variables

            string moviehash = Helpers.GetTagValueFromItem(item,"VideoHash");
            string imdbid = Helpers.GetTagValueFromItem(item,"ImdbID");
            #endregion


            if (!String.IsNullOrEmpty(imdbid))
                return imdbid;

            #region Compute Hash
            if (String.IsNullOrEmpty(moviehash))
            {
                //if ( Importer.EnableHashing)
                //{
                if (!IsUNC || FileServerIsOnline)
                {
                    if (File.Exists(location))
                    {
                        Debugger.LogMessageToFile("Computing video fingerprint for " + item.Name + "...");
                        MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress, "Computing video fingerprint for " + item.Name + "...");
                        Thread.Sleep(200);
                        moviehash = Hasher.ComputeHash(location, item);
                        item.Tags["VideoHash"] = moviehash;
                        item.SaveTags();
                    }
                    else
                    {
                        MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress, "The video file in location field was not found. MediaFairy cannot identify this film.");
                        Thread.Sleep(Settings.SleepValue);
                    }
                }
                //}
            }
            else moviehash = Helpers.GetTagValueFromItem(item,"VideoHash");

            item.SaveTags();
            #endregion


            MovieDescriptorReader.ReadMovieDescriptor(item, moviehash, parent, item.Name );


            if (Settings.PrimaryVideoFingerprintMatchingSource == "OSDb")
            {
                OSDbVideoFingeprintIdentifier.IdentifyMovieByHashOSDb(item, connectionresult);
                imdbid = TMDbVideoFingerprintIdentifier.IdentifyMovieByHashTMDb(item, connectionresult);
            }
            else
            {
                TMDbVideoFingerprintIdentifier.IdentifyMovieByHashTMDb(item, connectionresult);
                imdbid = OSDbVideoFingeprintIdentifier.IdentifyMovieByHashOSDb(item, connectionresult);
            }

            return imdbid;
        }
Пример #7
0
        public static void ResolveConnectionFailed(ConnectionResult connectionResult)
        {
            if (connectionResult.HasResolution) {

            } else {

            }
        }
Пример #8
0
        public void OnConnectionFailed(ConnectionResult result)
        {
            if (progressDialog.IsShowing) {
                ResolveLogin (result);
            }

            connectionResult = result;
            Toast.MakeText (this, "Connection Failed!", ToastLength.Long).Show ();
        }
        public void DisconnectMessage(ConnectionResult result, string customReason)
        {
            var msg = new DisconnectMessage();
            msg.Reason = ConnectionResult.Success;
            msg.CustomReason = null;

            var mresult = msg.AssertLengthMatches();
            Assert.AreEqual (msg.Reason, mresult.Reason);
            Assert.AreEqual (msg.CustomReason, mresult.CustomReason);
        }
        public static string IdentifyFilmByFilmTitleMatchingEngines
            (IMLItem item, string imdbid, IMDbOperations imdbOp, 
             string year, ConnectionResult connectionresult)
        {


            #region Return Cases
            if (!Settings.FilmTitleMatchingEnginesAreEnabled)
            {
                Debugger.LogMessageToFile("[IMDb Film Title Matcher] IMDb Title matching is disabled. Returning...");
                return imdbid;
            }

            if (!String.IsNullOrEmpty(imdbid))
            {
                Debugger.LogMessageToFile("[IMDb Film Title Matcher] This item is already identified. Returning...");
                return imdbid;
            }
            #endregion

            if (Settings.PrimaryFilmTitleMatchingEngine == "TMDb")
            {


                imdbid = Code.Media_Identifiers.
                    Film_Identifiers.Title_Matching_Engines
                    .TMDb.TMDbTitleMatchingEngine.
                    IdentifyFilmByTMDbFilmTitleMatchingEngine(item);

                imdbid = IdentifyFilmByIMDbFilmTitleMatchingEngines
                    (item, imdbid, imdbOp, connectionresult);
            
            
            }
            else
            {


                imdbid = IdentifyFilmByIMDbFilmTitleMatchingEngines
                    (item, imdbid, imdbOp, connectionresult);


                imdbid = Code.Media_Identifiers.
                    Film_Identifiers.Title_Matching_Engines
                    .TMDb.TMDbTitleMatchingEngine.
                    IdentifyFilmByTMDbFilmTitleMatchingEngine(item);


            }



            return imdbid;
        }
        private static ConnectionResult InternetConnectionTestWasSuccessful()
        {
            ConnectionResult connectionresult = new ConnectionResult();

            Helpers.UpdateProgress("Performing Diagnostic Operations...",
                                   "Internet connection test was successful.", null);

            Thread.Sleep(3000);

            connectionresult.InternetConnectionAvailable = true;
            return connectionresult;
        }
        public static string IdentifyEpisode(IMLItem item, ConnectionResult connectionresult,
            bool fileServerIsOnline, bool isUNC, string location, string parent)
        {

            CalculateVideoHash(item, fileServerIsOnline, isUNC, location);

            //Helpers.ReadXmlForEpisode(Item, moviehash, parent );

            string videoHash = Helpers.GetTagValueFromItem(item, "Hash");
            string imdbID = Helpers.GetTagValueFromItem(item, "ImdbID");

            //imdbID = GetIMDbIdByVideoHash(item, connectionresult, imdbID, videoHash);

            return imdbID;

        }
        internal static ConnectionResult ConnectToOsDb(ConnectionResult connectionResult)
        {
            if (!connectionResult.InternetConnectionAvailable
                &&
                Settings.ConnectionDiagnosticsEnabled)
            {
                connectionResult.OsDbIsOnline = false;
                return connectionResult;
            }

            OSoperations osDbOperations = new OSoperations();

            connectionResult =
                TryConnection(osDbOperations, connectionResult);

            return connectionResult;
        }
        internal static ConnectionResult OsDbConnectionFirstTry(OSoperations osDbOperations,
            ConnectionResult connectionResult)
        {
            connectionResult.OsDbLoginResult =
                osDbOperations.SiteLogin();

            MainImportingEngine.ThisProgress.Progress
                (MainImportingEngine.CurrentProgress,
                 "login status: " +
                 connectionResult.OsDbLoginResult.Status);

            Thread.Sleep(3000);

            connectionResult.OsDbIsOnline = true;

            return connectionResult;
        }
        internal static int CalculateMusicDnsIdentificationTime(ConnectionResult connectionresult,
                            out int tracksToIdentify, ref int totalTracksToIdentifyCount)
        {

            int remainingTime = 0;
            tracksToIdentify = 0;

            if (!Settings.EnableMusicDnsAudioTrackIdentification)
                return remainingTime;

            if (
                !Settings.EstimateAudioIdentification ||
                (
                    !connectionresult.InternetConnectionAvailable && 
                    Settings.ConnectionDiagnosticsEnabled
                )
                )
                return remainingTime;


            Debugger.LogMessageToFile("Calculating audio identification time...");
            MainImportingEngine.ThisProgress.Progress(MainImportingEngine.CurrentProgress,
                                                      "Calculating audio identification time...");
            Thread.Sleep(500);


            CountItemsWhichNeedMusicDnsIdentification
                (ref totalTracksToIdentifyCount);


            remainingTime = totalTracksToIdentifyCount*10;
            tracksToIdentify = totalTracksToIdentifyCount;


            if (totalTracksToIdentifyCount > 12)
            {
                StatusForm.statusForm.TrayIcon.ShowBalloonTip(5000,
                    "Music Track Identification has started.",
                    "This operation will need approximately " +
                    remainingTime/60 + " minutes to complete. ",
                    ToolTipIcon.Info);
            }

            return remainingTime;
        
        }
        public void OnConnectionFailed(ConnectionResult result)
        {
            if (resolvingError)
                return; // Already attempting to resolve an error.

            if (result.HasResolution)
                try {
                    resolvingError = true;
                    result.StartResolutionForResult(context, 1001);
                } catch (Exception e) {
                    Console.WriteLine("[SimpleLocation: Connection failed. Error: {0}]", e.Message);
                    googleApiClient.Connect(); // There was an error with the resolution intent. Try again.
                }
            else {
                GooglePlayServicesUtil.GetErrorDialog(result.ErrorCode, context, 9000)?.Show();
                resolvingError = true;
            }
        }
        internal static string PerformMediaOrganizing
            (bool fileServerChecked,
            bool fileServerIsOnline,
            ConnectionResult connectionresult,
            int currentItem,
            string[] multipart, string location,
            IMLItem Item, bool IsMultipart)
        {

            if (!Settings.WantSortingTvShows)
                return location;
            
            string itemTitle
                = Helpers.GetTagValueFromItem
                (Item, "EpisodeName");



            #region update runtime paramaters

            itemUpdateParams updateParams;
            updateParams.FileInUse = Settings.FileInUse;
            updateParams.IsMultipart = IsMultipart;
            updateParams.CanWorkOnline = connectionresult.InternetConnectionAvailable;
            updateParams.CompletedItems = currentItem;
            updateParams.FileServerChecked = fileServerChecked;
            updateParams.FileServerIsOnline = fileServerIsOnline;
            updateParams.OSIsOnline = connectionresult.OSDbIsOnline;

            #endregion



            MediaOrganizers.OrganizeMediaFiles
                (Item, itemTitle, multipart, ref location,
                 Settings.SortingDestinationTvShows,
                 Settings.DirectoryTagMaskTvShows,
                 updateParams,
                 "TvShow");


            return location;
       
        }
        internal static ConnectionResult DisableOsDbConnection(ConnectionResult connectionResult)
        {
            MainImportingEngine.ThisProgress.Progress
                (MainImportingEngine.CurrentProgress,
                 "Unable to connect to OSdb online database. ");

            //StatusForm.statusForm.TrayIcon.ShowBalloonTip
            //    (5000, "Unable to connect to OSDb",
            //     "MediaFairy was unable to connect to " +
            //     "OpenSubtitles.org databse." +
            //     "Video Fingerprint Identifying and Subtitle Downloading" +
            //     "will not be performed in this session using this source.",
            //     ToolTipIcon.Warning);

            Thread.Sleep(2000);

            connectionResult.OsDbIsOnline = true;

            return connectionResult;
        }
 public void OnConnectionFailed(ConnectionResult p0)
 {
     if (p0.HasResolution)
     {
         try
         {
             Mvx.TaggedTrace("OnConnectionFailed()", "Launching Resolution for ConnectionResult with ErrorCode: {0}", p0.ErrorCode.ToString());
             var intent = new Intent();
             var receiver = new ConnectionFailedPendingIntentReceiver();
             receiver.ResultOk += ok => {
                 if (ok)
                     _locationClient.Connect();
             };
             p0.Resolution.Send(Context, 0, intent, receiver, null);
         }
         catch (PendingIntent.CanceledException ex)
         {
             Mvx.TaggedTrace("OnConnectionFailed()", "Resolution for ConnectionResult Cancelled! Exception: {0}", ex);
         }
     }
 }
        private static ConnectionResult TryConnection(OSoperations osDbOperations, ConnectionResult connectionResult)
        {
            Helpers.UpdateProgress("Performing Diagnostic Operations... ",
                                   "Connecting to OSDb...", null);

            try
            {
                connectionResult =
                    OsDbConnectionFirstTry
                        (osDbOperations, connectionResult);
            }
            catch (Exception)
            {
                connectionResult =
                    OsDbConnectionRetry
                        (osDbOperations, connectionResult);
            }

            return connectionResult;

        }
Пример #21
0
        IObservable<bool> IConnectionResultHandler.HandleConnectionResult(ConnectionResult connectionResult)
        {
            if (!connectionResult.HasResolution)
            {
                GoogleApiAvailability
                    .Instance
                    .GetErrorDialog(this, connectionResult.ErrorCode, 0)
                    .Show();
                return Observable.Return(false);
            }

            try
            {
                this.resultResolutionSubject.Disposable = new Subject<bool>();
                connectionResult.StartResolutionForResult(this, RequestCodeResolution);
                return this.resultResolutionSubject.Disposable;
            }
            catch (IntentSender.SendIntentException)
            {
                return Observable.Return(false);
            }
        }
        internal static bool DownloadSubtitleForVideoParent(string videoHash, string imdbid, 
            IMLItem item, string location , ConnectionResult connectionresult,
            bool useSameFolder, string subtitlesFolder, bool isMovie)
        {
            if (!Settings.EnableSubtitleDownloader)
                return false;

            if (!connectionresult.OSDbIsOnline)
                return false;

            string hasSubtitle = Helpers.GetTagValueFromItem(item, "HasSubtitle");

            if (!String.IsNullOrEmpty(hasSubtitle))
                return true;

            //if (String.IsNullOrEmpty(imdbid))
            //    return false;

            if (Settings.SubDloadLimitExceeded)
                return false;

            string subfilePathSrt;
            string subfilePathSub;
            string parentPath;

            var videoFilename = VideoSubtitleDownloaderHelpers.ConstructSubtitlePath(location, useSameFolder,
                subtitlesFolder, out subfilePathSrt, out subfilePathSub, out parentPath);

            if (!VideoSubtitleDownloaderHelpers.CheckForExistingSubtitleSetHasSubtitleFlag
                (videoHash, item, parentPath, subfilePathSrt, subfilePathSub))
                return false;

            var subsDownloadResult = VideoSubtitleDownloaderHelpers.DownloadSubtitleForPrimaryOrSecondaryLanguage
                (videoHash, imdbid, item, connectionresult, isMovie, videoFilename, parentPath);

            VideoSubtitleDownloaderHelpers.DeleteSubtitleZipFile(videoHash, parentPath);

            return subsDownloadResult;
        }
        private static string GetIMDbIdByVideoHash(IMLItem item,
            ConnectionResult connectionresult, 
            string imdbid, string moviehash)
        {
            if (!connectionresult.OSDbIsOnline)
                return imdbid;

            if (String.IsNullOrEmpty(moviehash))
                return imdbid;

            if (!String.IsNullOrEmpty(imdbid))
                return imdbid;
            
            imdbid = OSoperations.FindImdbIDbyHash2
                (moviehash, item, connectionresult.OsDbLoginResult.token,
                 ref connectionresult.OSDbIsOnline);

            item.Tags["ImdbID"] = imdbid;
            item.SaveTags();

            return imdbid;
        }
        private static bool ReturnCases(ConnectionResult connectionresult)
        {

            if (!Settings.EnableRssImporter)
                return true;
            Debugger.LogMessageToFile("[RSS news downloader] RSS news downloader is enabled");


            if (Settings.RsSfeeds == null)
                return true;

            if (Settings.RsSfeeds.Length == 0)
                return true;

            Debugger.LogMessageToFile("[RSS news downloader] RSS feeds were provided by the user."
                                      + Environment.NewLine +
                                      "Proceeding to download and import " + Settings.RsSfeeds.Length + " RSS feeds...");


            return !CheckInternetConnection( connectionresult);

        }
Пример #25
0
    public static IEnumerator Register(System.Action<ConnectionResult> callOnCompletion, string email, string username, string password)
    {
        string hash = StringEncoder.CalculateMD5Hash(email + username + password + ConfigConnectionScript.Key);

        string url = ConfigConnectionScript.RegisterUrl + "?" +
                     "email=" + WWW.EscapeURL(email) +
                     "&username="******"&password="******"&hash=" + hash;

        WWW result = new WWW(url);
        yield return result;

        ConnectionResult connectionResult = null;

        if (result.error == null) {
            connectionResult = new ConnectionResult(result.text);
        } else {
            connectionResult = new ConnectionResult(ConnectionResult.ErrorType.CouldNotConnect);
        }

        callOnCompletion(connectionResult);
    }
        public void OnConnectionFailed(ConnectionResult result)
        {
            Log.Error(TAG, "Connect to Google API failed: {0}.", result.ErrorCode);
            if (_authInProgress)
            {
                return;
            }
            if (!result.HasResolution)
            {
                return;
            }

            try
            {
                _authInProgress = true;
                result.StartResolutionForResult(this, GOOGLE_PLAY_SERVICES_REQUEST_AUTHORIZATION);
            }
            catch (IntentSender.SendIntentException e)
            {
                _authInProgress = false;
                Log.Error(TAG, "Could not resolve Google Play Services error: {0}", e.LocalizedMessage);
            }
        }
        internal static ConnectionResult CheckInternetConnection()
        {


            ConnectionResult connectionresult = new ConnectionResult();

            if (!Settings.ConnectionDiagnosticsEnabled)
                return connectionresult;

            
            Helpers.UpdateProgress("Performing Diagnostic Operations...",
                                   "Checking Internet Connection...", null);

            Thread.Sleep(1000);

            try
            {

                bool pingResult = Ping("www.google.com");

                connectionresult =
                    SetConnectionFlagBasedOnPingResult(pingResult);

                

            }
            catch (Exception e)
            {
                connectionresult = InternetConnectionWasNotDetected();
                Debugger.LogMessageToFile(e.ToString());
            }


            return connectionresult;


        }
        private static ConnectionResult InternetConnectionWasNotDetected()
        {
            ConnectionResult connectionresult = new ConnectionResult();

            StatusForm.statusForm.TrayIcon.ShowBalloonTip(1000,
                        "Internet connection was not detected.",
                        "Internet Connection diagnostic was unable" +
                        " to etabilish a test connection. " +
                        "All online features will be disabled." +
                        "", ToolTipIcon.Info);

            MainImportingEngine.ThisProgress.
                Progress(MainImportingEngine.CurrentProgress,
                         "Internet Connection was not detected." +
                         " All online features will be disabled. ");

            Thread.Sleep(3000);

            connectionresult.InternetConnectionAvailable
                = false;

            return connectionresult;
        
        }
        internal static void ImportRssFeeds(ConnectionResult connectionresult)
        {


            if (ReturnCases(connectionresult))
                return;

            //TODO: Provide choice to not delete existing RSS items, but instead check for existing items and skip re-importing them. ("Only Update New Items" feature)
           
            Debugger.LogMessageToFile("[RSS news downloader]" +
            " Deleting all RSS Section items in order to import new items...");
            
            MediaSectionsAllocator.NewsSection.DeleteAllItems();

            using (WebClient webClient = new WebClient())
            {

                DownloadRssFeedsAndPopulateFeedEntries
                    (MediaSectionsAllocator.NewsSection, webClient);
            
            }


        }
Пример #30
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     result.StartResolutionForResult(this, 999);
 }
 //google
 public void OnConnectionFailed(ConnectionResult result)
 {
     //throw new System.NotImplementedException();
 }
Пример #32
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     Log.Debug("Steve", result.ErrorMessage);
 }
Пример #33
0
 /// <summary> Creates a <see cref="SecureUdpConnection"/> with the given parent <see cref="TcpConnection"/>. </summary>
 /// <param name="tcpConnection">    The <see cref="TcpConnection"/> via which to connect the <see cref="SecureUdpConnection"/>. </param>
 /// <param name="connectionResult"> The connection result. </param>
 /// <param name="keySize">          The size of the RSA keys. </param>
 /// <returns> The created <see cref="SecureUdpConnection"/>. </returns>
 public static UdpConnection CreateSecureUdpConnection(TcpConnection tcpConnection, out ConnectionResult connectionResult, int keySize = 2048) =>
 CreateSecureUdpConnection(tcpConnection, RSAKeyGeneration.Generate(keySize), out connectionResult);
Пример #34
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     Rock.Mobile.Util.Debug.WriteToLog(string.Format("LocationManagerService: OnConnectionFailed Cause: {0}", result));
 }
        public async Task<ConnectionResult> Connect(ServerInfo server, ConnectionOptions options, CancellationToken cancellationToken = default(CancellationToken))
        {
            var result = new ConnectionResult
            {
                State = ConnectionState.Unavailable
            };

            PublicSystemInfo systemInfo = null;
            var connectionMode = ConnectionMode.Manual;

            var tests = new[] { ConnectionMode.Manual, ConnectionMode.Local, ConnectionMode.Remote }.ToList();

            // If we've connected to the server before, try to optimize by starting with the last used connection mode
            if (server.LastConnectionMode.HasValue)
            {
                tests.Remove(server.LastConnectionMode.Value);
                tests.Insert(0, server.LastConnectionMode.Value);
            }

            var isLocalNetworkAvailable = _networkConnectivity.GetNetworkStatus().GetIsAnyLocalNetworkAvailable();

            // Kick off wake on lan on a separate thread (if applicable)
            var sendWakeOnLan = server.WakeOnLanInfos.Count > 0 && isLocalNetworkAvailable;

            var wakeOnLanTask = sendWakeOnLan ?
                Task.Run(() => WakeServer(server, cancellationToken), cancellationToken) :
                Task.FromResult(true);

            var wakeOnLanSendTime = DateTime.Now;

            foreach (var mode in tests)
            {
                _logger.Debug("Attempting to connect to server {0}. ConnectionMode: {1}", server.Name, mode.ToString());

                if (mode == ConnectionMode.Local)
                {
                    // Try connect locally if there's a local address,
                    // and we're either on localhost or the device has a local connection
                    if (!string.IsNullOrEmpty(server.LocalAddress) && isLocalNetworkAvailable)
                    {
                        // Try to connect to the local address
                        systemInfo = await TryConnect(server.LocalAddress, 8000, cancellationToken).ConfigureAwait(false);
                    }
                }
                else if (mode == ConnectionMode.Manual)
                {
                    // Try manual address if there is one, but only if it's different from the local/remote addresses
                    if (!string.IsNullOrEmpty(server.ManualAddress)
                        && !string.Equals(server.ManualAddress, server.LocalAddress, StringComparison.OrdinalIgnoreCase)
                        && !string.Equals(server.ManualAddress, server.RemoteAddress, StringComparison.OrdinalIgnoreCase))
                    {
                        // Try to connect to the local address
                        systemInfo = await TryConnect(server.ManualAddress, 15000, cancellationToken).ConfigureAwait(false);
                    }
                }
                else if (mode == ConnectionMode.Remote)
                {
                    if (!string.IsNullOrEmpty(server.RemoteAddress))
                    {
                        systemInfo = await TryConnect(server.RemoteAddress, 15000, cancellationToken).ConfigureAwait(false);
                    }
                }

                if (systemInfo != null)
                {
                    connectionMode = mode;
                    break;
                }
            }

            if (systemInfo == null && !string.IsNullOrEmpty(server.LocalAddress) && isLocalNetworkAvailable && sendWakeOnLan)
            {
                await wakeOnLanTask.ConfigureAwait(false);

                // After wake on lan finishes, make sure at least 10 seconds have elapsed since the time it was first sent out
                var waitTime = TimeSpan.FromSeconds(10).TotalMilliseconds -
                               (DateTime.Now - wakeOnLanSendTime).TotalMilliseconds;

                if (waitTime > 0)
                {
                    await Task.Delay(Convert.ToInt32(waitTime, CultureInfo.InvariantCulture), cancellationToken).ConfigureAwait(false);
                }

                systemInfo = await TryConnect(server.LocalAddress, 15000, cancellationToken).ConfigureAwait(false);
            }

            if (systemInfo != null)
            {
                await OnSuccessfulConnection(server, options, systemInfo, result, connectionMode, cancellationToken)
                        .ConfigureAwait(false);
            }

            result.ConnectUser = ConnectUser;
            return result;
        }
Пример #36
0
        public void OnConnectionFailed(ConnectionResult result)
        {
            ConnectTcs.SetResult(apiClient.IsConnected);

            WriteLine("Connection failed, attempting to reach google play services");
        }
Пример #37
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     Console.WriteLine("Google API client suspended!");
     Toast.MakeText(this, "Failed to connect", ToastLength.Long).Show();
 }
Пример #38
0
 /* Interface */ /// <see cref="GoogleApiClient.IOnConnectionFailedListener"/>
 public void OnConnectionFailed(ConnectionResult bundle)
 {
     Log.Info("LocationClient", "Verbinden met GoogleApi clien mislukt");
 }
Пример #39
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     tcsSignOut.TrySetException(new Exception("Google Services Connection Failed: " + result.ErrorMessage));
 }
Пример #40
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     Log.Error(TAG, "OnConnectionFailed");
     StopLocationUpdates();
     StopSelf();
 }
Пример #41
0
        /// <summary> Creates a <see cref="SecureTcpConnection"/> and connects it to the given IP address and port. </summary>
        /// <param name="ipAddress">        The IP address to connect to. </param>
        /// <param name="port">             The port to connect to. </param>
        /// <param name="rsaPair">          The RSA key-pair to use. </param>
        /// <param name="connectionResult"> The connection result. </param>
        /// <returns> The created <see cref="SecureTcpConnection"/>. </returns>
        public static TcpConnection CreateSecureTcpConnection(string ipAddress, int port, RSAPair rsaPair, out ConnectionResult connectionResult)
        {
            Tuple <TcpConnection, ConnectionResult> tcpConnection = CreateSecureTcpConnectionAsync(ipAddress, port, rsaPair).Result;

            connectionResult = tcpConnection.Item2;
            return(tcpConnection.Item1);
        }
Пример #42
0
        /// <summary> Creates a <see cref="SecureTcpConnection"/> and connects it to the given IP address and port. </summary>
        /// <param name="ipAddress">        The IP address to connect to. </param>
        /// <param name="port">             The port to connect to. </param>
        /// <param name="publicKey">        The public RSA key in xml format. (https://superdry.apphb.com/tools/online-rsa-key-converter) </param>
        /// <param name="privateKey">       The private RSA key in xml format. (https://superdry.apphb.com/tools/online-rsa-key-converter) </param>
        /// <param name="connectionResult"> The connection result. </param>
        /// <param name="keySize">          The size to use for the RSA keys. </param>
        /// <returns> The created <see cref="SecureTcpConnection"/>. </returns>
        public static TcpConnection CreateSecureTcpConnection(string ipAddress, int port, string publicKey, string privateKey, out ConnectionResult connectionResult, int keySize = 2048)
        {
            Tuple <TcpConnection, ConnectionResult> tcpConnection = CreateSecureTcpConnectionAsync(ipAddress, port, publicKey, privateKey, keySize).Result;

            connectionResult = tcpConnection.Item2;
            return(tcpConnection.Item1);
        }
Пример #43
0
 /// <summary>
 /// Creates a new instance of <see cref="ConnectionEventArgs"/>.
 /// </summary>
 /// <param name="connection">The connection of the event.</param>
 /// <param name="reason">Result for disconnection.</param>
 /// <exception cref="ArgumentNullException"><paramref name="connection"/> is <c>null</c>.</exception>
 public DisconnectedEventArgs(IConnection connection, ConnectionResult reason)
     : base(connection)
 {
     this.Result = reason;
 }
Пример #44
0
 public Task DisconnectAsync(ConnectionResult reason, string customReason = null)
 {
     return(this.connection.DisconnectAsync(reason, customReason));
 }
Пример #45
0
 public DisconnectedEventArgs(IConnection connection, ConnectionResult reason, string customReason)
     : this(connection, reason)
 {
     CustomReason = customReason;
 }
Пример #46
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     Log.Info(TAG, "Connection failed: ConnectionResult.getErrorCode() = " + result.ErrorCode);
 }
Пример #47
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     // An unresolvable error has occurred and Google APIs will not
     // be available.
     Log.Debug(TAG, "onConnectionFailed:" + result);
 }
Пример #48
0
 public void OnConnectionFailed(ConnectionResult connectionResult)
 {
     Log.Error(TAG, "Failed to connect to Google Api Client");
 }
Пример #49
0
 public void OnConnectionFailed(ConnectionResult status)
 {
     // Nothing to do.
 }
Пример #50
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     _onLoginComplete?.Invoke(null, result.ErrorMessage);
 }
Пример #51
0
        private static eLoginEnum Connect(String AUserName, String APassword, Int64 ASiteKey)
        {
            eLoginEnum ConnectionResult;
            String     WelcomeMessage;
            String     LoginError;
            Int32      ProcessID;
            Boolean    SystemEnabled;

            TLogging.Log("connecting UserId: " + AUserName + " to Server...");
            ConnectionResult = ((TConnectionManagement)TConnectionManagement.GConnectionManagement).ConnectToServer(
                AUserName.ToUpper(), APassword,
                out ProcessID,
                out WelcomeMessage,
                out SystemEnabled,
                out LoginError);

            if (ConnectionResult != eLoginEnum.eLoginSucceeded)
            {
                TLogging.Log("Connection to PetraServer failed! ConnectionResult: " + ConnectionResult.ToString() + " Error: " + LoginError);
                return(ConnectionResult);
            }

            TUserDefaults.InitUserDefaults();
            new TServerInfo(Utilities.DetermineExecutingOS());
            TLogging.Log(
                "client is connected ClientID: " + TConnectionManagement.GConnectionManagement.ClientID.ToString() + " UserId: " + AUserName +
                " to Server...");

            return(eLoginEnum.eLoginSucceeded);
        }
 bool resolveConnectionFailure(Activity activity, Android.Gms.Common.Apis.GoogleApiClient client, ConnectionResult result, int requestCode, string fallbackErrorMessage)
 {
     if (result.HasResolution)
     {
         try {
             result.StartResolutionForResult(activity, requestCode);
             return(true);
         } catch (IntentSender.SendIntentException e) {
             // The intent was canceled before it was sent.  Return to the default
             // state and attempt to connect to get an updated ConnectionResult.
             client.Connect();
             return(false);
         }
     }
     else
     {
         // not resolvable... so show an error message
         int errorCode = result.ErrorCode;
         var dialog    = GooglePlayServicesUtil.GetErrorDialog(errorCode, activity, requestCode);
         if (dialog != null)
         {
             dialog.Show();
         }
         else
         {
             // no built-in dialog: show the fallback error message
             //ShowAlert (activity, fallbackErrorMessage);
             (new AlertDialog.Builder(activity)).SetMessage(fallbackErrorMessage)
             .SetNeutralButton(Android.Resource.String.Ok, delegate { }).Create().Show();
         }
         return(false);
     }
 }
Пример #53
0
 public void OnConnectionFailed(ConnectionResult result)
 {
 }
Пример #54
0
 /// <summary> Creates a <see cref="SecureUdpConnection"/> with the given parent <see cref="TcpConnection"/>. </summary>
 /// <param name="tcpConnection">    The <see cref="TcpConnection"/> via which to connect the <see cref="SecureUdpConnection"/>. </param>
 /// <param name="publicKey">        The public RSA key in xml format. (https://superdry.apphb.com/tools/online-rsa-key-converter) </param>
 /// <param name="privateKey">       The private RSA key in xml format. (https://superdry.apphb.com/tools/online-rsa-key-converter) </param>
 /// <param name="connectionResult"> The connection result. </param>
 /// <param name="keySize">          The size of the RSA keys. </param>
 /// <returns> The created <see cref="SecureUdpConnection"/>. </returns>
 public static UdpConnection CreateSecureUdpConnection(TcpConnection tcpConnection, string publicKey, string privateKey, out ConnectionResult connectionResult, int keySize = 2048) =>
 CreateSecureUdpConnection(tcpConnection, new RSAPair(publicKey, privateKey, keySize), out connectionResult);
Пример #55
0
        public static async void OnConnect(ConnectionResult result, byte[] secretKey)
        {
            if (result == ConnectionResult.Succeeded)
            {
                try
                {
                    //Sync settings
                    Windesheart.PairedDevice.SetTime(DateTime.Now);
                    Windesheart.PairedDevice.SetDateDisplayFormat(DeviceSettings.DateFormatDMY);
                    Windesheart.PairedDevice.SetLanguage(DeviceSettings.DeviceLanguage);
                    Windesheart.PairedDevice.SetTimeDisplayFormat(DeviceSettings.TimeFormat24Hour);
                    Windesheart.PairedDevice.SetActivateOnLiftWrist(DeviceSettings.WristRaiseDisplay);
                    Windesheart.PairedDevice.SetStepGoal(DeviceSettings.DailyStepsGoal);
                    Windesheart.PairedDevice.EnableFitnessGoalNotification(true);
                    Windesheart.PairedDevice.EnableSleepTracking(true);
                    Windesheart.PairedDevice.SetHeartrateMeasurementInterval(1);

                    Globals.HomePageViewModel.ReadCurrentBattery();
                    Globals.HomePageViewModel.BandNameLabel = Windesheart.PairedDevice.Name;

                    //Callbacks
                    Windesheart.PairedDevice.EnableRealTimeHeartrate(OnHeartrateUpdated);
                    Windesheart.PairedDevice.EnableRealTimeBattery(OnBatteryUpdated);
                    Windesheart.PairedDevice.EnableRealTimeSteps(OnStepsUpdated);
                    Windesheart.PairedDevice.SubscribeToDisconnect(OnDisconnect);

                    Globals.DevicePageViewModel.StatusText = "Connected";
                    Globals.DevicePageViewModel.DeviceList = new ObservableCollection <BLEScanResult>();
                    Device.BeginInvokeOnMainThread(delegate
                    {
                        DevicePage.DisconnectButton.IsEnabled = true;
                    });
                    Globals.DevicePageViewModel.IsLoading = false;
                    Globals.SamplesService.StartFetching();
                    SaveGuid(secretKey);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    Debug.WriteLine("Something went wrong while connecting to device, disconnecting...");
                    Windesheart.PairedDevice?.Disconnect();
                    Globals.DevicePageViewModel.IsLoading = false;
                }
            }
            else if (result == ConnectionResult.Failed)
            {
                Debug.WriteLine("Connection failed");
                if (Windesheart.PairedDevice.SecretKey != null && Application.Current.Properties.ContainsKey(Windesheart.PairedDevice.IDevice.Uuid.ToString()))
                {
                    Application.Current.Properties.Remove(Windesheart.PairedDevice.IDevice.Uuid.ToString());
                    Device.BeginInvokeOnMainThread(delegate
                    {
                        Application.Current.MainPage.DisplayAlert("Connecting failed, Please try again", "The secret key of this device has changed since the last time it was connected to this phone. Please try connecting to this device again or try to factory reset the device!", "OK");
                    });
                }
                Windesheart.PairedDevice?.Disconnect();
                Globals.DevicePageViewModel.StatusText = "Disconnected";
                Device.BeginInvokeOnMainThread(delegate
                {
                    DevicePage.DisconnectButton.IsEnabled = true;
                    Globals.HomePageViewModel.IsLoading   = false;
                    Globals.HomePageViewModel.EnableDisableButtons(true);
                    Globals.DevicePageViewModel.ScanButtonText = "Scan for devices";
                    DevicePage.ScanButton.IsEnabled            = true;
                    DevicePage.ReturnButton.IsVisible          = true;
                });
                Globals.DevicePageViewModel.IsLoading = false;
            }
        }
Пример #56
0
        /**
         * Transfer the required data over to the wearable
         * @param attractions list of attraction data to transfer over
         */
        private void SendDataToWearable(List <Attraction> attractions)
        {
            GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
                                              .AddApi(WearableClass.API)
                                              .Build();

            // It's OK to use blockingConnect() here as we are running in an
            // IntentService that executes work on a separate (background) thread.
            ConnectionResult connectionResult = googleApiClient.BlockingConnect(
                Constants.GOOGLE_API_CLIENT_TIMEOUT_S, TimeUnit.Seconds);

            // Limit attractions to send
            int count = attractions.Count > Constants.MAX_ATTRACTIONS ?
                        Constants.MAX_ATTRACTIONS : attractions.Count;

            List <DataMap> attractionsData = new List <DataMap>(count);

            for (int i = 0; i < count; i++)
            {
                Attraction attraction = attractions[i];

                Bitmap image          = null;
                Bitmap secondaryImage = null;

                try
                {
                    //TODO:
                    // Fetch and resize attraction image bitmap
                    //image = Glide.with(this)
                    //		.load(attraction.imageUrl)
                    //		.asBitmap()
                    //		.diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    //		.into(Constants.WEAR_IMAGE_SIZE_PARALLAX_WIDTH, Constants.WEAR_IMAGE_SIZE)
                    //		.get();

                    //secondaryImage = Glide.with(this)
                    //		.load(attraction.secondaryImageUrl)
                    //		.asBitmap()
                    //		.diskCacheStrategy(DiskCacheStrategy.SOURCE)
                    //		.into(Constants.WEAR_IMAGE_SIZE_PARALLAX_WIDTH, Constants.WEAR_IMAGE_SIZE)
                    //		.get();
                }
                catch (Exception e)
                {
                    Log.Error("UtilityService", "Exception loading bitmap from network");
                }

                if (image != null && secondaryImage != null)
                {
                    DataMap attractionData = new DataMap();

                    string distance = Utils.FormatDistanceBetween(
                        Utils.GetLocation(this), attraction.Location);

                    attractionData.PutString(Constants.EXTRA_TITLE, attraction.Name);
                    attractionData.PutString(Constants.EXTRA_DESCRIPTION, attraction.Description);
                    attractionData.PutDouble(
                        Constants.EXTRA_LOCATION_LAT, attraction.Location.Latitude);
                    attractionData.PutDouble(
                        Constants.EXTRA_LOCATION_LNG, attraction.Location.Longitude);
                    attractionData.PutString(Constants.EXTRA_DISTANCE, distance);
                    attractionData.PutString(Constants.EXTRA_CITY, attraction.City);

                    //TODO:
                    //	attractionData.PutAsset(Constants.EXTRA_IMAGE,
                    //		Utils.CreateAssetFromBitmap(image));
                    //attractionData.PutAsset(Constants.EXTRA_IMAGE_SECONDARY,
                    //		Utils.CreateAssetFromBitmap(secondaryImage));

                    attractionsData.Add(attractionData);
                }
            }

            if (connectionResult.IsSuccess && googleApiClient.IsConnected &&
                attractionsData.Count > 0)
            {
                PutDataMapRequest dataMap = PutDataMapRequest.Create(Constants.ATTRACTION_PATH);
                dataMap.DataMap.PutDataMapArrayList(Constants.EXTRA_ATTRACTIONS, attractionsData);
                //TODO:
                //dataMap.DataMap.PutLong(Constants.EXTRA_TIMESTAMP, DateTime.Now.ToFileTime);
                PutDataRequest request = dataMap.AsPutDataRequest();
                request.SetUrgent();

                //TODO: Async/Await
                // Send the data over
                //            var result =
                //					WearableClass.DataApi.PutDataItem(googleApiClient, request));

                //            if (!result.).isSuccess()) {
                //                Log.e(TAG, String.format("Error sending data using DataApi (error code = %d)",
                //                        result.getStatus().getStatusCode()));
                //            }

                //} else {
                //            Log.e(TAG, String.format(Constants.GOOGLE_API_CLIENT_ERROR_MSG,
                //                    connectionResult.getErrorCode()));
                //        }
                googleApiClient.Disconnect();
            }
        }
Пример #57
0
        /// <summary> Creates a <see cref="SecureUdpConnection"/> with the given parent <see cref="TcpConnection"/>. </summary>
        /// <param name="tcpConnection">    The <see cref="TcpConnection"/> via which to connect the <see cref="SecureUdpConnection"/>. </param>
        /// <param name="rsaPair">          The RSA key-pair to use. </param>
        /// <param name="connectionResult"> The connection result. </param>
        /// <returns> The created <see cref="SecureUdpConnection"/>. </returns>
        public static UdpConnection CreateSecureUdpConnection(TcpConnection tcpConnection, RSAPair rsaPair, out ConnectionResult connectionResult)
        {
            Tuple <UdpConnection, ConnectionResult> connectionRequest = CreateSecureUdpConnectionAsync(tcpConnection, rsaPair).Result;

            connectionResult = connectionRequest.Item2;
            return(connectionRequest.Item1);
        }
Пример #58
0
 public void OnConnectionFailed(ConnectionResult result)
 {
     Toast.MakeText(this, "Connection failed! " + result.ErrorMessage + ", " + result.ErrorCode, ToastLength.Short).Show();
 }
Пример #59
0
        protected override void OnCreate (Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
            // If you want to understand the life cycle more, you can use below command to turn on
            // verbose logging for this Activity on your testing device:
            // adb shell setprop log.tag.SignInActivity VERBOSE
            mIsLogVerbose = Android.Util.Log.IsLoggable (TAG, Android.Util.LogPriority.Verbose);

            SetContentView (Resource.Layout.sign_in_activity);

            restoreState (savedInstanceState);

            logVerbose ("Activity onCreate, creating new GoogleApiClient");

            mGoogleApiClient = buildGoogleApiClient (false);

            mSignInStatus = FindViewById<TextView> (Resource.Id.sign_in_status);
            mSignInButton = FindViewById<SignInButton> (Resource.Id.sign_in_button);
            mSignInButton.Click += (sender, e) => {
                if (!mGoogleApiClient.IsConnecting) {
                    int available = GooglePlayServicesUtil.IsGooglePlayServicesAvailable (this);
                    if (available != ConnectionResult.Success) {
                        ShowDialog (DIALOG_GET_GOOGLE_PLAY_SERVICES);
                        return;
                    }

                    mSignInClicked = true;
                    mSignInStatus.Text = GetString (Resource.String.signing_in_status);
                    resolveSignInError ();
                }
            };

            mServerAuthCodeDisabledLabel = FindViewById<TextView> (Resource.Id.server_auth_code_disabled);
            mServerAuthCodeResetButton = FindViewById<View> (Resource.Id.server_auth_code_reset_button);
            mServerAuthCodeResetButton.Click += (sender, e) => {
                mServerAuthCodeRequired.Set (true);
            };
            if (!isUsingOfflineAccess ()) {
                mServerAuthCodeDisabledLabel.Visibility = ViewStates.Visible;
                mServerAuthCodeResetButton.Visibility = ViewStates.Gone;
            } else {
                mServerAuthCodeDisabledLabel.Visibility = ViewStates.Gone;
                mServerAuthCodeResetButton.Visibility = ViewStates.Visible;
            }

            mSignOutButton = FindViewById<View> (Resource.Id.sign_out_button);
            mSignOutButton.Click += (sender, e) => {
                if (mGoogleApiClient.IsConnected)
                    mGoogleApiClient.ClearDefaultAccountAndReconnect ();
            };
            mRevokeAccessButton = FindViewById (Resource.Id.revoke_access_button);
            mRevokeAccessButton.Click += async delegate {
                mServerAuthCodeRequired.Set (true);
                if (mGoogleApiClient.IsConnected) {
                    var result = await PlusClass.AccountApi.RevokeAccessAndDisconnectAsync (mGoogleApiClient);

                    if (result.IsSuccess) {
                        mSignInStatus.SetText (Resource.String.revoke_access_status);
                    } else {
                        mSignInStatus.SetText (Resource.String.revoke_access_error_status);
                    }
                    mGoogleApiClient.Reconnect ();
                       
                    updateButtons (false /* isSignedIn */);
                }
            };

            mScopeSelector = FindViewById<ToggleButton> (Resource.Id.scope_selection_toggle);
            mScopeSelector.CheckedChange += (sender, e) => {
                mGoogleApiClient.Disconnect ();
                // Since we changed the configuration, the cached connection result is no longer
                // valid.
                mConnectionResult = null;
                mGoogleApiClient = buildGoogleApiClient (e.IsChecked);
                mGoogleApiClient.Connect ();
            };


            if (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) {
                ActionBar.SetDisplayHomeAsUpEnabled (true);
            }
        }
Пример #60
0
        /// <summary> Creates a <see cref="SecureTcpConnection"/> and connects it to the given IP address and port. </summary>
        /// <param name="ipAddress">        The IP address to connect to. </param>
        /// <param name="port">             The port to connect to. </param>
        /// <param name="connectionResult"> The connection result. </param>
        /// <param name="keySize">          The size to use for the RSA keys. </param>
        /// <returns> The created <see cref="SecureTcpConnection"/>. </returns>
        public static TcpConnection CreateSecureTcpConnection(string ipAddress, int port, out ConnectionResult connectionResult, int keySize = 2048)
        {
            Tuple <TcpConnection, ConnectionResult> tcpConnection = CreateSecureTcpConnectionAsync(ipAddress, port, RSAKeyGeneration.Generate(keySize)).Result;

            connectionResult = tcpConnection.Item2;
            return(tcpConnection.Item1);
        }