private void OnLoginClicked(object sender, RoutedEventArgs e) { var userId = txtLoginName.Text; if (string.IsNullOrEmpty(userId)) { return; } if (m_OnlineClient == null) { m_OnlineClient = new OnlineClient(m_MessageRouter); } listCharacter.Items.Clear(); listZone.Items.Clear(); SavedValueRegistry.SaveValue("LoginName", userId); var loginAddress = txtLoginServer.Text; SavedValueRegistry.SaveValue("LoginServer", loginAddress); var logServer = txtLogServer.Text; SavedValueRegistry.SaveValue("LogServer", logServer); var result = m_OnlineClient.StartConnection(1, "FishingOnline", loginAddress, userId, userId); if (result.IsSucceeded) { } UpdateButtonState(); }
/// <summary> /// set to offline when user logout /// </summary> /// <param name="onlineClientDto"></param> /// <returns></returns> public bool UserOffline(string userIDIP) { string webUserFlag = "web login user"; string[] userIDs = userIDIP.Split('&'); if (userIDs.Length == 2) { string userIDs1 = userIDs[0]; string userIDs2 = userIDs[1]; OnlineClient onlineClientOld = _dbContext.Set <OnlineClient>().Where(o => o.UniqueID == userIDs1 && o.Comments == webUserFlag && o.MachineIP == userIDs2).FirstOrDefault(); if (onlineClientOld != null) { if (onlineClientOld.IsOnline == 0) { onlineClientOld.IsOnline = 1; } _dbContext.SaveChanges(); onlineClientOld = _dbContext.Set <OnlineClient>().Where(o => o.UniqueID == userIDs1 && o.Comments == webUserFlag && o.MachineIP == userIDs2).FirstOrDefault(); if (onlineClientOld.IsOnline == 1) { onlineClientOld.IsOnline = 0; } _dbContext.SaveChanges(); return(true); } } return(false); }
public static void Run(ILogger logger) { OnlineClient client = Bootstrap.Client(logger); logger.LogInformation("Executing create test object function to API"); TestObjectCreate create = new TestObjectCreate() { Name = "hello world", }; Task <OnlineResponse> createTask = client.Execute(create); createTask.Wait(); OnlineResponse createResponse = createTask.Result; Result createResult = createResponse.Results[0]; try { int recordNo = int.Parse(createResult.Data[0].Element("id").Value); Console.WriteLine("Created record ID " + recordNo.ToString()); } catch (NullReferenceException e) { logger.LogDebug("No response in Data. {0}", e); } finally { LogManager.Flush(); } }
protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); SavedValueRegistry.SaveValue("LoginName", txtLoginName.Text); SavedValueRegistry.SaveValue("LoginServer", txtLoginServer.Text); SavedValueRegistry.SaveValue("LogServer", txtLogServer.Text); SavedValueRegistry.SaveValue("ProcessName", txtLogId.Text); m_TickTimer.Stop(); m_TickTimer = null; if (m_OnlineClient != null) { m_OnlineClient.DisconnectAll(); m_OnlineClient.Dispose(); m_OnlineClient = null; } if (m_MessageRouter != null) { m_MessageRouter.Dispose(); m_MessageRouter = null; } GlobalEngine.Stop(); }
public int OnUnPublish(ReqSrsClientOnOrUnPublish client) { OnlineClient tmpOnlineClient = new OnlineClient() { Device_Id = client.Device_Id, Client_Id = client.Client_Id, ClientIp = client.Ip, ClientType = ClientType.Monitor, App = client.App, HttpUrl = "", IsOnline = true, Param = client.Param, RtmpUrl = client.TcUrl, Stream = client.Stream, UpdateTime = DateTime.Now, Vhost = client.Vhost, }; var rt = SrsHooksApis.OnPublish(tmpOnlineClient); if (rt) { return(0); } return(-1); }
/// <summary> /// Downloads a mapset banner and returns a stream for it /// </summary> /// <param name="id"></param> public static async Task <Texture2D> DownloadMapsetBanner(int id) { if (DownloadScreen.MapsetBanners.ContainsKey(id)) { return(DownloadScreen.MapsetBanners[id]); } var url = OnlineClient.GetBannerUrl(id); try { using (var webClient = new WebClient()) { var data = await webClient.DownloadDataTaskAsync(url); using (var mem = new MemoryStream(data)) { var img = AssetLoader.LoadTexture2D(mem); DownloadScreen.MapsetBanners[id] = img; return(img); } } } catch (Exception) { // ignored } // Make a transparent texture. return(UserInterface.MenuBackgroundBlurred); }
public async Task ExecuteTest() { string xml = @"<?xml version=""1.0"" encoding=""utf-8""?> <response> <control> <status>success</status> <senderid>testsenderid</senderid> <controlid>requestUnitTest</controlid> <uniqueid>false</uniqueid> <dtdversion>3.0</dtdversion> </control> <operation> <authentication> <status>success</status> <userid>testuser</userid> <companyid>testcompany</companyid> <sessiontimestamp>2015-12-06T15:57:08-08:00</sessiontimestamp> </authentication> <result> <status>success</status> <function>getAPISession</function> <controlid>func1UnitTest</controlid> <data> <api> <sessionid>unittest..</sessionid> <endpoint>https://unittest.intacct.com/ia/xml/xmlgw.phtml</endpoint> </api> </data> </result> </operation> </response>"; HttpResponseMessage mockResponse1 = new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.OK, Content = new StringContent(xml) }; List <HttpResponseMessage> mockResponses = new List <HttpResponseMessage> { mockResponse1, }; MockHandler mockHandler = new MockHandler(mockResponses); ClientConfig clientConfig = new ClientConfig { SenderId = "testsender", SenderPassword = "******", SessionId = "testsession..", MockHandler = mockHandler, }; OnlineClient client = new OnlineClient(clientConfig); OnlineResponse response = await client.Execute(new ApiSessionCreate("func1UnitTest")); Assert.Equal("requestUnitTest", response.Control.ControlId); }
private static readonly int _expireTime = 600;//10分钟 #region .ctor public OnlineCore(int p) { if (!ShareUtil.IsCross) { if (!CacheFactory.ServicetionSectionCache.HasOnlineService()) { _onlineClient = new OnlineClient(); } } }
/// <summary> /// Disconnect All Clients whose having the same IP /// </summary> /// <param name="Client"></param> public void DisconnectAll(Operation Client) { foreach (Operation OnlineClient in Clients.ToArray()) { if (OnlineClient.EndPoint.Address.Equals(Client.EndPoint.Address)) { RemoveHandlers(OnlineClient); OnlineClient.ShutdownOperation(); } } }
private void OnDisconnectClicked(object sender, RoutedEventArgs e) { if (m_OnlineClient != null) { m_OnlineClient.DisconnectAll(); m_OnlineClient.Dispose(); m_OnlineClient = null; } UpdateButtonState(); }
public static OnlineClient Client(ILogger logger) { ClientConfig clientConfig = new ClientConfig() { ProfileFile = Path.Combine(Directory.GetCurrentDirectory(), "credentials.ini"), Logger = logger, }; OnlineClient client = new OnlineClient(clientConfig); return(client); }
/// <summary> /// is online /// </summary> /// <param name="onlineClientDto"></param> /// <returns></returns> public bool IsOnline(OnlineClientDto onlineClientDto) { string webUserFlag = "web login user"; OnlineClient onlineClientOld = _OnlineClientRepository.Get(o => o.UniqueID == onlineClientDto.UniqueID && o.Comments == webUserFlag && o.IsOnline == 1 && o.MachineIP == onlineClientDto.MachineIP).FirstOrDefault(); if (onlineClientOld != null) { return(true); } return(false); }
public JsonResult CheckLiveCh(OnlineClient client) { ResponseStruct rss = CommonFunctions.CheckParams(new object[] { client }); if (rss.Code != ErrorNumber.None) { return(Program.CommonFunctions.DelApisResult(null !, rss)); } var rt = LiveBroadcastApis.CheckIsLiveCh(client, out ResponseStruct rs); return(Program.CommonFunctions.DelApisResult(rt, rs)); }
public void TestInitialize() { _onlineClient = MockData.Generate <OnlineClient>(c => { c.IsOnline = 1; c.Comments = "web login user"; }); var risProContext = Container.Resolve <IRisProContext>(); risProContext.Set <OnlineClient>().RemoveRange(risProContext.Set <OnlineClient>()); risProContext.Set <OnlineClient>().Add(_onlineClient); risProContext.SaveChanges(); }
public static void Run(ILogger logger) { OnlineClient client = Bootstrap.Client(logger); Read read = new Read() { ObjectName = "CUSTOMER", Fields = { "RECORDNO", "CUSTOMERID", "NAME", }, Keys = { 33 // Replace with the record number of a customer in your company } }; Task <OnlineResponse> task = client.Execute(read); task.Wait(); OnlineResponse response = task.Result; Result result = response.Results[0]; dynamic json = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(result.Data)); try { string jsonString = json.ToString(); logger.LogDebug( "Read successful [ Company ID={0}, User ID={1}, Request control ID={2}, Function control ID={3}, Total count={4}, Data={5}]", response.Authentication.CompanyId, response.Authentication.UserId, response.Control.ControlId, result.ControlId, result.TotalCount, jsonString ); Console.WriteLine("Success! Found these customers: " + json); } catch (NullReferenceException e) { logger.LogDebug("No response in Data. {0}", e); } finally { LogManager.Flush(); } }
/// <summary> /// Sends a Hours Journal to the Intacct STATISTIC System /// </summary> /// <param name="client"></param> /// <param name="Org"></param> /// <param name="lines"></param> /// <param name="PostingDate"></param> /// <param name="ReferenceNumber"></param> /// <param name="JournalSymbol"></param> /// <param name="Description"></param> /// <param name="HistoryComment"></param> /// <param name="AsDraft"></param> /// <returns></returns> private async Task SendStatHoursJournalCmd(OnlineClient client, int Org, IEnumerable <IntacctStatHours> lines, DateTime PostingDate, string ReferenceNumber, string JournalSymbol, string Description, string HistoryComment, bool AsDraft) { StatisticalJournalEntryCreate create = new StatisticalJournalEntryCreate(); create.JournalSymbol = JournalSymbol; create.ReferenceNumber = ReferenceNumber; create.PostingDate = PostingDate; create.Description = Description; create.HistoryComment = HistoryComment; if (AsDraft) { create.CustomFields.Add("STATE", "Draft"); } foreach (var item in lines) { StatisticalJournalEntryLineCreate line = new StatisticalJournalEntryLineCreate { StatAccountNumber = item.Account, Amount = decimal.Parse(item.Hours.ToString("F2")), Memo = $"Part of Practice Engine Batch #{item.BatchID}" }; if (!String.IsNullOrWhiteSpace(item.EmployeeID)) { line.EmployeeId = item.EmployeeID; } if (!String.IsNullOrWhiteSpace(item.ProjectID)) { line.ProjectId = item.ProjectID; } if (!String.IsNullOrWhiteSpace(item.IntacctCustomerID)) { line.CustomerId = item.IntacctCustomerID; } if (!String.IsNullOrWhiteSpace(item.IntacctDepartment)) { line.DepartmentId = item.IntacctDepartment; } if (!String.IsNullOrWhiteSpace(item.IntacctLocation)) { line.LocationId = item.IntacctLocation; } create.Lines.Add(line); } OnlineResponse onlineResponse = await client.Execute(create); foreach (var result in onlineResponse.Results) { result.EnsureStatusSuccess(); } }
/// <summary> /// Sends a Journal to the Intacct GL System /// </summary> /// <param name="client"></param> /// <param name="Org"></param> /// <param name="lines"></param> /// <param name="PostingDate"></param> /// <param name="ReferenceNumber"></param> /// <param name="JournalSymbol"></param> /// <param name="Description"></param> /// <param name="HistoryComment"></param> /// <param name="AsDraft"></param> /// <returns></returns> private async Task SendJournalCmd(OnlineClient client, int Org, IEnumerable <JournalExtract> lines, DateTime PostingDate, string ReferenceNumber, string JournalSymbol, string Description, string HistoryComment, bool AsDraft) { JournalEntryCreate create = new JournalEntryCreate(); create.JournalSymbol = JournalSymbol; create.ReferenceNumber = ReferenceNumber; create.PostingDate = PostingDate; create.Description = Description; create.HistoryComment = HistoryComment; if (AsDraft) { create.CustomFields.Add("STATE", "Draft"); } foreach (var item in lines) { JournalEntryLineCreate line = new JournalEntryLineCreate { GlAccountNumber = item.AccountCode, TransactionAmount = decimal.Parse(item.NomAmount.ToString("F2")), Memo = String.IsNullOrWhiteSpace(item.NomTransRef) ? item.NomNarrative : item.NomNarrative + " (" + item.NomTransRef + ")" }; if (!String.IsNullOrWhiteSpace(item.IntacctCustomerID)) { line.CustomerId = item.IntacctCustomerID; } if (!String.IsNullOrWhiteSpace(item.IntacctEmployeeID)) { line.EmployeeId = item.IntacctEmployeeID; } if (!String.IsNullOrWhiteSpace(item.IntacctProjectID)) { line.ProjectId = item.IntacctProjectID; } if (!String.IsNullOrWhiteSpace(item.IntacctDepartment)) { line.DepartmentId = item.IntacctDepartment; } if (!String.IsNullOrWhiteSpace(item.IntacctLocation)) { line.LocationId = item.IntacctLocation; } create.Lines.Add(line); } OnlineResponse onlineResponse = await client.Execute(create); foreach (var result in onlineResponse.Results) { result.EnsureStatusSuccess(); } }
public override async Task OnConnected(string connectionId, WebSocketClient client, HttpContext context) { await base.OnConnected(connectionId, client, context); var onlineClient = new OnlineClient( client.ConnectionId, client.IpAddress, client.TenantId, client.UserId ); onlineClient["UserName"] = ""; onlineClient["Server"] = _appContext.LocalHostName; OnlineClientManager.Add(onlineClient); }
/// <summary> /// Returns an Intacct Client Connected to the correct database for Cashbook Posting /// </summary> /// <param name="org"></param> /// <returns></returns> private OnlineClient GetCashClient(int org) { var orgConfig = GetOrgCashConfig(org); var intacctClient = new OnlineClient(new ClientConfig { SenderId = orgConfig.SenderID, SenderPassword = orgConfig.SenderPassword, CompanyId = orgConfig.CompanyID, UserId = orgConfig.UserID, UserPassword = orgConfig.UserPassword }); return(intacctClient); }
public async override Task OnConnected() { await base.OnConnected(); var client = new OnlineClient( Context.ConnectionId, GetIpAddressOfClient(), AbpSession.TenantId, AbpSession.UserId ); Logger.Debug("A client is connected: " + client); _onlineClientManager.Add(client); }
/// <summary> /// Returns an Intacct Client Connected to the correct database for the Organization /// </summary> /// <param name="org"></param> /// <returns></returns> protected OnlineClient GetClient(int org) { var orgConfig = GetOrgConfig(org); var intacctClient = new OnlineClient(new ClientConfig { SenderId = orgConfig.SenderID, SenderPassword = orgConfig.SenderPassword, CompanyId = orgConfig.CompanyID, UserId = orgConfig.UserID, UserPassword = orgConfig.UserPassword, Logger = NLog.LogManager.GetLogger("Intacct") }); return(intacctClient); }
public int OnClose(ReqSrsClientOnClose client) { OnlineClient tmpOnlineClient = new OnlineClient() { Device_Id = client.Device_Id, Client_Id = client.Client_Id, ClientIp = client.Ip, App = client.App, Vhost = client.Vhost, }; var rt = SrsHooksApis.OnClose(tmpOnlineClient); if (rt) { return(0); } return(-1); }
public override async Task OnConnectedAsync() { if (!AbpSession.UserId.HasValue) { throw new UserFriendlyException(L("UserNotLoggedIn")); } var client = new OnlineClient( Context.ConnectionId, GetIpAddressOfClient(), AbpSession.TenantId, (long)AbpSession.UserId ); Logger.Debug("A client is connected: " + client); UserClients[client.ConnectionId] = client; await base.OnConnectedAsync(); }
/// <summary> /// Returns a list of all known Customer Types from Intacct /// </summary> /// <param name="client"></param> /// <returns></returns> private async Task <IList <string> > GetCustTypes(OnlineClient client, PerformContext context) { // Get Types (assume less than 1000 exist) ReadByQuery read = new ReadByQuery { ObjectName = "CUSTTYPE", PageSize = 1000 }; context.WriteLine("Loading Customer Types from Intacct"); var response = await client.Execute(read); var xmlResult = response.Results.First(); xmlResult.EnsureStatusSuccess(); return(new List <string>(xmlResult.Data.Select(el => el.Element("NAME").Value))); }
public override async Task OnConnectedAsync() { var userId = Context.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var username = Context.User.FindFirst(ClaimTypes.Name)?.Value; var client = new OnlineClient { ConnectTime = DateTime.Now, Username = username, ConnectionId = Context.ConnectionId, UserId = userId }; _clientService.Add(client); var onlineClients = _clientService.GetAll(); await Clients.All.SendAsync("ConnectedUsers", onlineClients); await base.OnConnectedAsync(); }
public override async Task OnConnectedAsync() { await base.OnConnectedAsync(); try { // connection.User?.Identity?.Name; var client = new OnlineClient( Context.ConnectionId, CommonHelper.GetClientIpAddress(), Current.User != null ? Current.User.Id : (int?)null, Current.Device != null ? Current.Device.Id : (int?)null, SysOptions.SysName); OnlineManager.Add(client); //Logger.LogInformation( "一个客户端连接: " + client + ":::" + OnlineManager.GetAllClients().Count + ":::id" + Current.Device?.Id); } catch (Exception ex) { Logger.LogError("HubBase Error" + ex.ToString(), ex); } }
public override async Task OnConnectedAsync() { var http = Context.GetHttpContext(); var client = new OnlineClient() { NickName = http.Request.Query["nickName"], Avatar = http.Request.Query["avatar"] }; lock (SyncObj) { OnlineClients[Context.ConnectionId] = client; } await base.OnConnectedAsync(); await Groups.AddToGroupAsync(Context.ConnectionId, ChatName); await Clients.GroupExcept(ChatName, new[] { Context.ConnectionId }).SendAsync("system", $"用户{client.NickName}加入了群聊"); await Clients.Client(Context.ConnectionId).SendAsync("system", $"成功加入{ChatName}"); }
/// <summary> /// Downloads a mapset banner and returns a stream for it /// </summary> /// <param name="id"></param> public static Texture2D DownloadMapsetBanner(int id) { if (DownloadScreen.MapsetBanners.ContainsKey(id)) { return(DownloadScreen.MapsetBanners[id]); } var url = OnlineClient.GetBannerUrl(id); try { using (var webClient = new WebClient()) { var data = webClient.DownloadData(url); using (var mem = new MemoryStream(data)) { var img = AssetLoader.LoadTexture2D(mem); DownloadScreen.MapsetBanners[id] = img; return(img); } } } catch (Exception) { // ignored } // Make a transparent texture. var texture = new Texture2D(GameBase.Game.GraphicsDevice, 1, 1); texture.SetData(new[] { Color.Transparent }); DownloadScreen.MapsetBanners[id] = texture; return(texture); }
//static object lookObj = new object(); public void StartServer(string ip, int port) { if (hySever == null) { hySever = new TCPSyncSocketServer(port, ip, 1024 * 1024 * 6); try { hySever.OnReceviceByte += (o, a, c) => { try { ////if(c>0) //try //{ // if (c > 0) // { // lock (lookObj) // { // datas.Add(new ZDPowerData.PowerData() { o = o, data = a, lenght = c }); // } // } //} //catch (Exception) { } DataHandle(o, a, c); //SendData(((IPEndPoint)o.RemoteEndPoint).Address.ToString(), ((IPEndPoint)o.RemoteEndPoint).Port, "Zzzdgyjk000210Zzzdgyjk"); } catch (Exception) { } }; hySever.OnOfflineClient += (c) => { try { //clientInfo.RemoveAt(clientInfo.FindIndex(o => o.Ip == ((IPEndPoint)c.RemoteEndPoint).Address.ToString())); OfflineClient?.Invoke(c); ClientInfo pd = clientInfo.Find(a => a.Ip == ((IPEndPoint)c.RemoteEndPoint).Address.ToString()); if (pd != null) { pd.OnlineTime = DateTime.Now; pd.Status = "离线中"; } } catch (Exception) { } }; hySever.OnOnlineClient += (o) => { OnlineClient?.Invoke(o); //SendData(((IPEndPoint)o.RemoteEndPoint).Address.ToString(), ((IPEndPoint)o.RemoteEndPoint).Port, "stxzjzdstart1002"); //SendData(((IPEndPoint)o.RemoteEndPoint).Address.ToString(), ((IPEndPoint)o.RemoteEndPoint).Port, "zzzdgyjk000210Zzzzdgyjk" + Environment.NewLine); ClientInfo pd = clientInfo.Find(a => a.Ip == ((IPEndPoint)o.RemoteEndPoint).Address.ToString()); if (pd != null) { pd.OnlineTime = DateTime.Now; pd.Status = "在线上"; } }; hySever.OnStateInfo += (o, a) => { StateInfo?.Invoke(o, a); }; //hySever.OnExceptionMsg += (o) => //{ // //try // //{ // // txtFxMsg.Dispatcher.BeginInvoke(new Action(() => // // { // // txtFxMsg.AppendText(Environment.NewLine + AppLogHelper.GetLogStr("----->>>" + string.Format("{0} {1}\r\n", o, DateTime.Now.ToString()), "错误消息")); // // })); // //} // //catch (Exception) { } //}; } catch (InvalidOperationException) { } catch (Exception) { } } hySever.StartListen(); (new Thread(SendHert) { IsBackground = true }).Start(); }
void Start() { if (Network.isServer) { server = GameObject.Find("Network").GetComponent<Server>(); } else { Network.isMessageQueueRunning = true; GameObject obj =GameObject.Find("Client Scripts"); client = obj.GetComponent<OnlineClient>(); hudon = obj.GetComponent<HudOn>(); print("Client Bridge initial" + Network.player); networkView.RPC("clientBridgeLoaded", RPCMode.Server, Network.player); } setUniverseBuffer = new Dictionary<NetworkPlayer, int>(); updateUniverseNamesBuffer = new Dictionary<NetworkPlayer, Dictionary<NetworkViewID, string>>(); updateCharacterNamesBuffer = new Dictionary<NetworkPlayer, Dictionary<NetworkViewID, string>>(); hasClientLoaded = new Dictionary<NetworkPlayer, bool>(); }
public void Start() { if (Application.loadedLevelName == "OnlineClient") onlineClient = GameObject.Find("Client Scripts").GetComponent<OnlineClient>(); else if (Application.loadedLevelName == "server") server = GameObject.Find("Network").GetComponent<Server>(); playerManager = gameObject.GetComponent<PlayerManager>(); firingHandler = GetComponent<FiringHandler>(); camtoggle = false; rottoggle = true; }
/// <summary> /// add or update online info when login /// </summary> /// <param name="onlineClientDto"></param> /// <returns>0:sucess;1:error, same user login on other location;2:error, max user; 3:same user login in other location 4: can not get license data 5:license expired</returns> public int LoginToOnline(OnlineClientDto onlineClientDto, string isForce, out string message) { message = ""; List <OnlineClient> onlineClientList = _OnlineClientRepository.Get(o => o.MachineIP == onlineClientDto.MachineIP && o.IsOnline == 1).ToList(); foreach (OnlineClient onlineClient in onlineClientList) { //not selfservice login user if ((onlineClient.Comments == null || onlineClient.Comments.ToLower() != "selfservice login user") && string.Compare(onlineClient.UniqueID, onlineClientDto.UniqueID, true) != 0) { //同一台机器上只能允许登陆1次,请退出后再登陆! if (isForce == "0") { UserDto user = GetUserByID(onlineClient.UniqueID); if (user != null) { message = user.LoginName; } return(1); } else { //onlineClient.IsOnline = 0; } } } //get max value string countName = "OnlineUserCheckTimePeriod"; string countValue = null; int currentOnline = 0; SystemProfile systemProfile = null; SiteProfile siteProfile = _dbContext.Set <SiteProfile>().Where(s => s.Name == countName && s.Domain == onlineClientDto.Domain && s.Site == onlineClientDto.Site).FirstOrDefault(); if (siteProfile != null && siteProfile.Value != null) { countValue = siteProfile.Value; currentOnline = _OnlineClientRepository.Get(o => o.IsOnline == 1 && o.Domain == onlineClientDto.Domain && o.Site == onlineClientDto.Site).Count(); } else { systemProfile = _dbContext.Set <SystemProfile>().Where(s => s.Name == countName && s.Domain == onlineClientDto.Domain).FirstOrDefault(); if (systemProfile != null && systemProfile.Value != null) { countValue = systemProfile.Value; currentOnline = _OnlineClientRepository.Get(o => o.IsOnline == 1 && o.Domain == onlineClientDto.Domain).Count(); } } if (countValue != null) { //Max user count reached int profileMaxUserNumber = GetMaxOnlineUserCount(countValue); if (currentOnline >= profileMaxUserNumber) { return(2); } } List <OnlineClient> onlineClientList2 = _OnlineClientRepository.Get(o => o.UniqueID == onlineClientDto.UniqueID && o.IsOnline == 1).ToList(); foreach (OnlineClient onlineClient in onlineClientList2) { //not selfservice login user //if ((onlineClient.Comments == null || onlineClient.Comments.ToLower() != "selfservice login user") // && (string.Compare(onlineClient.MachineIP, onlineClientDto.MachineIP, true) != 0 // || string.Compare(onlineClient.Comments, onlineClientDto.Comments, true) != 0)) if (onlineClient.Comments != null && onlineClient.Comments.ToLower() != "selfservice login user" && string.Compare(onlineClient.MachineIP, onlineClientDto.MachineIP, true) != 0) { //同一用户只能在一个地方登录 if (isForce == "0") { message = onlineClient.MachineName + "&" + onlineClient.MachineIP; return(3); } else { //onlineClient.IsOnline = 0; } } } //clear all offline List <OnlineClient> onlineClientList3 = _OnlineClientRepository.Get(o => o.UniqueID == onlineClientDto.UniqueID && o.IsOnline == 0).ToList(); foreach (OnlineClient onlineClient in onlineClientList3) { _OnlineClientRepository.Delete(onlineClient); } _OnlineClientRepository.SaveChanges(); //add or update online data string webUserFlag = "web login user"; // check web license var webOnline = _OnlineClientRepository.Get(o => o.IsOnline == 1 && o.Domain == onlineClientDto.Domain && o.Comments == webUserFlag).Count(); if (_license.IsSuccessed) { if (_license.IsExpired) { return(5); } if (webOnline >= _license.MaxOnlineUserCount) { return(2); } } else { return(4); } OnlineClient onlineClientOld = _OnlineClientRepository.Get(o => o.UniqueID == onlineClientDto.UniqueID && o.Comments != "selfservice login user").FirstOrDefault(); if (onlineClientOld != null && onlineClientOld.IsOnline == 1) { } else { OnlineClient onlineClientNew = Mapper.Map <OnlineClientDto, OnlineClient>(onlineClientDto); onlineClientNew.RoleName = GetUserDefaultRole(new UserDto { UniqueID = onlineClientDto.UniqueID, Domain = onlineClientDto.Domain }); _OnlineClientRepository.Add(onlineClientNew); _OnlineClientRepository.SaveChanges(); } return(0); }