Beispiel #1
0
 protected void SendNotification(ServiceNotification notification, ServiceStatus status, Reply replyObject = null, String msg = "")
 {
     if (Notifications != null)
     {
         Notifications(notification,
                       status,
                       replyObject,
                       msg);
     }
 }
Beispiel #2
0
 //
 // Notify callback for the TCP/IP Server
 //
 public void HandleSocketServerCallbacks(ServiceNotification notification, ServiceStatus status, Reply reply, String msg)
 {
     if (notification == ServiceNotification.StatusChange)
     {
         HandleSocketServerStatusChange(status);
     }
     else
     {
         HandleSocketServerNotification(notification, status, (SocketServer.ServerReplyContext)reply, msg);
     }
 }
        /// <inheritdoc cref="ServiceNotificationRepository.Remove"/>
        public bool Remove(
            ServiceNotification notification)
        {
            if (notification == null)
            {
                return(false);
            }

            _context.Remove(notification);
            return(_context.SaveChangesAsync().Result > 0);
        }
        /// <inheritdoc cref="ServiceNotificationRepository.Update"/>
        public bool Update(
            ServiceNotification notification)
        {
            var existingSite = Get(notification.Id.ToString());

            if (existingSite == null)
            {
                return(false);
            }

            _context.ServiceNotification.Update(existingSite);
            return(_context.SaveChangesAsync().Result > 0);
        }
Beispiel #5
0
        //
        // Notify callback for the TCP/IP Client
        //
        public void HandleClientNotifications(ServiceNotification notify, ServiceStatus status, Reply reply, String msg)
        {
            String s = null;

            switch (notify)
            {
            case ServiceNotification.StatusChange:
                if (status == ServiceStatus.Started)
                {
                    s = "Connecting to " + Settings.ClientHost + ":" + Settings.ClientPort;
                    SetStatusBar(s);
                    HideCommandWindow();
                }
                else if (status == ServiceStatus.Connected)
                {
                    s = "Connected to " + Settings.ClientHost + ":" + Settings.ClientPort;
                    SetStatusBar(s);
                    ShowCommandWindow();
                }
                else if (status == ServiceStatus.Stopped)
                {
                    s = "Stopped.";
                    SetStatusBar("Client/Sever Not Active");
                    HideCommandWindow();
                }
                else if (status == ServiceStatus.Sleeping)
                {
                    s = "Waiting " + (Settings.ClientDelayTime / 1000) +
                        " seconds to connect.";
                    SetStatusBar(s);
                    HideCommandWindow();
                }
                break;

            case ServiceNotification.ReceivedData:
                AddLogEntry(String.Format("Client: Received; {0}", msg));
                ReceivedData(reply, (string)msg);
                return;

            case ServiceNotification.Error:
                AddLogEntry("Client: Error; " + (string)msg);
                RestartClient();
                return;

            default:
                s = "Unknown notification";
                break;
            }
            AddLogEntry("Client: " + s);
        }
Beispiel #6
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            int delay = 9990;

            statusLabelTime.Text = AppCommon.GetServerDateTime().ToString();
            if (worker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }
            while (!worker.CancellationPending)
            {
                if (Program.CURR_USER != null)
                {
                    ServiceNotification      _serviceNotofication = new ServiceNotification();
                    List <NotificationModel> lstNotiofication     = _serviceNotofication.GetAllAssociationNotifications(Program.CURR_USER.EmployeeID);
                    #region FOLLOWP NOTIFICATIONS
                    List <NotificationModel> lstFollowUps = _serviceNotofication.GetAllFollowupsNotifications(Program.CURR_USER.EmployeeID);
                    foreach (NotificationModel model in lstFollowUps)
                    {
                        notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
                        //notifyIcon1.Icon = new Icon("global::appExcelERP.Properties.Resources.Excel_logo");
                        //notifyIcon1.BalloonTipIcon =(new ToolTipIcon()).  global::appExcelERP.Properties.Resources.Excel_logo;
                        notifyIcon1.BalloonTipText  = model.Description;
                        notifyIcon1.BalloonTipTitle = model.Title;
                        notifyIcon1.ShowBalloonTip(delay);
                        Thread.Sleep(delay);
                    }
                    #endregion

                    #region APPROVE PENDING LEAVES NOTIFICATION
                    List <NotificationModel> lstApproveLeaves = _serviceNotofication.GetAllLeaveApprovalNotification(Program.CURR_USER.EmployeeID, Program.CURR_USER.FinYearID);
                    foreach (NotificationModel model in lstApproveLeaves)
                    {
                        notifyIcon1.BalloonTipIcon  = ToolTipIcon.Info;
                        notifyIcon1.Icon            = System.Drawing.SystemIcons.Information;
                        notifyIcon1.BalloonTipText  = model.Description;
                        notifyIcon1.BalloonTipTitle = model.Title;
                        //notifyIcon1.Text = model.Description;
                        notifyIcon1.ShowBalloonTip(5555);
                        Thread.Sleep(5555);
                    }
                    #endregion
                }
            }
            e.Cancel = true;
        }
