private void userButton_login_Click(object sender, EventArgs e)
        {
            // 点击了注册,先获取数据
            UserAccount account = new UserAccount();

            account.UserName  = textBox1.Text;
            account.NameAlias = textBox3.Text;
            account.Password  = textBox2.Text;
            account.Factory   = comboBox_factory.SelectedItem.ToString();
            switch (comboBox1.SelectedIndex)
            {
            case 0: account.Grade = AccountGrade.SuperAdministrator; break;

            case 1: account.Grade = AccountGrade.Admin; break;

            case 2: account.Grade = AccountGrade.Technology; break;

            default: account.Grade = AccountGrade.General; break;
            }
            account.LoginEnable   = comboBox2.SelectedItem.ToString() == "允许";
            account.ForbidMessage = textBox4.Text;

            OperateResultString result = net_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.注册账号, account.ToJsonString());

            if (result.IsSuccess && result.Content == "1")
            {
                MessageBox.Show("注册成功!");
            }
            else
            {
                MessageBox.Show("注册失败!");
            }
        }
Ejemplo n.º 2
0
        private void userButton3_Click(object sender, EventArgs e)
        {
            List <string> list = new List <string>();

            foreach (var m in listBox1.Items)
            {
                if (!string.IsNullOrEmpty(m.ToString()))
                {
                    list.Add(m.ToString());
                }
            }

            JObject json = new JObject
            {
                { "TrustEnable", new JValue(checkBox1.Checked) },
                { "TrustList", new JArray(list.ToArray()) }
            };

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(
                CommonLibrary.CommonHeadCode.SimplifyHeadCode.信任客户端, json.ToString());

            if (result.IsSuccess)
            {
                MessageBox.Show("上传成功!");
            }
            else
            {
                MessageBox.Show("上传失败!");
            }
        }
Ejemplo n.º 3
0
        private void userButton4_Click(object sender, EventArgs e)
        {
            // save
            List <RoleItem> roles = new List <RoleItem>();

            foreach (var m in listBox1.Items)
            {
                if (m is RoleItem item)
                {
                    roles.Add(item);
                }
            }

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(
                CommonHeadCode.SimplifyHeadCode.角色配置, JArray.FromObject(roles).ToString());

            if (result.IsSuccess)
            {
                MessageBox.Show("上传数据成功!");
            }
            else
            {
                MessageBox.Show("上传数据失败:" + result.Message);
            }
        }
        private void FactoryConfiguration_Load(object sender, EventArgs e)
        {
            dataGridView1.Columns[0].HeaderText = HeadText;

            // 向服务器请求数据初始化
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(Download, "");

            if (result.IsSuccess)
            {
                List <string> ListData = Newtonsoft.Json.Linq.JArray.Parse(result.Content).ToObject <List <string> >();

                for (int i = 0; i < ListData.Count; i++)
                {
                    int rowIndex = dataGridView1.Rows.Add();
                    dataGridView1.Rows[rowIndex].Cells[0].Value = ListData[i];
                }
            }
            else
            {
                MessageBox.Show(result.Message);
                userButton_save.Enabled = false;
            }

            // 本地化支持
            UILocalization();
        }
 public ActionResult RegisterAccount(FormCollection fc)
 {
     if (Request.IsAjaxRequest())
     {
         try
         {
             UserAccount account = new UserAccount();
             account.UserName      = fc["username"];
             account.NameAlias     = fc["alias"];
             account.Password      = fc["password"];
             account.Factory       = fc["factory"];
             account.Grade         = int.Parse(fc["grade"]);
             account.LoginEnable   = bool.Parse(fc["loginEnable"]);
             account.ForbidMessage = fc["reason"];
             OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.注册账号, account.ToJsonString());
             if (result.IsSuccess && result.Content == "1")
             {
                 return(PartialViewMessage(MessageBoxStyle.success, "账户注册成功!"));
             }
             else
             {
                 return(PartialViewMessage(MessageBoxStyle.warning, "账户注册失败!"));
             }
         }
         catch
         {
             return(PartialViewMessage(MessageBoxStyle.danger, "数据异常!"));
         }
     }
     else
     {
         return(PartialViewMessage(MessageBoxStyle.danger, "请求无效!"));
     }
 }
        public ActionResult SendMessage(FormCollection fc)
        {
            if (Request.IsAjaxRequest())
            {
                string      SendMessage = fc["SendMessage"];
                UserAccount account     = Session[SessionItemsDescription.UserAccount] as UserAccount;

                if (SendMessage.Length > 1000)
                {
                    return(PartialViewMessage(MessageBoxStyle.warning, "需要发送的字数超过了1000字!"));
                }


                OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.群发消息, SendMessage);
                if (result.IsSuccess)
                {
                    UserClient.Announcement = SendMessage;
                    return(PartialViewMessage(MessageBoxStyle.success, "消息群发成功!"));
                }
                else
                {
                    return(PartialViewMessage(MessageBoxStyle.danger, result.Message));
                }
            }
            else
            {
                return(PartialViewMessage(MessageBoxStyle.danger, "请求无效!"));
            }
        }
