예제 #1
0
        private void EmailNext()
        {
            if (0 == EmailBox.Text.Length)
            {
                RunningDatas.ErrorNotify("注册邮箱不能为空");
                return;
            }

            if (!Utils.Utils.IsEmail(EmailBox.Text))
            {
                RunningDatas.ErrorNotify("注册邮箱无效");
                return;
            }

            RunningDatas.RequestTable.TryAdd(RequestID, this);
            if (RunningDatas.DataSender.RegistEmailReq
                (
                    RequestID,
                    new KXTNetStruct.RegistEmailReq
            {
                Email = EmailBox.Text
            }
                ))
            {
                NextButton.Visibility  = Visibility.Collapsed;
                RingControl.Visibility = Visibility.Visible;
                RingControl.IsActive   = true;

                OperationTimer.Start();
            }
            else
            {
                RunningDatas.InfoNotify("无法连接到网络");
            }
        }
예제 #2
0
        private void OnReceice(IAsyncResult ar)
        {
            try
            {
                int count = Server.EndReceive(ar);
                if (Datagram.DatagramDataHead <= count)
                {
                    Action <byte[]> action = OnProcess;
                    byte[]          buffer = new byte[count];
                    Array.Copy(Buffer, 0, buffer, 0, count);
                    action.BeginInvoke(buffer, null, null);
                }
            }
            catch
            {
            }

            try
            {
                if (IsConnect)
                {
                    Server.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, OnReceice, null);
                }
            }
            catch
            {
                if (IsConnect)
                {
                    Disconnect();
                    RunningDatas.ErrorNotify("程序错误 无法接收网络消息 请重新启动软件后重试");
                }
            }
        }
예제 #3
0
        public void RequestCallback(object response)
        {
            OperationTimer.Stop();

            UserIDBox.IsEnabled    = true;
            UserPassword.IsEnabled = true;
            OKButton.IsEnabled     = true;
            CancelButton.IsEnabled = true;

            ProgressWaitBar.Visibility      = Visibility.Collapsed;
            ProgressWaitBar.IsIndeterminate = false;
            ProgressWaitBar.ShowPaused      = false;
            ProgressWaitBar.ShowError       = false;

            LoginResponse res = response as LoginResponse;

            if (LoginResult.Success != res.LoginResult)
            {
                RunningDatas.ErrorNotify("用户无法验证登录");
                return;
            }

            LocalDB.AddAccount(Request.UserID, Request.UserPW, Request.UserIDType);

            _ = Dispatcher.RunAsync
                (
                Windows.UI.Core.CoreDispatcherPriority.Normal,
                new Windows.UI.Core.DispatchedHandler(() =>
            {
                Hide();
            }
                                                      ));
        }
        private void SearchButton_Click(object sender, RoutedEventArgs e)
        {
            FriendAndGroupList.Items.Clear();

            if (0 == SearchBox.Text.Length)
            {
                RunningDatas.ErrorNotify("查询条件不能为空!");
                return;
            }

            KXTNetStruct.SearchReq req = new KXTNetStruct.SearchReq
            {
                SearchString = SearchBox.Text
            };
            if ((bool)FriendRadioButton.IsChecked)
            {
                req.SearchType = KXTNetStruct.SearchReq.SearchType_User;
            }
            else if ((bool)GroupRadioButton.IsChecked)
            {
                req.SearchType = KXTNetStruct.SearchReq.SearchType_Group;
            }

            RunningDatas.DataSender.SearchReq(RequestID, req);
        }
