예제 #1
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += (sender, arg) => { arg.Handled = true; };
            if (StaticObj.user is Student)
            {
                forStudent.Visibility    = Visibility.Visible;
                forSupervisor.Visibility = Visibility.Collapsed;
            }
            else
            {
                forSupervisor.Visibility = Visibility.Visible;
                forStudent.Visibility    = Visibility.Collapsed;
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetRepair), ""));

                Packet[] incomming = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnRepair))
                {
                    List <Dictionary <string, string> > repairList = JsonParser.DeserializeListOfDictionaryObject(DataParser.Packets2Str(incomming));
                    foreach (Dictionary <string, string> temp in repairList)
                    {
                        display.Items.Add(temp["CONTENT"]);
                    }
                }
                else
                {
                    await(new MessageDialog("获得失败")).ShowAsync();
                }
            }
        }
        private async void Logout_Click(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> logoutPair = new Dictionary <string, string>();

            if (StaticObj.user is Student)
            {
                logoutPair.Add("Type", "Stu");
            }
            else
            {
                logoutPair.Add("Type", "Sup");
            }
            logoutPair.Add("ID", StaticObj.user.ID);
            StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.Logout), JsonParser.SerializeObject(logoutPair)));

            Packet[] incomming = await StaticObj.ReceivePackets();

            if (Convert.ToInt32(DataParser.GetPacketCommandCode(incomming[0])) == Convert.ToInt32(CommandCode.Logout))
            {
                if (Convert.ToInt32(DataParser.Packets2Str(incomming)) != 0)
                {
                    await(new MessageDialog("已注销")).ShowAsync();
                    Frame.BackStack.Clear();
                    Frame.Navigate(typeof(Login));
                }
                else
                {
                    await(new MessageDialog("注销失败")).ShowAsync();
                }
            }
        }
예제 #3
0
        private async void Confirm(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> messagePair = new Dictionary <string, string>();

            messagePair.Add("SENDTIME", DateTime.Now.ToString());
            if (StaticObj.user is Student)
            {
                messagePair.Add("ISFROMSTUDENT", "1");
            }
            else
            {
                messagePair.Add("ISFROMSTUDENT", "0");
            }
            messagePair.Add("ID", StaticObj.user.ID);
            messagePair.Add("CONTENT", message.Text.Trim());
            StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SendMessageBox), JsonParser.SerializeObject(messagePair)));

            Packet[] incomming = await StaticObj.ReceivePackets();

            if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnMessageBox))
            {
                if (Convert.ToInt32(DataParser.Packets2Str(incomming)) != 0)
                {
                    await(new MessageDialog("发送成功!")).ShowAsync();
                    Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
                    Frame.Navigate(typeof(Main));
                }
                else
                {
                    await(new MessageDialog("发送失败!")).ShowAsync();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += (sender, arg) => { arg.Handled = true; };
            if (StaticObj.user is HeartLink_Lib.Student)
            {
                gridForStudent.Visibility    = Visibility.Visible;
                gridForSupervisor.Visibility = Visibility.Collapsed;
            }
            else
            {
                gridForSupervisor.Visibility = Visibility.Visible;
                gridForStudent.Visibility    = Visibility.Collapsed;
                AskOffList = new ContentCollection <AskOffContent>();
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetAskOff), ""));

                Packet[] incommingAskOff = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incommingAskOff[0]) == Convert.ToInt32(CommandCode.ReturnAskOff))
                {
                    List <Dictionary <string, string> > jsonAskOffs = JsonParser.DeserializeListOfDictionaryObject(DataParser.Packets2Str(incommingAskOff));

                    foreach (Dictionary <string, string> con in jsonAskOffs)
                    {
                        AskOffContent temp = new AskOffContent();
                        temp.Reason = con["REASON"];
                        temp.ID     = con["ID"];
                        temp.Date   = con["ASKOFFDATE"];
                        temp.Time   = con["ASKOFFTIME"];
                        AskOffList.Add(temp);
                    }

                    display.ItemsSource = AskOffList;
                }
            }
        }