Beispiel #7
0
        //
        // Notify callback for the TCP/IP Client
        //
        public void clientSocketNotificationHandler(ServiceNotification notify, ServiceStatus status, Reply reply, String msg)
        {
            SetClientStatus(status);
            String s = null;

            switch (notify)
            {
            case ServiceNotification.StatusChange:
                if (status == ServiceStatus.Started)
                {
                    Logger.Instance.Log4.Debug("ClientSocketNotificationHandler - ServiceStatus.Started");
                    s = $"Connecting to {Settings.ClientHost}:{Settings.ClientPort}";
                }
                else if (status == ServiceStatus.Connected)
                {
                    Logger.Instance.Log4.Debug("ClientSocketNotificationHandler - ServiceStatus.Connected");
                    s = $"Connected to {Settings.ClientHost}:{Settings.ClientPort}";
                }
                else if (status == ServiceStatus.Stopped)
                {
                    Logger.Instance.Log4.Debug("ClientSocketNotificationHandler - ServiceStatus.Stopped");
                    s = "Stopped";
                }
                else if (status == ServiceStatus.Sleeping)
                {
                    Logger.Instance.Log4.Debug("ClientSocketNotificationHandler - ServiceStatus.Sleeping");
                    s = $"Waiting {(Settings.ClientDelayTime / 1000)} seconds to connect";
                }
                break;

            case ServiceNotification.ReceivedData:
                Logger.Instance.Log4.Info($"Client: Received; {msg}");
                ReceivedData(reply, (string)msg);
                return;

            case ServiceNotification.Error:
                Logger.Instance.Log4.Debug($"ClientSocketNotificationHandler - ServiceStatus.Error: {(string)msg}");
                Logger.Instance.Log4.Info($"Client: Error; {(string)msg}");
                RestartClient();
                return;

            default:
                s = "Unknown notification";
                break;
            }
            Logger.Instance.Log4.Info($"Client: {s}");
        }
Beispiel #8
0
        //
        // Notify callback for the Serial Server
        //
        public void HandleSerialServerNotifications(ServiceNotification notify, ServiceStatus status, Reply reply, String msg)
        {
            SetSerialStatus(status);
            String s = null;

            switch (notify)
            {
            case ServiceNotification.StatusChange:
                switch (status)
                {
                case ServiceStatus.Started:
                    s = $"SerialServer: Opening port: {msg}";
                    break;

                case ServiceStatus.Waiting:
                    s = $"SerialServer: Waiting for commands on {msg}...";
                    //SetStatus("Waiting for Serial commands...");
                    break;

                case ServiceStatus.Stopped:
                    s = "SerialServer: Stopped";
                    //SetStatus("Serial Server Not Active");
                    break;
                }
                break;

            case ServiceNotification.ReceivedData:
                Logger.Instance.Log4.Info($"SerialServer: Received: {msg}");
                ReceivedData(reply, (string)msg);
                return;

            case ServiceNotification.Error:
                s = $"SerialServer: Error: {msg}";
                break;

            default:
                s = "SerialServer: Unknown notification";
                break;
            }
            Logger.Instance.Log4.Info(s);
        }
