示例#1
0
 private DataTable makeTable(Profile ret)
 {
     DataTable dt = new DataTable();
     dt.Columns.Add("key", typeof(string));
     dt.Columns.Add("value", typeof(string));
     DataRow row = dt.NewRow();
     row[0] = "viewName"; row[1] = ret.Name; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "url"; row[1] = ret.WebsiteUrl; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "timeZone"; row[1] = ret.Timezone; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "defaultPage"; row[1] = ret.DefaultPage; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "exclude parameters"; row[1] = ret.ExcludeQueryParameters; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "currency"; row[1] = ret.Currency; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "siteSearch"; row[1] = ret.SiteSearchQueryParameters; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "stripSiteSearchParam"; row[1] = ret.StripSiteSearchQueryParameters; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "siteSearchCategory"; row[1] = ret.SiteSearchCategoryParameters; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "stripSiteSearchCategoryParam"; row[1] = ret.StripSiteSearchCategoryParameters; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "ecommerce"; row[1] = ret.ECommerceTracking; dt.Rows.Add(row);
     row = dt.NewRow(); row[0] = "enhancedEcommerce"; row[1] = ret.EnhancedECommerceTracking; dt.Rows.Add(row);
     return dt;
 }
        /// <summary>
        /// Updates an existing view (profile). This method supports patch semantics.
        /// Documentation:https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/webproperties/patch
        /// 
        /// Beta Access: https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtprofilesGuide#code
        /// Write operations in the Management API (e.g. create, update, delete, patch) for Web Property, View (Profile), 
        /// and Goal resources is currently available as a developer preview in limited beta. If you're interested in using these features, 
        /// request access to the beta.
        /// https://docs.google.com/forms/d/1xyjp6ca4YkGjh7TDi1Z3XyA3XHcRHkKzFentxzUrmPY/viewform
        /// 
        /// 
        /// </summary>
        /// <param name="service">Valid Authenticated Analytics Service </param>
        /// <param name="Body">relevant portions of a management.profiles resource, according to the rules of patch semantics.</param>
        /// <param name="accountId">Account ID to which the web property belongs </param>
        /// <param name="webPropertyId">Web property Id</param>
        /// <param name="profilesId">profile ID</param>
        /// <returns>A Web property resource https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/webproperties </returns>
        public static Profile ProfileUpdate(AnalyticsService service, Profile body, string accountId, string webPropertyId, string profilesId)
        {
            try
            {
                Profile result = service.Management.Profiles.Update(body, accountId, webPropertyId, profilesId).Execute();
                return result;
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
                return null;
            }
        }