Beispiel #1
0
        public UserWindow(GetUserInfoResponse userInfo)
        {
            this.InitializeComponent();


            IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;// 获得窗体的 样式

            int oldstyle = MedSys.PresentationCore.AdjustWindow.NativeMethods.GetWindowLong(hwnd, MedSys.PresentationCore.AdjustWindow.NativeMethods.GWL_STYLE);

            MedSys.PresentationCore.AdjustWindow.NativeMethods.SetWindowLong(hwnd, MedSys.PresentationCore.AdjustWindow.NativeMethods.GWL_STYLE, oldstyle & ~MedSys.PresentationCore.AdjustWindow.NativeMethods.WS_CAPTION);
            MedSys.PresentationCore.AdjustWindow.NativeMethods.SetLayeredWindowAttributes(hwnd, 1 | 2 << 8 | 3 << 16, 0, MedSys.PresentationCore.AdjustWindow.NativeMethods.LWA_ALPHA);

            this.RefreshRoundWindowRect();
            this.Loaded      += new RoutedEventHandler(MainWindow_Loaded);
            this.SizeChanged += MainWindow_SizeChanged;
            //this.Width = SystemParameters.WorkArea.Width;
            //this.Height = SystemParameters.WorkArea.Height;


            headBorder.MouseDown += headBorder_MouseDown;

            this._userInfo = userInfo;
            LoadUserInfo();
            loadCertificateImage();
            loadAllData();
            GetCertificateApproveStatus();
        }
Beispiel #2
0
        public static GetUserInfoResponse Unmarshall(UnmarshallerContext context)
        {
            GetUserInfoResponse getUserInfoResponse = new GetUserInfoResponse();

            getUserInfoResponse.HttpResponse = context.HttpResponse;
            getUserInfoResponse.RequestId    = context.StringValue("GetUserInfo.RequestId");
            getUserInfoResponse.Code         = context.StringValue("GetUserInfo.Code");
            getUserInfoResponse.Message      = context.StringValue("GetUserInfo.Message");

            GetUserInfoResponse.GetUserInfo_LoginResult loginResult = new GetUserInfoResponse.GetUserInfo_LoginResult();
            loginResult.LmUserId    = context.LongValue("GetUserInfo.LoginResult.LmUserId");
            loginResult.BizId       = context.StringValue("GetUserInfo.LoginResult.BizId");
            loginResult.BizUid      = context.StringValue("GetUserInfo.LoginResult.BizUid");
            loginResult.BizUserName = context.StringValue("GetUserInfo.LoginResult.BizUserName");
            loginResult.ReturnUrl   = context.StringValue("GetUserInfo.LoginResult.ReturnUrl");
            loginResult.ExtInfo     = context.StringValue("GetUserInfo.LoginResult.ExtInfo");

            List <string> loginResult_subBizId = new List <string>();

            for (int i = 0; i < context.Length("GetUserInfo.LoginResult.SubBizId.Length"); i++)
            {
                loginResult_subBizId.Add(context.StringValue("GetUserInfo.LoginResult.SubBizId[" + i + "]"));
            }
            loginResult.SubBizId            = loginResult_subBizId;
            getUserInfoResponse.LoginResult = loginResult;

            return(getUserInfoResponse);
        }
        /// <summary>
        /// Handles the SignInButtonClick event of the SignInPage control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private async void SignInPage_SignInButtonClick(Object sender,
                                                        EventArgs e)
        {
            // TODO: Move from here
            String clientId     = "golfhandicap.mobile";
            String clientSecret = "golfhandicap.mobile";

            // Get a token
            String token = await this.SecurityServiceClient.GetPasswordToken(clientId,
                                                                             clientSecret,
                                                                             this.SignInViewModel.EmailAddress,
                                                                             this.SignInViewModel.Password,
                                                                             CancellationToken.None);

            // Store the token
            App.AccessToken = token;

            // Get the users information
            GetUserInfoResponse userInformation = await this.SecurityServiceClient.GetUserInfo(token, CancellationToken.None);

            // TODO: Navigate to the next page (based on user type)
            if (userInformation.RoleName == RoleNames.Player)
            {
                // Store the player id claim
                App.PlayerId = Guid.Parse(userInformation.PlayerId);

                this.Device.SetInstabugUserDetails(userInformation.UserName, userInformation.EmailAddress);

                // Go to signed in page
                Application.Current.MainPage = new AppShell();
            }
        }
        private void LoadUserInfo()
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                LungCare.SupportPlatform.WebAPIWorkers.RetrieveUserInfoWorker.SendUserInfoRequest(
                    successCallback : delegate(LungCare.SupportPlatform.Models.GetUserInfoResponse response)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        _userInfo = response;

                        GetCertificateApproveStatus();
                    }));
                },
                    failureCallback : delegate(string failureReason)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        ResumeGUI();
                        MessageBox.Show(failureReason);
                    }));
                },
                    errorCallback : delegate(Exception ex)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        ResumeGUI();
                        LungCare.SupportPlatform.WebAPIWorkers.Util.ShowExceptionMessage(ex, "获取用户信息出错。");
                    }));
                });
            });
        }
Beispiel #5
0
        public static GetUserInfoResponse Unmarshall(UnmarshallerContext context)
        {
            GetUserInfoResponse getUserInfoResponse = new GetUserInfoResponse();

            getUserInfoResponse.HttpResponse = context.HttpResponse;
            getUserInfoResponse.Code         = context.IntegerValue("GetUserInfo.Code");
            getUserInfoResponse.Message      = context.StringValue("GetUserInfo.Message");
            getUserInfoResponse.RequestId    = context.StringValue("GetUserInfo.RequestId");

            GetUserInfoResponse.GetUserInfo_Data data = new GetUserInfoResponse.GetUserInfo_Data();
            data.Total = context.IntegerValue("GetUserInfo.Data.Total");

            List <GetUserInfoResponse.GetUserInfo_Data.GetUserInfo_Instance> data_detail = new List <GetUserInfoResponse.GetUserInfo_Data.GetUserInfo_Instance>();

            for (int i = 0; i < context.Length("GetUserInfo.Data.Detail.Length"); i++)
            {
                GetUserInfoResponse.GetUserInfo_Data.GetUserInfo_Instance instance = new GetUserInfoResponse.GetUserInfo_Data.GetUserInfo_Instance();
                instance.Project     = context.StringValue("GetUserInfo.Data.Detail[" + i + "].Project");
                instance.InstanceId  = context.StringValue("GetUserInfo.Data.Detail[" + i + "].InstanceId");
                instance.Status      = context.StringValue("GetUserInfo.Data.Detail[" + i + "].Status");
                instance.UserAccount = context.StringValue("GetUserInfo.Data.Detail[" + i + "].UserAccount");
                instance.NickName    = context.StringValue("GetUserInfo.Data.Detail[" + i + "].NickName");
                instance.Cluster     = context.StringValue("GetUserInfo.Data.Detail[" + i + "].Cluster");
                instance.RunTime     = context.StringValue("GetUserInfo.Data.Detail[" + i + "].RunTime");

                data_detail.Add(instance);
            }
            data.Detail = data_detail;
            getUserInfoResponse.Data = data;

            return(getUserInfoResponse);
        }
        /// <summary>
        /// Metoda pobiera z WebServisu informacje o użytkowniku, którego nie ma w Usłudze.
        /// </summary>
        /// <param name="guest">Parametr z którego pobierane są informacje, którego użytkownika dodać.</param>
        private async Task AddNewUser(SimpleBookingUser guest)
        {
            Logs.WriteErrorLog("AddNewUser");
            Logs.WriteErrorLog("guest.UserId: " + guest.UserId.ToString() + ", Booking title: " + guest.BookingTitle);

            GetUserInfoResponse userInfo = null;

            userInfo = await WebServiceConnection.SendGet <GetUserInfoResponse>("user/" + guest.UserId + "/info");

            if (userInfo == null)
            {
                Logs.WriteErrorLog("UserInfo zwrocilo null z WebSerwisu");
            }
            if (userInfo.Email == null)
            {
                Logs.WriteErrorLog("UserEmil zwrocil null");
            }
            var userNew = new User(userInfo.Email, guest.UserId);

            //userNew.UserId = guest.UserId;
            Logs.WriteErrorLog("UserNew.UserEmail: " + userNew.UserEmail + ", UserNew.UserId" + userNew.UserId);
            //Autoryzuj użytkownika, zakładając że jego token istnieje.
            userNew.Calendar.AuthorizeTask();
            if (userNew.Calendar.IsCalendarAuthorized == false)
            {
                return;
            }
            Logs.WriteErrorLog("uzytkownik " + userNew.UserEmail + " zostal zautoryzowany.");
            userNew.Calendar.Service.Events.QuickAdd("primary", "Testujemy poprawnosc autoryzacji").ExecuteAsync();

            _usersList.Add(userNew);
            Logs.WriteErrorLog("Pierwszy uzytkownik w kolejce to: " + _usersList.First().UserEmail);
        }