예제 #5
0
        private async void Confirm(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> contacterPair = new Dictionary <string, string>();

            contacterPair.Add("OWNERID", StaticObj.user.ID);
            if (student.IsChecked == true)
            {
                contacterPair.Add("ISFORSTUDENT", "1");
            }
            else
            {
                contacterPair.Add("ISFORSTUDENT", "0");
            }
            contacterPair.Add("CONTACTORID", ID.Text.Trim());
            StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SendContacter), JsonParser.SerializeObject(contacterPair)));

            Packet[] incomming = await StaticObj.ReceivePackets();

            if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnContacters))
            {
                if (Convert.ToInt32(DataParser.Packets2Str(incomming)) != 0)
                {
                    await(new MessageDialog("发送成功!")).ShowAsync();
                    Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
                    Frame.Navigate(typeof(Main));
                }
                else
                {
                    await(new MessageDialog("上传失败!")).ShowAsync();
                }
            }
        }
예제 #6
0
        private async void confirm_Click(object sender, RoutedEventArgs e)
        {
            #region Stu
            if (StaticObj.user is Student)
            {
                Dictionary <string, string> askoffPair = new Dictionary <string, string>();
                askoffPair.Add("ID", StaticObj.user.ID);
                askoffPair.Add("ASKOFFDATE", date.Date.ToString().Split(new char[] { ' ' })[0]);
                askoffPair.Add("ASKOFFTIME", String.Format("{0}~{1}", fromTime.Time.ToString().Substring(0, 5), toTime.Time.ToString().Substring(0, 5)));
                askoffPair.Add("REASON", reasonTxtBox.Text.Trim());
                askoffPair.Add("ISSOLVED", "0");
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SendAskOff), JsonParser.SerializeObject(askoffPair)));

                Packet[] incommingAskOff = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incommingAskOff[0]) == Convert.ToInt32(CommandCode.ReturnAskOff))
                {
                    if (Convert.ToInt32(DataParser.Packets2Str(incommingAskOff)) != 0)
                    {
                        await(new MessageDialog("已上传")).ShowAsync();
                        Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
                        Frame.Navigate(typeof(Main));
                    }
                    else
                    {
                        await(new MessageDialog("上传失败")).ShowAsync();
                    }
                }
            }
            #endregion
            #region Sup
            else
            {
                AskOffContent selected = (AskOffContent)display.SelectedItem;
                Dictionary <string, string> solvePair = new Dictionary <string, string>();
                solvePair.Add("ID", selected.ID);
                solvePair.Add("ASKOFFDATE", selected.Date);
                solvePair.Add("ASKOFFTIME", selected.Time);
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SolveAskOff), JsonParser.SerializeObject(solvePair)));

                Packet[] incomming = await StaticObj.ReceivePackets();

                int solveResult = DataParser.GetPacketCommandCode(incomming[0]);
                if (solveResult == Convert.ToInt32(CommandCode.Succeed))
                {
                    await(new MessageDialog("已解决")).ShowAsync();
                    display.Items.RemoveAt(display.SelectedIndex);
                }
                else
                {
                    await(new MessageDialog("错误")).ShowAsync();
                }
            }
            #endregion
        }