Beispiel #9
0
        //
        // Notify callback for the Serial Server
        //
        public void HandleSerialServerNotifications(ServiceNotification notify, ServiceStatus status, Reply reply, String msg)
        {
            String s = null;

            switch (notify)
            {
            case ServiceNotification.StatusChange:
                switch (status)
                {
                case ServiceStatus.Started:
                    s = String.Format("SerialServer: Opening port: {0}", msg);
                    break;

                case ServiceStatus.Waiting:
                    s = String.Format("SerialServer: Waiting for commands on {0}...", msg);
                    SetStatusBar("Waiting for Serial commands...");
                    break;

                case ServiceStatus.Stopped:
                    s = "SerialServer: Stopped.";
                    SetStatusBar("Serial Server Not Active");
                    break;
                }
                break;

            case ServiceNotification.ReceivedData:
                AddLogEntry(String.Format("SerialServer: Received: {0}", msg));
                ReceivedData(reply, (string)msg);
                return;

            case ServiceNotification.Error:
                s = String.Format("SerialServer: Error: {0}", msg);
                break;

            default:
                s = "SerialServer: Unknown notification";
                break;
            }
            AddLogEntry(s);
        }
Beispiel #10
0
        /// <summary>
        /// A simple function that takes a string and does a ToUpper
        /// </summary>
        /// <param name="input"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public ResponseNotification FunctionHandler(Notification Input, ILambdaContext context)
        {
            var outResponse = new ResponseNotification()
            {
                Error = false, Status = 1, Message = "OK"
            };

            try
            {
                outResponse = Validation(Input);
                if (!outResponse.Error)
                {
                    Input.State                = StateNotification.Send.GetHashCode();
                    Input.IdNotification       = context.AwsRequestId;
                    Input.ReminderSend.NetTime = Input.ReminderSend.Begin;
                    Input.Try = 0;
                    if (Input.ReminderSend.IsRemainder)
                    {
                        ServiceNotification.Save(Input);
                    }
                    else
                    {
                        ServicePublication.SendMessage(Input);
                        outResponse.Message = context.AwsRequestId;
                        context.Logger.Log("se registro notificacion:" + context.AwsRequestId);
                    }
                }
            }
            catch (Exception ex)
            {
                outResponse.Error   = true;
                outResponse.Status  = ex.HResult;
                outResponse.Message = ex.Message;
                context.Logger.Log($"--Error--  \r Status: {ex.HResult} \r  Mensaje: {ex.Message} \r Source: {ex.Source} \r Trace: {ex.StackTrace}");
            }
            return(outResponse);
        }
Beispiel #11
0
 public UserController(IUserApplication userApp, ServiceNotification notification)
     : base(notification)
 {
     _userApp = userApp;
 }
Beispiel #12
0
 protected void SendNotification(ServiceNotification notification, ServiceStatus status, Reply replyContext = null, String msg = "")
 {
     Notifications?.Invoke(notification, status, replyContext, msg);
 }
 /// <inheritdoc cref="ServiceNotificationRepository.Add"/>
 public bool Add(
     ServiceNotification notification)
 {
     _context.ServiceNotification.AddAsync(notification);
     return(_context.SaveChangesAsync().Result > 0);
 }
 public BaseController(ServiceNotification notification)
 {
     _notification = notification;
 }
