public string GetAuthToken(int tenantId) { var result = string.Empty; if (!IsAvailable()) { return(result); } var userName = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).UserName ?? string.Empty; if (string.IsNullOrEmpty(userName)) { return(result); } using (var service = new JabberServiceClientWcf()) { try { result = Attempt(() => service.GetUserToken(tenantId, userName), 3); } catch (Exception error) { ProcessError(error); } } return(result); }
public override string Check(int tenantId) { try { log.Debug("CheckJabberState"); using (var jabberServiceClient = new JabberServiceClientWcf()) { jabberServiceClient.Open(); var userGuid = new Guid(fakeUserId); var user = CoreContext.UserManager.GetUsers(userGuid); var status = jabberServiceClient.HealthCheck(user.UserName, tenantId); if (status == string.Empty) { log.Debug("Jabber is OK!"); return(string.Empty); } log.ErrorFormat("Jabber is failed! {0}", status); return(status); } } catch (Exception ex) { log.ErrorFormat("Jabber is failed! {0} {1} {2}", ex.Message, ex.StackTrace, ex.InnerException != null ? ex.InnerException.Message : string.Empty); return(HealthCheckResource.ServiceCheckFailed); } }
public bool SendMessage(string to, string subject, string text, int tenantId) { if (IsServiceProbablyNotAvailable()) return false; using (var service = new JabberServiceClientWcf()) { try { service.SendMessage(to, subject, text, tenantId); return true; } catch (FaultException e) { log.Error(e); throw; } catch (CommunicationException e) { log.Error(e); lastErrorTime = DateTime.Now; } catch (TimeoutException e) { log.Error(e); lastErrorTime = DateTime.Now; } } return false; }
private JabberServiceClientWcf GetService() { var service = new JabberServiceClientWcf(); try { service.Open(); } catch (Exception error) { ProcessError(error); } return(service); }
public void Ping(string userId, int tenantId, string userName, byte state) { try { if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { service.Ping(userId, tenantId, userName, state); } } catch (Exception error) { ProcessError(error); } }
public void SendMessage(int tenantId, string from, string to, string text) { try { if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { service.SendMessage(tenantId, from, to, text, null); } } catch (Exception error) { ProcessError(error); } }
public byte SendState(int tenantId, string userName, byte state) { try { if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { return(service.SendState(tenantId, userName, state)); } } catch (Exception error) { ProcessError(error); } return(Chat.UserOffline); }
public void SendCommand(int tenantId, string from, string to, string command, bool fromTenant) { if (!IsAvailable()) { return; } using (var service = new JabberServiceClientWcf()) { try { service.SendCommand(tenantId, from, to, command, fromTenant); } catch (Exception error) { ProcessError(error); } } }
public MessageClass[] GetRecentMessages(int tenantId, string from, string to, int id) { MessageClass[] messages = null; try { if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { messages = service.GetRecentMessages(tenantId, from, to, id); } } catch (Exception error) { ProcessError(error); } return(messages); }
public byte GetState(int tenantId, string userName) { byte state = 0; try { if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { state = service.GetState(tenantId, userName); } } catch (Exception error) { ProcessError(error); } return(state); }
public Dictionary <string, byte> GetAllStates(int tenantId, string userName) { Dictionary <string, byte> states = null; try { if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { states = service.GetAllStates(tenantId, userName); } } catch (Exception error) { ProcessError(error); } return(states); }
public int GetNewMessagesCount(int tenantId, string userName) { var result = 0; if (string.IsNullOrEmpty(userName) || !IsAvailable()) { return(result); } using (var service = new JabberServiceClientWcf()) { try { result = service.GetNewMessagesCount(tenantId, userName); } catch (Exception error) { ProcessError(error); } } return(result); }
public byte RemoveXmppConnection(string connectionId, string userName, int tenantId) { byte result = Chat.UserOffline; if (!IsAvailable()) { throw new Exception(); } using (var service = new JabberServiceClientWcf()) { try { result = service.RemoveXmppConnection(connectionId, userName, tenantId); } catch (Exception error) { ProcessError(error); } return(result); } }