Ejemplo n.º 7
0
        private void FileDeleteButton_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //删除文件
            if (Hufile.UploadName != UserClient.UserAccount.UserName)
            {
                MessageBox.Show("无法删除不是自己上传的文件。");
                return;
            }
            if (MessageBox.Show("请确认是否真的删除?", "删除确认", MessageBoxButton.YesNo) == MessageBoxResult.No)
            {
                return;
            }

            //确认删除
            OperateResultString result = SimpleFileClient.DeleteFile(UserClient.ServerIp, CommonLibrary.CommonLibrary.Port_Share_File, Hufile.FileName);

            if (result.IsSuccess)
            {
                MessageBox.Show("删除成功!");
            }
            else
            {
                MessageBox.Show("删除失败!原因:" + result.Message);
            }
        }
Ejemplo n.º 8
0
        private void ClientConfiguration_Load(object sender, EventArgs e)
        {
            // 初始化

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求信任客户端, "");

            if (result.IsSuccess)
            {
                JObject json = JObject.Parse(result.Content);
                checkBox1.Checked = json["TrustEnable"].ToObject <bool>();
                string[] data = json["TrustList"].ToObject <string[]>();
                foreach (var m in data)
                {
                    listBox1.Items.Add(m);
                }
            }
            else
            {
                MessageBox.Show("请求服务器失败,请稍后重试!");
                userButton3.Enabled = false;
            }

            // 本地化
            UILocalization();
        }
Ejemplo n.º 9
0
        private void ClearFromServer(int head_code)
        {
            OperateResultString result = net_simplify_client.ReadFromServer(head_code);

            if (result.IsSuccess)
            {
                MessageBox.Show("清除成功");
            }
            else
            {
                MessageBox.Show(result.ToMessageShowString());
            }
        }
Ejemplo n.º 10
0
        private void ReadFromServer(string head_code)
        {
            OperateResultString result = net_simplify_client.ReadFromServer(head_code);

            if (result.IsSuccess)
            {
                textBox1.Text = result.Content;
            }
            else
            {
                textBox1.Text = result.ToMessageShowString();
            }
        }
Ejemplo n.º 11
0
        private void ClearFromServer(int head_code)
        {
            OperateResultString result = net_simplify_client.ReadFromServer(head_code);

            if (result.IsSuccess)
            {
                textBox1.Text = "清除成功";
            }
            else
            {
                textBox1.Text = result.ToMessageShowString();
            }
        }
        private void userButton_version_Click(object sender, EventArgs e)
        {
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.更新版本, textBox1.Text);

            if (result.IsSuccess && result.Content == "1")
            {
                MessageBox.Show("更新成功!");
            }
            else
            {
                MessageBox.Show("更新失败!原因:" + result.ToMessageShowString());
            }
        }
Ejemplo n.º 13
0
        private void ReadFromServer(int head_code)
        {
            OperateResultString result = net_simplify_client.ReadFromServer(head_code);

            if (result.IsSuccess)
            {
                logNetAnalysisControl1.SetLogNetSource(result.Content);
            }
            else
            {
                MessageBox.Show(result.ToMessageShowString());
            }
        }
Ejemplo n.º 14
0
        public ActionResult ManagementAccount()
        {
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.获取账户);

            if (result.IsSuccess)
            {
                ViewData["accounts"] = result.Content;
            }
            else
            {
                ViewData["accounts"] = "数据获取失败:" + result.ToMessageShowString();
            }
            return(View());
        }