Beispiel #7
0
        public WeiXin.Domain.User GetUserInfo(string OpenID)
        {
            GetUserInfoResponse response = null;

            int retry = 0;

            do
            {
                IMpClient mpClient = new MpClient();

                GetUserInfoRequest request = new GetUserInfoRequest()
                {
                    AccessToken = this.GetAccessToken(),
                    OpenId      = OpenID,
                };

                response = mpClient.Execute(request);
                if (!RefreshAccessToken(response, request.AccessToken))
                {
                    break;
                }
                retry++;
            } while (retry < 2 && response.IsError);
            if (response.IsError)
            {
                LogHelper.WriteInfo("faild", "获取OpenID:" + OpenID + "基本信息失败。获取用户基本信息失败,错误信息为:" + response.ErrInfo.ErrCode + "-" + response.ErrInfo.ErrMsg);
                return(null);
            }
            else
            {
                LogHelper.WriteInfo("sucess", "获取OpenID:" + OpenID + "基本信息成功");
                return(response.UserInfo);
            }
        }
Beispiel #8
0
        public UserCertificateCheckWindow(GetUserInfoResponse userInfo)
        {
            this.InitializeComponent();
            IntPtr hwnd = new System.Windows.Interop.WindowInteropHelper(this).Handle;// 获得窗体的 样式

            int oldstyle = MedSys.PresentationCore.AdjustWindow.NativeMethods.GetWindowLong(hwnd, MedSys.PresentationCore.AdjustWindow.NativeMethods.GWL_STYLE);

            MedSys.PresentationCore.AdjustWindow.NativeMethods.SetWindowLong(hwnd, MedSys.PresentationCore.AdjustWindow.NativeMethods.GWL_STYLE, oldstyle & ~MedSys.PresentationCore.AdjustWindow.NativeMethods.WS_CAPTION);
            MedSys.PresentationCore.AdjustWindow.NativeMethods.SetLayeredWindowAttributes(hwnd, 1 | 2 << 8 | 3 << 16, 0, MedSys.PresentationCore.AdjustWindow.NativeMethods.LWA_ALPHA);

            this.RefreshRoundWindowRect();
            this.Loaded          += new RoutedEventHandler(MainWindow_Loaded);
            this.SizeChanged     += MainWindow_SizeChanged;
            headBorder.MouseDown += headBorder_MouseDown;
            _UserInfo             = userInfo;
            List <GetUserInfoResponse> list = new List <GetUserInfoResponse>();

            list.Add(_UserInfo);

            listViewUser.DataContext =
                new System.ComponentModel.BindingList <LungCare.SupportPlatform.Models.GetUserInfoResponse>(list);
            //listView.DataContext = new System.ComponentModel.BindingList<Models.DataListItem>(dataSource);
            listViewUser.SetBinding(System.Windows.Controls.ListView.ItemsSourceProperty, new System.Windows.Data.Binding());

            loadCertifyImage();
            GetCertificateApproveStatus();
        }
        public static GetUserInfoResponse Unmarshall(UnmarshallerContext context)
        {
            GetUserInfoResponse getUserInfoResponse = new GetUserInfoResponse();

            getUserInfoResponse.HttpResponse = context.HttpResponse;

            return(getUserInfoResponse);
        }
 private void GetWaitingApproveUser()
 {
     ThreadPool.QueueUserWorkItem(delegate
     {
         GetCertiWaitingApprovedUserNamesWorker.SendGetCertiWaitingApprovedUserNamesRequest(
             successCallback : delegate(GetCertiWaitingApprovedUserNamesResponse response)
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 if (response.UserNameList != null)
                 {
                     _waitingApproveUserNameList = response.UserNameList;
                     if (_oldWaitingApproveUserNameList == null)
                     {
                         _oldWaitingApproveUserNameList = response.UserNameList;
                     }
                     if (_oldWaitingApproveUserNameList.Count < response.UserNameList.Count)
                     {
                         Console.WriteLine("new user");
                         string newUserID = response.UserNameList[response.UserNameList.Count - 1];
                         if (_AllUserInfoList != null)
                         {
                             GetUserInfoResponse newUser = _AllUserInfoList.FirstOrDefault(item => item.PhoneNumber == newUserID);
                             if (newUser != null)
                             {
                                 string emailSubject = "用户审核通知";
                                 string emailBody    = "您收到用户 " + newUser.ChineseName + "(手机号 " + newUser.PhoneNumber + " ) 提交资格证书审核,请查阅 【朗开医疗】";;
                                 SendNotificateEmail(emailSubject, emailBody);
                                 SendPhoneMessage(emailBody);
                             }
                         }
                         _oldWaitingApproveUserNameList = response.UserNameList;
                     }
                 }
                 getAllUserInfo();
             }));
         },
             failureCallback : delegate(string failureReason)
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 getAllUserInfo();
                 //MessageBox.Show("获取用户列表。" + failureReason, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
             }));
         },
             errorCallback : delegate(Exception ex)
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 getAllUserInfo();
                 Util.ShowExceptionMessage(ex, "获取用户列表出错。");
             }));
         }
             );
     });
 }
        public override async Task <GetUserInfoResponse> GetUserInfo(GetUserInfoRequest request, ServerCallContext context)
        {
            var user = new GetUserInfoResponse
            {
                Id      = request.Id,
                Name    = "张小明",
                Phone   = "17621499260",
                Address = "上海市虹口区"
            };

            return(await Task.FromResult(user));
        }