예제 #7
0
        private async void Confirm(object sender, RoutedEventArgs e)
        {
            #region Stu
            if (StaticObj.user is Student)
            {
                Dictionary <string, string> repairPair = new Dictionary <string, string>();
                repairPair.Add("students_ID", StaticObj.user.ID);
                repairPair.Add("CONTENT", RequestTextBox.Text.Trim());
                repairPair.Add("ISSOLVED", "0");
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SendRepair), JsonParser.SerializeObject(repairPair)));

                Packet[] incomming = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnRepair))
                {
                    if (Convert.ToInt32(DataParser.Packets2Str(incomming)) != 0)
                    {
                        await(new MessageDialog("发送成功")).ShowAsync();
                        Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
                        Frame.Navigate(typeof(Main));
                    }
                    else
                    {
                        await(new MessageDialog("操作失败")).ShowAsync();
                    }
                }
            }
            #endregion
            #region Sup
            else
            {
                string selected = (string)display.SelectedItem;
                Dictionary <string, string> repairPair = new Dictionary <string, string>();
                repairPair.Add("students_ID", StaticObj.user.ID);
                repairPair.Add("CONTENT", selected);
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SolveRepair), JsonParser.SerializeObject(repairPair)));

                Packet[] incomming = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.Succeed))
                {
                    await(new MessageDialog("已完成")).ShowAsync();
                    display.Items.Remove(selected);
                }
                else
                {
                    await(new MessageDialog("操作失败")).ShowAsync();
                }
            }
            #endregion
        }
예제 #8
0
        private async void UploadLocation(object sender, RoutedEventArgs e)
        {
            Geolocator geolocator = new Geolocator();

            // 期望的精度级别(PositionAccuracy.Default 或 PositionAccuracy.High)
            geolocator.DesiredAccuracy = PositionAccuracy.High;
            // 期望的数据精度(米)
            geolocator.DesiredAccuracyInMeters = 50;

            try
            {
                Geoposition geoposition = await geolocator.GetGeopositionAsync();

                Dictionary <string, string> locationPair = new Dictionary <string, string>();
                locationPair.Add("ID", StaticObj.user.ID);
                locationPair.Add("LONGITUDE", geoposition.Coordinate.Point.Position.Longitude.ToString("0.000"));
                locationPair.Add("LATITUDE", geoposition.Coordinate.Point.Position.Latitude.ToString("0.000"));
                locationPair.Add("ALTITUDE", geoposition.Coordinate.Point.Position.Altitude.ToString("0.000"));
                locationPair.Add("TIME", DateTime.Now.ToString());
                locationPair.Add("POSITIONSOURCE", geoposition.Coordinate.PositionSource.ToString());

                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SendLocation), JsonParser.SerializeObject(locationPair)));
                Packet[] incomming = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnLocation))
                {
                    if (Convert.ToInt32(DataParser.Packets2Str(incomming)) != 0)
                    {
                        await(new MessageDialog(String.Format("发送成功!\n时间:{0}\n经度:{1}\n纬度:{2}海拔:{3}\n位置信息来源:{4}", locationPair["TIME"], locationPair["LONGITUDE"], locationPair["LATITUDE"], locationPair["ALTITUDE"], locationPair["POSITIONSOURCE"]))).ShowAsync();
                    }
                }
                else
                {
                    await(new MessageDialog("上传失败!")).ShowAsync();
                }
            }
            catch { }
        }
예제 #9
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += (sender, arg) => { arg.Handled = true; };
            #region Stu
            if (StaticObj.user is HeartLink_Lib.Student)
            {
                gridForSupervisor.Visibility = Visibility.Collapsed;
                gridForStudent.Visibility    = Visibility.Visible;
                Dictionary <string, string> deliveryPair = new Dictionary <string, string>();
                deliveryPair.Add("ID", StaticObj.user.ID);
                deliveryPair.Add("ISSOLVED", "0");
                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetDelivery), JsonParser.SerializeObject(deliveryPair)));

                Packet[] incomming = await StaticObj.ReceivePackets();

                if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnDelivery))
                {
                    List <Dictionary <string, string> > deliveryList = JsonParser.DeserializeListOfDictionaryObject(DataParser.Packets2Str(incomming));
                    foreach (Dictionary <string, string> temp in deliveryList)
                    {
                        display.Items.Add(temp["CONTENT"]);
                    }
                }
                else
                {
                    await(new MessageDialog("获得失败")).ShowAsync();
                }
            }
            #endregion
            #region Sup
            else
            {
                gridForStudent.Visibility    = Visibility.Collapsed;
                gridForSupervisor.Visibility = Visibility.Visible;
            }
            #endregion
        }
