static void Main(string[] args) { Console.WriteLine("Hello World!"); String user = ""; String pwd = ""; PublicVariable4CS.ServerIP = INIhelp.GetValue("serverip"); PublicVariable4CS.ServerPort = int.Parse(INIhelp.GetValue("serverport")); Console.WriteLine("请输入用户名!"); PublicVariable4CS.UserName = Console.ReadLine(); Console.WriteLine("请输入密码!"); PublicVariable4CS.PassWord = Console.ReadLine(); getLink(); Console.WriteLine("请输入指令!输入 help 查看指令表"); while (true) { String command = ""; Console.Write("PCC>>:"); command = Console.ReadLine(); commandTable(command); } }
static void getLink() { string link_str = INIhelp.GetValue("link");//读取历史转发记录并自动填写 ipconfigList = new List <Hashtable>(); if (link_str.Length > 0) { string[] links = link_str.Split('|'); for (int i = 0; i < links.Length; i++) { Hashtable hashtable = new Hashtable(); string[] tmp = links[i].Split(';'); string[] tmptmp = tmp[0].Split(':'); hashtable.Add("AG_IP", tmptmp[0]); hashtable.Add("AG_PORT", tmptmp[1]); tmptmp = tmp[1].Split(':'); hashtable.Add("RM_IP", tmptmp[0]); hashtable.Add("RM_PORT", tmptmp[1]); ipconfigList.Add(hashtable); } } }
public Login() { InitializeComponent(); string userid = INIhelp.GetValue("userid"); string userpwd = INIhelp.GetValue("userpwd"); string serverIp = INIhelp.GetValue("serverip"); string serverPort = INIhelp.GetValue("serverport"); string saveUser = INIhelp.GetValue("saveuser"); if (!"false".Equals(INIhelp.GetValue("isNewVersion"))) { updateMessage updateM = new updateMessage(); INIhelp.SetValue("isNewVersion", "false"); updateM.ShowDialog(); // 模式窗体 } this.serverIP.Text = serverIp; this.serverPort.Text = serverPort; this.userName.Text = userid; this.passWord.Text = userpwd; if ("true" == saveUser) { this.saveUsername.Checked = true; } else { this.saveUsername.Checked = false; } }
private IEnumerable <t_finace> GetFinacesWithPlateType(int order, string date1, string date2, string ptype, int index) { string key = "Codes"; float rate = -100; var codeArray = INIhelp.GetValue(key, ptype).Split(','); var t_finaces = proc.ProcServer.ExecFinanceProc(rate, order, date1, date2.IsDateTime() ? date2 : date1); var pd = t_finaces.Where(d => codeArray.Contains(d.Code)).ToList().ToPagedList(index, pageSize); return(pd); }
static void Main(string[] args) { int serverPort = int.Parse(INIhelp.GetValue("port")); Boolean offline = false; if (INIhelp.GetValue("offline") == "true") { offline = true; } TcpListener tl = new TcpListener(serverPort); //IPEndPoint ipe = new IPEndPoint(serverPort); tl.Start(); while (true) { try { TcpClient tc1 = tl.AcceptTcpClient();//这里是等待数据再执行下边,不会100%占用cpu Console.WriteLine("线程数:" + threadCount); NetworkStream ns1 = tc1.GetStream(); byte[] bt = new byte[10240]; int count = ns1.Read(bt, 0, bt.Length); string str = System.Text.Encoding.UTF8.GetString(bt); Hashtable message = getMessages(str); Hashtable reMessage = new Hashtable(); if ((string)message["TYPE"] == "LOGIN") { float ver = float.Parse((string)message["VER"]); if (ver < float.Parse(INIhelp.GetValue("ver"))) { reMessage.Add("TYPE", "LOGIN-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "客户端版本过低!当前版本 v" + ver + ",请更新至 v" + INIhelp.GetValue("ver")); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } if (!offline) { DataTable dt = queryUserLoginMessage((string)message["USER"]); if (dt.Rows.Count <= 0) { reMessage.Add("TYPE", "LOGIN-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "用户不存在!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } String pwd = dt.Rows[0]["PASSWORD"].ToString(); String username = dt.Rows[0]["userdesc"].ToString(); String inherit = dt.Rows[0]["inherit"].ToString(); if ((string)message["PWD"] == pwd) { reMessage.Add("TYPE", "LOGIN-RE"); reMessage.Add("RE_ANSWER", "TRUE"); reMessage.Add("USERDESC", username); if (inherit == "admin") { reMessage.Add("INHERIT", "ADMIN"); } else { reMessage.Add("INHERIT", "USER"); } byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } else { reMessage.Add("TYPE", "LOGIN-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "密码错误!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } continue; } else { if ((string)message["USER"] == "zdkj") { if ((string)message["PWD"] == "scyy@68669820") { reMessage.Add("TYPE", "LOGIN-RE"); reMessage.Add("RE_ANSWER", "TRUE"); reMessage.Add("USERDESC", "离线管理账户"); reMessage.Add("INHERIT", "ADMIN"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } } else { reMessage.Add("TYPE", "LOGIN-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "用户不存在!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } continue; } } else if ((string)message["TYPE"] == "CONNECT") { float ver = float.Parse((string)message["VER"]); if (ver < float.Parse(INIhelp.GetValue("ver"))) { reMessage.Add("TYPE", "CONNECT-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "客户端版本过低!当前版本 v" + ver + ",请更新至 v" + INIhelp.GetValue("ver")); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } if (!offline) { DataTable dt = queryUserLicense((string)message["USER"], (string)message["PWD"], (string)message["TOTAL_IP"], (string)message["TOTAL_PORT"]); if (int.Parse(dt.Rows[0]["License"].ToString()) <= 0) { reMessage.Add("TYPE", "CONNECT-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "权限不足"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } else { try { TcpClient tc2 = new TcpClient((string)message["TOTAL_IP"], int.Parse((string)message["TOTAL_PORT"])); ThreadMessage threadMessage1 = new ThreadMessage(); ThreadMessage threadMessage2 = new ThreadMessage(); threadMessage1.TOTAL_IP = (string)message["TOTAL_IP"]; threadMessage2.TOTAL_IP = (string)message["TOTAL_IP"]; threadMessage1.TOTAL_PORT = (string)message["TOTAL_PORT"]; threadMessage2.TOTAL_PORT = (string)message["TOTAL_PORT"]; reMessage.Add("TYPE", "CONNECT-RE"); reMessage.Add("RE_ANSWER", "TRUE"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); threadMessage1.tc1 = tc1; threadMessage1.tc2 = tc2; threadMessage2.tc1 = tc2; threadMessage2.tc2 = tc1; threadMessage1.type = "user"; threadMessage2.type = "target"; //object obj1 = (object)(new TcpClient[] { tc1, tc2 }); //object obj2 = (object)(new TcpClient[] { tc2, tc1 }); object obj1 = (object)threadMessage1; object obj2 = (object)threadMessage2; ThreadPool.QueueUserWorkItem(new WaitCallback(transfer), obj1); ThreadPool.QueueUserWorkItem(new WaitCallback(transfer), obj2); } catch (Exception ex) { reMessage.Add("TYPE", "CONNECT-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", ex.Message); byte[] byteArray1 = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray1, 0, byteArray1.Length); continue; } //TcpClient tc2 = new TcpClient("172.30.200.50", 3389); } continue; } else { try { TcpClient tc2 = new TcpClient((string)message["TOTAL_IP"], int.Parse((string)message["TOTAL_PORT"])); reMessage.Add("TYPE", "CONNECT-RE"); reMessage.Add("RE_ANSWER", "TRUE"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); object obj1 = (object)(new TcpClient[] { tc1, tc2 }); object obj2 = (object)(new TcpClient[] { tc2, tc1 }); ThreadPool.QueueUserWorkItem(new WaitCallback(transfer), obj1); ThreadPool.QueueUserWorkItem(new WaitCallback(transfer), obj2); } catch (Exception ex) { reMessage.Add("TYPE", "CONNECT-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", ex.Message); byte[] byteArray1 = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray1, 0, byteArray1.Length); continue; } continue; } } else if ((string)message["TYPE"] == "CHANGPWD") { float ver = float.Parse((string)message["VER"]); if (ver < float.Parse(INIhelp.GetValue("ver"))) { reMessage.Add("TYPE", "CHANGPWD-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "客户端版本过低!当前版本 v" + ver + ",请更新至 v" + INIhelp.GetValue("ver")); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } DataTable dt = queryUserLoginMessage((string)message["USER"]); if (dt.Rows.Count <= 0) { reMessage.Add("TYPE", "CHANGPWD-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "用户不存在!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } String pwd = dt.Rows[0]["PASSWORD"].ToString(); String username = dt.Rows[0]["userdesc"].ToString(); String inherit = dt.Rows[0]["inherit"].ToString(); if ((string)message["PWD"] == pwd) { updateUserPwd((string)message["USER"], (string)message["NEWPWD"]); reMessage.Add("TYPE", "CHANGPWD-RE"); reMessage.Add("RE_ANSWER", "TRUE"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } else { reMessage.Add("TYPE", "CHANGPWD-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "原密码错误!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } } else if ((string)message["TYPE"] == "CHANGENAME") { float ver = float.Parse((string)message["VER"]); if (ver < float.Parse(INIhelp.GetValue("ver"))) { reMessage.Add("TYPE", "CHANGENAME-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "客户端版本过低!当前版本 v" + ver + ",请更新至 v" + INIhelp.GetValue("ver")); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } DataTable dt = queryUserLoginMessage((string)message["USER"]); if (dt.Rows.Count <= 0) { reMessage.Add("TYPE", "CHANGENAME-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "用户不存在!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } String pwd = dt.Rows[0]["PASSWORD"].ToString(); String username = dt.Rows[0]["userdesc"].ToString(); String inherit = dt.Rows[0]["inherit"].ToString(); if ((string)message["PWD"] == pwd) { updateUserName((string)message["USER"], (string)message["NEWDESC"]); reMessage.Add("TYPE", "CHANGENAME-RE"); reMessage.Add("RE_ANSWER", "TRUE"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } else { reMessage.Add("TYPE", "CHANGENAME-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "原密码错误!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } } else if ((string)message["TYPE"] == "RESET-USER-PWD") { float ver = float.Parse((string)message["VER"]); if (ver < float.Parse(INIhelp.GetValue("ver"))) { reMessage.Add("TYPE", "RESET-USER-PWD-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "客户端版本过低!当前版本 v" + ver + ",请更新至 v" + INIhelp.GetValue("ver")); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } DataTable dt = queryUserLoginMessage((string)message["USER"]); if (dt.Rows.Count <= 0) { reMessage.Add("TYPE", "RESET-USER-PWD-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "用户不存在!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); continue; } String pwd = dt.Rows[0]["PASSWORD"].ToString(); String username = dt.Rows[0]["userdesc"].ToString(); String inherit = dt.Rows[0]["inherit"].ToString(); if ((string)message["PWD"] == pwd) { updateTargetUserPwd((string)message["TARGET-USER"]); reMessage.Add("TYPE", "RESET-USER-PWD-RE"); reMessage.Add("RE_ANSWER", "TRUE"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } else { reMessage.Add("TYPE", "CHANGENAME-RE"); reMessage.Add("RE_ANSWER", "FALSE"); reMessage.Add("RE_MESSAGE", "你的密码错误!"); byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(setMessages(reMessage)); ns1.Write(byteArray, 0, byteArray.Length); } } else { continue; } } catch (Exception ex) { errorMessage(ex); } } }
public mainForm() { InitializeComponent(); Login login = new Login(); login.Visible = false; login.ShowDialog(); this.userDesc.Text = PublicVariable4CS.UserDesc; if (!PublicVariable4CS.login) { Environment.Exit(0); } string link_str = INIhelp.GetValue("link");//读取历史转发记录并自动填写 if (link_str.Length > 0) { string[] links = link_str.Split('|'); for (int i = 0; i < links.Length; i++) { this.portList.Rows.Add(); DataGridViewRow dgvr = this.portList.Rows[i]; string[] tmp = links[i].Split(';'); string[] tmptmp = tmp[0].Split(':'); dgvr.Cells[0].Value = tmptmp[0]; dgvr.Cells[1].Value = tmptmp[1]; tmptmp = tmp[1].Split(':'); dgvr.Cells[2].Value = tmptmp[0]; dgvr.Cells[3].Value = tmptmp[1]; } } label1.BackColor = Color.Transparent; userDesc.BackColor = Color.Transparent; startPort.BackColor = Color.Transparent; this.toolStripMenuItem2.Text = "开启端口映射"; if (PublicVariable4CS.INHERIT == "ADMIN") { this.adminBox.Visible = false; } else { this.adminBox.Visible = false; } /*this.portList.Rows.Add(); * * * DataGridViewRow dgvr = this.portList.Rows[0]; * dgvr.Cells[0].Value = 3; * dgvr.Cells[1].Value = "直接添加一行"; * dgvr.Cells[2].Value = 3; * dgvr.Cells[3].Value = "直接添加一行";*/ }
public async Task <JsonResult> GetChanges(string ptype) { IEnumerable <t_change> changesList = new List <t_change>(); Dictionary <string, int> dic = new Dictionary <string, int>(); if (String.IsNullOrEmpty(ptype)) { return(Json(changesList)); } if (int.TryParse(ptype, out int _page)) { int _size = 10; int _skip = _page * _size; changesList = await(from v in db.ChangesList where v.Date_x == db.ChangesList.Max(dx => dx.Date_x) select v) .OrderByDescending(v => v.Change_x - v.Change_9) .ThenByDescending(v => v.Change_9 - v.Change_8) .ThenByDescending(v => v.Change_8 - v.Change_7) .ThenByDescending(v => v.Change_7 - v.Change_6) .ThenByDescending(v => v.Change_6 - v.Change_5) .ThenByDescending(v => v.Change_5 - v.Change_4) .ThenByDescending(v => v.Change_4 - v.Change_3) .ThenByDescending(v => v.Change_3 - v.Change_2) .ThenByDescending(v => v.Change_2 - v.Change_1) .ThenByDescending(v => v.Change_1) .Take(_skip + _size).Skip(_skip).ToArrayAsync(); } else { string key = "Codes"; var codeArray = INIhelp.GetValue(key, ptype).Split(','); changesList = await(from v in db.ChangesList where v.Date_x == db.ChangesList.Max(dx => dx.Date_x) select v).Where(v => codeArray.Contains(v.Code)).OrderByDescending(v => v.Change_x - v.Change_9) .OrderByDescending(v => v.Change_x - v.Change_9) .ThenByDescending(v => v.Change_9 - v.Change_8) .ThenByDescending(v => v.Change_8 - v.Change_7) .ThenByDescending(v => v.Change_7 - v.Change_6) .ThenByDescending(v => v.Change_6 - v.Change_5) .ThenByDescending(v => v.Change_5 - v.Change_4) .ThenByDescending(v => v.Change_4 - v.Change_3) .ThenByDescending(v => v.Change_3 - v.Change_2) .ThenByDescending(v => v.Change_2 - v.Change_1) .ThenByDescending(v => v.Change_1).ToArrayAsync(); dic = TotalSamples(codeArray); } var pd = changesList.Select(d => new { name = String.Format("{0}({1})", d.Name, (dic.ContainsKey(d.Code) ? dic[d.Code].ToString() : "")), type = "line", axis = new string[] { d.Date_1, d.Date_2, d.Date_3, d.Date_4, d.Date_5, d.Date_6, d.Date_7, d.Date_8, d.Date_9, d.Date_x }, data = new decimal?[] { d.Change_1, d.Change_2, d.Change_3, d.Change_4, d.Change_5, d.Change_6, d.Change_7, d.Change_8, d.Change_9, d.Change_x } }); return(Json(pd)); }
public IEnumerable <string> GetPlateCodes(string pkey) { return(INIhelp.GetValue("Codes", pkey).Split(',').AsEnumerable()); }
public IEnumerable <string> GetPlateTypes() { return(INIhelp.GetValue("PlateType", "plateType").Split(',').AsEnumerable()); }