Beispiel #12
0
        public ResultJson <GetUserInfoResponse> MailRegister(MailRegisterRequest request)
        {
            ResultJson <GetUserInfoResponse> result = new ResultJson <GetUserInfoResponse>();
            Customer customer1 = new Customer();

            customer1.phone = request.Phone;
            var users = CustomerOper.Instance.Select(customer1);

            if (users.Count != 0)
            {
                result.HttpCode = 300;
                result.Message  = "用户已注册";
            }
            else
            {
                var verification = CacheForModelUser.Instance.GetUserVerificationCode(request.Phone);
                if (verification == null)
                {
                    result.HttpCode = 500;
                    result.Message  = "请重新发送验证码";
                }
                else
                {
                    if (request.Code == verification)
                    {
                        Customer customer = new Customer();
                        customer.phone    = request.Phone;
                        customer.password = request.PassWord;
                        if (CustomerOper.Instance.Insert(customer))
                        {
                            CacheForModelUser.Instance.ClearUserVerificationCode(request.Phone);
                            var user = CacheForModelUser.Instance.GetUserInfoByPassWord(request.Phone, request.PassWord);
                            GetUserInfoResponse response = new GetUserInfoResponse(user, Request.Headers.Host);
                            result.HttpCode = 200;
                            result.Message  = "注册成功";
                            result.ListData.Add(response);
                        }
                        else
                        {
                            result.HttpCode = 300;
                            result.Message  = "注册失败";
                        }
                    }
                    else
                    {
                        result.HttpCode = 400;
                        result.Message  = "验证码错误";
                    }
                }
            }
            return(result);
        }
Beispiel #13
0
        /// <summary>
        /// 获取用户基本信息
        /// </summary>
        /// <param name="OpenID"></param>
        /// <returns></returns>
        public static User GetWxUser(string OpenID)
        {
            IMpClient          mpClient = new MpClient();
            GetUserInfoRequest request  = new GetUserInfoRequest()
            {
                AppIdInfo = new DefAppIdInfo(), AccessToken = WxAccToken.AccessTokenStr, OpenId = OpenID
            };
            GetUserInfoResponse response = mpClient.Execute(request);

            if (response.IsError)
            {
                Logger.WriteTxtLog(string.Format("获取USER发生错误,错误编码为:{0},错误消息为:{1}", response.ErrInfo.ErrCode, response.ErrInfo.ErrMsg));
                return(null);
            }
            return(response.UserInfo);
        }
        public void LoadPage(int currentPage, int pageSize, GetUserInfoResponse[] _alluser, int maxPage)
        {
            Array.Sort(_alluser, (t1, t2) => DateTime.Parse(t2.RegistrationTimeStamp).CompareTo(DateTime.Parse(t1.RegistrationTimeStamp)));
            label_totalNumber.Content = "用户总数:" + _alluser.Length;
            string now = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            label_lastRefreshTime.Content = "最后刷新的时间是:" + now;
            label_Pages.Content           = "第" + (currentPage + 1) + "页  共" + (maxPage + 1) + "页";
            if (currentPage < maxPage)
            {
                GetUserInfoResponse[] _CurrentPageuserList = new GetUserInfoResponse[pageSize];
                for (int i = 0; i < pageSize; i++)
                {
                    _CurrentPageuserList[i] = _alluser[currentPage * pageSize + i];
                }
                listView.DataContext = null;
                listView.DataContext = new System.ComponentModel.BindingList <GetUserInfoResponse>(_CurrentPageuserList);
                listView.SetBinding(System.Windows.Controls.ListView.ItemsSourceProperty, new System.Windows.Data.Binding());
            }
            if (currentPage == maxPage)
            {
                if (_alluser.Count() % pageSize != 0)
                {
                    GetUserInfoResponse[] _CurrentPageuserList = new GetUserInfoResponse[_alluser.Count() % pageSize];
                    for (int i = 0; i < _alluser.Count() % pageSize; i++)
                    {
                        _CurrentPageuserList[i] = _alluser[currentPage * pageSize + i];
                    }
                    listView.DataContext = null;
                    listView.DataContext = new System.ComponentModel.BindingList <GetUserInfoResponse>(_CurrentPageuserList);
                    listView.SetBinding(System.Windows.Controls.ListView.ItemsSourceProperty, new System.Windows.Data.Binding());
                }
                if (_alluser.Count() % pageSize == 0)
                {
                    GetUserInfoResponse[] _CurrentPageuserList = new GetUserInfoResponse[pageSize];
                    for (int i = 0; i < pageSize; i++)
                    {
                        _CurrentPageuserList[i] = _alluser[currentPage * pageSize + i];
                    }
                    listView.DataContext = null;
                    listView.DataContext = new System.ComponentModel.BindingList <GetUserInfoResponse>(_CurrentPageuserList);
                    listView.SetBinding(System.Windows.Controls.ListView.ItemsSourceProperty, new System.Windows.Data.Binding());
                }
            }
        }
Beispiel #15
0
        public ResultJson <GetUserInfoResponse> GetUserBodyInfo(GetInfoByOtherIdRequest request)
        {
            ResultJson <GetUserInfoResponse> result = new ResultJson <GetUserInfoResponse>();
            ////重置用户信息
            //CacheForModelUser.Instance.GetUserInfo(request.id);
            Customer user = CacheForModelUser.Instance.GetUserInfo(request.UserId);

            if (user == null)
            {
                result.HttpCode = 300;
                result.Message  = "此用户不存在";
                return(result);
            }
            GetUserInfoResponse response = new GetUserInfoResponse(user, Request.Headers.Host);

            result.HttpCode = 200;
            result.ListData.Add(response);
            return(result);
        }
Beispiel #16
0
        public override Task <GetUserInfoResponse> GetUserInfo(GetUserInfoRequest request, ServerCallContext context)
        {
            var resp        = new GetUserInfoResponse();
            var accessToken = _redis.StringGet(CacheKey.UserAccessTokenPrefix + request.AppId);

            if (accessToken.HasValue)
            {
                var data = WxWebApi.GetUserInfo(accessToken, request.OpenId);
                if (data.ErrCode == 0)
                {
                    resp.SubscribeTime = data.Subscribe == 1 ? data.SubscribeTime : 0;
                    resp.OpenId        = data.OpenId;
                    if (resp.SubscribeTime != 0)
                    {
                        resp.NickName = data.NickName;
                        resp.Sex      = data.Sex;
                        resp.City     = data.City;
                        resp.Province = data.Province;
                        resp.Country  = data.Country;
                        resp.Photo    = data.HeadImgUrl;
                        resp.UnionId  = data.UnionId;
                    }
                }
                else
                {
                    resp.Error = new Error
                    {
                        ErrCode = data.ErrCode,
                        ErrMsg  = data.ErrMsg
                    };
                }
            }
            else
            {
                resp.Error = new Error
                {
                    ErrCode = 99999,
                    ErrMsg  = "AccessToken Missing"
                };
            }
            return(Task.FromResult(resp));
        }
