Example #1
0
        /// <summary>
        /// “关注”指定的目标用户(异步)
        /// </summary>
        /// <param name="userId">用户编号</param>
        /// <param name="targetUserId">被关注的目标用户编号</param>
        public static async void FollowedTargetUser(int userId, int targetUserId)
        {
            await Task.Run(() =>
            {
                UserFollowed uFollowed = new UserFollowed {
                    UserId = userId, FollowedUserId = targetUserId, CreateDate = DateTime.Now
                };
                bool result = SocialData.ChangedFollowedWithTargetUser(uFollowed, 1);
                if (result)
                {
                    SocialConfig config = SocialConfigs.GetSocialConfigCache();

                    if (config.BeFollowedExpChanged != 0)
                    {
                        UserBiz.UpdateUserExp(targetUserId, config.BeFollowedExpChanged, "被关注");
                    }

                    if (config.BeFollowedCoinChanged != 0)
                    {
                        UserBiz.UpdateUserCoin(targetUserId, config.BeFollowedCoinChanged, "被关注");
                    }

                    UserBiz.SetUserCacheInfo(userId);
                    UserBiz.SetUserCacheInfo(targetUserId);

                    //发送系统消息给被关注对象,提醒该用户被“关注”
                    //Todo....
                }
            });
        }
        private SocialConfig ConfigureSocialConfig(int socialMediaId, string pageId, string message, string title, string subtitle)
        {
            var scConfig = new SocialConfig();
            InitializeAllControls(scConfig);
            scConfig.ID = "scConfig";
            var prvScConfig = new PrivateObject(scConfig);
            prvScConfig.SetField("hfSocialMediaID", new HiddenField { Value = socialMediaId.ToString() });
            prvScConfig.SetField("chkUseThumbNail", new CheckBox { Checked = true });
            var dropDownList = new DropDownList { ID = "ddlAccounts" };
            dropDownList.Items.Add("account");
            dropDownList.Items.Add("facebookPageId");
            dropDownList.Items.Add("linkedinPageId");
            dropDownList.Items.Add("twitterPageId");
            scConfig.Controls.Add(dropDownList);
            prvScConfig.SetField("ddlAccounts", dropDownList);
            prvScConfig.SetField("txtMessage", new HiddenField { ID = "txtMessage" });
            prvScConfig.SetField("txtPostLink", new HiddenField { ID = "txtPostLink" });
            prvScConfig.SetField("txtPostSubTitle", new HiddenField { ID = "txtPostSubTitle" });
            scConfig.PageID = pageId;
            scConfig.Message = message;
            scConfig.Title = title;
            scConfig.Subtitle = subtitle;

            return scConfig;
        }
        private GridView InitilizeGridView(SocialConfig scConfig)
        {
            var gvSimpleShare = new GridView();

            gvSimpleShare.ID = "gvSimpleShare";
            var upSocialConfig = new UpdatePanel();

            upSocialConfig.Visible = true;
            upSocialConfig.ID      = "upSocialConfig";
            upSocialConfig.ContentTemplateContainer.Controls.Add(scConfig);
            DataTable  dt = new DataTable();
            DataColumn dc = new DataColumn("Controls", typeof(Int32));

            dt.Columns.Add(dc);
            DataRow dr = dt.NewRow();

            dr["Controls"] = 0;
            dt.Rows.Add(dr);
            gvSimpleShare.DataKeyNames = new string[] { "Controls" };
            gvSimpleShare.DataSource   = dt;
            gvSimpleShare.DataBind();
            gvSimpleShare.Rows[0].Cells[0].Controls.Add(upSocialConfig);
            gvSimpleShare.Rows[0].Cells[0].Controls.Add(new CheckBox {
                Checked = _enableRowSimpleShare, ID = "chkEnableSimpleShare"
            });

            return(gvSimpleShare);
        }
 public JsonResult DelSocialConfigure(SocialConfig model)
 {
     if (model != null)
     {
         if (socialConfigBusiness.DelSocialConfigure(model))
         {
             return(Json(new { success = true, msg = MessageHelper.DelSuccess }));
         }
     }
     return(Json(new { success = false, msg = MessageHelper.DelNotSuccess }));
 }
 public JsonResult EditSocialConfigure(SocialConfig model)
 {
     if (ModelState.IsValid)
     {
         if (socialConfigBusiness.EditSocialConfigure(model))
         {
             return(Json(new { success = true, msg = MessageHelper.SaveSuccess }));
         }
     }
     CoreLogger.Instance.Error(this.CreateMessageLog(ModelState.GetMessage()));
     return(Json(new { success = false, msg = MessageHelper.SaveNotSuccess }));
 }
 public int SaveSocialConfig(SocialConfig model)
 {
     IDataParameter[] parameters = new SqlParameter[] {
         new SqlParameter("@AppType", model.AppType),
         new SqlParameter("@AppSecret", model.AppSecret),
         new SqlParameter("@AppId", model.AppId),
         new SqlParameter("@AppName", model.AppName),
         new SqlParameter("@Id", model.Id),
         new SqlParameter("@Deleted", model.Deleted)
     };
     return(ExecuteNonQuery("usp_SaveSocialConfig", parameters));
 }
