public ActionResult InitInitJurisdictionRoleGroup(string groupId) { var model = new JurisdictionByRoleGroupEditViewModel { UserList = new List <UserDic>(), }; var groupInfo = JurisdictionBusiness.GetGroupById(long.Parse(EncryptHelper.DesDecrypt(groupId))); if (groupInfo != null) { model.GroupId = groupId; model.GroupName = groupInfo.BGName; var relationinfo = JurisdictionBusiness.GetUserRoleRelationByGroupId(long.Parse(EncryptHelper.DesDecrypt(groupId))); if (relationinfo != null) { foreach (var rolegroup in relationinfo) { var userInfo = HomeBusiness.GetUserById(rolegroup.BURUserId); if (userInfo != null) { var dic = new UserDic(); dic.UserName = userInfo.BUName; dic.userId = EncryptHelper.DesEncrypt(userInfo.Id.ToString()); dic.JobNumber = userInfo.BUJobNumber; model.UserList.Add(dic); } } } } return(Json(model, JsonRequestBehavior.AllowGet)); }
static void DoSomeMagic(object fileName) { string[] s = fileName.ToString().Split(' '); for (int i = 0; i < s.Length - 1; i++) { StreamReader sr = new StreamReader("log" + i + ".txt"); Dictionary <string, int> User = new Dictionary <string, int>(); Dictionary <string, int> Domen = new Dictionary <string, int>(); Dictionary <string, int> Date = new Dictionary <string, int>(); string str; string[] temp = new string[4]; while (!sr.EndOfStream) { str = sr.ReadLine(); temp = str.Split(' '); if (UserDic.ContainsKey(temp[0])) { UserDic[temp[0]] += Convert.ToInt32(temp[3]); } else { UserDic.Add(temp[0], Convert.ToInt32(temp[3])); } if (DomenDic.ContainsKey(temp[1])) { DomenDic[temp[1]] += Convert.ToInt32(temp[3]); } else { DomenDic.Add(temp[1], Convert.ToInt32(temp[3])); } if (DateDic.ContainsKey(temp[2])) { DateDic[temp[2]] += Convert.ToInt32(temp[3]); } else { DateDic.Add(temp[2], Convert.ToInt32(temp[3])); } } DropToDics(UserDic, DomenDic, DateDic); } }
public void Send(string connectionId, byte[] buffer) { UserTokenEventArgs userToken = UserDic.Get(connectionId); if (userToken == null || userToken.Socket == null) { return; } if (userToken.ClientType == ClientType.WebSocket) { buffer = WebSocketUtils.PackServerData(buffer);//或者使用DataFram } SocketAsyncEventArgs sendEventArgs = null; lock (sendStackPool) { sendEventArgs = sendStackPool.Pop(); } if (sendEventArgs != null && sendEventArgs.SocketError == SocketError.Success) { sendEventArgs.UserToken = userToken; sendEventArgs.SetBuffer(buffer, 0, buffer.Length);//最后设置发送数据 try { //异步发送数据 //Array.Copy(buffer, 0, sendEventArgs.Buffer, 0, buffer.Length);//设置发送数据 bool willRaiseEvent = userToken.Socket.SendAsync(sendEventArgs);//采用异步发送才能处理sendStackPool if (!willRaiseEvent) { ProcessSend(sendEventArgs); } } catch (Exception ex) { RaiseErrorEvent(userToken, ex); Console.WriteLine("Send调试" + ex.ToString()); } } }
public void Send(string connectionId, byte[] buffer) { UserTokenEventArgs userToken = UserDic.Get(connectionId); if (userToken == null || userToken.UserSocket == null) { return; } if (userToken.ClientType == ClientType.WebSocket) { buffer = WebSocketUtils.PackServerData(buffer);//或者使用DataFram } SocketAsyncEventArgs sendEventArgs = null; if (this.sendStackPool.TryPop(out sendEventArgs)) { try { sendEventArgs.UserToken = userToken; sendEventArgs.SetBuffer(buffer, 0, buffer.Length);//最后设置发送数据 //异步发送数据 //Array.Copy(buffer, 0, sendEventArgs.Buffer, 0, buffer.Length);//设置发送数据 bool willRaiseEvent = userToken.UserSocket.SendAsync(sendEventArgs);//采用异步发送才能处理sendStackPool if (!willRaiseEvent) { ProcessSend(sendEventArgs); } } catch (ObjectDisposedException)//调用此处的异步发送可能socket被其他进程关闭异常 { RaiseDisconnectedEvent(userToken); } catch (Exception ex) { RaiseErrorEvent(userToken, ex); RaiseDisconnectedEvent(userToken); } } }