Ejemplo n.º 15
0
        private void ThreadRequestServer()
        {
            //后台请求数据
            System.Threading.Thread.Sleep(100);
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(net_cmd);

            Invoke(new Action(() =>
            {
                DealWithResult(result);
                time.Stop();
                System.Threading.Thread.Sleep(20);
                Dispose();
            }));
        }
Ejemplo n.º 16
0
        private void userButton_refresh_Click(object sender, EventArgs e)
        {
            //向服务器请求数据
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求文件);

            if (result.IsSuccess)
            {
                Cache_Files = JArray.Parse(result.Content).ToObject <List <HslSoftFile> >();
                SetFilesShow(Cache_Files);
            }
            else
            {
                MessageBox.Show(result.ToMessageShowString());
            }
        }
Ejemplo n.º 17
0
        public void DownloadUserPortraint(string path)
        {
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.载小头, UserClient.UserAccount.UserName);

            if (result.IsSuccess)
            {
                if (result.Content[0] == 'Y')
                {
                    byte[] data   = Convert.FromBase64String(result.Content.Substring(1));
                    string path32 = path + @"\" + PortraitSupport.SmallPortrait;
                    System.IO.File.WriteAllBytes(path32, data);
                    LoadPic?.Invoke(path32);
                }
            }
        }
Ejemplo n.º 18
0
        public void ThreadPoolDownloadSizeLarge()
        {
            string path = FileSavePath;
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.载大头, UserClient.UserAccount.UserName);

            if (result.IsSuccess)
            {
                if (result.Content[0] == 'Y')
                {
                    byte[] data   = Convert.FromBase64String(result.Content.Substring(1));
                    string path32 = path + @"\" + PortraitSupport.LargePortrait;
                    System.IO.File.WriteAllBytes(path32, data);
                    System.Diagnostics.Process.Start(path32);
                }
            }
            Thread.Sleep(1000);
        }
Ejemplo n.º 19
0
        private void MenuItem账户管理_Click(object sender, RoutedEventArgs e)
        {
            FormAccountManage fam = new FormAccountManage(() =>
            {
                OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.获取账户);
                if (result.IsSuccess)
                {
                    return(result.Content);
                }
                else
                {
                    return(result.ToMessageShowString());
                }
            }, m => UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.更细账户, m).IsSuccess);

            fam.ShowDialog();
            fam.Dispose();
        }
Ejemplo n.º 20
0
        private void RolesConfiguration_Load(object sender, EventArgs e)
        {
            UILocalization();
            // 初始化

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求角色配置, "");

            if (result.IsSuccess)
            {
                List <RoleItem> roles = JArray.Parse(result.Content).ToObject <List <RoleItem> >();
                roles.ForEach(m => listBox1.Items.Add(m));
            }
            else
            {
                MessageBox.Show("请求服务器失败,请稍后重试!");
                userButton4.Enabled = false;
            }
        }