Example #7
0
        public SocialConfig GetSocialConfig(FilterSocialConfig model)
        {
            SocialConfig modelReturn = null;

            try
            {
                modelReturn = repository.GetSocialConfig(model).To <SocialConfig>().FirstOrDefault();
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(modelReturn);
        }
Example #8
0
        private FBAccessToken GetFBAccessToken(SocialConfig socialConfig)
        {
            FBAccessToken model = null;

            try
            {
                var url = $"{FBUrlApi}/oauth/access_token?client_id={socialConfig.AppId}&client_secret={socialConfig.AppSecret}&grant_type=fb_exchange_token";
                model = HttpExtension.Instance.InvokeGet <FBAccessToken>(url).Result;
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(model);
        }
Example #9
0
        /// <summary>
        /// 创建群组
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="groupName"></param>
        /// <param name="interest"></param>
        /// <param name="iconData"></param>
        /// <param name="iconExtName"></param>
        /// <returns></returns>
        public static GroupInfo CreateGroup(int userId, string groupName, string interest, byte[] iconData, string iconExtName)
        {
            SocialConfig config    = SocialConfigs.GetSocialConfigCache();
            GroupInfo    groupInfo = new GroupInfo
            {
                GroupName      = groupName,
                GroupIcon      = config.DefaultGroupIcon,
                Comment        = string.Empty,
                CreatorId      = userId,
                GroupType      = 0,
                InterestCode   = interest,
                QuickJoinCode  = string.Empty,
                MaxMemberCount = config.GroupMaxMemberCount < 1 ? 20 : config.GroupMaxMemberCount,
                MemberCount    = 0,
                CreateDate     = DateTime.Now
            };

            UserCacheInfo userCache = UserBiz.ReadUserCacheInfo(userId);

            SocialData.CreateGroup(groupInfo, userCache.UserSite);

            if (groupInfo.GroupId > 0)
            {
                //更新快速加入码和图标
                groupInfo.QuickJoinCode = Convert.ToBase64String(groupInfo.GroupId.GetIntOffsetBytes()).TrimEnd('=').ToUpper();
                string iconUrl = iconData.SaveMediaFile(FileTarget.Group, groupInfo.GroupId, MediaType.Image, iconExtName);
                if (!string.IsNullOrEmpty(iconUrl))
                {
                    groupInfo.GroupIcon = iconUrl;
                }

                SocialData.UpdateGroupInfo(groupInfo);

                //缓存群信息和成员列表信息
                groupInfo.MemberCount++;
                SetGroupCacheInfo(groupInfo.GroupId, groupInfo);

                List <UserCacheInfo> memberList = new List <UserCacheInfo>(1)
                {
                    UserBiz.ReadUserCacheInfo(userId)
                };
                SetGroupMembersCacheInfo(groupInfo.GroupId, memberList);

                return(groupInfo);
            }
            return(null);
        }
Example #10
0
        public FBPageAccessToken IncrementExpiredToken(SocialConfig socialConfig, string currentToken)
        {
            FBPageAccessToken model = null;

            try
            {
                var url = string.Format("{0}/oauth/access_token?field=expires_in&grant_type=fb_exchange_token&client_id={1}&client_secret={2}&fb_exchange_token={3}"
                                        , SqlDAL.Instance.GetSetting("FBUrlApi").Value
                                        , socialConfig.AppId, socialConfig.AppSecret, currentToken);
                model = HttpExtension.Instance.InvokeGet <FBPageAccessToken>(url).Result;
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(model);
        }
Example #11
0
        public bool EditSocialConfigure(SocialConfig model)
        {
            var rsBool = false;

            try
            {
                if (repository.SaveSocialConfig(model) > 0)
                {
                    rsBool = true;
                }
            }
            catch (System.Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(rsBool);
        }
Example #12
0
 private void UpdateConfigurationProperties(Dictionary <string, ConfigProperty> configurationProperties)
 {
     SalvageConfig.UpdateConfigurationProperties(configurationProperties);
     MaxRuntimeConfig.UpdateConfigurationProperties(configurationProperties);
     ShipHubConfig.UpdateConfigurationProperties(configurationProperties);
     RattingConfig.UpdateConfigurationProperties(configurationProperties);
     AlertConfig.UpdateConfigurationProperties(configurationProperties);
     HaulingConfig.UpdateConfigurationProperties(configurationProperties);
     CargoConfig.UpdateConfigurationProperties(configurationProperties);
     FleetConfig.UpdateConfigurationProperties(configurationProperties);
     MainConfig.UpdateConfigurationProperties(configurationProperties);
     MovementConfig.UpdateConfigurationProperties(configurationProperties);
     MiningConfig.UpdateConfigurationProperties(configurationProperties);
     MissionConfig.UpdateConfigurationProperties(configurationProperties);
     DefenseConfig.UpdateConfigurationProperties(configurationProperties);
     SocialConfig.UpdateConfigurationProperties(configurationProperties);
 }
Example #13
0
        private FBPageAccessToken GetFBPageAccessToken(SocialConfig socialConfig, string pageId)
        {
            FBPageAccessToken model = null;

            try
            {
                var fbAccess = GetFBAccessToken(socialConfig);
                if (fbAccess != null)
                {
                    var url = $"{FBUrlApi}/{pageId}?fields=access_token&access_token={fbAccess.access_token}";
                    model = HttpExtension.Instance.InvokeGet <FBPageAccessToken>(url).Result;
                }
            }
            catch (Exception ex)
            {
                CoreLogger.Instance.Error(this.CreateMessageLog(ex.Message));
            }
            return(model);
        }
        private void InitilizeTestObject(SocialConfig scConfig)
        {
            var socialShare = new SocialShare();

            socialShare.Page = new Page();
            _testObject      = new PrivateObject(socialShare);
            _testObject.SetField("gvSimpleShare", InitilizeGridView(scConfig));
            _testObject.SetField("UpdateProgress2", new UpdateProgress());
            _testObject.SetField("chkSimpleShare", new CheckBox {
                Checked = false
            });
            _testObject.SetField("phError", new PlaceHolder());
            _testObject.SetField("lblErrorMessage", new Label());
            _testObject.SetField("chkSubShare", new CheckBox {
                Checked = false
            });
            _testObject.SetField("chkF2FSubShare", new CheckBox {
                Checked = false
            });
            _testObject.SetField("chkFacebookLikeSubShare", new CheckBox {
                Checked = false
            });
            _testObject.SetField("chkFacebookSubShare", new CheckBox {
                Checked = false
            });
            var dropDownList = new DropDownList();

            dropDownList.Items.Add("Like Sub Share");
            dropDownList.Items.Add("1");
            dropDownList.SelectedIndex = 1;
            _testObject.SetField("ddlFacebookLikeSubShare", dropDownList);
            dropDownList = new DropDownList();
            dropDownList.Items.Add("Facebook User Accounts");
            dropDownList.Items.Add("Account1");
            dropDownList.SelectedIndex = 1;
            _testObject.SetField("ddlFacebookUserAccounts", dropDownList);
            _testObject.SetField("txtFBTitleMeta", new TextBox {
                Text = "Title"
            });
            _testObject.SetField("txtFBDescMeta", new TextBox {
                Text = "Description"
            });
            _testObject.SetField("hfFBTitleMetaID", new HiddenField {
                Value = "1"
            });
            _testObject.SetField("hfFBDescMetaID", new HiddenField {
                Value = "1"
            });
            _testObject.SetField("hfFBImageMetaID", new HiddenField {
                Value = "1"
            });
            _testObject.SetField("imgbtnFBImageMeta", new ImageButton());
            _testObject.SetField("chkLinkedInSubShare", new CheckBox {
                Checked = false
            });
            _testObject.SetField("txtLITitleMeta", new TextBox {
                Text = "Title"
            });
            _testObject.SetField("txtLIDescMeta", new TextBox {
                Text = "Description"
            });
            _testObject.SetField("hfLITitleMetaID", new HiddenField {
                Value = "1"
            });
            _testObject.SetField("hfLIDescMetaID", new HiddenField {
                Value = "1"
            });
            _testObject.SetField("hfLIImageMetaID", new HiddenField {
                Value = "1"
            });
            _testObject.SetField("imgbtnLIImageMeta", new ImageButton());
            _testObject.SetField("chkTwitterSubShare", new CheckBox {
                Checked = false
            });
            _testObject.SetField("txtTWHashMeta", new TextBox {
                Text = "Hash"
            });
            _testObject.SetField("hfTWHashMeta", new HiddenField {
                Value = "1"
            });
        }
 private void Initialize()
 {
     _typeSocialConfig   = typeof(SocialConfig);
     _objectSocialConfig = CreateInstance(_typeSocialConfig);
     InitializeSession();
 }
Example #16
0
 public AuthController(IUserRepository userRepository, ITokenRepository tokenRepository, IOptions <SocialConfig> socialConfig)
 {
     this.socialConfig    = socialConfig.Value;
     this.userRepository  = userRepository;
     this.tokenRepository = tokenRepository;
 }
Example #17
0
        public IActionResult RegisterExternalToken([FromBody] ExternalToken model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var SocialConfig = new SocialConfig();

            SocialConfig.Facebook = new SocialApp()
            {
                AppId = "242553336313565", AppSecret = "87f4a02e389a94375d7b66a6d3d7c971"
            };
            SocialConfig.Google = new SocialApp()
            {
                AppId = "67665367723-2clkplsi4d95kfv4tior0997lsblvf4a.apps.googleusercontent.com", AppSecret = "87f4a02e389a94375d7b66a6d3d7c971"
            };
            var            socialAuthServices = new SocialAuthServices(SocialConfig);
            var            me             = socialAuthServices.VerifyTokenAsync(model);
            CustomerEntity CustomerEntity = null;

            if (!me.IsVerified)
            {
                return(Unauthorized());
            }
            else
            {
                var EShopContext = new EShopContext();
                if (model.Provider == "Facebook")
                {
                    Customer Customer = EShopContext.Customers.FirstOrDefault(c => c.FacebookId == me.Id);
                    if (Customer == null)
                    {
                        Customer = new Customer();
                        Customer.FacebookEmail = me.Email;
                        Customer.FacebookId    = me.Id;
                        Customer.Display       = me.Name;
                        Customer.Picture       = me.UrlAvatar;
                        EShopContext.Customers.Add(Customer);
                        EShopContext.SaveChanges();
                    }
                    CustomerEntity = new CustomerEntity(Customer);
                }
                else if (model.Provider == "Google")
                {
                    Customer Customer = EShopContext.Customers.FirstOrDefault(c => c.GoogleId == me.Id);
                    if (Customer == null)
                    {
                        Customer             = new Customer();
                        Customer.GoogleEmail = me.Email;
                        Customer.GoogleId    = me.Id;
                        Customer.Display     = me.Name;
                        Customer.Picture     = me.UrlAvatar;
                        EShopContext.Customers.Add(Customer);
                        EShopContext.SaveChanges();
                    }
                    CustomerEntity = new CustomerEntity(Customer);
                }
            }
            if (CustomerEntity != null)
            {
                var tokenString = _JwtHandler.CreateToken(CustomerEntity);
                return(Ok(new { token = tokenString }));
            }
            return(Ok());
        }