예제 #10
0
        private async void Confirm(object sender, RoutedEventArgs e)
        {
            Dictionary <string, string> dailyReminderPair = new Dictionary <string, string>();

            dailyReminderPair.Add("REMINDTIME", DateTime.Now.ToString());
            dailyReminderPair.Add("CONTENT", dailyReminder.Text.Trim());
            StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.SendDailyReminder), JsonParser.SerializeObject(dailyReminderPair)));

            Packet[] incomming = await StaticObj.ReceivePackets();

            if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnDailyReminder))
            {
                if (Convert.ToInt32(DataParser.Packets2Str(incomming)) != 0)
                {
                    await(new MessageDialog("发送成功!")).ShowAsync();
                    Frame.BackStack.RemoveAt(Frame.BackStackDepth - 1);
                    Frame.Navigate(typeof(Main));
                }
                else
                {
                    await(new MessageDialog("发送失败!")).ShowAsync();
                }
            }
        }
예제 #11
0
        private async void submitButton_Click(object sender, RoutedEventArgs e)
        {
            //判断以及登录
            string id  = idTextBox.Text.Trim();
            string psw = pswPasswordBox.Password;

            if (psw.Length < 4 || psw.Length > 15)
            {
                await(new MessageDialog(String.Format("请确保密码长度在{0}~{1}位之间", Consts.PasswordLength_MIN, Consts.PasswordLength_MAX))).ShowAsync();
            }

            Dictionary <string, string> loginPair = new Dictionary <string, string>();

            loginPair.Add("ID", id);
            loginPair.Add("Password", psw);
            if (studentRadioButton.IsChecked == true)
            {
                loginPair.Add("Type", "Stu");
            }
            else
            {
                loginPair.Add("Type", "Sup");
            }
            Packet[] packets = DataParser.Str2Packets(Convert.ToInt32(CommandCode.Login), JsonParser.SerializeObject(loginPair));
            StaticObj.SendPackets(packets);

            Packet[] incomming = await StaticObj.ReceivePackets();

            int loginResult = DataParser.GetPacketCommandCode(incomming[0]);

            if (loginResult == Convert.ToInt32(CommandCode.Succeed))  //登录成功
            {
                Dictionary <string, string> resultPair = JsonParser.DeserializeObject(DataParser.Packets2Str(incomming));
                if (studentRadioButton.IsChecked == true)
                {
                    StaticObj.user = new Student();
                }
                else
                {
                    StaticObj.user = new Supervisor();
                }
                StaticObj.user.ID       = id;
                StaticObj.user.PASSWORD = psw;
                StaticObj.user.NAME     = resultPair["NAME"];
                StaticObj.user.GENDER   = resultPair["GENDER"];
                if (studentRadioButton.IsChecked == true)
                {
                    (StaticObj.user as Student).DORMITORYADDRESS        = resultPair["DORMITORY"];
                    (StaticObj.user as Student).CLASSNUMBER             = resultPair["CLASSNUMBER"];
                    (StaticObj.user as Student).DIRECTORNAME            = resultPair["DIRECTORNAME"];
                    (StaticObj.user as Student).DIRECTORCELLPHONENUMBER = resultPair["DIRECTORCELLPHONE"];
                }
                else
                {
                    (StaticObj.user as Supervisor).DORMITORYBUILDINGS = resultPair["BUILDING"];
                }

                Dictionary <string, string> remember = new Dictionary <string, string>();
                remember.Add("ID", idTextBox.Text.Trim());
                remember.Add("PASSWORD", pswPasswordBox.Password);
                if (studentRadioButton.IsChecked == true)
                {
                    remember.Add("ISSTUDENT", "1");
                }
                else
                {
                    remember.Add("ISSTUDENT", "0");
                }
                var         fold = Windows.Storage.ApplicationData.Current.LocalFolder;                              //打开文件夹
                StorageFile file = await fold.CreateFileAsync("Info.json", CreationCollisionOption.ReplaceExisting); //创建文件

                await FileIO.WriteTextAsync(file, JsonParser.SerializeObject(remember));                             //写入

                Frame.BackStack.Clear();
                Frame.Navigate(typeof(Main));
            }
            else if (loginResult == Convert.ToInt32(CommandCode.WrongPsw))
            {
                await(new MessageDialog("用户名或密码错误")).ShowAsync();
            }
            else if (loginResult == Convert.ToInt32(CommandCode.AlreadyLogin))
            {
                await(new MessageDialog("该用户已登录,若非本人操作请修改密码")).ShowAsync();
            }
            else
            {
                await(new MessageDialog("该用户名未注册")).ShowAsync();
            }
        }
