예제 #1
0
파일: Admin.cs 프로젝트: lsmolic/hangoutsrc
        private IList <metrics> GetMetrics(List <string> metrics, DateTime startDate, DateTime endDate, Period period,
                                           bool isAsync, GetMetricsCallback callback, Object state)
        {
            var parameterList = new Dictionary <string, string> {
                { "method", "facebook.admin.getMetrics" }
            };

            Utilities.AddRequiredParameter(parameterList, "start_time", DateHelper.ConvertDateToFacebookDate(startDate).ToString());
            Utilities.AddRequiredParameter(parameterList, "end_time", DateHelper.ConvertDateToFacebookDate(endDate).ToString());
            Utilities.AddRequiredParameter(parameterList, "period", period.ToString("D"));
            Utilities.AddJSONArray(parameterList, "metrics", metrics);

            if (isAsync)
            {
                SendRequestAsync <admin_getMetrics_response, IList <metrics> >(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted <IList <metrics> >(callback), state, "metrics");
                return(null);
            }

            var response = SendRequest <admin_getMetrics_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey));

            return(response == null ? null : response.metrics);
        }
예제 #2
0
파일: Admin.cs 프로젝트: lsmolic/hangoutsrc
 /// <summary>
 /// Returns specified metrics for your application, given a time period.
 /// </summary>
 /// <example>
 /// <code>
 /// private void RunDemo()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     DateTime startDate = DateTime.Now.Subtract(new TimeSpan(10, 0, 0, 0));
 ///     DateTime endDate = DateTime.Now;
 ///     Admin.Period period = Admin.Period.Day;
 ///     List&lt;string&gt; metrics = new List&lt;string&gt; { "active_users", "canvas_page_views" };
 ///     api.Admin.GetMetricsAsync(startDate, endDate, period, DemoCompleted, null);
 ///}
 ///
 /// private void DemoCompleted(IList&lt;metrics&gt; status, Object state, FacebookException e)
 /// {
 ///     IList&lt;metrics&gt; actual = status;
 /// }
 /// </code>
 /// </example>
 /// <param name="metrics">A List of metrics to retrieve (e.g. "active_users", "canvas_page_views")</param>
 /// <param name="startDate">A DateTime for the start of the range (inclusive).</param>
 /// <param name="endDate">A DateTime time for the end of the range (inclusive). The end_time cannot be more than 30 days after the start_time.</param>
 /// <param name="period">The length of the period, in seconds, during which the metrics were collected. Currently, the only supported periods are 86400 (1 day), 604800 (7-days), and 2592000 (30 days).</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>
 /// <returns>This method returns the metrics specified for the given range and time period.</returns>
 public void GetMetricsAsync(List <string> metrics, DateTime startDate, DateTime endDate, Period period, GetMetricsCallback callback, Object state)
 {
     GetMetrics(metrics, startDate, endDate, period, true, callback, state);
 }
