// Use this for initialization
	void Start () {
		server = FindObjectOfType<ServerManager> ();
		result = FindObjectOfType<ResultContainer> ();

		SPAWN_POSITION = new Vector3 (0f, 0.5f, 0f);

		startTime = Time.time;
		remainingTime = timeLength;
	}
        internal static void DeserializeAccountStatesRating(ResultContainer<TvEpisodeAccountState> accountState, string responseContent)
        {
            // Match both below, capture either "false" or "3.0" (numbers)
            // "rated":{"value":3.0}
            // "rated":false
            const string rgx = "\"rated\":(?:(?<value>false)|\\{\"value\":(?<value>\\d+(?:\\.\\d{1,2}))\\})";

            Regex regex = new Regex(rgx, RegexOptions.IgnoreCase);
            MatchCollection matches = regex.Matches(responseContent);

            for (int i = 0; i < matches.Count; i++)
            {
                Match match = matches[i];

                string value = match.Groups["value"].Value;

                if (value == "false")
                    accountState.Results[i].Rating = null;
                else
                    accountState.Results[i].Rating = Double.Parse(value, CultureInfo.InvariantCulture.NumberFormat);
            }
        }
        public ResultContainer Add(Citation entity)
        {
            const string    COMMAND_TEXT    = "usp_TaxonomyCitation_Insert";
            ResultContainer resultContainer = new ResultContainer();

            try
            {
                using (SqlConnection cn = DataContext.GetConnection(this.GetConnectionStringKey(_context)))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = COMMAND_TEXT;

                        cmd.Parameters.AddWithValue("@literature_id", entity.LiteratureID);

                        if (!String.IsNullOrEmpty(entity.CitationTitle))
                        {
                            cmd.Parameters.AddWithValue("@citation_title", entity.CitationTitle);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@citation_title", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.LiteratureEditorAuthorName))
                        {
                            cmd.Parameters.AddWithValue("@author_name", entity.LiteratureEditorAuthorName);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@author_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.CitationYear))
                        {
                            cmd.Parameters.AddWithValue("@citation_year", entity.CitationYear);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@citation_year", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.Reference))
                        {
                            cmd.Parameters.AddWithValue("@reference", entity.Reference);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@reference", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.DOIReference))
                        {
                            cmd.Parameters.AddWithValue("@doi_reference", entity.DOIReference);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@doi_reference", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.URL))
                        {
                            cmd.Parameters.AddWithValue("@url", entity.URL);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@url", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.Title))
                        {
                            cmd.Parameters.AddWithValue("@title", entity.Title);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@title", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.Description))
                        {
                            cmd.Parameters.AddWithValue("@description", entity.Description);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@description", DBNull.Value);
                        }

                        cmd.Parameters.AddWithValue("@accession_id", DBNull.Value);
                        cmd.Parameters.AddWithValue("@method_id", DBNull.Value);


                        if (entity.SpeciesID > 0)
                        {
                            cmd.Parameters.AddWithValue("@taxonomy_species_id", entity.SpeciesID);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@taxonomy_species_id", DBNull.Value);
                        }

                        if (entity.GenusID > 0)
                        {
                            cmd.Parameters.AddWithValue("@taxonomy_genus_id", entity.GenusID);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@taxonomy_genus_id", DBNull.Value);
                        }

                        if (entity.FamilyID > 0)
                        {
                            cmd.Parameters.AddWithValue("@taxonomy_family_id", entity.FamilyID);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@taxonomy_family_id", DBNull.Value);
                        }

                        cmd.Parameters.AddWithValue("@accession_ipr_id", DBNull.Value);
                        cmd.Parameters.AddWithValue("@accession_pedigree_id", DBNull.Value);
                        cmd.Parameters.AddWithValue("@genetic_marker_id", DBNull.Value);
                        cmd.Parameters.AddWithValue("@unique_key", DBNull.Value);

                        if (!String.IsNullOrEmpty(entity.TypeCode))
                        {
                            cmd.Parameters.AddWithValue("@type_code", entity.TypeCode);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@type_code", DBNull.Value);
                        }

                        cmd.Parameters.AddWithValue("@is_accepted_name", UnBool(entity.IsAcceptedName));

                        if (!String.IsNullOrEmpty(entity.Note))
                        {
                            cmd.Parameters.AddWithValue("@note", entity.Note);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@note", DBNull.Value);
                        }

                        cmd.Parameters.AddWithValue("@created_by", entity.CreatedByCooperatorID);

                        SqlParameter errorParam = new SqlParameter();
                        errorParam.SqlDbType     = System.Data.SqlDbType.Int;
                        errorParam.ParameterName = "@out_error_number";
                        errorParam.Direction     = System.Data.ParameterDirection.Output;
                        errorParam.Value         = 0;
                        cmd.Parameters.Add(errorParam);

                        SqlParameter genusIdParam = new SqlParameter();
                        genusIdParam.SqlDbType     = System.Data.SqlDbType.Int;
                        genusIdParam.ParameterName = "@out_citation_id";
                        genusIdParam.Direction     = System.Data.ParameterDirection.Output;
                        genusIdParam.Value         = 0;
                        cmd.Parameters.Add(genusIdParam);

                        cmd.ExecuteNonQuery();
                        resultContainer.ResultCode = cmd.Parameters["@out_error_number"].Value.ToString();
                        if (!String.IsNullOrEmpty(resultContainer.ResultCode))
                        {
                            if (Int32.Parse(resultContainer.ResultCode) > 0)
                            {
                                throw new Exception(resultContainer.ResultCode + resultContainer.ResultMessage);
                            }
                        }
                        resultContainer.EntityID = GetInt(cmd.Parameters["@out_citation_id"].Value.ToString());
                    }
                }
            }
            catch (SqlException ex)
            {
                switch (ex.Errors[0].Number)
                {
                case 547:     // Foreign Key violation
                    string s = ex.Message;
                    s = s.Substring(s.IndexOf("column "));
                    string[] array = s.Split('.');
                    s = array[0].Substring(array[0].IndexOf('\''));
                    break;
                }
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resultContainer);
        }
Exemple #4
0
        public void OnOpenAppStoreComplete(ResultContainer resultContainer)
        {
            var result = new OpenAppStoreResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #5
0
        public void OnShowRewardedVideoComplete(ResultContainer resultContainer)
        {
            var result = new RewardedVideoResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #6
0
        public void OnPayComplete(ResultContainer resultContainer)
        {
            var result = new PayResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #7
0
        public override void OnShareLinkComplete(ResultContainer resultContainer)
        {
            var result = new ShareResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
 public CommandAttributeTestCommand(ResultContainer r)
 {
     _Result = r;
 }
	// Use this for initialization
	void Start () {
		container = FindObjectOfType<ResultContainer> ();

	}
 public override void OnGroupJoinComplete(ResultContainer resultContainer)
 {
     throw new NotSupportedException();
 }
 public override void OnGetAppLinkComplete(ResultContainer resultContainer)
 {
     throw new NotSupportedException();
 }
Exemple #12
0
        public void OnRefreshCurrentAccessTokenComplete(ResultContainer resultContainer)
        {
            var result = new AccessTokenRefreshResult(resultContainer);
            if (result.AccessToken != null)
            {
                AccessToken.CurrentAccessToken = result.AccessToken;
            }

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #13
0
        /// <summary>
        /// Get the link to the youtube trailer of a movie
        /// </summary>
        /// <param name="movie">The movie</param>
        /// <param name="ct">Used to cancel loading trailer</param>
        /// <returns>Video trailer</returns>
        public async Task<ResultContainer<Video>> GetMovieTrailerAsync(MovieFull movie, CancellationToken ct)
        {
            var watch = Stopwatch.StartNew();

            var trailers = new ResultContainer<Video>();
            try
            {
                await Task.Run(async () => trailers = (await TmdbClient.GetMovieAsync(movie.ImdbCode, MovieMethods.Videos))?.Videos, ct);
            }
            catch (Exception exception) when (exception is TaskCanceledException)
            {
                Logger.Debug(
                    "GetMovieTrailerAsync cancelled.");
            }
            catch (Exception exception)
            {
                Logger.Error(
                    $"GetMovieTrailerAsync: {exception.Message}");
                throw;
            }
            finally
            {
                watch.Stop();
                var elapsedMs = watch.ElapsedMilliseconds;
                Logger.Debug(
                    $"GetMovieTrailerAsync ({movie.ImdbCode}) in {elapsedMs} milliseconds.");
            }

            return trailers;
        }
 public AppInviteResult(ResultContainer resultContainer) : base(resultContainer)
 {
 }
        public ResultContainer AddTaxonCitation(int citationId, int taxonId, string dataSource)
        {
            string          commandText      = String.Empty;
            string          taxonIdParamName = String.Empty;
            ResultContainer resultContainer  = new ResultContainer();

            try
            {
                switch (dataSource)
                {
                case "taxonomy_family":
                    commandText      = "usp_TaxonomyCitationFamilyClone_Insert";
                    taxonIdParamName = "@taxonomy_family_id";
                    break;

                case "taxonomy_genus":
                    commandText      = "usp_TaxonomyCitationGenusClone_Insert";
                    taxonIdParamName = "@taxonomy_genus_id";
                    break;

                case "taxonomy_species":
                    commandText      = "usp_TaxonomyCitationSpeciesClone_Insert";
                    taxonIdParamName = "@taxonomy_species_id";
                    break;
                }

                using (SqlConnection cn = DataContext.GetConnection(this.GetConnectionStringKey(_context)))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = commandText;
                        cmd.Parameters.AddWithValue("@citation_id", citationId);
                        cmd.Parameters.AddWithValue(taxonIdParamName, taxonId);

                        SqlParameter errorParam = new SqlParameter();
                        errorParam.SqlDbType     = System.Data.SqlDbType.Int;
                        errorParam.ParameterName = "@out_error_number";
                        errorParam.Direction     = System.Data.ParameterDirection.Output;
                        errorParam.Value         = 0;
                        cmd.Parameters.Add(errorParam);

                        SqlParameter familyIdParam = new SqlParameter();
                        familyIdParam.SqlDbType     = System.Data.SqlDbType.Int;
                        familyIdParam.ParameterName = "@out_citation_id";
                        familyIdParam.Direction     = System.Data.ParameterDirection.Output;
                        familyIdParam.Value         = 0;
                        cmd.Parameters.Add(familyIdParam);

                        cmd.ExecuteNonQuery();
                        resultContainer.ResultCode = cmd.Parameters["@out_error_number"].Value.ToString();
                        if (!String.IsNullOrEmpty(resultContainer.ResultCode))
                        {
                            if (Int32.Parse(resultContainer.ResultCode) > 0)
                            {
                                throw new Exception(resultContainer.ResultCode + resultContainer.ResultMessage);
                            }
                        }
                        resultContainer.EntityID = GetInt(cmd.Parameters["@out_citation_id"].Value.ToString());
                    }
                }
            }
            catch (SqlException ex)
            {
                switch (ex.Errors[0].Number)
                {
                case 547:     // Foreign Key violation
                    string s = ex.Message;
                    s = s.Substring(s.IndexOf("column "));
                    string[] array = s.Split('.');
                    s = array[0].Substring(array[0].IndexOf('\''));
                    break;
                }
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resultContainer);
        }
Exemple #16
0
 public void OnAppInviteComplete(ResultContainer resultContainer)
 {
     var result = new AppInviteResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
        public void OnAppInviteComplete(ResultContainer resultContainer)
        {
            var result = new AppInviteResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #18
0
 public override void OnAppRequestsComplete(ResultContainer resultContainer)
 {
     var result = new AppRequestResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
        public void OnLoginStatusRetrieved(ResultContainer resultContainer)
        {
            var result = new LoginStatusResult(resultContainer);

            this.OnAuthResponse(result);
        }
Exemple #20
0
 public void OnFacebookAuthResponseChange(ResultContainer resultContainer)
 {
     throw new NotSupportedException();
 }
 public override void OnLoginComplete(ResultContainer resultContainer)
 {
     this.OnAuthResponse(new LoginResult(resultContainer));
 }
Exemple #22
0
 public void OnFetchDeferredAppLinkComplete(ResultContainer resultContainer)
 {
     var result = new AppLinkResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
Exemple #23
0
        protected override void Execute()
        {
            IGeometryObject             geometry   = null;
            Dictionary <string, object> attributes = null;
            string message;
            int    status;

            if (Container is ResultContainer <GeocodeAddressResult> )
            {
                var container = Container as ResultContainer <GeocodeAddressResult>;
                message = container.Message;
                status  = container.Status;

                var result = container.Result;

                if (result?.Location != null)
                {
                    geometry   = new Point(new GeographicPosition(result.Location.Y, result.Location.X));
                    attributes = GetProperties(result);
                }
            }
            else if (Container is ResultContainer <RouteMilepostResult> )
            {
                var container = Container as ResultContainer <RouteMilepostResult>;
                message = container.Message;
                status  = container.Status;

                var result = container.Result;

                if (result?.Location != null)
                {
                    geometry   = new Point(new GeographicPosition(result.Location.Y, result.Location.X));
                    attributes = GetProperties(result);
                }
            }
            else
            {
                Result = null;
                return;
            }

            if (geometry == null && attributes == null)
            {
                Result = new ResultContainer <Feature>
                {
                    Status  = status,
                    Message = message
                };

                return;
            }

            var feature = new Feature(geometry, attributes);

            var geoJsonContainer = new ResultContainer <Feature>
            {
                Result  = feature,
                Status  = status,
                Message = message
            };

            Result = geoJsonContainer;
        }
Exemple #24
0
 public override void OnGroupJoinComplete(ResultContainer resultContainer)
 {
     var result = new GroupJoinResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
 internal GroupJoinResult(ResultContainer resultContainer) : base(resultContainer)
 {
 }
Exemple #26
0
 public override void OnLoginComplete(ResultContainer resultContainer)
 {
     var result = new LoginResult(resultContainer);
     this.OnAuthResponse(result);
 }
Exemple #27
0
 public void OnPostSessionScoreComplete(ResultContainer resultContainer)
 {
     var result = new SessionScoreResult(resultContainer);
 }
Exemple #28
0
 public void OnPayComplete(ResultContainer resultContainer)
 {
     var result = new PayResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
        public ResultContainer Update(Genus entity)
        {
            const string    COMMAND_TEXT    = "usp_TaxonomyGenus_Update";
            ResultContainer resultContainer = new ResultContainer();

            try
            {
                using (SqlConnection cn = DataContext.GetConnection(this.GetConnectionStringKey(_context)))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = COMMAND_TEXT;

                        cmd.Parameters.AddWithValue("@taxonomy_genus_id", entity.ID);
                        if (entity.ParentID == 0)
                        {
                            cmd.Parameters.AddWithValue("@current_taxonomy_genus_id", DBNull.Value);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@current_taxonomy_genus_id", entity.ParentID);
                        }

                        cmd.Parameters.AddWithValue("@taxonomy_family_id", entity.FamilyID);

                        if (!String.IsNullOrEmpty(entity.QualifyingCode))
                        {
                            cmd.Parameters.AddWithValue("@qualifying_code", entity.QualifyingCode);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@qualifying_code", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.HybridCode))
                        {
                            cmd.Parameters.AddWithValue("@hybrid_code", entity.HybridCode);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@hybrid_code", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.Name))
                        {
                            cmd.Parameters.AddWithValue("@genus_name", entity.Name);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@genus_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.Authority))
                        {
                            cmd.Parameters.AddWithValue("@genus_authority", entity.Authority);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@genus_authority", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.SubGenusName))
                        {
                            cmd.Parameters.AddWithValue("@subgenus_name", entity.SubGenusName);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@subgenus_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.SectionName))
                        {
                            cmd.Parameters.AddWithValue("@section_name", entity.SectionName);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@section_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.SubSectionName))
                        {
                            cmd.Parameters.AddWithValue("@subsection_name", entity.SubSectionName);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@subsection_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.SeriesName))
                        {
                            cmd.Parameters.AddWithValue("@series_name", entity.SeriesName);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@series_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.SubSeriesName))
                        {
                            cmd.Parameters.AddWithValue("@subseries_name", entity.SubSeriesName);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@subseries_name", DBNull.Value);
                        }

                        if (!String.IsNullOrEmpty(entity.Note))
                        {
                            cmd.Parameters.AddWithValue("@note", entity.Note);
                        }
                        else
                        {
                            cmd.Parameters.AddWithValue("@note", DBNull.Value);
                        }

                        cmd.Parameters.AddWithValue("@modified_by", entity.ModifiedByCooperatorID);

                        SqlParameter errorParam = new SqlParameter();
                        errorParam.SqlDbType     = System.Data.SqlDbType.Int;
                        errorParam.ParameterName = "@out_error_number";
                        errorParam.Direction     = System.Data.ParameterDirection.Output;
                        errorParam.Value         = 0;
                        cmd.Parameters.Add(errorParam);
                        cmd.ExecuteNonQuery();
                        resultContainer.ResultCode = cmd.Parameters["@out_error_number"].Value.ToString();
                        if (!String.IsNullOrEmpty(resultContainer.ResultCode))
                        {
                            if (Int32.Parse(resultContainer.ResultCode) > 0)
                            {
                                throw new Exception(resultContainer.ResultCode + resultContainer.ResultMessage);
                            }
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                switch (ex.Errors[0].Number)
                {
                case 547:     // Foreign Key violation
                    string s = ex.Message;
                    s = s.Substring(s.IndexOf("column "));
                    string[] array = s.Split('.');
                    s = array[0].Substring(array[0].IndexOf('\''));
                    break;
                }
                throw ex;
            }
            return(resultContainer);
        }
Exemple #30
0
 public void OnRefreshCurrentAccessTokenComplete(ResultContainer resultContainer)
 {
     var result = new AccessTokenRefreshResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
        public ResultContainer Update(Citation entity)
        {
            const string    COMMAND_TEXT    = "usp_TaxonomyCitation_Update";
            ResultContainer resultContainer = new ResultContainer();

            try
            {
                using (SqlConnection cn = DataContext.GetConnection(this.GetConnectionStringKey(_context)))
                {
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection  = cn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = COMMAND_TEXT;
                    cmd.Parameters.AddWithValue("@citation_id", entity.ID);
                    cmd.Parameters.AddWithValue("@literature_id", entity.LiteratureID);

                    if (!String.IsNullOrEmpty(entity.CitationTitle))
                    {
                        cmd.Parameters.AddWithValue("@citation_title", entity.CitationTitle);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@citation_title", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.LiteratureEditorAuthorName))
                    {
                        cmd.Parameters.AddWithValue("@author_name", entity.LiteratureEditorAuthorName);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@author_name", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.CitationYear))
                    {
                        cmd.Parameters.AddWithValue("@citation_year", entity.CitationYear);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@citation_year", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.Reference))
                    {
                        cmd.Parameters.AddWithValue("@reference", entity.Reference);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@reference", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.DOIReference))
                    {
                        cmd.Parameters.AddWithValue("@doi_reference", entity.DOIReference);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@doi_reference", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.URL))
                    {
                        cmd.Parameters.AddWithValue("@url", entity.URL);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@url", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.Title))
                    {
                        cmd.Parameters.AddWithValue("@title", entity.Title);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@title", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.Description))
                    {
                        cmd.Parameters.AddWithValue("@description", entity.Description);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@description", DBNull.Value);
                    }

                    if (entity.SpeciesID > 0)
                    {
                        cmd.Parameters.AddWithValue("@taxonomy_species_id", entity.SpeciesID);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@taxonomy_species_id", DBNull.Value);
                    }

                    if (entity.GenusID > 0)
                    {
                        cmd.Parameters.AddWithValue("@taxonomy_genus_id", entity.GenusID);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@taxonomy_genus_id", DBNull.Value);
                    }

                    if (entity.FamilyID > 0)
                    {
                        cmd.Parameters.AddWithValue("@taxonomy_family_id", entity.FamilyID);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@taxonomy_family_id", DBNull.Value);
                    }

                    if (!String.IsNullOrEmpty(entity.TypeCode))
                    {
                        cmd.Parameters.AddWithValue("@type_code", entity.TypeCode);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@type_code", DBNull.Value);
                    }

                    cmd.Parameters.AddWithValue("@is_accepted_name", UnBool(entity.IsAcceptedName));

                    if (!String.IsNullOrEmpty(entity.Note))
                    {
                        cmd.Parameters.AddWithValue("@note", entity.Note);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@note", DBNull.Value);
                    }

                    cmd.Parameters.AddWithValue("@modified_by", entity.ModifiedByCooperatorID);

                    SqlParameter errorParam = new SqlParameter();
                    errorParam.SqlDbType     = System.Data.SqlDbType.Int;
                    errorParam.ParameterName = "@out_error_number";
                    errorParam.Direction     = System.Data.ParameterDirection.Output;
                    errorParam.Value         = 0;
                    cmd.Parameters.Add(errorParam);
                    cmd.ExecuteNonQuery();
                    resultContainer.ResultCode = cmd.Parameters["@out_error_number"].Value.ToString();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(resultContainer);
        }
Exemple #32
0
 public override void OnShareLinkComplete(ResultContainer resultContainer)
 {
     var result = new ShareResult(resultContainer);
     CallbackManager.OnFacebookResponse(result);
 }
 public override void OnGroupJoinComplete(ResultContainer resultContainer)
 {
     throw new NotSupportedException();
 }
Exemple #34
0
        public void OnFriendFinderComplete(ResultContainer resultContainer)
        {
            var result = new GamingServicesFriendFinderResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
        public void OnFetchDeferredAppLinkComplete(ResultContainer resultContainer)
        {
            var result = new AppLinkResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #36
0
        public void OnUploadVideoToMediaLibraryComplete(ResultContainer resultContainer)
        {
            var result = new MediaUploadResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #37
0
        /// <summary>
        /// Get the link to the youtube trailer of a movie
        /// </summary>
        /// <param name="movie">The movie</param>
        /// <returns>Video trailer</returns>
        public async Task<ResultContainer<Video>> GetMovieTrailerAsync(MovieFull movie)
        {
            var watch = Stopwatch.StartNew();

            var trailers = new ResultContainer<Video>();
            try
            {
                await Task.Run(() =>
                {
                    trailers = TmdbClient.GetMovie(movie.ImdbCode, MovieMethods.Videos)?.Videos;
                });
            }
            catch (Exception ex) when (ex is SocketException || ex is WebException)
            {
                Logger.Error(
                    $"Error while getting the movie's trailer of {movie.Title}: {ex.Message}");
                Messenger.Default.Send(new ManageExceptionMessage(ex));
            }

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;
            Logger.Debug(
                $"GetMovieTrailerAsync ({movie.ImdbCode}) in {elapsedMs} milliseconds.");

            return trailers;
        }
Exemple #38
0
        public void OnGetCatalogComplete(ResultContainer resultContainer)
        {
            var result = new CatalogResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
        public override void OnGroupJoinComplete(ResultContainer resultContainer)
        {
            var result = new GroupJoinResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #40
0
        public void OnGetPurchasesComplete(ResultContainer resultContainer)
        {
            var result = new PurchasesResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
 public override void OnGetAppLinkComplete(ResultContainer resultContainer)
 {
     throw new NotSupportedException();
 }
Exemple #42
0
        public void OnConsumePurchaseComplete(ResultContainer resultContainer)
        {
            var result = new ConsumePurchaseResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
 public void OnHasLicenseComplete(ResultContainer resultContainer)
 {
     CallbackManager.OnFacebookResponse(new HasLicenseResult(resultContainer));
 }
Exemple #44
0
        public void OnInitCloudGameComplete(ResultContainer resultContainer)
        {
            var result = new InitCloudGameResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #45
0
        private static void FormatAuthResponse(ResultContainer result, Utilities.Callback <ResultContainer> callback)
        {
            if (result.ResultDictionary == null)
            {
                callback(result);
                return;
            }

            IDictionary <string, object> authResponse;

            if (result.ResultDictionary.TryGetValue(CanvasFacebook.AuthResponseKey, out authResponse))
            {
                result.ResultDictionary.Remove(CanvasFacebook.AuthResponseKey);
                foreach (var item in authResponse)
                {
                    result.ResultDictionary[item.Key] = item.Value;
                }
            }

            // The JS SDK doesn't always store the permissions so request them before returning the results
            if (result.ResultDictionary.ContainsKey(LoginResult.AccessTokenKey) &&
                !result.ResultDictionary.ContainsKey(LoginResult.PermissionsKey))
            {
                var parameters = new Dictionary <string, string>()
                {
                    { "fields", "permissions" },
                    { Constants.AccessTokenKey, (string)result.ResultDictionary[LoginResult.AccessTokenKey] },
                };
                FacebookDelegate <IGraphResult> apiCallback = (IGraphResult r) =>
                {
                    IDictionary <string, object> permissionsJson;
                    if (r.ResultDictionary != null && r.ResultDictionary.TryGetValue("permissions", out permissionsJson))
                    {
                        IList <string> permissions = new List <string>();
                        IList <object> data;
                        if (permissionsJson.TryGetValue("data", out data))
                        {
                            foreach (var permission in data)
                            {
                                var permissionDictionary = permission as IDictionary <string, object>;
                                if (permissionDictionary != null)
                                {
                                    string status;
                                    if (permissionDictionary.TryGetValue("status", out status) &&
                                        status.Equals("granted", StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        string permissionName;
                                        if (permissionDictionary.TryGetValue("permission", out permissionName))
                                        {
                                            permissions.Add(permissionName);
                                        }
                                        else
                                        {
                                            FacebookLogger.Warn("Didn't find permission name");
                                        }
                                    }
                                    else
                                    {
                                        FacebookLogger.Warn("Didn't find status in permissions result");
                                    }
                                }
                                else
                                {
                                    FacebookLogger.Warn("Failed to case permission dictionary");
                                }
                            }
                        }
                        else
                        {
                            FacebookLogger.Warn("Failed to extract data from permissions");
                        }

                        result.ResultDictionary[LoginResult.PermissionsKey] = permissions.ToCommaSeparateList();
                    }
                    else
                    {
                        FacebookLogger.Warn("Failed to load permissions for access token");
                    }

                    callback(result);
                };
                FB.API(
                    "me",
                    HttpMethod.GET,
                    apiCallback,
                    parameters);
            }
            else
            {
                callback(result);
            }
        }
Exemple #46
0
        public void OnScheduleAppToUserNotificationComplete(ResultContainer resultContainer)
        {
            var result = new ScheduleAppToUserNotificationResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #47
0
 public override void OnGetAppLinkComplete(ResultContainer message)
 {
     // We should never get here on canvas. We store the app link on this object
     // so should never hit this method.
     throw new NotImplementedException();
 }
Exemple #48
0
        public void OnShowInterstitialAdComplete(ResultContainer resultContainer)
        {
            var result = new InterstitialAdResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
Exemple #49
0
        public override void OnAppRequestsComplete(ResultContainer resultContainer)
        {
            var result = new AppRequestResult(resultContainer);

            CallbackManager.OnFacebookResponse(result);
        }
        public void Init(
            string appId,
            bool frictionlessRequests,
            string urlSuffix,
            string unityUserAgentSuffix)
        {
            this.LogMethodCall();

            // Handle testing of init returning access token. It would be nice
            // to not have init return the access token but this could be
            // a breaking change for people who read the raw result
            ResultContainer resultContainer;
            IDictionary<string, object> resultExtras = this.ResultExtras;
            if (resultExtras != null)
            {
                var result = MockResults.GetGenericResult(0, resultExtras);
                resultContainer = new ResultContainer(result);
            }
            else
            {
                resultContainer = new ResultContainer(string.Empty);
            }

            Facebook.OnInitComplete(resultContainer);
        }