예제 #12
0
        private async void nextStepButton_Click(object sender, RoutedEventArgs e)
        {
            //做判断

            Dictionary <string, string> regPair = new Dictionary <string, string>();

            regPair.Add("ID", idTextBox.Text.Trim());
            //TODO:Encryption
            //string encrypted=Encryption.Encrypt(pswPasswordBox.Password);
            string encrypted = pswPasswordBox.Password;

            regPair.Add("PASSWORD", encrypted);
            regPair.Add("NAME", nameTextBox.Text.Trim());
            regPair.Add("STATUS", "OFFLINE");
            if (maleRadioButton.IsChecked == true)
            {
                regPair.Add("GENDER", "Male");
            }
            else
            {
                regPair.Add("GENDER", "Female");
            }
            regPair.Add("CELLPHONE", phonenumTextBox.Text.Trim());
            if (studentRadioButton.IsChecked == true)
            {
                regPair.Add("Type", "Stu");
                regPair.Add("DORMITORY", dormnumTextBox.Text.Trim());
                regPair.Add("CLASSNUMBER", classnumTextBox.Text.Trim());
                regPair.Add("DIRECTORNAME", directorNameTextBox.Text.Trim());
                regPair.Add("DIRECTORCELLPHONE", directorPhonenumTextBox.Text.Trim());
            }
            else
            {
                regPair.Add("Type", "Sup");
                regPair.Add("BUILDING", buildingTextBox.Text.Trim());
            }
            Packet[] packets = DataParser.Str2Packets(Convert.ToInt32(CommandCode.Register), JsonParser.SerializeObject(regPair));
            StaticObj.SendPackets(packets);

            Packet[] incomming = await StaticObj.ReceivePackets();

            int regResult = DataParser.GetPacketCommandCode(incomming[0]);

            if (regResult == Convert.ToInt32(CommandCode.Succeed))
            {
                await(new MessageDialog("注册成功")).ShowAsync();
                //将登录名及加密后的密码写入文件中,以便以后可一键登录
                Dictionary <string, string> remember = new Dictionary <string, string>();
                remember.Add("ID", idTextBox.Text.Trim());
                remember.Add("PASSWORD", encrypted);
                if (studentRadioButton.IsChecked == true)
                {
                    remember.Add("ISSTUDENT", "1");
                }
                else
                {
                    remember.Add("ISSTUDENT", "0");
                }
                var         fold = Windows.Storage.ApplicationData.Current.LocalFolder;                              //打开文件夹
                StorageFile file = await fold.CreateFileAsync("Info.json", CreationCollisionOption.ReplaceExisting); //创建文件

                await FileIO.WriteTextAsync(file, JsonParser.SerializeObject(remember));                             //写入

                Frame.BackStack.Clear();
                Frame.Navigate(typeof(Login));
            }
            else if (regResult == Convert.ToInt32(CommandCode.RegisterFailed))
            {
                await(new MessageDialog("注册失败")).ShowAsync();
            }
            else
            {
                await(new MessageDialog("该用户名已被注册")).ShowAsync();
            }
        }