Beispiel #17
0
        public static GetUserInfoResponse Unmarshall(UnmarshallerContext _ctx)
        {
            GetUserInfoResponse getUserInfoResponse = new GetUserInfoResponse();

            getUserInfoResponse.HttpResponse = _ctx.HttpResponse;
            getUserInfoResponse.RequestId    = _ctx.StringValue("GetUserInfo.RequestId");
            getUserInfoResponse.ErrorCode    = _ctx.StringValue("GetUserInfo.ErrorCode");
            getUserInfoResponse.Success      = _ctx.BooleanValue("GetUserInfo.Success");
            getUserInfoResponse.ErrorMessage = _ctx.StringValue("GetUserInfo.ErrorMessage");

            GetUserInfoResponse.GetUserInfo_Result result = new GetUserInfoResponse.GetUserInfo_Result();
            result.Id                  = _ctx.LongValue("GetUserInfo.Result.Id");
            result.ExternalUserId      = _ctx.StringValue("GetUserInfo.Result.ExternalUserId");
            result.Username            = _ctx.StringValue("GetUserInfo.Result.Username");
            result.Name                = _ctx.StringValue("GetUserInfo.Result.Name");
            result.Email               = _ctx.StringValue("GetUserInfo.Result.Email");
            result.AvatarUrl           = _ctx.StringValue("GetUserInfo.Result.AvatarUrl");
            getUserInfoResponse.Result = result;

            return(getUserInfoResponse);
        }
        public GetUserInfoResponse GetUserInfo(GetUserInfoRequest request)
        {
            var response = new GetUserInfoResponse()
            {
                ResponseToken = Guid.NewGuid(),
                Request       = request
            };

            try
            {
                response.User    = _repository.FindBy(request.UserId).MapToView();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = GenericErrorMessageFactory.GeneralError;
            }

            return(response);
        }
        public void process(ServiceRequest request, ServiceResponse response)
        {
            if (request == null || request.requestObj == null)
            {
                response.errMessage = ReportServiceMessage.REQUEST_INVALID;
                response.returnCode = -1;
                return;
            }

            GetUserInfoRequest serviceRequest = (GetUserInfoRequest)request.requestObj;

            if (serviceRequest.userId < 0)
            {
                response.errMessage = ReportServiceMessage.USER_ID_ILLEGAL;
                response.returnCode = -1;
                return;
            }

            GetUserInfoResponse serviceResponse = new GetUserInfoResponse();
            response.responseObj = serviceResponse;
            response.returnCode = 0;

        }
Beispiel #20
0
        public ResultJson <GetUserInfoResponse> SetUserBodyInfo(SetUserBodyInfoRequest request)
        {
            ResultJson <GetUserInfoResponse> result = new ResultJson <GetUserInfoResponse>();
            Customer user = CacheForModelUser.Instance.GetUserInfo(request.UserId);

            if (user == null)
            {
                result.HttpCode = 301;
                result.Message  = Enum_Message.UserNotExitMessage.Enum_GetString();
                return(result);
            }
            user.sex             = request.UserSex.ParseBool();
            user.height          = request.UserHeight.GetValueOrDefault().ToString();
            user.weight          = request.UserWeight.GetValueOrDefault().ToString();
            user.birthday        = request.UserBirthTime.GetValueOrDefault();
            user.labourIntensity = request.labInten;
            user.HeadImage       = request.HeadImage;
            user.name            = request.UserName;
            var resultForUpDate = DbOpertion.DBoperation.CustomerOper.Instance.Update(user);

            if (resultForUpDate)
            {
                CacheForModelUser.Instance.SetUserInfo(request.UserId);
                var userInfo = CacheForModelUser.Instance.GetUserInfo(request.UserId);
                GetUserInfoResponse response = new GetUserInfoResponse(userInfo, Request.Headers.Host);
                result.HttpCode = 200;
                result.Message  = "修改成功";
                result.ListData.Add(response);
            }
            else
            {
                result.HttpCode = 500;
                result.Message  = "修改失败";
            }
            return(result);
        }
        public void Start()
        {
            Output("Starting SalienClient...");

            while (true)
            {
                GetUserInfoResponse UserInfo = GetUserInfo();
                if (UserInfo == null)
                {
                    Output(String.Format("Failed Getting UserInfo, retrying in {0} seconds...", SleepSeconds), ConsoleColor.Red);
                    Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                    continue;
                }

                // Leave our current game
                if (UserInfo.Active_Zone_Game != 0)
                {
                    Output("Leaving Active Zone...");
                    EResult LeaveGameResult = LeaveGame(UserInfo.Active_Zone_Game);
                    if (LeaveGameResult == EResult.OK)
                    {
                        Output("Left Active Zone!", ConsoleColor.Green);
                    }
                    else
                    {
                        Output(String.Format("Error Leaving Active Zone: {0}, retrying in {1} seconds...", LeaveGameResult.ToString(), SleepSeconds), ConsoleColor.Red);
                        Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                        continue;
                    }
                }

                // Leave our current planet
                if (UserInfo.Active_Planet != 0)
                {
                    Output("Leaving Active Planet...");
                    EResult LeavePlanetResult = LeaveGame(UserInfo.Active_Planet);
                    if (LeavePlanetResult == EResult.OK)
                    {
                        Output("Left Active Planet!", ConsoleColor.Green);
                    }
                    else
                    {
                        Output(String.Format("Error Leaving Active Planet: {0}, retrying in {1} seconds...", LeavePlanetResult.ToString(), SleepSeconds), ConsoleColor.Red);
                        Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                        continue;
                    }
                }

                // Search for a new game
                Output("Finding Planet and Zone to Join...");
                (Planet planet, Planet_Zone zone) = FindZone();
                if (zone == null)
                {
                    Output(String.Format("Failed to Find a Zone, retrying in {0} seconds...", SleepSeconds), ConsoleColor.Red);
                    Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                    continue;
                }

                if (zone.Type == 4)
                {
                    Output(String.Format("Found Boss Zone: {0} on Planet: {1} ({2})!", zone.Zone_Position, planet.ID, planet.State.Name), ConsoleColor.Blue);
                }
                else
                {
                    Output(String.Format("Found Zone: {0} with Difficulty: {1} on Planet: {2} ({3})!", zone.Zone_Position, zone.Difficulty, planet.ID, planet.State.Name), ConsoleColor.Green);
                }

                // Join Planet
                Output("Joining Planet...");
                EResult JoinPlanetResult = JoinPlanet(planet.ID);
                if (JoinPlanetResult == EResult.OK)
                {
                    Output("Joined Planet!", ConsoleColor.Green);
                }
                else
                {
                    Output(String.Format("Error Joining Planet: {0}, retrying in {1} seconds...", JoinPlanetResult.ToString(), SleepSeconds), ConsoleColor.Red);
                    Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                    continue;
                }

                while (true)
                {
                    // Join Zone
                    Output("Joining Zone...");

                    // Boss Zone
                    if (zone.Type == 4)
                    {
                        (EResult Result, bool WaitingForPlayers)JoinBossZoneResult = JoinBossZone(zone.Zone_Position);
                        if (JoinBossZoneResult.Result == EResult.OK)
                        {
                            Output("Joined Boss Zone!", ConsoleColor.Blue);
                        }
                        else
                        {
                            Output(String.Format("Error Joining Boss Zone: {0}, retrying in {1} seconds...", JoinBossZoneResult.Result.ToString(), SleepSeconds), ConsoleColor.Red);
                            Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                            break;
                        }

                        // Report Score
                        int  Heal              = 0;
                        int  Fails             = 0;
                        int  PreviousXPGained  = 0;
                        bool WaitingForPlayers = JoinBossZoneResult.WaitingForPlayers;
                        while (true)
                        {
                            (EResult Result, ReportBossDamageResponse Response) = ReportBossDamage(WaitingForPlayers, (Heal == 23));
                            if (Result == EResult.OK)
                            {
                                if (Response.Boss_Status == null)
                                {
                                    Output(String.Format("Waiting... Sleeping for {0} seconds...", SleepSeconds), ConsoleColor.Blue);
                                    Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                                    continue;
                                }
                                else
                                {
                                    WaitingForPlayers = Response.Waiting_For_Players;
                                }

                                if (WaitingForPlayers)
                                {
                                    Output(String.Format("Waiting for players... Sleeping for {0}", SleepSeconds), ConsoleColor.Blue);
                                    Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                                    continue;
                                }

                                string output = String.Format("Boss HP: {0} / {1}\t Lasers: {2}, Heals: {3}\t",
                                                              Response.Boss_Status.Boss_HP, Response.Boss_Status.Boss_Max_HP,
                                                              Response.Num_Laser_Uses, Response.Num_Team_Heals);

                                if (Response.Game_Over)
                                {
                                    output = "GAME OVER";
                                }

                                if (AccountID != 0)
                                {
                                    Boss_Player Player = Response.Boss_Status.Boss_Players.First(x => x.AccountID == AccountID);
                                    if (!Response.Game_Over)
                                    {
                                        output += String.Format("HP: {0} / {1}, Level: {2}, Score: {3} / {4}, XP Earned: {5}",
                                                                Player.HP, Player.Max_HP, Player.New_Level, Player.Score_On_Join + Player.XP_Earned, Player.Next_Level_Score, Player.XP_Earned);

                                        PreviousXPGained = Player.XP_Earned;
                                    }
                                    else
                                    {
                                        output += String.Format(", XP Gained: {0}, Bonus XP: {1}, Total XP: {2}",
                                                                PreviousXPGained, Player.XP_Earned - PreviousXPGained, Player.XP_Earned);
                                    }
                                }
                                Output(output, ConsoleColor.Blue);

                                if (Response.Game_Over)
                                {
                                    break;
                                }
                            }
                            else if (Result == EResult.InvalidState)
                            {
                                break;
                            }
                            else
                            {
                                Output(String.Format("Error Reporting Boss Damage: {0}, retrying in {1} seconds...", Result.ToString(), SleepSeconds), ConsoleColor.Red);
                                Fails++;
                                Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                            }

                            if (Fails > 5)
                            {
                                break;
                            }

                            Heal++;

                            if (Heal > 23)
                            {
                                Heal = 0;
                            }

                            Thread.Sleep(TimeSpan.FromSeconds(5));
                        }
                        break;
                    }
                    // Normal Zone
                    else
                    {
                        EResult JoinZoneResult = JoinZone(zone.Zone_Position);
                        if (JoinZoneResult == EResult.OK)
                        {
                            Output("Joined Zone!", ConsoleColor.Green);
                        }
                        else if (JoinZoneResult == EResult.Expired)
                        {
                            Output("The Zone we tried joining has been captured...", ConsoleColor.Yellow);
                            break;
                        }
                        else
                        {
                            Output(String.Format("Error Joining Zone: {0}, retrying in {1} seconds...", JoinZoneResult.ToString(), SleepSeconds), ConsoleColor.Red);
                            Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                            break;
                        }


                        // Wait (and check if a better zone was found)
                        Output("Sleeping for 110 seconds...");
                        for (int i = 1; i < 110; i++)
                        {
                            Thread.Sleep(TimeSpan.FromSeconds(1));
                            if (Program.NewZone != null)
                            {
                                if (zone.Difficulty < Program.NewZone.Difficulty || Program.NewZone.Type == 4)
                                {
                                    break;
                                }
                            }
                        }
                        if (Program.NewZone != null)
                        {
                            if (zone.Difficulty < Program.NewZone.Difficulty || Program.NewZone.Type == 4)
                            {
                                break;
                            }
                        }

                        // Report Score
                        (EResult Result, ReportScoreResponse Response) = ReportScore(300 << zone.Difficulty);
                        if (Result == EResult.OK)
                        {
                            Output(String.Format("Finished Zone for {0} XP... Current Level: {1}, Current Score: {2}, Next Level Score: {3}",
                                                 300 << zone.Difficulty, Response.New_Level, Response.New_Score, Response.Next_Level_Score), ConsoleColor.Magenta);
                        }
                        else if (Result == EResult.NoMatch)
                        {
                            Output("The Zone we just finished was captured before we could report our score...", ConsoleColor.Yellow);
                            break;
                        }
                        else
                        {
                            Output(String.Format("Error Reporting Score: {0}, retrying in {1} seconds...", Response.ToString(), SleepSeconds), ConsoleColor.Red);
                            Thread.Sleep(TimeSpan.FromSeconds(SleepSeconds));
                            break;
                        }
                    }
                }
            }
        }