예제 #3
0
파일: Admin.cs 프로젝트: lsmolic/hangoutsrc
 /// <summary>
 /// Returns specified metrics for your application, given a time period.
 /// </summary>
 /// <example>
 /// <code>
 /// private void RunDemo()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     DateTime startDate = DateTime.Now.Subtract(new TimeSpan(10, 0, 0, 0));
 ///     DateTime endDate = DateTime.Now;
 ///     Admin.Period period = Admin.Period.Day;
 ///     api.Admin.GetMetricsAsync(startDate, endDate, period, DemoCompleted, null);
 ///}
 ///
 /// private void DemoCompleted(IList&lt;metrics&gt; status, Object state, FacebookException e)
 /// {
 ///     IList&lt;metrics&gt; actual = status;
 /// }
 /// </code>
 /// </example>
 /// <param name="startDate">A DateTime for the start of the range (inclusive).</param>
 /// <param name="endDate">A DateTime time for the end of the range (inclusive). The end_time cannot be more than 30 days after the start_time.</param>
 /// <param name="period">The length of the period, in seconds, during which the metrics were collected. Currently, the only supported periods are 86400 (1 day), 604800 (7-days), and 2592000 (30 days).</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>
 /// <returns>This method returns the metrics specified for the given range and time period.</returns>
 public void GetMetricsAsync(DateTime startDate, DateTime endDate, Period period, GetMetricsCallback callback, Object state)
 {
     GetMetrics(GetMetricNames(period), startDate, endDate, period, true, callback, state);
 }
        private IList<metrics> GetMetrics(List<string> metrics, DateTime startDate, DateTime endDate, Period period, 
            bool isAsync, GetMetricsCallback callback, Object state)
        {
            var parameterList = new Dictionary<string, string> {{"method", "facebook.admin.getMetrics"}};
            Utilities.AddRequiredParameter(parameterList, "start_time", DateHelper.ConvertDateToFacebookDate(startDate).ToString());
            Utilities.AddRequiredParameter(parameterList, "end_time", DateHelper.ConvertDateToFacebookDate(endDate).ToString());
            Utilities.AddRequiredParameter(parameterList, "period", period.ToString("D"));
            Utilities.AddJSONArray(parameterList, "metrics", metrics);

            if (isAsync)
            {
                SendRequestAsync<admin_getMetrics_response, IList<metrics>>(parameterList, !string.IsNullOrEmpty(Session.SessionKey), new FacebookCallCompleted<IList<metrics>>(callback), state, "metrics");
                return null;
            }

            var response = SendRequest<admin_getMetrics_response>(parameterList, !string.IsNullOrEmpty(Session.SessionKey));
            return response == null ? null : response.metrics;
        }
 /// <summary>
 /// Returns specified metrics for your application, given a time period.
 /// </summary>
 /// <example>
 /// <code>
 /// private void RunDemo()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     DateTime startDate = DateTime.Now.Subtract(new TimeSpan(10, 0, 0, 0));
 ///     DateTime endDate = DateTime.Now;
 ///     Admin.Period period = Admin.Period.Day;
 ///     List&lt;string&gt; metrics = new List&lt;string&gt; { "active_users", "canvas_page_views" };
 ///     api.Admin.GetMetricsAsync(startDate, endDate, period, DemoCompleted, null);
 ///}
 ///
 /// private void DemoCompleted(IList&lt;metrics&gt; status, Object state, FacebookException e)
 /// {
 ///     IList&lt;metrics&gt; actual = status;
 /// }
 /// </code>
 /// </example>
 /// <param name="metrics">A List of metrics to retrieve (e.g. "active_users", "canvas_page_views")</param>
 /// <param name="startDate">A DateTime for the start of the range (inclusive).</param>
 /// <param name="endDate">A DateTime time for the end of the range (inclusive). The end_time cannot be more than 30 days after the start_time.</param>
 /// <param name="period">The length of the period, in seconds, during which the metrics were collected. Currently, the only supported periods are 86400 (1 day), 604800 (7-days), and 2592000 (30 days).</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>        
 /// <returns>This method returns the metrics specified for the given range and time period.</returns>
 public void GetMetricsAsync(List<string> metrics, DateTime startDate, DateTime endDate, Period period, GetMetricsCallback callback, Object state)
 {
     GetMetrics(metrics, startDate, endDate, period, true, callback, state);
 }
 /// <summary>
 /// Returns specified metrics for your application, given a time period.
 /// </summary>
 /// <example>
 /// <code>
 /// private void RunDemo()
 /// {
 ///     Api api = new Api(new DesktopSession(Constants.ApplicationKey, Constants.ApplicationSecret, Constants.ApplicationSecret, Constants.SessionKey));
 ///     DateTime startDate = DateTime.Now.Subtract(new TimeSpan(10, 0, 0, 0));
 ///     DateTime endDate = DateTime.Now;
 ///     Admin.Period period = Admin.Period.Day;
 ///     api.Admin.GetMetricsAsync(startDate, endDate, period, DemoCompleted, null);
 ///}
 ///
 /// private void DemoCompleted(IList&lt;metrics&gt; status, Object state, FacebookException e)
 /// {
 ///     IList&lt;metrics&gt; actual = status;
 /// }
 /// </code>
 /// </example>
 /// <param name="startDate">A DateTime for the start of the range (inclusive).</param>
 /// <param name="endDate">A DateTime time for the end of the range (inclusive). The end_time cannot be more than 30 days after the start_time.</param>
 /// <param name="period">The length of the period, in seconds, during which the metrics were collected. Currently, the only supported periods are 86400 (1 day), 604800 (7-days), and 2592000 (30 days).</param>
 /// <param name="callback">The AsyncCallback delegate</param>
 /// <param name="state">An object containing state information for this asynchronous request</param>        
 /// <returns>This method returns the metrics specified for the given range and time period.</returns>
 public void GetMetricsAsync(DateTime startDate, DateTime endDate, Period period, GetMetricsCallback callback, Object state)
 {
     GetMetrics(GetMetricNames(period), startDate, endDate, period, true, callback, state);
 }