chat 서버 기능 추가
This commit is contained in:
102
Project/Dialog/fChat.Designer.cs
generated
Normal file
102
Project/Dialog/fChat.Designer.cs
generated
Normal file
@@ -0,0 +1,102 @@
|
||||
namespace Project.Dialog
|
||||
{
|
||||
partial class fChat
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel4 = new System.Windows.Forms.Panel();
|
||||
this.tbMsg = new System.Windows.Forms.TextBox();
|
||||
this.btnSend = new System.Windows.Forms.Button();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.panel4.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel4
|
||||
//
|
||||
this.panel4.Controls.Add(this.tbMsg);
|
||||
this.panel4.Controls.Add(this.btnSend);
|
||||
this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel4.Location = new System.Drawing.Point(0, 500);
|
||||
this.panel4.Name = "panel4";
|
||||
this.panel4.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.panel4.Size = new System.Drawing.Size(444, 40);
|
||||
this.panel4.TabIndex = 0;
|
||||
//
|
||||
// tbMsg
|
||||
//
|
||||
this.tbMsg.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tbMsg.Font = new System.Drawing.Font("굴림", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(129)));
|
||||
this.tbMsg.Location = new System.Drawing.Point(5, 5);
|
||||
this.tbMsg.Name = "tbMsg";
|
||||
this.tbMsg.Size = new System.Drawing.Size(335, 29);
|
||||
this.tbMsg.TabIndex = 0;
|
||||
//
|
||||
// btnSend
|
||||
//
|
||||
this.btnSend.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.btnSend.Location = new System.Drawing.Point(340, 5);
|
||||
this.btnSend.Name = "btnSend";
|
||||
this.btnSend.Size = new System.Drawing.Size(99, 30);
|
||||
this.btnSend.TabIndex = 1;
|
||||
this.btnSend.Text = "전송";
|
||||
this.btnSend.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.ReadOnly = true;
|
||||
this.richTextBox1.Size = new System.Drawing.Size(444, 500);
|
||||
this.richTextBox1.TabIndex = 1;
|
||||
this.richTextBox1.TabStop = false;
|
||||
this.richTextBox1.Text = "";
|
||||
//
|
||||
// fChat
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(444, 540);
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.panel4);
|
||||
this.Name = "fChat";
|
||||
this.Text = "fChat";
|
||||
this.Load += new System.EventHandler(this.fChat_Load);
|
||||
this.panel4.ResumeLayout(false);
|
||||
this.panel4.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel4;
|
||||
private System.Windows.Forms.TextBox tbMsg;
|
||||
private System.Windows.Forms.Button btnSend;
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
}
|
||||
}
|
||||
91
Project/Dialog/fChat.cs
Normal file
91
Project/Dialog/fChat.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using arTCPService.Shared.Messages;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Project.Dialog
|
||||
{
|
||||
public partial class fChat : Form
|
||||
{
|
||||
|
||||
arTCPService.Server.Receiver client;
|
||||
public fChat(arTCPService.Server.Receiver client_)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.client = client_;
|
||||
this.client.DataSend += Svr_DataSend;
|
||||
this.client.DataReceived += Svr_DataReceived;
|
||||
this.client.ClientDisconnected += Svr_ClientDisconnected;
|
||||
this.client.Message += Svr_Message;
|
||||
this.FormClosed += FChat_FormClosed;
|
||||
this.KeyDown += (s1, e1) =>
|
||||
{
|
||||
if (e1.KeyCode == Keys.Escape) this.Close();
|
||||
};
|
||||
|
||||
tbMsg.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Enter) btnSend.PerformClick(); };
|
||||
btnSend.Click += (s1, e1) =>
|
||||
{
|
||||
this.client.SendMessage(new Packet(Header.Message, tbMsg.Text));
|
||||
tbMsg.SelectAll();
|
||||
tbMsg.Focus();
|
||||
};
|
||||
}
|
||||
|
||||
private void FChat_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
this.client.DataSend -= Svr_DataSend;
|
||||
this.client.DataReceived -= Svr_DataReceived;
|
||||
this.client.ClientDisconnected -= Svr_ClientDisconnected;
|
||||
this.client.Message -= Svr_Message;
|
||||
}
|
||||
|
||||
private void Svr_DataSend(arTCPService.Server.Receiver arg1, arTCPService.Shared.Messages.Packet arg2)
|
||||
{
|
||||
if (arg2.header == arTCPService.Shared.Messages.Header.Message)
|
||||
addLog("발신:" + arg2.Message);
|
||||
}
|
||||
|
||||
private void Svr_Message(arTCPService.Server.Receiver arg1, string arg2, bool arg3)
|
||||
{
|
||||
addLog("시스템메세지:" + arg2);
|
||||
}
|
||||
|
||||
private void Svr_ClientDisconnected(arTCPService.Server.Receiver obj)
|
||||
{
|
||||
addLog("연결종료");
|
||||
}
|
||||
|
||||
private void Svr_DataReceived(arTCPService.Server.Receiver arg1, arTCPService.Shared.Messages.Packet arg2)
|
||||
{
|
||||
if (arg2.header == arTCPService.Shared.Messages.Header.Message)
|
||||
{
|
||||
addLog("수신:" + arg2.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void fChat_Load(object sender, EventArgs e)
|
||||
{
|
||||
addLog("채팅이 시작되었습니다 :" + this.client.ID);
|
||||
}
|
||||
private void InvokeUI(Action action)
|
||||
{
|
||||
this.Invoke(action);
|
||||
}
|
||||
|
||||
void addLog(string m)
|
||||
{
|
||||
richTextBox1.Invoke(new Action(() =>
|
||||
{
|
||||
this.richTextBox1.AppendText(m + "\r\n");
|
||||
this.richTextBox1.ScrollToCaret();
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Project/Dialog/fChat.resx
Normal file
120
Project/Dialog/fChat.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -4,6 +4,8 @@ using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -17,7 +19,8 @@ namespace Project.Dialog
|
||||
this.tbID.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Enter) tbPW.Focus(); };
|
||||
this.tbPW.KeyDown += (s1, e1) => { if (e1.KeyCode == Keys.Enter) btLogin.PerformClick(); };
|
||||
this.KeyPreview = true;
|
||||
this.KeyDown += (s1, e1) => {
|
||||
this.KeyDown += (s1, e1) =>
|
||||
{
|
||||
if (e1.KeyCode == Keys.Escape) this.Close();
|
||||
};
|
||||
}
|
||||
@@ -37,7 +40,7 @@ namespace Project.Dialog
|
||||
|
||||
//마지막으로사용한 부서이름
|
||||
if (Pub.setting.lastdpt.isEmpty()) this.cmbDept.SelectedIndex = -1;
|
||||
else this.cmbDept.Text =Pub.setting.lastdpt;
|
||||
else this.cmbDept.Text = Pub.setting.lastdpt;
|
||||
//foreach (var item in dlist)
|
||||
// if (item != "") this.cmbDept.Items.Add(item);
|
||||
//if (cmbDept.Items.Count > 0) cmbDept.SelectedIndex = 0;
|
||||
@@ -50,18 +53,18 @@ namespace Project.Dialog
|
||||
}
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
if (this.tbID.Text.isEmpty())
|
||||
{
|
||||
tbID.Focus();
|
||||
return;
|
||||
}
|
||||
if(this.tbPW.Text.isEmpty())
|
||||
if (this.tbPW.Text.isEmpty())
|
||||
{
|
||||
tbPW.Focus();
|
||||
return;
|
||||
}
|
||||
if(cmbDept.SelectedIndex < 0)
|
||||
if (cmbDept.SelectedIndex < 0)
|
||||
{
|
||||
FCOMMON.Util.MsgE("소속 부서를 선택하세요");
|
||||
cmbDept.Focus();
|
||||
@@ -97,11 +100,11 @@ namespace Project.Dialog
|
||||
var ta = new dsMSSQLTableAdapters.UsersTableAdapter();
|
||||
try
|
||||
{
|
||||
var users = ta.GetIDPW(encpass, tbID.Text.Trim());
|
||||
var users = ta.GetIDPW(encpass, tbID.Text.Trim());
|
||||
if (users.Rows.Count != 1)
|
||||
{
|
||||
users = ta.GetByNamePw(tbID.Text.Trim(), encpass);
|
||||
if(users.Rows.Count != 1)
|
||||
if (users.Rows.Count != 1)
|
||||
{
|
||||
Util.MsgE("입력한 사용자 계정이 존재하지 않습니다");
|
||||
tbPW.SelectAll();
|
||||
@@ -114,7 +117,7 @@ namespace Project.Dialog
|
||||
var userdr = users.Rows[0] as dsMSSQL.UsersRow;
|
||||
var taGrpUser = new dsMSSQLTableAdapters.EETGW_GroupUserTableAdapter();
|
||||
var Exist = taGrpUser.ExistCheck(gCode, userdr.id) > 0;
|
||||
if (userdr.level < 9 && Exist==false)
|
||||
if (userdr.level < 9 && Exist == false)
|
||||
{
|
||||
Util.MsgE("입력한 사용자는 지정한 부서에 접속할 권한이 없습니다");
|
||||
return;
|
||||
@@ -136,18 +139,65 @@ namespace Project.Dialog
|
||||
FCOMMON.info.Login.permission = 0;
|
||||
FCOMMON.info.Login.gpermission = int.Parse(gperm);
|
||||
|
||||
//로그인정보 기록
|
||||
AddLoginInfo();
|
||||
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
}catch (Exception ex)
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Util.MsgE("데이터베이스 조회 실패 다음 오류 메세지를 참고하세요.\n\n"+ ex.Message + "\n\n증상이 동일 할 경우 서버가 접속가능한지 먼저 확인하세요");
|
||||
Util.MsgE("데이터베이스 조회 실패 다음 오류 메세지를 참고하세요.\n\n" + ex.Message + "\n\n증상이 동일 할 경우 서버가 접속가능한지 먼저 확인하세요");
|
||||
DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void AddLoginInfo()
|
||||
{
|
||||
string ip = string.Empty;
|
||||
string hostname = Dns.GetHostName();
|
||||
string fullname = System.Net.Dns.GetHostEntry("").HostName;
|
||||
|
||||
var nif = NetworkInterface.GetAllNetworkInterfaces();
|
||||
var host = Dns.GetHostEntry(hostname);
|
||||
foreach (IPAddress r in host.AddressList)
|
||||
{
|
||||
string str = r.ToString();
|
||||
|
||||
if (str != "" && str.Substring(0, 3) == "10.")
|
||||
{
|
||||
ip = str;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ip == "" || hostname == "") return;
|
||||
|
||||
try
|
||||
{
|
||||
var db = new EEEntitiesMain();
|
||||
db.EETGW_LoginInfo.Add(new EETGW_LoginInfo
|
||||
{
|
||||
uid = FCOMMON.info.Login.no,
|
||||
hostname = fullname,
|
||||
ip = ip,
|
||||
login = DateTime.Now,
|
||||
wuid = FCOMMON.info.Login.no,
|
||||
wdate = DateTime.Now
|
||||
});
|
||||
db.SaveChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FCOMMON.Util.MsgE(ex.Message);
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void label3_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user