예제 #5
0
        private void ContentDialog_OKButtonClick(object sender, RoutedEventArgs args)
        {
            if (0 == UserIDBox.Text.Length || 0 == UserPassword.Password.Length)
            {
                RunningDatas.ErrorNotify("用户名与密码不能为空");
                return;
            }

            if (!Utils.Utils.LoginUserCheck(UserIDBox.Text, out KXTNetStruct.Struct.LoginType type))
            {
                RunningDatas.ErrorNotify("无法识别的用户名");
                return;
            }

            Request.UserID     = UserIDBox.Text;
            Request.UserPW     = Utils.Security.SHA1Encode(UserPassword.Password);
            Request.UserIDType = type;

            RunningDatas.RequestTable.TryAdd(RequestID, this);
            RunningDatas.DataSender.Login(RequestID, Request);

            OperationTimer.Start();

            UserIDBox.IsEnabled    = false;
            UserPassword.IsEnabled = false;
            OKButton.IsEnabled     = false;
            CancelButton.IsEnabled = false;

            ProgressWaitBar.Visibility      = Visibility.Visible;
            ProgressWaitBar.IsIndeterminate = true;
            ProgressWaitBar.ShowPaused      = false;
            ProgressWaitBar.ShowError       = false;
        }
예제 #6
0
        public void CreateDownload(Guid stream_id, StorageFolder path, string name, int length)
        {
            Download download;

            try
            {
                download = new Download(path, name, length);
            }
            catch
            {
                RunningDatas.ErrorNotify
                (
                    string.Format
                    (
                        " 创建下载任务失败:{0} \n\r 无法写入到文件",
                        name
                    )
                );
                return;
            }

            if (!FileCache.TryAdd(stream_id, download))
            {
                download.Clear();
                RunningDatas.ErrorNotify
                (
                    string.Format
                    (
                        " 创建下载任务失败:{0} ",
                        name
                    )
                );
            }
        }
예제 #7
0
        private void CacheFresh_Trigger(object sender, System.Timers.ElapsedEventArgs args)
        {
            if (0 < FileCache.Count)
            {
                foreach (var item in FileCache)
                {
                    item.Value.Flush();

                    if (item.Value.Invaild)
                    {
                        item.Value.Close();
                        FileCache.TryRemove(item.Key, out _);

                        RunningDatas.ErrorNotify
                        (
                            string.Format
                            (
                                " {0}超时 \n\r 文件:{1} ",
                                item.Value.GetStreamType() == StreamType.Download ? "下载" : "上传",
                                item.Value.GetName()
                            )
                        );
                    }
                    else if ((DateTime.Now - item.Value.Time).TotalMilliseconds > CacheVaildTime)
                    {
                        item.Value.Invaild = true;
                    }
                }
            }

            CacheTimer.Start();
        }
예제 #8
0
        private void OnMain_HeartRequest(Datagram datagram)
        {
            datagram.DataType    = DatagramType.Client;
            datagram.MessageType = MainMessageType.HeartResponse;

            if (!Send(datagram))
            {
                Disconnect();
                RunningDatas.ErrorNotify("网络连接失败 请重启软件后重试");
            }
        }
