internal ManagerWindow(ClientList Clients, MainWindow mainWindow) { InitializeComponent(); this.Clients = Clients; this.mainWindow = mainWindow; Clients.Sort(); ClientsListView.ItemsSource = Clients; this.Owner = mainWindow; }
public static void glownySposob() { ClientList clients = new ClientList(); ConcurrentDictionary<string, Channel> channels = new ConcurrentDictionary<string, Channel>(); AbstractServer udpServer = new AppUdpServer(clients, channels); AbstractServer tcpServer = new AppTcpServer(clients, channels); Thread udpThread = new Thread(new ThreadStart(udpServer.runServer)); Thread tcpThread = new Thread(new ThreadStart(tcpServer.runServer)); udpThread.Start(); tcpThread.Start(); }
public Types.PagedList <Client> ApiToDomain(ClientList value) { if (value == null) { return(null); } return(new Types.PagedList <Client> { Page = value.Page, ItemsPerPage = value.PerPage, TotalItems = value.Total, List = value.List?.Select(ApiToDomain).ToList() }); }
/// <summary> /// Handles the Click event of the AddContact control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> protected void AddContact_Click(object sender, EventArgs e) { this.clients = ClientList.GetClients(); bool clientAdded = this.clients.AddClient(this.selectedClient); HttpContext.Current.Session["Clients"] = this.clients; if (clientAdded) { this.lblContactAdded.Text = "[" + this.selectedClient.Name + "] added"; } else { this.lblContactAdded.Text = "[" + this.selectedClient.Name + "] has already been added"; } }
public void SortMaster(Client nextMaster) { if (!HasClient(nextMaster)) { return; } var index = ClientList.IndexOf(nextMaster); ClientList.RemoveAt(index); var oldMaster = ClientList[0]; ClientList.RemoveAt(0); ClientList.Insert(0, nextMaster); ClientList.Insert(index, oldMaster); }
public ActionResult Create([Bind(Include = "ClientListId,CustomerId,EmployeeId,ServiceId,Appointment,CustomerName")] ClientList clientList) { User user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); bool isEmployee = UsersHelper.IsEmployeeOfCurrentBusiness(User, clientList.EmployeeId); if (!isEmployee) { return(RedirectToAction("BusinessCustomers")); } Customer customer = db.Customers.Find(clientList.CustomerId); if (string.IsNullOrEmpty(clientList.CustomerName)) { ModelState.AddModelError("CustomerName", "The field Customer is required"); } else if (customer != null) { if (isEmployee && customer.UserId == user.UserId && customer.IsAccountOwner) { ModelState.AddModelError(string.Empty, "Same employee customer not allowed"); } } else { ModelState.AddModelError("CustomerName", "Customer not found"); } if (ModelState.IsValid) { clientList.ListStatusId = db.ListStatus.Where(ls => ls.Confirmed == true).FirstOrDefault().ListStatusId; clientList.AddedByUserId = user.UserId; clientList.AddedDate = DateTime.Now; clientList.ModifiedByUserId = user.UserId; clientList.ModifiedDate = clientList.AddedDate; db.ClientLists.Add(clientList); db.SaveChanges(); return(RedirectToAction("Index", new { id = clientList.EmployeeId })); } ViewBag.ServiceId = new SelectList(ListsHelper.GetEmployeeServices(clientList.EmployeeId), "ServiceId", "Description", clientList.EmployeeId); ViewBag.CustomerId = new SelectList(ListsHelper.GetCustomers(isEmployee, user.UserId), "CustomerId", "CustomerName", clientList.CustomerId); ViewBag.ReturnUrl = string.Format("~/ClientLists/Create/{0}", clientList.EmployeeId); ViewBag.EmployeeName = user.Name; ViewBag.EmployeeUserId = user.UserId; return(View(clientList)); }
/// <summary> /// Starts the server. /// </summary> public void Start() { if (IsRunning) { throw new ServerException("Server is already running!"); } IsRunning = true; clients = new ClientList(); currentClientID = 0; tcpListener = new TcpListener(IPAddress.Any, Port); listenThread = new Thread(ListenForClientConnection); listenThread.Start(); }
// GET: ClientList/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClientList client = db.ClientLists .SingleOrDefault(a => a.Id == id); if (client == null) { return(HttpNotFound()); } return(View(client)); }
protected void btnRemoveClient_Click(object sender, EventArgs e) { try { ClientList temporaryList = ClientList.GetClients(); temporaryList.RemoveAt(this.lbxContacts.SelectedIndex); HttpContext.Current.Session["Clients"] = temporaryList; } catch (IndexOutOfRangeException) { Console.WriteLine("There are no more clients to remove"); } this.updateClients(); }
private async void RestoreClientAsync(ClientName job) { bool result = await RecoverClientWarning(); if (!result) { if (job.Name != null) { job.IsSoftDeleted = false; ClientList.Remove(job); } else { job.IsSoftDeleted = false; EstimateList.Remove(job); } database.Update(job); //start RefreshList(); SearchBarVisible(); ESearchBarVisible(); if (ClientList.Count == 3) { SearchText = ""; SearchTextChanged(); } else { SearchTextChanged(); } if (EstimateList.Count == 3) { ESearchText = ""; SearchETextChanged(); } else { SearchETextChanged(); } //finish } }
//finish private async void RemoveClientAsync(ClientName job) { bool result = await DeleteClientWarning(); if (!result) { if (job.Name != null) { ClientList.Remove(job); } else { EstimateList.Remove(job); } database.Table <ClientName>().Delete(x => x.Id == job.Id); database.Update(job); //start RefreshList(); SearchBarVisible(); ESearchBarVisible(); if (ClientList.Count == 3) { SearchText = ""; SearchTextChanged(); } else { SearchTextChanged(); } if (EstimateList.Count == 3) { ESearchText = ""; SearchETextChanged(); } else { SearchETextChanged(); } //finish } }
protected void Page_Load(object sender, EventArgs e) { if ((Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.IsLoggedIn] == null || Convert.ToBoolean(Session[MtbBillCollection.Global.Definitions.SessionVariable.Value.IsLoggedIn]) == false) || (MtbBillCollection.Utility.Screen.IsUserPermitedToAccessScreen(Convert.ToInt32(Session["userTypeId"].ToString()), "Clearing")) == false) { Response.Redirect("/Default.aspx"); } else { if (!Page.IsPostBack) { gridCollList.Enabled = false; gridCollList.Visible = false; ClientList.DataSource = _bilCollectionManager.GetClientist(); ClientList.DataBind(); if (ClientList.Items.Count > 0) { ClientList.SelectedIndex = 0; //lblClient.Text = ClientList.Text; _clientid = ClientList.Items[0].Value; } ViewState.Add(MtbBillCollection.Global.Definitions.SessionVariable.Value.ClientId, _clientid); _authenticationManger.ConnectionString = MtbBillCollection.WebConfigManager.GetCollDBConnString(); cboBranch.DataSource = _authenticationManger.GetBranchList(); cboBranch.DataBind(); InstrumentTypeList.DataSource = _bilCollectionManager.GetInstrumentTypeist(); InstrumentTypeList.DataBind(); InstrumentTypeList.RepeatDirection = RepeatDirection.Horizontal; ProducTypeList.DataSource = _bilCollectionManager.GetProductList(1); ProducTypeList.DataBind(); ProducTypeList.RepeatDirection = RepeatDirection.Horizontal; txtFromDate.Text = DateTime.Now.ToString("dd/MM/yyyy"); txtToDate.Text = DateTime.Now.ToString("dd/MM/yyyy"); txtConfirmation.Text = ""; } else { gridCollList.Enabled = true; gridCollList.Visible = true; txtConfirmation.Text = ""; } } }
private static void AcceptClientCompleted(object sender, SocketAsyncEventArgs e) { e.Completed -= AcceptClientCompleted; if (e.SocketError == SocketError.Success) { var clientConnection = new ClientConnection(); clientConnection.Socket = e.AcceptSocket; clientConnection.SocketMessageHandler = new ServerSocketMessages(clientConnection); ClientList.Add(clientConnection); Pages.Server.Current?.RefreshUICall(); WaitForClientMessage(clientConnection); WaitForClientConnection(); clientConnection.SocketMessageHandler.SendEncryptionStatus(); } }
public void ContractSaveAndEditValues() { var clientName = ClientList.FirstOrDefault(x => x.ClientId == SelectedClientId); string selectedClientname = (clientName != null) ? clientName.ClientName : ""; var contractName = ClientList.FirstOrDefault(x => x.ContractId == SelectedContractId); string selectedContractName = (contractName != null) ? contractName.ContractName : ""; var startDate = StartDate.Date; var endDate = EndDate.Date; _contract.EmployeeId = CurrentUser.EmployeeId; _contract.ClientId = SelectedClientId; _contract.ClientName = selectedClientname; _contract.ContractName = selectedContractName; _contract.StartDate = startDate; _contract.EndDate = endDate; }
// GET: AdministrationCost/Delete/5 public ActionResult Delete(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClientList client = db.ClientLists .Include(a => a.Subcontractor) .SingleOrDefault(a => a.Id == id); if (client == null) { return(HttpNotFound()); } return(View(client)); }
public async void RemoveClient(ClientName client) { bool result = await DeleteClientWarning(); if (!result) { if (client.Name != null) { ClientList.Remove(client); } else { EstimateList.Remove(client); } client.IsSoftDeleted = true; database.Update(client); RefreshList(); SearchBarVisible(); ESearchBarVisible(); if (ClientList.Count == 3) { SearchText = ""; SearchTextChanged(); } else { SearchTextChanged(); } if (EstimateList.Count == 3) { ESearchText = ""; SearchETextChanged(); } else { SearchETextChanged(); } } }
/// <summary> /// 接收文字线程 /// </summary> /// <param name="socket"></param> public void ReceiveThread(Socket socket, string id) { if (whatRecv == 0) //接收文字 { while (ClientList.haveId(id)) { if (whatRecv == 0) { Tool.Log("接收死循环开始"); string recvStr = MyServer.ReceiveText((Socket)socket); if (recvStr != null) { if (!recvStr.Equals("退出")) { Tool.Log("接收到文字:" + recvStr); SendMessage(id, MSG_RECEIVE, recvStr); } else { Tool.Log("ID为" + id + "的客户端退出"); ClientList.Remove(id); } } } else if (whatRecv == 1) //接收文件 { int ret = MyServer.ReceiveFile((Socket)socket); //接收文件 MessageBox.Show("接收返回"); //不能返回 if (ret == Return.SUCCEED) { //SendMessage(MSG_RECEIVE_SUCCEED, "接收成功"); } else { //SendMessage(MSG_RECEIVE_FAIL, "接收失败"); } } } Tool.Log("ID为" + id + "的接收死循环结束"); SendMessage(id, MSG_UPADTE_COUNT, null); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (ClientList != null) { foreach (var item in ClientList) { if (item.Value is IDisposable disposable) { disposable.Dispose(); } } ClientList.Clear(); ClientList = null; } } }
void OnDisconnected(TcpClient clientScoket) { try { IpPoint = (IPEndPoint)clientScoket.Client.RemoteEndPoint; ClientIP = ClientIP = IpPoint.Address + ":" + IpPoint.Port; DisplayText(ClientIP + "/ 님의 연결이 해제되었습니다."); SendMessageAll(ClientIP + "/ 님의 연결이 해제되었습니다.", ClientList[clientScoket].ToString(), true); if (ClientList.ContainsKey(clientScoket)) { ClientList.Remove(clientScoket); } } catch (Exception ex) { ServerEvent.ErrorLog("OnDisconnected", ex.Message); } }
public int AddOrEdit(ClientList clientList) { if (clientList.ClientID == 0) { clientList.CreatedDate = DateTime.Now; clientList.UpdatedDate = DateTime.Now; clientList.CreatedBy = 1; clientList.UpdatedBy = 1; _dbContext.ClientLists.Add(clientList); } else { clientList.UpdatedBy = 1; clientList.UpdatedDate = DateTime.Now; _dbContext.Entry(clientList).State = EntityState.Modified; } return(_dbContext.SaveChanges()); }
/// <summary> /// 进入房间 /// </summary> /// <param name="playerId"></param> /// <param name="client"></param> public void Enter(int playerId, MobaClient client) { if (team1Dict.ContainsKey(playerId)) { team1Dict[playerId].isEnter = true; } else if (team2Dict.ContainsKey(playerId)) { team2Dict[playerId].isEnter = true; } else { return; } //添加房间内的连接对象 ClientList.Add(client); //增加进入人数 enterCount++; }
public void Save() { try { ClientList list = new ClientList(); list.Path = System.IO.Path.Combine(Core.LaunchData.PhoenixDir, ClientList.Filename); list.Load(); list.AddClient(ClientInfo); list.Save(); Trace.WriteLine("Clients keys updated.", "Phoenix"); } catch (Exception e) { Trace.WriteLine(String.Format("Error saving client keys. Exception: {0}", e.Message), "Phoenix"); } }
public bool Load() { ClientList list = new ClientList(); list.Path = System.IO.Path.Combine(Core.LaunchData.PhoenixDir, ClientList.Filename); list.Load(); ClientInfo = list.FindClient(Core.LaunchData.ClientHash); if (Calculated) { Trace.WriteLine("Clients keys found.", "Phoenix"); return(true); } else { Trace.WriteLine("Clients keys not found.", "Phoenix"); return(false); } }
public async Task LoadClients() { ClientManager manager = new ClientManager(); List <TimeReport> clientList = await manager.GetAllClients(); if (clientList != null && clientList.Count > 0) { ClientList = clientList; } ClientNameList = new List <string>(); if (ClientList != null) { ClientNameList.AddRange(ClientList.Select(x => x.ClientName).Distinct()); var cl = ClientList.FirstOrDefault(); ContractNameList = new List <string>(); if (cl != null) { foreach (var client in ClientList) { if (client.ClientName == cl.ClientName) { ContractNameList.Add(client.ClientName); } } } ContractNameList.AddRange(ClientList.Where(x => x.ClientName == ClientList.FirstOrDefault().ClientName).Select(x => x.ContractName).Distinct()); var firstClient = ContractNameList.First(); var matchingClients = ClientList.Where(x => x.ClientName == firstClient).ToList(); ContractList = new List <string>(); foreach (var contract in matchingClients) { ContractList.Add(contract.ContractName); } } }
public void SaveCurrentClient() { DataModel.Client matchByCode = ClientList.FirstOrDefault(client => client.IdCode == CurrentClient.IdCode); // An IdCode collision occurred and it's not the same client. if (matchByCode != null && matchByCode.Id != CurrentClient.Id) { throw new Exception($"Asiakas tunnisteella {CurrentClient.IdCode} on jo olemassa."); } if (SaveAsNew && matchByCode == null) { CurrentClient.Id = null; } CurrentClient.Save(); ClientList = new ObservableCollection <DataModel.Client>(DataModel.Client.LoadAll()); // If the user changes the IdCode and saves the client as new, this updates the Id to the view model. CurrentClient = ClientList.First(client => client.IdCode == CurrentClient.IdCode).Copy(); }
/// <summary> /// 进入房间 /// </summary> public void Enter(int playerID, MOBAClient client) { if (RedTeamSelectModels.ContainsKey(playerID)) { RedTeamSelectModels[playerID].IsEnter = true; } else if (BlueTeamSelectModels.ContainsKey(playerID)) { BlueTeamSelectModels[playerID].IsEnter = true; } else { //失败 return; } //添加客户端 ClientList.Add(client); //更新进入人数 _enterCount++; }
private void Stop() { if (!ServerStatus) { return; } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Stopping server..."); ServerStatus = false; while (ClientList.Count != 0) { Client client = ClientList[0]; ClientList.Remove(client); client.Dispose(); } ListeningSocket.Close(); ListeningSocket = null; Console.WriteLine("Server stopped."); Console.ForegroundColor = ConsoleColor.Gray; }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ClientList clientList = db.ClientLists.Find(id); if (clientList == null) { return(HttpNotFound()); } User user = db.Users.Where(u => u.UserName == User.Identity.Name).FirstOrDefault(); bool isEmployee = UsersHelper.IsEmployeeOfCurrentBusiness(User, clientList.EmployeeId); ViewBag.ServiceId = new SelectList(ListsHelper.GetEmployeeServices(clientList.EmployeeId), "ServiceId", "Description", clientList.ServiceId); return(View(clientList)); }
public Server() { //Initializes Datamembers users = new ClientList(); //UnconfirmedUsers = new UserCollection(); textMessages = new List <TextMessage>(); // create list of documents listOfDocuments = new List <Document>(); //Creates random server password. serverPassword = randomString(10); Console.WriteLine(serverPassword); //Reads in users. string[] UserFiles; if (Directory.Exists(Client.pathToDir + Client.USER_LOCATION) == true) { UserFiles = Directory.GetFiles(Client.pathToDir + Client.USER_LOCATION); Client tempUser; foreach (string item in UserFiles) { tempUser = new Client(item); this.users.Add(tempUser); } } else { Directory.CreateDirectory(Client.pathToDir + Client.USER_LOCATION); } //Creates directory for files if it doesnt exist. if (!Directory.Exists(Document.pathToDir + Document.FILE_LOCATION)) { Directory.CreateDirectory(Document.pathToDir + Document.FILE_LOCATION); } //Starts thread to keep track of inline users Thread thread = new Thread(new ThreadStart(setOnline)); thread.Start(); }
public ActionResult AddOrEdit(ClientList clientList, HttpPostedFileBase uploadedFile) { var allowedExtensions = new[] { ".GIF", ".PNG", ".JPG", ".JPEG" }; if (uploadedFile != null) { var ext = Path.GetExtension(uploadedFile.FileName); if (allowedExtensions.Contains(ext.ToUpper())) //check what type of extension { string myfile = "ClientListImage" + DateTime.Now.ToString("ddMMyyhhmm") + ext; var path = ConfigurationManager.AppSettings["ClientListImage"]; var finalpath = Path.Combine(Server.MapPath(path), myfile); if (clientList.ClientID > 0) { var imageName = clientList.ClientImage; var existingpath = ConfigurationManager.AppSettings["ClientListImage"]; if (System.IO.File.Exists(Server.MapPath(existingpath + imageName))) { System.IO.File.Delete(Server.MapPath(existingpath + imageName)); } } clientList.ClientImage = myfile; uploadedFile.SaveAs(finalpath); } else { Message message = new Message(); message.ReturnMessage = "Choose only Image File!"; message.MessageType = MessageTypes.Information; } } else { Message message = new Message(); message.ReturnMessage = "Select an Image!"; message.MessageType = MessageTypes.Information; } var data = _iClientListManager.AddOrEdit(clientList); return(Json(new { messageType = data.MessageType, message = data.ReturnMessage, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", _iClientListManager.GetAllClientList()) }, JsonRequestBehavior.AllowGet)); }
void AcceptCallBack(IAsyncResult ar) { Tool.Log("监听到一个连接"); Socket socket = ar.AsyncState as Socket; //结束异步Accept并获已连接的Socket Socket acceptSock = socket.EndAccept(ar); //测试是否连接成功 if (!acceptSock.Connected) { MessageBox.Show("未连接"); } //获得客户端的IP地址 IPAddress clientIp = ((System.Net.IPEndPoint)acceptSock.RemoteEndPoint).Address; string strip = clientIp.ToString(); string id = ClientList.Add(acceptSock); //为每一个客户端分配一个接收线程 //创建线程开始接受消息 Thread th = new Thread(delegate() { ReceiveThread(acceptSock, id); }); th.Start(); //ClientList.Add()后再发送 SendMessage(id, MSG_ACCEPT, id); //TODO 数据包多合一 //继续异步Accept,保持Accept一直开启! socket.BeginAccept(AcceptCallBack, socket); }
private void Delete() { for (int i = 0; i < ClientList.Count; i++) { if (ClientList[i].IsConnected == true) { if (ClientList[i].LocalEndPoint.ToString() == SelectedClientConnectInfo.LocalEndPoint) { string localEndPoint = SelectedClientConnectInfo.LocalEndPoint; if (ClientList[i].Close().Result) { ClientList.Remove(ClientList[i]); for (int k = 0; k < ClientConnectInfoList.Count; k++) { if (ClientConnectInfoList[k].LocalEndPoint == localEndPoint) { ClientConnectInfoList.Remove(ClientConnectInfoList[k]); AllClientMessageList.Remove(localEndPoint); } } } } } else { if (ClientList[i].LocalEndPoint.ToString() == SelectedClientConnectInfo.LocalEndPoint) { string localEndPoint = SelectedClientConnectInfo.LocalEndPoint; ClientList.Remove(ClientList[i]); for (int k = 0; k < ClientConnectInfoList.Count; k++) { if (ClientConnectInfoList[k].LocalEndPoint == localEndPoint) { ClientConnectInfoList.Remove(ClientConnectInfoList[k]); } } } } } }
public Server() { //Initializes Datamembers users = new ClientList(); //UnconfirmedUsers = new UserCollection(); textMessages = new List<TextMessage>(); // create list of documents listOfDocuments = new List<Document>(); //Creates random server password. serverPassword = randomString(10); Console.WriteLine(serverPassword); //Reads in users. string[] UserFiles; if (Directory.Exists(Client.pathToDir + Client.USER_LOCATION) == true) { UserFiles = Directory.GetFiles(Client.pathToDir + Client.USER_LOCATION); Client tempUser; foreach (string item in UserFiles) { tempUser = new Client(item); this.users.Add(tempUser); } } else { Directory.CreateDirectory(Client.pathToDir + Client.USER_LOCATION); } //Creates directory for files if it doesnt exist. if (!Directory.Exists(Document.pathToDir + Document.FILE_LOCATION)) { Directory.CreateDirectory(Document.pathToDir + Document.FILE_LOCATION); } //Starts thread to keep track of inline users Thread thread = new Thread(new ThreadStart(setOnline)); thread.Start(); }
protected AbstractTcpServer(ClientList clients, ConcurrentDictionary<string, Channel> channels, int send_port) : base(clients, channels) { this.tcpListener = new TcpListener(addr, send_port); }
public ConnectClient(ClientList clientList, Context context) { _clientList = clientList; _context = context; }
public AppUdpServer(ClientList clients, ConcurrentDictionary<string, Channel> channels) : base(clients, channels, Consts.STANDARD_UDP_PORT_RCV, Consts.STANDARD_UDP_PORT_SEND) { }
public Channel(string channelName) { this.channelName = channelName; listeners = new ClientList(); }
public AbstractUdpServer(ClientList clients, ConcurrentDictionary<string, Channel> channels, int rcv_port, int send_port) : base(clients, channels) { this.listener = new UdpClient(new IPEndPoint(addr, rcv_port)); this.sender = new UdpClient(new IPEndPoint(addr, send_port)); }
public async Task<ClientList.response> ClientList(ClientList.request request, CancellationToken? token = null) { return await SendAsync<ClientList.response>(request.ToXmlString(), token.GetValueOrDefault(CancellationToken.None)); }
protected AbstractTcpServer(ClientList clients, ConcurrentDictionary<string, Channel> channels) : this(clients, channels, Consts.STANDARD_TCP_PORT_RCV) { }
public AppTcpServer(ClientList clients, ConcurrentDictionary<string, Channel> channels) : base(clients, channels, Consts.STANDARD_TCP_PORT_RCV) { }
public AbstractServer(ClientList clients, ConcurrentDictionary<string, Channel> channels) { this.clients = clients; this.channels = channels; log.Info("Creating server"); }