예제 #13
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += (sender, arg) => { arg.Handled = true; };
            Contacters = new ContentCollection <ContactorContent>();
            MessageBox = new ContentCollection <MessageBoxContent>();

            #region GetContacters
            Dictionary <string, string> commandPair = new Dictionary <string, string>();
            commandPair.Add("ID", StaticObj.user.ID);
            Packet[] packets = DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetContacters), JsonParser.SerializeObject(commandPair));
            StaticObj.SendPackets(packets);

            Packet[] incommingContacters = await StaticObj.ReceivePackets();

            if (DataParser.GetPacketCommandCode(incommingContacters[0]) == Convert.ToInt32(CommandCode.ReturnContacters))
            {
                List <Dictionary <string, string> > jsonContacters = JsonParser.DeserializeListOfDictionaryObject(DataParser.Packets2Str(incommingContacters));

                foreach (Dictionary <string, string> con in jsonContacters)
                {
                    ContactorContent listContent = new ContactorContent();
                    listContent.Name     = con["NAME"];
                    listContent.PhoneNum = con["CELLPHONE"];
                    Contacters.Add(listContent);
                }
            }
            #endregion

            #region GetMessageBox
            packets = DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetMessageBox), "");
            StaticObj.SendPackets(packets);

            Packet[] incommingMessageBox = await StaticObj.ReceivePackets();

            if (DataParser.GetPacketCommandCode(incommingMessageBox[0]) == Convert.ToInt32(CommandCode.ReturnMessageBox))
            {
                List <Dictionary <string, string> > jsonMessageBox = JsonParser.DeserializeListOfDictionaryObject(DataParser.Packets2Str(incommingMessageBox));

                foreach (Dictionary <string, string> msg in jsonMessageBox)
                {
                    MessageBoxContent listContent = new MessageBoxContent();
                    listContent.ID = msg["ID"];
                    if (msg["ISFROMSTUDENT"].Equals("1"))
                    {
                        listContent.Type = "Student";
                    }
                    else
                    {
                        listContent.Type = "Supervisor";
                    }
                    //listContent.Type = msg["TYPE"];
                    listContent.Time    = msg["SENDTIME"];
                    listContent.Content = msg["CONTENT"];
                    MessageBox.Add(listContent);
                }
            }
            #endregion

            if (StaticObj.user is HeartLink_Lib.Student)
            {
                WorkServiceForStudent.Visibility    = Visibility.Visible;
                WorkServiceForSupervisor.Visibility = Visibility.Collapsed;

                StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetDailyReminder), ""));

                Packet[] incommingDailyReminder = await StaticObj.ReceivePackets();

                DailyReminderDisplay dis = new DailyReminderDisplay();
                if (DataParser.GetPacketCommandCode(incommingDailyReminder[0]) == Convert.ToInt32(CommandCode.ReturnDailyReminder))
                {
                    Dictionary <string, string> dailyReminder = JsonParser.DeserializeObject(DataParser.Packets2Str(incommingDailyReminder));
                    dis.ReminderTime    = dailyReminder["REMINDTIME"];
                    dis.ReminderContent = dailyReminder["CONTENT"];
                }
                WorkServiceForStudent.DataContext = dis;
            }
            else
            {
                WorkServiceForSupervisor.Visibility = Visibility.Visible;
                WorkServiceForStudent.Visibility    = Visibility.Collapsed;
            }
        }