Beispiel #15
0
        private void HandleSocketServerNotification(ServiceNotification notification, ServiceStatus status,
                                                    SocketServer.ServerReplyContext serverReplyContext, String msg)
        {
            var s = "";

            switch (notification)
            {
            case ServiceNotification.ReceivedData:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = $"SocketServer: Received from Client #{serverReplyContext.ClientNumber} at {serverReplyContext.Socket.RemoteEndPoint}: {msg}";
                Logger.Instance.Log4.Info(s);
                ReceivedData(serverReplyContext, msg);
                return;

            case ServiceNotification.Write:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = $"Wrote to Client #{serverReplyContext.ClientNumber} at {serverReplyContext.Socket.RemoteEndPoint}: {msg}";
                break;

            case ServiceNotification.WriteFailed:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = $"Write failed to Client #{serverReplyContext.ClientNumber} at {serverReplyContext.Socket.RemoteEndPoint}: {msg}";
                break;

            case ServiceNotification.ClientConnected:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = $"Client #{serverReplyContext.ClientNumber} at {serverReplyContext.Socket.RemoteEndPoint} connected";
                break;

            case ServiceNotification.ClientDisconnected:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = $"Client #{serverReplyContext.ClientNumber} at {serverReplyContext.Socket.RemoteEndPoint} has disconnected";
                break;

            case ServiceNotification.Wakeup:
                s = $"Wakeup: {(string)msg}";
                break;

            case ServiceNotification.Error:
                switch (status)
                {
                case ServiceStatus.Waiting:
                case ServiceStatus.Stopped:
                case ServiceStatus.Sleeping:
                    s = $"({status}): {msg}";
                    break;

                case ServiceStatus.Connected:
                    if (serverReplyContext != null)
                    {
                        Debug.Assert(serverReplyContext.Socket != null);
                        Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null);
                        s = $"(Client #{serverReplyContext.ClientNumber} at {(serverReplyContext.Socket == null ? "n/a" : serverReplyContext.Socket.RemoteEndPoint.ToString())}): {msg}";
                    }
                    else
                    {
                        s = msg;
                    }

                    break;
                }
                s = "Error " + s;
                break;

            default:
                s = "Unknown notification: " + notification;
                break;
            }
            Logger.Instance.Log4.Info($"SocketServer: {s}");
        }
 private void CloseNotification(ServiceNotification n)
 {
     n.Close();
 }
Beispiel #17
0
        private void HandleSocketServerNotification(ServiceNotification notification, ServiceStatus status,
                                                    SocketServer.ServerReplyContext serverReplyContext, String msg)
        {
            String s = "";

            switch (notification)
            {
            case ServiceNotification.ReceivedData:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = String.Format("Server: Received from Client #{0} at {1}: {2}",
                                  serverReplyContext.ClientNumber, serverReplyContext.Socket.RemoteEndPoint, msg);
                AddLogEntry(s);
                ReceivedData(serverReplyContext, msg);
                return;

            case ServiceNotification.Write:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = String.Format("Wrote to Client #{0} at {1}: {2}",
                                  serverReplyContext.ClientNumber, serverReplyContext.Socket.RemoteEndPoint, msg);
                break;

            case ServiceNotification.WriteFailed:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = String.Format("Write failed to Client #{0} at {1}: {2}",
                                  serverReplyContext.ClientNumber, serverReplyContext.Socket.RemoteEndPoint, msg);
                break;

            case ServiceNotification.ClientConnected:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = String.Format("Client #{0} at {1} connected.",
                                  serverReplyContext.ClientNumber, serverReplyContext.Socket.RemoteEndPoint);
                break;

            case ServiceNotification.ClientDisconnected:
                Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null, notification.ToString());
                s = String.Format("Client #{0} at {1} has disconnected.",
                                  serverReplyContext.ClientNumber, serverReplyContext.Socket.RemoteEndPoint);
                break;

            case ServiceNotification.Wakeup:
                s = "Wakeup: " + (string)msg;
                break;

            case ServiceNotification.Error:
                switch (status)
                {
                case ServiceStatus.Waiting:
                case ServiceStatus.Stopped:
                case ServiceStatus.Sleeping:
                    s = String.Format("{0}: {1}", status, msg);
                    break;

                case ServiceStatus.Connected:
                    if (serverReplyContext != null)
                    {
                        Debug.Assert(serverReplyContext.Socket != null);
                        Debug.Assert(serverReplyContext.Socket.RemoteEndPoint != null);
                        s = String.Format("(Client #{0} at {1}): {2}",
                                          serverReplyContext.ClientNumber,
                                          serverReplyContext.Socket == null
                                        ? "n/a"
                                        : serverReplyContext.Socket.RemoteEndPoint.ToString(),
                                          msg);
                    }
                    else
                    {
                        s = msg;
                    }
                    break;
                }
                s = "Error " + s;
                break;

            default:
                s = "Unknown notification: " + notification;
                break;
            }
            AddLogEntry("Server: " + s);
        }