예제 #9
0
        private void VerificationNext()
        {
            if (0 == VerificationBox.Text.Length)
            {
                RunningDatas.ErrorNotify("验证码不能为空");
                return;
            }

            if (8 > VerificationBox.Text.Length)
            {
                RunningDatas.ErrorNotify("验证码无效");
                return;
            }

            if (!Utils.Utils.ConvertVerifyCode(VerificationBox.Text, out byte[] value))
예제 #10
0
        public void CreateUpload(Guid stream_id, StorageFile file)
        {
            Upload upload = new Upload(file);

            if (!FileCache.TryAdd(stream_id, upload))
            {
                upload.Close();
                RunningDatas.ErrorNotify
                (
                    string.Format
                    (
                        " 创建上传任务失败:{0} ",
                        file.Path + "\\" + file.Name
                    )
                );
            }
        }
예제 #11
0
        private void OperationTimer_Trigger(object sender, System.Timers.ElapsedEventArgs args)
        {
            _ = Dispatcher.RunAsync
                    (Windows.UI.Core.CoreDispatcherPriority.Normal,
                    new Windows.UI.Core.DispatchedHandler(() =>
            {
                UserIDBox.IsEnabled    = true;
                UserPassword.IsEnabled = true;
                OKButton.IsEnabled     = true;
                CancelButton.IsEnabled = true;

                ProgressWaitBar.Visibility      = Visibility.Collapsed;
                ProgressWaitBar.IsIndeterminate = false;
                ProgressWaitBar.ShowPaused      = false;
                ProgressWaitBar.ShowError       = false;
            }));

            RunningDatas.RequestTable.TryRemove(RequestID, out _);

            RunningDatas.ErrorNotify("登录超时 请重试");
        }
예제 #12
0
        private async void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            if (!OperationWaiting.IsIndeterminate)
            {
                if (ListViewSelectionMode.Single == FilesGridView.SelectionMode)
                {
                    if (-1 != FilesGridView.SelectedIndex)
                    {
                        TemporaryFilesList file = FilesGridView.SelectedItem as TemporaryFilesList;
                        if (FileType.Folder == file.Type)
                        {
                            RunningDatas.ErrorNotify("不能下载文件夹");
                            return;
                        }

                        StorageFolder folder = await GetFolder();

                        if (null == folder)
                        {
                            return;
                        }

                        RunningDatas.FileWaiting.Add
                        (
                            FolderPath.Text,
                            file.Name,
                            new FileReqPackage
                        {
                            FileName = file.Name,
                            Path     = folder,
                            Size     = file.Size,
                            Type     = StreamType.Download
                        }
                        );
                    }
                    else
                    {
                        RunningDatas.ErrorNotify("请选择需要下载的文件");
                    }
                }
                else
                {
                    if (0 != FilesGridView.SelectedItems.Count)
                    {
                        StorageFolder folder = await GetFolder();

                        if (null == folder)
                        {
                            return;
                        }

                        foreach (var i in FilesGridView.SelectedItems)
                        {
                            TemporaryFilesList item = i as TemporaryFilesList;

                            if (FileType.Folder == item.Type)
                            {
                                RunningDatas.InfoNotify("不能下载文件夹:" + item.Name);
                                return;
                            }

                            RunningDatas.FileWaiting.Add
                            (
                                FolderPath.Text,
                                item.Name,
                                new FileReqPackage
                            {
                                FileName = item.Name,
                                Path     = folder,
                                Size     = item.Size,
                                Type     = StreamType.Download
                            }
                            );
                        }
                    }
                    else
                    {
                        RunningDatas.ErrorNotify("请选择需要下载的文件");
                    }
                }
            }
        }
예제 #13
0
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if (!OperationWaiting.IsIndeterminate)
            {
                if (ListViewSelectionMode.Single == FilesGridView.SelectionMode)
                {
                    if (-1 != FilesGridView.SelectedIndex)
                    {
                        TemporaryFilesList file = FilesGridView.SelectedItem as TemporaryFilesList;
                        if (FileType.Folder == file.Type)
                        {
                            RunningDatas.DataSender.DeleteFolder(new DeleteFolderFile
                            {
                                Path = FolderPath.Text,
                                Name = file.Name
                            });
                        }
                        else
                        {
                            RunningDatas.DataSender.DeleteFile(new DeleteFolderFile
                            {
                                Path = FolderPath.Text,
                                Name = file.Name
                            });
                        }
                        RequestFiles();
                    }
                    else
                    {
                        RunningDatas.ErrorNotify("请选择需要删除的文件或文件夹");
                    }
                }
                else
                {
                    if (0 != FilesGridView.SelectedItems.Count)
                    {
                        foreach (var i in FilesGridView.SelectedItems)
                        {
                            TemporaryFilesList item = i as TemporaryFilesList;

                            if (FileType.Folder == item.Type)
                            {
                                RunningDatas.DataSender.DeleteFolder(new DeleteFolderFile
                                {
                                    Path = FolderPath.Text,
                                    Name = item.Name
                                });
                            }
                            else
                            {
                                RunningDatas.DataSender.DeleteFile(new DeleteFolderFile
                                {
                                    Path = FolderPath.Text,
                                    Name = item.Name
                                });
                            }
                            RequestFiles();
                        }
                    }
                    else
                    {
                        RunningDatas.ErrorNotify("请选择需要删除的文件或文件夹");
                    }
                }
            }
        }