예제 #14
0
        /// <summary>
        /// 在此页将要在 Frame 中显示时进行调用。
        /// </summary>
        /// <param name="e">描述如何访问此页的事件数据。
        /// 此参数通常用于配置页。</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            Windows.Phone.UI.Input.HardwareButtons.BackPressed += (sender, arg) => { arg.Handled = true; };

            locationBox.Clear();

            Geolocator       geolocator         = new Geolocator();
            Geoposition      geoposition        = null;
            BasicGeoposition supervisorPosition = new BasicGeoposition();

            try
            {
                geoposition = await geolocator.GetGeopositionAsync();

                supervisorPosition.Longitude = geoposition.Coordinate.Point.Position.Longitude;
                supervisorPosition.Latitude  = geoposition.Coordinate.Point.Position.Latitude;
                supervisorPosition.Altitude  = geoposition.Coordinate.Point.Position.Altitude;

                MapIcon supervisorIcon = new MapIcon();
                supervisorIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/PinkPushPin.png"));
                supervisorIcon.NormalizedAnchorPoint = new Point(0.25, 0.9);
                supervisorIcon.Location = new Geopoint(supervisorPosition);

                MapControl.Center = geoposition.Coordinate.Point;
            }
            catch { }

            StaticObj.SendPackets(DataParser.Str2Packets(Convert.ToInt32(CommandCode.GetLocation), ""));

            Packet[] incomming = await StaticObj.ReceivePackets();

            if (DataParser.GetPacketCommandCode(incomming[0]) == Convert.ToInt32(CommandCode.ReturnLocation))
            {
                List <Dictionary <string, string> > locationDict = JsonParser.DeserializeListOfDictionaryObject(DataParser.Packets2Str(incomming));
                foreach (Dictionary <string, string> dic in locationDict)
                {
                    BasicGeoposition position = new BasicGeoposition();
                    position.Longitude = Convert.ToDouble(dic["LONGITUDE"]);
                    position.Latitude  = Convert.ToDouble(dic["LATITUDE"]);
                    position.Altitude  = Convert.ToDouble(dic["ALTITUDE"]);

                    MapIcon studentIcon = new MapIcon();
                    studentIcon.Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/PinkPushPin.png"));
                    studentIcon.NormalizedAnchorPoint = new Point(0.25, 0.9);
                    studentIcon.Location = new Geopoint(position);

                    MapControl.MapElements.Add(studentIcon);

                    LocationContent locationContent = new LocationContent();
                    locationContent.ID             = dic["ID"];
                    locationContent.Time           = dic["TIME"];
                    locationContent.PositionSource = dic["POSITIONSOURCE"];
                    double distance = GetDistance(geoposition.Coordinate.Point.Position.Latitude, geoposition.Coordinate.Point.Position.Longitude,
                                                  Convert.ToDouble(dic["LATITUDE"]), Convert.ToDouble(dic["LONGITUDE"]));
                    if (distance < 1000)
                    {
                        locationContent.Distance = "距离:" + distance.ToString("0.0") + "米";
                    }
                    else
                    {
                        locationContent.Distance = "距离:" + (distance / 1000).ToString("0.00") + "千米";
                    }
                    double azimuth = GetAzimuth(geoposition.Coordinate.Point.Position.Latitude, geoposition.Coordinate.Point.Position.Longitude,
                                                Convert.ToDouble(dic["LATITUDE"]), Convert.ToDouble(dic["LONGITUDE"]));
                    if (azimuth == 0)
                    {
                        locationContent.Azimuth = "北";
                    }
                    else if (azimuth > 0 && azimuth < 90)
                    {
                        locationContent.Azimuth = "北偏东\t" + azimuth.ToString("0.000") + "°";
                    }
                    else if (azimuth == 90)
                    {
                        locationContent.Azimuth = "东";
                    }
                    else if (azimuth > 90 && azimuth < 180)
                    {
                        locationContent.Azimuth = "南偏东\t" + (180 - azimuth).ToString("0.000") + "°";
                    }
                    else if (azimuth == 180)
                    {
                        locationContent.Azimuth = "南";
                    }
                    else if (azimuth > 180 && azimuth < 270)
                    {
                        locationContent.Azimuth = "南偏西\t" + (azimuth - 270).ToString("0.000") + "°";
                    }
                    else if (azimuth == 270)
                    {
                        locationContent.Azimuth = "西";
                    }
                    else if (azimuth > 270 && azimuth < 360)
                    {
                        locationContent.Azimuth = "北偏西\t" + (360 - azimuth).ToString("0.000") + "°";
                    }

                    locationBox.Add(locationContent);
                }
                InspectionList.ItemsSource = locationBox;
            }

            ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }