コード例 #1
0
ファイル: WXLogin.cs プロジェクト: zhaoy615/Guizhoule
        /// <summary>
        /// 判断登陆用户信息(如无则添加)
        /// </summary>
        /// <param name="md"></param>
        /// <returns></returns>
        public mjuserinfo AddUser(mjuserinfo md, GameSession session)
        {
            int           returnid = 0;
            mjuserinfoDAL dal      = new mjuserinfoDAL();
            mjuserinfo    model    = dal.GetModel(md.openid);
            login_logDAL  Ldal     = new login_logDAL();
            login_log     Lmodel   = new login_log();



            if (model == null)
            {
                try
                {
                    returnid   = dal.GetMaxID() + 1;
                    md.id      = returnid;
                    md.addtime = DateTime.Now;
                    string fileName = string.Empty;
                    string imgurl   = PictureUtility.SavePicture(md.headimg, out fileName); //将图片保存至本地返回详细路径和文件名
                    if (!string.IsNullOrEmpty(imgurl))                                      //验证是否保存成功
                    {
                        md.headimg = PutObjectSample.PutObjectFromFile(imgurl, fileName);
                    }
                    dal.Add(md);
                    Lmodel.id          = Ldal.GetMaxID() + 1;
                    Lmodel.login_state = 1;
                    Lmodel.login_time  = DateTime.Now;
                    Lmodel.openid      = md.openid;
                    Ldal.Add(Lmodel);
                }
                catch (Exception ex)
                {
                    session.Logger.Error(ex);
                }



                return(md);
            }
            else
            {
                try
                {
                    Lmodel.id          = Ldal.GetMaxID() + 1;
                    Lmodel.login_state = 1;
                    Lmodel.login_time  = DateTime.Now;
                    Lmodel.openid      = md.openid;
                    Ldal.Add(Lmodel);
                }
                catch (Exception)
                {
                    throw;
                }

                return(model);
            }
        }
コード例 #2
0
ファイル: PlayerInfoView.cs プロジェクト: rerwr/test
        /// <summary>
        /// 传上服务器并且删除本地
        /// </summary>
        /// <returns></returns>
        IEnumerator wait2LoadIcon()
        {
            yield return(0.3f);

            var a = NewPlayerCreateController.Instance;

            byte[] t2d = headIcon.sprite.texture.EncodeToPNG();
            //上传
            PutObjectSample.PutObjectFromString(GetUIDPath(LoginModel.Instance.Uid), t2d);
            //请求改变头像
            a.CreateNewUserReq(name.text, int.Parse(LoginModel.Instance.Sex), GetUIDPath(LoginModel.Instance.Uid));
            //删除本地头像,防止asyncimage认为本地还有
            GlobalDispatcher.Instance.Dispatch(GlobalEvent.onPlayerPanelReflash);

            ViewMgr.Instance.Close(ViewNames.PlayerInfoView);
        }