Beispiel #22
0
        //接收信息
        private void ActiveMQ_Received(object sender, string e)
        {
            var package = JsonConvert.DeserializeObject <Package>(e);

            switch (package.Type)
            {
            case "Response":
            {
                switch (package.Method)
                {
                case nameof(RegisterUser):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(int)
                                });

                        RegisterUserResponse?.Invoke(this, data.Result);
                    }
                }
                break;

                case nameof(UserLogin):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(Tuple <int, List <User> >)
                                });

                        UserLoginResponse?.Invoke(this, data.Result);
                    }
                }
                break;

                case nameof(SearchFriends):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(Tuple <int, List <User> >)
                                });

                        FriendsSearchedResponse?.Invoke(this, data.Result.Item2);
                    }
                }
                break;

                case nameof(AddFriend):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(Tuple <int, User, User>)
                                });

                        AddFriendResponse?.Invoke(this, data.Result);
                    }
                }
                break;

                case nameof(GetMyFriends):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(Tuple <int, List <User> >)
                                });

                        GetMyFriendsResponse?.Invoke(this, data.Result);
                    }
                }
                break;

                case nameof(GetUserInfo):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(Tuple <int, User>)
                                });

                        GetUserInfoResponse?.Invoke(this, data.Result);
                    }
                }
                break;

                case nameof(UpdateUserInfo):
                {
                    if (Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result = default(Tuple <int>)
                                });

                        UpdateUserInfoResponse?.Invoke(this, data.Result);
                    }
                }
                break;

                default:
                    break;
                }
            }
            break;

            case "Notice":
            {
                switch (package.Method)
                {
                case "AddFriend":
                {
                    var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                            {
                                Result = default(Tuple <int, User, User>)
                            });

                    FriendAddedNotice?.Invoke(this, data.Result);
                }
                break;

                //好友登录广播地址
                case "FriendLoginNotice":
                {
                    if (!Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Username = default(string),
                                    Address  = default(string)
                                });;

                        FriendLoginNotice?.Invoke(this, new Tuple <string, string>(data.Username, data.Address));
                    }
                }
                break;

                case "Logout":
                {
                    if (!Sessions.ContainsKey(package.SessionID))
                    {
                        var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                                {
                                    Result   = default(int),
                                    UserName = default(string)
                                });

                        LogoutResponse?.Invoke(this, new Tuple <int, string>(data.Result, data.UserName));
                    }
                }
                break;
                }
            }
            break;

            case "Chat":
            {
                switch (package.Method)
                {
                case "Text":
                    var data = JsonConvert.DeserializeAnonymousType(package.Data, new
                        {
                            Username = default(string),
                            Message  = default(string)
                        });

                    ChatReceived?.Invoke(this, new Tuple <string, string>(data.Username, data.Message));
                    break;

                default:
                    break;
                }
            }
            break;

            default:
                break;
            }
        }
        public GetUserInfoResponse GetUserInfo(GetUserInfoRequest request, IAuthContext authContext)
        {
            GetUserInfoResponse response = new GetUserInfoResponse();

            response.UserProviders = new List <UserProviderInfo>();

            var userProviderRepo = _unitOfWork.GetRepository <UserProvider>();
            var userAccountRepo  = _unitOfWork.GetRepository <Account>();
            var userAccountIdentificaitonRepo = _unitOfWork.GetRepository <AccountIdentification>();
            var userBalanceRepo     = _unitOfWork.GetRepository <Balance>();
            var userTransactionRepo = _unitOfWork.GetRepository <Transaction>();

            var userProviders = userProviderRepo.GetList(x => x.UserId.ToString() == authContext.UserId);

            foreach (var up in userProviders)
            {
                UserProviderInfo info = new UserProviderInfo();
                info.ProviderId      = up.Provider.ToString();
                info.ProviderName    = Provider.GetInstance(up.Provider).Text;
                info.ProviderLogoUrl = Provider.GetInstance(up.Provider).FlagUrl;
                info.Accounts        = new List <UserAccount>();

                var userAccounts = userAccountRepo.GetList(x => x.UserId.ToString() == authContext.UserId && x.ProviderId == up.Provider);

                foreach (var a in userAccounts)
                {
                    UserAccount account = new UserAccount();
                    account.AccountId             = a.Id.ToString();
                    account.AccountType           = AccountType.GetInstance(a.AccountType).Text;
                    account.CurrencyType          = CurrencyType.GetInstance(a.CurrencyType).Text;
                    account.Name                  = a.Name;
                    account.ProviderAccountId     = a.ProviderAccountId;
                    account.AccountIdentification = new List <string>();
                    account.Balances              = new List <UserBalance>();
                    account.Transactions          = new List <UserTransaction>();

                    var userAccountIdentifications = userAccountIdentificaitonRepo.GetList(x => x.AccountId == a.Id);

                    foreach (var ai in userAccountIdentifications)
                    {
                        account.AccountIdentification.Add(AccountIdentificationType.GetInstance(ai.AccountIdentificationTypeId).Text + ": " + ai.Identification);
                    }

                    var userBalances = userBalanceRepo.GetList(x => x.AccountId == a.Id);

                    foreach (var b in userBalances)
                    {
                        account.Balances.Add(new UserBalance()
                        {
                            Amount      = b.Amount,
                            BalanceType = BalanceType.GetInstance(b.BalanceType).Text,
                            Currency    = CurrencyType.GetInstance(b.CurrencyType).Text
                        });
                    }

                    var userTransactions = userTransactionRepo.GetList(x => x.AccountId == a.Id);

                    foreach (var t in userTransactions)
                    {
                        account.Transactions.Add(new UserTransaction()
                        {
                            Amount                = t.Amount,
                            Date                  = t.Date.ToString(),
                            Description           = t.Description,
                            MerchantCategory      = MerchantCategory.GetInstance(t.MerchantCategory).Text,
                            ProviderTransactionId = t.ProviderTransactionId,
                            TransactionCategory   = TransactionCategory.GetInstance(t.TransactionCategory).Text,
                            TransactionStatus     = TransactionStatus.GetInstance(t.TransactionStatus).Text,
                            TransactionType       = TransactionType.GetInstance(t.TransactionType).Text
                        });
                    }

                    info.Accounts.Add(account);
                }

                response.UserProviders.Add(info);
            }

            return(response);
        }
Beispiel #24
0
        public ResultJson <GetUserInfoResponse> Login(UserLoginRequest request)
        {
            ResultJson <GetUserInfoResponse> result = new ResultJson <GetUserInfoResponse>();

            #region 微信查询
            if (request.TransMode.ToLower() == "wechat")
            {
                if (request.UserId.IsNullOrEmpty())
                {
                    result.HttpCode = 400;
                    result.Message  = "当登录方式是微信登入时,请输入UserId";
                }
                else
                {
                    var usermodel = CacheForModelUser.Instance.GetUserInfoByWeChat(request.UserId);
                    if (usermodel == null)
                    {
                        if (request.UserImage.IsNullOrEmpty() || request.UserSex.IsNullOrEmpty())
                        {
                            result.HttpCode = 400;
                            result.Message  = "当首次用微信登入时,请输入UserImage与UserSex";
                        }
                        usermodel        = new Customer();
                        usermodel.wechat = request.UserId;
                        if (request.UserSex == "男")
                        {
                            usermodel.sex = true;
                        }
                        else if (request.UserSex == "女")
                        {
                            usermodel.sex = false;
                        }
                        if (CustomerOper.Instance.Insert(usermodel))
                        {
                            usermodel       = CacheForModelUser.Instance.GetUserInfoByWeChat(request.UserId);
                            result.HttpCode = 200;
                            result.Message  = Enum_Message.LoginSuccessMessage.Enum_GetString();
                            result.ListData = new List <GetUserInfoResponse>();
                            CacheForModelUser.Instance.SetUserInfo(usermodel.id);
                            var token = CacheForModelUser.Instance.SetUserToken(usermodel);
                            GetUserInfoResponse user_model = new GetUserInfoResponse(usermodel, token, Request.Headers.Host);
                            result.ListData.Add(user_model);
                        }
                        else
                        {
                            result.HttpCode = 500;
                            result.Message  = "数据插入失败";
                        }
                    }
                    else
                    {
                        result.HttpCode = 200;
                        result.Message  = Enum_Message.LoginSuccessMessage.Enum_GetString();
                        result.ListData = new List <GetUserInfoResponse>();
                        var token = CacheForModelUser.Instance.SetUserToken(usermodel);
                        GetUserInfoResponse user_model = new GetUserInfoResponse(usermodel, token, Request.Headers.Host);
                        result.ListData.Add(user_model);
                    }
                }
            }
            #endregion

            #region 用户密码查询
            else if (request.TransMode.ToLower() == "password")
            {
                if (request.UserPhone.IsNullOrEmpty() || request.UserPassword.IsNullOrEmpty())
                {
                    result.HttpCode = 400;
                    result.Message  = "当登录方式是账户登入时,请输入UserName与UserPassword";
                }
                else
                {
                    var usermodel = CacheForModelUser.Instance.GetUserInfoByPassWord(request.UserPhone, request.UserPassword);
                    if (usermodel == null)
                    {
                        result.HttpCode = 301;
                        result.Message  = "用户名或密码不存在";
                    }
                    else
                    {
                        result.HttpCode = 200;
                        result.Message  = Enum_Message.LoginSuccessMessage.Enum_GetString();
                        result.ListData = new List <GetUserInfoResponse>();
                        CacheForModelUser.Instance.SetUserInfo(usermodel.id);
                        var token = CacheForModelUser.Instance.SetUserToken(usermodel);
                        GetUserInfoResponse user_model = new GetUserInfoResponse(usermodel, token, Request.Headers.Host);
                        result.ListData.Add(user_model);
                    }
                }
            }
            #endregion

            #region 用户Token查询
            else if (request.TransMode.ToLower() == "token")
            {
                if (request.Token.IsNullOrEmpty())
                {
                    result.HttpCode = 400;
                    result.Message  = "当登录方式是Token登入,请输入Token";
                }
                else
                {
                    Token token = CacheForModelUser.Instance.GetUserToken(request.Token);
                    if (token != null)
                    {
                        var usermodel = CacheForModelUser.Instance.GetUserInfo(token.Payload.UserID);

                        if (usermodel == null)
                        {
                            result.HttpCode = 300;
                            result.Message  = Enum_Message.LoginSuccessMessage.Enum_GetString();
                        }
                        else
                        {
                            result.HttpCode = 200;
                            result.Message  = Enum_Message.LoginSuccessMessage.Enum_GetString();
                            result.ListData = new List <GetUserInfoResponse>();
                            CacheForModelUser.Instance.SetUserInfo(usermodel.id);
                            GetUserInfoResponse user_model = new GetUserInfoResponse(usermodel, Request.Headers.Host);
                            result.ListData.Add(user_model);
                        }
                    }
                    else
                    {
                        result.HttpCode = 300;
                        result.Message  = Enum_Message.LoginSuccessMessage.Enum_GetString();
                    }
                }
            }
            #endregion
            else
            {
                result.HttpCode = 300;
                result.Message  = "请输入正确的登入方式";
            }
            return(result);
        }