Ejemplo n.º 21
0
        private void userButton3_Click(object sender, EventArgs e)
        {
            if (CurrentClient != null)
            {
                try
                {
                    NetHandle handle = 0;
                    if (textBox1.Text.IndexOf(".") < 0)
                    {
                        // 纯数字
                        handle = int.Parse(textBox1.Text);
                    }
                    else
                    {
                        string[] values = textBox1.Text.Split('.');
                        handle = new NetHandle(byte.Parse(values[0]), byte.Parse(values[1]), ushort.Parse(values[2]));
                    }

                    int count = int.Parse(textBox4.Text);

                    DateTime start = DateTime.Now;

                    for (int i = 0; i < count; i++)
                    {
                        OperateResultString resultString = CurrentClient.ReadFromServer(handle, textBox2.Text);

                        if (resultString.IsSuccess)
                        {
                            textBox3.AppendText(resultString.Content + Environment.NewLine);
                        }
                        else
                        {
                            textBox3.AppendText("读取失败:" + resultString.Message + Environment.NewLine);
                        }
                    }

                    label_timeSpend.Text = (DateTime.Now - start).TotalSeconds.ToString("F3");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void userButton2_Click(object sender, EventArgs e)
        {
            JObject json = new JObject
            {
                { "AllowUserMulti", new JValue(checkBox1.Checked) },
                { "AllowFrameLogin", new JValue(checkBox2.Checked) },
            };

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(
                CommonLibrary.CommonHeadCode.SimplifyHeadCode.信任客户端, json.ToString());

            if (result.IsSuccess)
            {
                MessageBox.Show("上传成功!");
            }
            else
            {
                MessageBox.Show("上传失败!");
            }
        }
        private void GeneralConfiguration_Load(object sender, EventArgs e)
        {
            // 初始化

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.请求信任客户端, "");

            if (result.IsSuccess)
            {
                JObject json = JObject.Parse(result.Content);
                checkBox1.Checked = HslCommunication.BasicFramework.SoftBasic.GetValueFromJsonObject(json, "AllowUserMulti", false);
            }
            else
            {
                MessageBox.Show("请求服务器失败,请稍后重试!");
                userButton2.Enabled = false;
            }

            // 文本本地化
            UILocalization();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// 客户端向服务器进行请求,请求字符串数据
        /// </summary>
        /// <param name="customer">用户的指令头</param>
        /// <param name="send">发送数据</param>
        /// <param name="sendStatus">发送数据时的进度报告</param>
        /// <param name="receiveStatus">接收数据时的进度报告</param>
        /// <returns></returns>
        public OperateResultString ReadFromServer(
            NetHandle customer,
            string send = null,
            Action <long, long> sendStatus    = null,
            Action <long, long> receiveStatus = null
            )
        {
            var result = new OperateResultString();
            var data   = string.IsNullOrEmpty(send) ? new byte[0] : Encoding.Unicode.GetBytes(send);
            var temp   = ReadFromServerBase(HslCommunicationCode.Hsl_Protocol_User_String, customer, data, sendStatus, receiveStatus);

            result.IsSuccess = temp.IsSuccess;
            result.ErrorCode = temp.ErrorCode;
            result.Message   = temp.Message;
            if (temp.IsSuccess)
            {
                result.Content = Encoding.Unicode.GetString(temp.Content);
            }
            temp = null;
            return(result);
        }
Ejemplo n.º 25
0
        public void DownloadUserPortraint()
        {
            string path = FileSavePath;
            //获取服务器文件名称
            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.请求小头, UserClient.UserAccount.UserName);

            if (result.IsSuccess)
            {
                if (result.Content[0] == 'Y')
                {
                    //服务器存在头像
                    string fileName = path + @"\" + PortraitSupport.SmallPortrait;
                    string FileMd5  = result.Content.Substring(1);
                    if (System.IO.File.Exists(fileName))
                    {
                        //文件文件
                        string currentMd5 = SoftBasic.CalculateFileMD5(fileName);
                        if (currentMd5 == FileMd5)
                        {
                            //加载本地头像
                            LoadPic?.Invoke(fileName);
                        }
                        else
                        {
                            //头像已经换了
                            DownloadUserPortraint(path);
                        }
                    }
                    else
                    {
                        //客户端不存在头像
                        DownloadUserPortraint(path);
                    }
                }
                else
                {
                    //服务器不存在头像,本次加载结束
                }
            }
        }
        public ActionResult SetNewPassword(string inputPassword1, string inputPassword2)
        {
            if (Request.IsAjaxRequest())
            {
                UserAccount account = Session[SessionItemsDescription.UserAccount] as UserAccount;
                if (inputPassword1 != inputPassword2)
                {
                    return(PartialViewMessage(MessageBoxStyle.warning, "两次密码不一致!"));
                }
                if (inputPassword1.Length < 5 || inputPassword1.Length > 8)
                {
                    return(PartialViewMessage(MessageBoxStyle.warning, "密码位数错误,应该在5-8位!"));
                }

                if (!System.Text.RegularExpressions.Regex.IsMatch(inputPassword1, "^[A-Za-z0-9]+$"))
                {
                    return(PartialViewMessage(MessageBoxStyle.warning, "密码包含了特殊字符,只能是字母数字。"));
                }

                JObject json = new JObject
                {
                    { UserAccount.UserNameText, UserClient.UserAccount.UserName },
                    { UserAccount.PasswordText, inputPassword1 }
                };

                OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.密码修改, json.ToString());
                if (result.IsSuccess)
                {
                    return(PartialViewMessage(MessageBoxStyle.success, "密码修改成功!"));
                }
                else
                {
                    return(PartialViewMessage(MessageBoxStyle.danger, result.Message));
                }
            }
            else
            {
                return(PartialViewMessage(MessageBoxStyle.danger, "请求无效!"));
            }
        }
Ejemplo n.º 27
0
        private void FormAccountSelect_Load(object sender, EventArgs e)
        {
            // 初始化

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonLibrary.CommonHeadCode.SimplifyHeadCode.获取账户, "");

            if (result.IsSuccess)
            {
                List <UserAccount> accounts = JArray.Parse(result.Content).ToObject <List <UserAccount> >();
                // 添加到数据表

                foreach (var m in accounts)
                {
                    DataGridViewRow dgvr = dataGridView1.Rows[dataGridView1.Rows.Add()];
                    if (m_selected != null)
                    {
                        if (m_selected.Contains(m.UserName))
                        {
                            dgvr.Cells[0].Value = true;
                        }
                    }

                    dgvr.Cells[1].Value = m.UserName;
                    dgvr.Cells[2].Value = m.NameAlias;
                    dgvr.Cells[3].Value = m.Factory;
                    dgvr.Cells[4].Value = m.RegisterTime.ToString();
                    dgvr.Tag            = m;
                }
            }
            else
            {
                MessageBox.Show("请求服务器失败,请稍后重试!");
            }

            // 本地化
            UILocalization();

            dataGridView1.RowsDefaultCellStyle.SelectionBackColor = dataGridView1.RowsDefaultCellStyle.BackColor;
            dataGridView1.RowsDefaultCellStyle.SelectionForeColor = dataGridView1.RowsDefaultCellStyle.ForeColor;
        }
Ejemplo n.º 28
0
        private void ThreadDownloadFile()
        {
            string save_file_name = AppDomain.CurrentDomain.BaseDirectory + "download\\files";

            if (!Directory.Exists(save_file_name))
            {
                Directory.CreateDirectory(save_file_name);
            }

            save_file_name += "\\" + Hufile.FileName;


            OperateResultString result = SimpleFileClient.DownloadFile(UserClient.ServerIp, CommonLibrary.CommonLibrary.Port_Share_File, Hufile.FileName,
                                                                       (m, n) =>
            {
                Dispatcher.Invoke(new Action(() =>
                {
                    FileDownloadProgress.Value = m * 100d / n;
                }));
            }, save_file_name);

            Dispatcher.Invoke(new Action(() =>
            {
                if (result.IsSuccess)
                {
                    if (MessageBox.Show("下载完成,路径为:" + save_file_name + Environment.NewLine +
                                        "是否打开文件路径?", "打开确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        System.Diagnostics.Process.Start("explorer.exe", @"/select," + save_file_name);
                    }
                }
                else
                {
                    MessageBox.Show("下载失败,错误原因:" + result.Message);
                }
                FileDownloadButton.IsEnabled = true;
            }));
        }
Ejemplo n.º 29
0
        public ActionResult SetManagementAccount(FormCollection fc)
        {
            if (Request.IsAjaxRequest())
            {
                string      Accounts = fc["NewAccounts"];
                UserAccount account  = Session[SessionItemsDescription.UserAccount] as UserAccount;


                OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(CommonHeadCode.SimplifyHeadCode.更细账户, Accounts);
                if (result.IsSuccess)
                {
                    return(PartialViewMessage(MessageBoxStyle.success, "账户更改成功!"));
                }
                else
                {
                    return(PartialViewMessage(MessageBoxStyle.danger, result.Message));
                }
            }
            else
            {
                return(PartialViewMessage(MessageBoxStyle.danger, "请求无效!"));
            }
        }
        private void userButton2_Click(object sender, EventArgs e)
        {
            List <string> data = new List <string>();

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (!string.IsNullOrEmpty(dataGridView1.Rows[i].Cells[0].Value.ToString()))
                {
                    data.Add(dataGridView1.Rows[i].Cells[0].Value.ToString());
                }
            }

            OperateResultString result = UserClient.Net_simplify_client.ReadFromServer(Upload,
                                                                                       Newtonsoft.Json.Linq.JArray.FromObject(data).ToString());

            if (result.IsSuccess)
            {
                MessageBox.Show("修改成功!");
            }
            else
            {
                MessageBox.Show("修改失败!原因:" + result.Message);
            }
        }