コード例 #1
0
        /// <summary>
        /// Creates a user's company relation. Affiliates the user to a company.
        /// Documentation https://developers.google.com/partners/v2/reference/users/createCompanyRelation
        /// Generation Note: This does not always build corectly.  Google needs to standardise things I need to figuer out which ones are wrong.
        /// </summary>
        /// <param name="service">Authenticated Partners service.</param>
        /// <param name="userId">The ID of the user. Can be set to <code>me</code> to meanthe currently authenticated user.</param>
        /// <param name="body">A valid Partners v2 body.</param>
        /// <param name="optional">Optional paramaters.</param>
        /// <returns>CompanyRelationResponse</returns>
        public static CompanyRelation CreateCompanyRelation(PartnersService service, string userId, CompanyRelation body, UsersCreateCompanyRelationOptionalParms optional = null)
        {
            try
            {
                // Initial validation.
                if (service == null)
                {
                    throw new ArgumentNullException("service");
                }
                if (body == null)
                {
                    throw new ArgumentNullException("body");
                }
                if (userId == null)
                {
                    throw new ArgumentNullException(userId);
                }

                // Building the initial request.
                var request = service.Users.CreateCompanyRelation(body, userId);

                // Applying optional parameters to the request.
                request = (UsersResource.CreateCompanyRelationRequest)SampleHelpers.ApplyOptionalParms(request, optional);

                // Requesting data.
                return(request.Execute());
            }
            catch (Exception ex)
            {
                throw new Exception("Request Users.CreateCompanyRelation failed.", ex);
            }
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     CompanyId      = DNTRequest.GetInt("CompanyId", 0);
     openTypeQR     = DNTRequest.GetInt("openTypeQR", 0);
     NetLoanApplyId = DNTRequest.GetInt("NetLoanApplyId", 0);
     if (CompanyId <= 0)
     {
         Response.Redirect("/Product/Index?wd=0");
     }
     try
     {
         int             UserId        = MerchantFrontCookieBLL.GetMerchantFrontUserId();
         CompanyRelation relationModel = oCompanyRelationBLL.GetModel(CompanyId, UserId);//获取商家(只能给多个二维码的)二维码
         if (relationModel != null)
         {
             QRImg = relationModel.QRCode;
             if (string.IsNullOrEmpty(QRImg))
             {
                 if (!string.IsNullOrEmpty(relationModel.API))
                 {
                     string imgName = relationModel.CompanyRelationId + "_" + relationModel.CompanyId.ToString() + "_" + UserId.ToString();//组合文件名格式:渠道扩展编号加横杆加渠道编号
                     QRImg = GetQRImg(relationModel.API, imgName, "", "");
                 }
             }
         }
         else
         {
             model = opCompanyBLL.GetModel(CompanyId);
             if (model != null)
             {
                 if (!string.IsNullOrEmpty(model.QRCode))
                 {
                     QRImg = model.QRCode;
                 }
                 else
                 {
                     string url          = string.Empty;
                     string referralCode = string.Empty;
                     string imgName      = string.Empty;
                     if (!model.IsAPK)
                     {
                         QRType = 0;
                         url    = model.API;
                         if (model.IsRelyOnPrimaryKey == 1)
                         {
                             string prefix    = model.RecommendationPrefix;
                             int    maxlength = model.RecommendationLength;
                             referralCode = prefix + "-" + UserId.ToString() + "-" + NetLoanApplyId.ToString().PadLeft(maxlength, '0');
                         }
                         else
                         {
                             referralCode = model.RecommendationCode;
                         }
                         if (url.IndexOf("{0}") > 0)
                         {
                             url = string.Format(url, referralCode);
                         }
                         //if (!string.IsNullOrEmpty(model.ReplaceUrlParam))
                         //{
                         //    url = WebUtils.ReplaceUrlParamValue(model.API, model.ReplaceUrlParam, referralCode);
                         //}
                     }
                     else
                     {
                         QRType = 1;
                         string domain = LinkFun.getBWJSDomain();
                         url = domain + "/Product/NetLoanMiddlePage.aspx?openTypeQR=" + QRType + "&CompanyId=" + CompanyId;
                     }
                     imgName = model.CompanyId.ToString() + "_" + UserId;//渠道编号加下划线加经销商编号
                     QRImg   = GetQRImg(url, imgName, model.Logo, "");
                 }
             }
         }
         if (!string.IsNullOrEmpty(QRImg))//追加时间戳
         {
             if (QRImg.IndexOf("?") == -1)
             {
                 QRImg += string.Format("?{0}={1}", "times", DateTime.Now.ToFileTime());
             }
             else
             {
                 QRImg += string.Format("&{0}={1}", "times", DateTime.Now.ToFileTime());
             }
         }
     }
     catch (Exception ex) { ExceptionLogBLL.WriteExceptionLogToDB(ex.ToString()); }
 }