Beispiel #25
0
        public ActionResult GetUserInfo()
        {
            string code  = Request.Params["code"];
            string state = Request.Params["state"];

            if (code == null && state == null)
            {
                return(RedirectToAction("Index"));
            }

            OxdModel oxd = new OxdModel();

            #region GetProtectionAccessToken
            string protectionAccessToken = "";

            if (dynamic_registration)
            {
                //For OXD Server
                if (OXDType == "local")
                {
                    //Get ProtectionAccessToken
                    protectionAccessToken = GetProtectionAccessToken(oxdHost, oxdPort);
                }

                //For OXD Web
                if (OXDType == "web")
                {
                    protectionAccessToken = GetProtectionAccessToken(httpresturl);
                }
            }
            #endregion


            #region Get Tokens by Code

            var getTokenByCodeInputParams = new GetTokensByCodeParams();
            var getTokenByCodeClient      = new GetTokensByCodeClient();

            //prepare input params for Getting Tokens from a site
            getTokenByCodeInputParams.OxdId = oxd_id;
            getTokenByCodeInputParams.Code  = code;
            getTokenByCodeInputParams.State = state;
            getTokenByCodeInputParams.ProtectionAccessToken = protectionAccessToken;

            var getTokensByCodeResponse = new GetTokensByCodeResponse();

            //For OXD Server
            if (OXDType == "local")
            {
                getTokensByCodeResponse = getTokenByCodeClient.GetTokensByCode(oxdHost, oxdPort, getTokenByCodeInputParams);
            }

            //For OXD Web
            if (OXDType == "web")
            {
                getTokensByCodeResponse = getTokenByCodeClient.GetTokensByCode(httpresturl, getTokenByCodeInputParams);
            }


            var accessToken  = getTokensByCodeResponse.Data.AccessToken;
            var refreshToken = getTokensByCodeResponse.Data.RefreshToken;
            #endregion


            #region Get Access Token By Refresh Token
            if (dynamic_registration)
            {
                var getAccessTokenByRefreshTokenInputParams = new GetAccessTokenByRefreshTokenParams();
                var getAccessTokenByRefreshTokenClient      = new GetAccessTokenByRefreshTokenClient();

                //prepare input params for Getting Tokens from a site
                getAccessTokenByRefreshTokenInputParams.OxdId                 = oxd_id;
                getAccessTokenByRefreshTokenInputParams.RefreshToken          = refreshToken;
                getAccessTokenByRefreshTokenInputParams.ProtectionAccessToken = protectionAccessToken;


                var getAccessTokenByRefreshTokenResponse = new GetAccessTokenByRefreshTokenResponse();

                //For OXD Server
                if (OXDType == "local")
                {
                    getAccessTokenByRefreshTokenResponse = getAccessTokenByRefreshTokenClient.GetAccessTokenByRefreshToken(oxdHost, oxdPort, getAccessTokenByRefreshTokenInputParams);
                }

                //For OXD Web
                if (OXDType == "web")
                {
                    getAccessTokenByRefreshTokenResponse = getAccessTokenByRefreshTokenClient.GetAccessTokenByRefreshToken(httpresturl, getAccessTokenByRefreshTokenInputParams);
                }


                accessToken  = getAccessTokenByRefreshTokenResponse.Data.AccessToken;
                refreshToken = getAccessTokenByRefreshTokenResponse.Data.RefreshToken;
            }
            #endregion


            #region Get User Info

            var getUserInfoInputParams = new GetUserInfoParams();
            var getUserInfoClient      = new GetUserInfoClient();

            //prepare input params for Getting User Info from a site
            getUserInfoInputParams.OxdId                 = oxd_id;
            getUserInfoInputParams.AccessToken           = accessToken;
            getUserInfoInputParams.ProtectionAccessToken = protectionAccessToken;


            var getUserInfoResponse = new GetUserInfoResponse();

            //For OXD Server
            if (OXDType == "local")
            {
                getUserInfoResponse = getUserInfoClient.GetUserInfo(oxdHost, oxdPort, getUserInfoInputParams);
            }

            //For OXD Web
            if (OXDType == "web")
            {
                getUserInfoResponse = getUserInfoClient.GetUserInfo(httpresturl, getUserInfoInputParams);
            }


            //Process response


            Session["userName"]  = getUserInfoResponse.Data.UserClaims["name"].FirstOrDefault();
            Session["userEmail"] = getUserInfoResponse.Data.UserClaims["email"] == null ? string.Empty : getUserInfoResponse.Data.UserClaims["email"].FirstOrDefault();
            #endregion

            return(RedirectToAction("UserInfo"));
        }
        private void getAllOrderInfo()
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                Dispatcher.Invoke(new Action(delegate
                {
                }));

                RetrieveAllOrdersInSystemWorker.SendRetrieveDataListRequest(
                    successCallback :
                    delegate(RetrieveDataListResponse response)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        foreach (var item in response.DataList)
                        {
                            if (item.PatientAge == null)
                            {
                                item.PatientAge = "未知";
                            }
                            if (item.PatientName == null)
                            {
                                item.PatientName = "未知";
                            }
                        }

                        response.DataList = response.DataList.OrderBy(item => string.IsNullOrEmpty(item.UploadTimestamp) ? DateTime.MinValue : DateTime.ParseExact(item.UploadTimestamp, "yyyyMMdd HHmmss", null)).Reverse().ToArray();
                        //response.DataList = response.DataList.Where(item => item.Status == "已上传"||item.Status=="核验成功"||item.Status=="核验失败").ToArray();
                        _AllOrder = response.DataList;
                        if (_oldOrderList == null)
                        {
                            _oldOrderList = response.DataList;
                        }

                        if (response.DataList.Length > _oldOrderList.Length)
                        {
                            GetUserInfoResponse userInfo = _AllUserInfoList.FirstOrDefault(t => t.PhoneNumber == response.DataList[0].UserId);
                            if (userInfo != null)
                            {
                                Console.WriteLine("you have new order.");
                                string subjectInfo = "新订单通知 【朗开医疗】";
                                string bodyInfo    = "您收到" + userInfo.Institution + " " + userInfo.ChineseName + "上传的新订单,订单号:" + response.DataList[0].DataID + " 【朗开医疗】";
                                SendNotificateEmail(subjectInfo, bodyInfo);
                                SendPhoneMessage(bodyInfo);
                            }

                            _oldOrderList = response.DataList;
                        }
                        //foreach (DataListItem item in _AllOrder)
                        //{
                        //    GetUserInfoResponse userInfo = _AllUserInfoList.FirstOrDefault(t => t.PhoneNumber == item.UserId);
                        //    if (userInfo != null)
                        //    {
                        //        item.ChineseName = userInfo.ChineseName;
                        //    }
                        //}
                        //dingdanliebiao.SetDataSource(_AllOrder);

                        GetWaitingApproveUser();
                    }));
                },
                    failureCallback :
                    delegate(string failureReason)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        GetWaitingApproveUser();
                        MessageBox.Show("获取数据列表失败。" + failureReason, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }));
                },
                    errorCallback :
                    delegate(Exception ex)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        GetWaitingApproveUser();
                        Util.ShowExceptionMessage(ex, "获取数据列表出错。");
                    }));
                });
            });
        }
        private void GetAllUserInfo()
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                GetAllUserInfoWorker.SendGetAllUserInfoRequest(
                    successCallback : delegate(GetAllUserInfoResponse response)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        _UserNameList        = response.DataList;
                        _UserNameList        = _UserNameList.Where(item => item.RegistrationTimeStamp != null).ToArray();
                        _WaitingUserInfoList = new List <GetUserInfoResponse>();
                        if (_waitingApproveUserNameList != null)
                        {
                            for (int i = 0; i < _waitingApproveUserNameList.Count; i++)
                            {
                                GetUserInfoResponse userInfo = _UserNameList.FirstOrDefault(t => t.PhoneNumber == _waitingApproveUserNameList[i]);
                                if (userInfo != null)
                                {
                                    _WaitingUserInfoList.Add(userInfo);
                                }
                            }
                        }
                        foreach (DataListItem item in _datalist)
                        {
                            GetUserInfoResponse userInfo = _UserNameList.FirstOrDefault(t => t.PhoneNumber == item.UserId);
                            if (userInfo != null)
                            {
                                item.ChineseName = userInfo.ChineseName;
                            }
                        }
                        //AdminWindow adminWindow = new AdminWindow(_UserNameList , _datalist , _WaitingApproveUserInfoList);
                        //adminWindow.Loaded += delegate
                        //{
                        //    Visibility = Visibility.Hidden;
                        //};
                        //adminWindow.ShowDialog();
                        NotificationWindow admin = new NotificationWindow(_WaitingUserInfoList, _datalist, _UserNameList);
                        admin.Loaded            += delegate
                        {
                            Visibility = System.Windows.Visibility.Hidden;
                        };

                        admin.ShowDialog();
                    }));
                },
                    failureCallback : delegate(string failureReason)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        ResumeGUI();
                        MessageBox.Show("获取用户列表。" + failureReason, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }));
                },
                    errorCallback : delegate(Exception ex)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        ResumeGUI();
                        Util.ShowExceptionMessage(ex, "获取用户列表出错。");
                    }));
                }
                    );
            });
        }
