private void SubmitEdit(object obj)
        {
            if (ErrorCollection.Count == 0)
            {
                Selected.Name        = Name;
                Selected.Description = Description;
                Selected.Latitude    = Convert.ToDouble(Latitude);
                Selected.Longitude   = Convert.ToDouble(Longitude);
                Selected.Link        = ToLinkWith.Tag;

                if (Selected is WindowDoorSensor windowDoorSensor)
                {
                    windowDoorSensor.Opened = Open;
                }
                else
                {
                    ((IHasRangeValue)Selected).MinValue = Convert.ToDecimal(MinValue);
                    ((IHasRangeValue)Selected).MaxValue = Convert.ToDecimal(MaxValue);
                }

                sensors.List[Index] = Selected;
                UpdateXml(sensors);
                Snackbar.Enqueue("Changes saved");
                DialogHost.CloseDialogCommand.Execute(null, null);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新好友验证
        /// </summary>
        private void UpdateFriendVerify()
        {
            EnableVerifySwitch     = false;//暂时禁用开关
            Settings.friendsVerify = (NeedFriendVerify == true) ? 1 : 0;
            var client = APIHelper.SetConcealAsync(Settings);

            client.UploadDataCompleted += (sen, res) =>
            {
                if (res.Error != null)
                {
                    var result = JsonConvert.DeserializeObject <JsonBase>(Encoding.UTF8.GetString(res.Result));
                    if (result.resultCode == 1)
                    {
                        Snackbar.Enqueue("已启用好友验证", true);
                        EnableVerifySwitch = true;//启用开关
                    }
                    else
                    {
                        Snackbar.Enqueue("设置失败\n" + result.resultMsg);
                        EnableVerifySwitch = true;//启用开关
                    }
                }
                else
                {
                    EnableVerifySwitch = true;//启用开关
                }
            };
        }
Beispiel #3
0
 /// <summary>
 /// 更新昵称完成
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void UpdateRemarkComplete(object sender, UploadDataCompletedEventArgs res)
 {
     if (res.Error == null)//正常情况
     {
         var result = JsonConvert.DeserializeObject <JsonBase>(Encoding.UTF8.GetString(res.Result));
         if (result.resultCode == 1)
         {
             new DataOfFriends().UpdateRemarkName(Friend.userId, TempRemarkName); //更新数据库
             RemarkName        = TempRemarkName;                                  //更新界面
             Friend.remarkName = RemarkName;                                      //更新好友昵称
             TempRemarkName    = "";                                              //重置编辑文本框
             IsEditing         = false;                                           //取消编辑状态(关闭对话框)
             //通知主窗口更改备注
             var item = new MessageListItem
             {
                 Jid          = friend.userId,
                 MessageTitle = Friend.remarkName,
                 Avator       = Applicate.LocalConfigData.GetDisplayAvatorPath(friend.userId)
             };
             Messenger.Default.Send(item, MainViewNotifactions.UpdateAccountName);//通知主窗口更新名称
             Snackbar.Enqueue("修改昵称成功");
         }
     }
     else
     {
         Snackbar.Enqueue("修改昵称失败:" + res.Error.Message);
     }
 }
Beispiel #4
0
        /// <summary>
        /// 从服务器获取设置
        /// </summary>
        private void GetSettingsByAPI()
        {
            var client = APIHelper.GetConcealAsync(Applicate.MyAccount.userId);//重新获得隐私

            client.UploadDataCompleted += (sen, res) =>
            {
                if (res.Error == null)
                {
                    var sets = JsonConvert.DeserializeObject <JsonSettings>(Encoding.UTF8.GetString(res.Result));
                    if (sets != null)
                    {
                        Settings = sets.data;
                    }
                    if (Settings == null)
                    {
                        Snackbar.Enqueue("设置获取失败!", "重试", () => { GetSettingsByAPI(); });
                        return;
                    }
                    NeedFriendVerify = Settings.friendsVerify == 1 ? true : false;
                }
                else
                {
                }
            };
        }
Beispiel #5
0
        /// <summary>
        /// 建群成功后
        /// </summary>
        /// <param name="sender">源</param>
        /// <param name="e">事件</param>
        private void CreateGroupChatComplete(object sender, UploadDataCompletedEventArgs e)
        {
            var tmpstr = Encoding.UTF8.GetString(e.Result);
            var result = JsonConvert.DeserializeObject <JsonRoom>(tmpstr);

            if (result != null && result.resultCode == 1)
            {
                if (result.data.members == null || result.data.members.Count == 0)
                {
                    var room = ((HttpClient)sender).Tag as Room;////获取群组
                    //jsonres.data.members = troom.members;//成员列表
                    room.members[0].AutoInsertRange(room.members, result.data.id);
                    result.data.userSize = room.userSize;                                        //成员数量
                }
                Messenger.Default.Send(result.data, CommonNotifications.CreateNewGroupFinished); //通知主窗口

                App.Current.Dispatcher.Invoke(() =>
                {
                    Messenger.Default.Send(true, GroupCreate.CloseWindow);//关闭窗口
                });

                Snackbar.Enqueue("创建群聊成功!");
            }
            else
            {
                Snackbar.Enqueue("群聊创建失败!\n" + result.resultMsg ?? "");
                EnableCreate = true;
            }
        }
Beispiel #6
0
        /// <summary>
        /// 显示本地用户详情
        /// </summary>
        /// <param name="userId">UserId</param>
        private void ShowLocalUserDetial(string userId)
        {
            var tmpFri = new DataOfFriends()
            {
                toUserId = userId
            }.GetByUserId();

            if (tmpFri != null)
            {
                Friend          = tmpFri.ToDataOfUserDetial();
                Friend.sex      = -1; //好友列表中无性别
                Friend.birthday = 0;  //无生日数据
                RemarkName      = Friend.remarkName;
            }
            var dclient = APIHelper.GetUserDetialAsync(userId);//详情

            //LogHelper.log.Info("用户详情GetUserDetial" + userId);
            dclient.UploadDataCompleted += (s, res) =>
            {
                if (res.Error == null)
                {
                    var user      = JsonConvert.DeserializeObject <JsonuserDetial>(Encoding.UTF8.GetString(res.Result));
                    var tmpfriend = user.data.ConvertToDataFriend();
                    if (tmpfriend != null)
                    {
                        int status = Friend.status; //暂时保存好友关系
                        Friend        = user.data;  //显示数据
                        Friend.status = status;     //重新赋值正确好友关系
                        if (!string.IsNullOrWhiteSpace(user.data._remarkName))
                        {
                            RemarkName = user.data._remarkName;
                        }
                        else
                        {
                            RemarkName = Friend.friends.remarkName;
                        }
                        var resfriend = new DataOfFriends();
                        resfriend = user.data.ToDataOfFriend();
                        //resfriend.status = 2;//设置为朋友
                        resfriend.AutoInsert();
                        if (Friend.remarkName != user.data.remarkName)
                        {
                            //刷新
                            Messenger.Default.Send(new MessageListItem
                            {
                                Jid       = user.data.userId,
                                ShowTitle = user.data._remarkName,
                                Avator    = Applicate.LocalConfigData.GetDisplayAvatorPath(user.data.userId)
                            }, MainViewNotifactions.UpdateAccountName);
                        }
                    }
                }
                else
                {
                    Snackbar.Enqueue(res.Error.Message);
                }
            };
        }
        private void Submit(object param)
        {
            Sensor sensor;

            CheckForBlanks();
            //check for errors
            if (ErrorCollection.Count == 0)
            {
                switch (SelectedItem)
                {
                case "Temperature":
                    sensor = new TemperatureSensor(Name, ToLinkWith.Tag, Description, Convert.ToDouble(Latitude),
                                                   Convert.ToDouble(Longitude), Tracking,
                                                   Convert.ToDecimal(MinValue), Convert.ToDecimal(MaxValue));
                    break;

                case "Humidity":
                    sensor = new HumiditySensor(Name, ToLinkWith.Tag, Description, Convert.ToDouble(Latitude),
                                                Convert.ToDouble(Longitude), Tracking,
                                                Convert.ToDecimal(MinValue), Convert.ToDecimal(MaxValue));
                    break;

                case "Electricity Consumption":
                    sensor = new PowerConsumptionSensor(Name, ToLinkWith.Tag, Description, Convert.ToDouble(Latitude),
                                                        Convert.ToDouble(Longitude), Tracking,
                                                        Convert.ToDecimal(MinValue), Convert.ToDecimal(MaxValue));
                    break;

                case "Noise":
                    sensor = new NoiseSensor(Name, ToLinkWith.Tag, Description, Convert.ToDouble(Latitude),
                                             Convert.ToDouble(Longitude), Tracking,
                                             Convert.ToDecimal(MinValue), Convert.ToDecimal(MaxValue));
                    break;

                case "Window/Door":
                    sensor = new WindowDoorSensor(Name, ToLinkWith.Tag, Description, Convert.ToDouble(Latitude),
                                                  Convert.ToDouble(Longitude), Tracking,
                                                  Open);
                    break;

                default:
                    sensor = null;
                    break;
                }

                sensors.List.Add(sensor);
                UpdateXml(sensors);
                Snackbar.Enqueue($"{sensor.Name} added");
                DialogHost.CloseDialogCommand.Execute(null, null);
            }
        }
        public void OnFinished()
        {
            GameInstanceRunning = false;

            if (Demos.Count == this.oldDemoCount)
            {
                Snackbar.Enqueue("No demos archived.");
            }
            else if (Demos.Count - 1 == this.oldDemoCount)
            {
                string archivedCount = (Demos.Count - this.oldDemoCount).ToString();
                Snackbar.Enqueue(archivedCount + " demo was archived.");
            }
            else
            {
                string archivedCount = (Demos.Count - this.oldDemoCount).ToString();
                Snackbar.Enqueue(archivedCount + " demos were archived.");
            }

            NotifyOfPropertyChange(() => Snackbar);
        }
        private void LoadDetials()
        {
            IsAllowEdit = false;
            var client = APIHelper.GetUserDetialAsync(Applicate.MyAccount.userId);//获取用户详情

            LogHelper.log.Info("详情窗口GetUserDetial" + Applicate.MyAccount.userId);
            client.UploadDataCompleted += (sen, res) =>
            {
                if (res.Error == null)
                {
                    var result  = Encoding.UTF8.GetString(res.Result);                    //获取字符
                    var tmpUser = JsonConvert.DeserializeObject <JsonuserDetial>(result); //反序列化
                    InitialViewAddress(tmpUser.data);                                     //初始化位置
                    //先加载集合
                    ViewUserDetial = tmpUser.data;                                        //赋值更新
                    IsAllowEdit    = true;                                                //允许编辑
                }
                else
                {
                    Snackbar.Enqueue("获取信息失败:" + res.Error.Message, "重试", () => { LoadDetials(); });
                }
            };
        }
 public void ShowNotification(string notif)
 {
     Snackbar.Enqueue(notif);
 }
Beispiel #11
0
        private void InitialCommands()
        {
            EditProfileCommand = new RelayCommand(EditProfile);
            SaveChangedCommand = new RelayCommand(() =>
            {
                IsUpdating = true;//设置为更新中
                editUserDetial.provinceId = ProvinceIndex;
                editUserDetial.cityId     = CityIndex;
                editUserDetial.areaId     = AreaIndex;
                var client = APIHelper.UpdateUserDetialAsync(EditUserDetial);//开始更新个人详情
                client.Tag = EditUserDetial;
                client.UploadDataCompleted += (sen, res) =>
                {
                    #region res
                    if (res.Error == null)
                    {
                        var source  = sen as HttpClient;                                    //获取源对象
                        var tmpEdit = source.Tag as DataOfUserDetial;                       //获取自己的详情
                        string resu = Encoding.UTF8.GetString(res.Result);
                        var result  = JsonConvert.DeserializeObject <JsonuserDetial>(resu); //反序列化
                        if (result.resultCode == 1)
                        {
                            if (!string.IsNullOrEmpty(AvatorPath))//上传头像
                            {
                                #region   头像
                                Task.Run(() =>
                                {
                                    var tClient = ShiKuManager.UploadAvator(Applicate.MyAccount.userId, AvatorPath);
                                    tClient.UploadDataCompleted += (send, even) =>
                                    {
                                        LogHelper.log.Debug("======================上传头像完成");
                                        App.Current.Dispatcher.Invoke(() =>
                                        {
                                            if (even.Error == null)
                                            {
                                                string value    = Encoding.UTF8.GetString(even.Result);//上传头像并接收返回值
                                                JsonBase rtnObj = JsonConvert.DeserializeObject <JsonBase>(value);
                                                if (rtnObj.resultCode == 1)
                                                {
                                                    Messenger.Default.Send(result.data, CommonNotifications.UpdateMyAccountDetail);//通知更新详情
                                                    Snackbar.Enqueue("更新个人信息和头像成功");
                                                    ViewUserDetial = new DataOfUserDetial
                                                    {
                                                        areaId      = result.data.areaId,
                                                        birthday    = result.data.birthday,
                                                        cityId      = result.data.cityId,
                                                        countryId   = result.data.countryId,
                                                        description = result.data.description,
                                                        name        = result.data.name,
                                                        nickname    = result.data.nickname,
                                                        remarkName  = result.data.remarkName,
                                                        phone       = result.data.phone,
                                                        sex         = result.data.sex,
                                                        status      = result.data.status,
                                                        provinceId  = result.data.provinceId,
                                                        Telephone   = result.data.Telephone,
                                                        userId      = result.data.userId,
                                                        areaCode    = result.data.areaCode,
                                                        avatarName  = result.data.avatarName,
                                                    };//赋值到编辑时数据
                                                    LogHelper.log.Debug("===================更新资料 " + result.data.avatarName);

                                                    InitialEditProperties();                                               //重置编辑信息
                                                    InitialViewAddress(ViewUserDetial);                                    //刷新地址
                                                    Messenger.Default.Send(tmpEdit, MainViewNotifactions.UpdateMyAccount); //更新详情
                                                    IsUpdating = false;
                                                    Transitioner.MovePreviousCommand.Execute(null, null);                  //返回上一页
                                                }
                                                else
                                                {
                                                    Snackbar.Enqueue("更新失败:" + rtnObj.resultMsg);//接口异常
                                                    IsUpdating = false;
                                                }
                                            }
                                            else
                                            {
                                                Snackbar.Enqueue("更新失败:" + even.Error.Message);
                                                IsUpdating = false;
                                            }
                                        });
                                    };
                                });
                                #endregion
                            }
                            else
                            {
                                Messenger.Default.Send(result.data, CommonNotifications.UpdateMyAccountDetail);//通知更新详情
                                ViewUserDetial = new DataOfUserDetial
                                {
                                    areaId      = result.data.areaId,
                                    birthday    = result.data.birthday,
                                    cityId      = result.data.cityId,
                                    countryId   = result.data.countryId,
                                    description = result.data.description,
                                    name        = result.data.name,
                                    nickname    = result.data.nickname,
                                    remarkName  = result.data.remarkName,
                                    phone       = result.data.phone,
                                    sex         = result.data.sex,
                                    status      = result.data.status,
                                    provinceId  = result.data.provinceId,
                                    Telephone   = result.data.Telephone,
                                    userId      = result.data.userId,
                                    areaCode    = result.data.areaCode,
                                    avatarName  = result.data.avatarName,
                                };                                  //赋值到编辑时数据
                                InitialViewAddress(ViewUserDetial); //刷新地址
                                Snackbar.Enqueue("更新个人资料成功");
                                IsUpdating = false;
                                Transitioner.MovePreviousCommand.Execute(null, null); //返回上一页
                                Messenger.Default.Send(tmpEdit, MainViewNotifactions.UpdateMyAccount);
                                Transitioner.MovePreviousCommand.Execute(null, null); //返回详情显示页面
                            }
                        }
                        else
                        {
                            Snackbar.Enqueue("更新失败:" + result.resultMsg);
                            IsUpdating = false;
                        }
                    }
                    else
                    {
                        Snackbar.Enqueue("更新失败:" + res.Error.Message);
                        IsUpdating = false;
                    }
                    #endregion
                };
                LoadDetials();
                Messenger.Default.Send(ViewUserDetial, CommonNotifications.UpdateMyAccountDetail);
            });
            SelectAvatorCommand = new RelayCommand(SelectAvator);
            LoadImageLocal      = new RelayCommand(SelectAvatorLocal);
        }
Beispiel #12
0
        /// <summary>
        /// 更新密码
        /// </summary>
        private void UpdatePassword()
        {
            if (string.IsNullOrEmpty(CurrentPassword))
            {
                Snackbar.Enqueue("请输入密码以修改");
                CurrentPassword = "";
                CurrentPassword = "";
                return;
            }
            if (NewPassword == "")
            {
                Snackbar.Enqueue("密码不能为空");
                NewCheckPassword = "";
                NewPassword      = "";
                return;
            }
            if (Pwd_spaces(NewPassword) == false)
            {
                Snackbar.Enqueue("密码不能包含空格");
                NewCheckPassword = "";
                NewPassword      = "";
                return;
            }
            if (NewPassword.Length < 6)
            {
                //Password's length Can't be smaller than 6
                Snackbar.Enqueue("密码长度不能小于6位");
                NewCheckPassword = "";
                NewPassword      = "";
                return;
            }
            if (NewPassword != NewCheckPassword)
            {
                Snackbar.Enqueue("新密码设置不一致");
                NewPassword      = "";
                NewCheckPassword = "";
                return;
            }
            else
            {
                //No Problem
            }
            if (NewCheckPassword == CurrentPassword)
            {
                Snackbar.Enqueue("新密码不能与旧密码相同");
                NewCheckPassword = "";
                NewPassword      = "";
                return;
            }
            var client = APIHelper.ResetPasswordAsync(Helpers.MD5create(CurrentPassword), Helpers.MD5create(NewCheckPassword));

            client.UploadDataCompleted += (sen, res) =>
            {
                var restxt = Encoding.UTF8.GetString(res.Result);
                var rtn    = JsonConvert.DeserializeObject <JsonBase>(restxt);
                if (rtn.resultCode == 1)
                {
                    //成功
                    CurrentPassword  = "";
                    NewPassword      = "";
                    NewCheckPassword = "";
                    Task.Run(() =>
                    {
                        var userObj = new LocalUser()
                        {
                            UserId = Applicate.MyAccount.userId
                        }.GetModel();
                        if (userObj != null)
                        {
                            userObj.UpdatePwd(Applicate.MyAccount.Telephone, NewCheckPassword, NewCheckPassword.Length);
                        }
                    });
                    Snackbar.Enqueue("设置成功,请重新登录");
                    Task.Run(() =>
                    {
                        Thread.Sleep(1000);
                        App.Current.Dispatcher.BeginInvoke((Action) delegate()
                        {
                            ShiKuManager.ApplicationExit();
                            System.Windows.Forms.Application.Restart();
                            Application.Current.Shutdown();
                        });
                    });
                }
                else
                {
                    //设置失败
                    Snackbar.Enqueue("设置失败" + rtn.resultMsg);
                }
            };
        }