Beispiel #28
0
        public ActionResult <GetUserInfoResponse> GetUserInfo([FromQuery] GetUserInfoRequest request)
        {
            GetUserInfoResponse response = _accountDataService.GetUserInfo(request, _authContext);

            return(Ok(response));
        }
Beispiel #29
0
        private void checkNewOrder()
        {
            ThreadPool.QueueUserWorkItem(delegate
            {
                Dispatcher.Invoke(new Action(delegate
                {
                }));

                RetrieveAllOrdersInSystemWorker.SendRetrieveDataListRequest(
                    successCallback :
                    delegate(RetrieveDataListResponse response)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        foreach (var item in response.DataList)
                        {
                            if (item.PatientAge == null)
                            {
                                item.PatientAge = "未知";
                            }
                            if (item.PatientName == null)
                            {
                                item.PatientName = "未知";
                            }
                        }

                        response.DataList = response.DataList;

                        response.DataList = response.DataList.OrderBy(item => string.IsNullOrEmpty(item.UploadTimestamp) ? DateTime.MinValue : DateTime.ParseExact(item.UploadTimestamp, "yyyyMMdd HHmmss", null)).Reverse().ToArray();
                        response.DataList = response.DataList.Where(item => item.Status == "已上传").ToArray();
                        if (response.DataList.Length > _datalist.Length)
                        {
                            GetUserInfoResponse userInfo = _UserNameList.FirstOrDefault(t => t.PhoneNumber == response.DataList[0].UserId);
                            if (userInfo != null)
                            {
                                Console.WriteLine("you have new order.");
                                _datalist           = response.DataList;
                                lbNewOrder1.Content = _datalist.Length;
                                SendNotificateEmail(userInfo.Institution + " " + userInfo.ChineseName, response.DataList[0].DataID);
                                SendPhoneMessage(userInfo.Institution + " " + userInfo.ChineseName, response.DataList[0].DataID);
                            }
                        }
                    }));
                },
                    failureCallback :
                    delegate(string failureReason)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        MessageBox.Show("获取数据列表失败。" + failureReason, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                    }));
                },
                    errorCallback :
                    delegate(Exception ex)
                {
                    Dispatcher.Invoke(new Action(delegate
                    {
                        Util.ShowExceptionMessage(ex, "获取数据列表出错。");
                    }));
                });
            });
        }
 private void getAllUserInfo()
 {
     ThreadPool.QueueUserWorkItem(delegate
     {
         GetAllUserInfoWorker.SendGetAllUserInfoRequest(
             successCallback : delegate(GetAllUserInfoResponse response)
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 response.DataList = response.DataList.Where(item => item.RegistrationTimeStamp != null).ToArray();
                 _AllUserInfoList  = response.DataList;
                 if (_oldAllUserInfo == null)
                 {
                     _oldAllUserInfo = response.DataList;
                 }
                 yonghuliebiao.SetDataSource(_AllUserInfoList);
                 if (_waitingApproveUserNameList != null)
                 {
                     _WaitingApproveUserList = new List <GetUserInfoResponse>();
                     for (int i = 0; i < _waitingApproveUserNameList.Count; i++)
                     {
                         GetUserInfoResponse userInfo = _AllUserInfoList.FirstOrDefault(t => t.PhoneNumber == _waitingApproveUserNameList[i]);
                         if (userInfo != null)
                         {
                             _WaitingApproveUserList.Add(userInfo);
                         }
                     }
                     if (_WaitingApproveUserList != null)
                     {
                         yonghushenhe.SetDataSource(_WaitingApproveUserList);
                     }
                 }
                 foreach (DataListItem item in _AllOrder)
                 {
                     GetUserInfoResponse userInfo = _AllUserInfoList.FirstOrDefault(t => t.PhoneNumber == item.UserId);
                     if (userInfo != null)
                     {
                         item.ChineseName = userInfo.ChineseName;
                     }
                 }
                 if (_AllOrder != null)
                 {
                     dingdanliebiao.SetDataSource(_AllOrder);
                 }
             }));
         },
             failureCallback : delegate(string failureReason)
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 MessageBox.Show("获取用户列表。" + failureReason, "", MessageBoxButton.OK, MessageBoxImage.Asterisk);
             }));
         },
             errorCallback : delegate(Exception ex)
         {
             Dispatcher.Invoke(new Action(delegate
             {
                 Util.ShowExceptionMessage(ex, "获取用户列表出错。");
             }));
         }
             );
     });
 }