public void OnServiceStart()
        {
            NotificationBusiness objNotificationBusiness = new NotificationBusiness();

            objNotificationBusiness.WriteErrLog("Service is Started");
            timeDelay.Enabled = true;
        }
        protected override void OnStart(string[] args)
        {
            NotificationBusiness objNotificationBusiness = new NotificationBusiness();

            objNotificationBusiness.WriteErrLog("Service is Started");
            timeDelay.Enabled = true;
        }
        protected override void OnStop()
        {
            NotificationBusiness objNotificationBusiness = new NotificationBusiness();

            objNotificationBusiness.WriteErrLog("Service is Stoped");
            timeDelay.Enabled = false;
        }
Beispiel #4
0
        public object ViewNotification([FromBody] ParamNotificationView obj)
        {
            NotificationBusiness objnote = new NotificationBusiness();

            return(new DivisionListResult()
            {
                IsSuccess = true, Notification = objnote.ViewNotification(obj)
            });
        }
Beispiel #5
0
        public ActionResult DetailNotification(int id)
        {
            INotificationBusiness       notificationBusiness = new NotificationBusiness();
            DetailNotificationViewModel model = new DetailNotificationViewModel();

            DataAccess.Notification currentNotification = notificationBusiness.GetNotiByIdAndSetReadState(id);
            model.Content = currentNotification.Content;
            model.Time    = currentNotification.Time.ToShortDateString() + " " + currentNotification.Time.ToShortTimeString();
            model.Title   = currentNotification.Title;
            return(PartialView(model));
        }
        private void BallotingProcess()
        {
            NotificationBusiness objNotificationBusiness = new NotificationBusiness();
            DataTable            GetBookedTable          = new DataTable();
            DataTable            GetResultTalbe          = new DataTable();

            try
            {
                GetBookedTable = objNotificationBusiness.GetBookedTable();
                GetBookedTable = CollectionExtensions.OrderRandomly(GetBookedTable.AsEnumerable()).CopyToDataTable();
                foreach (DataRow row in GetBookedTable.Rows)
                {
                    // start balloting 7 day in advance before the start date
                    DateTime startDate = DateTime.Parse(row["startDate"].ToString());
                    DateTime ballotDay = startDate.AddDays(-7);
                    // get record from record table with eventcode condition
                    GetResultTalbe = objNotificationBusiness.GetResultTable(row["eventCode"].ToString());
                    // count number of quantity and number of booked record
                    int numberOfRecords = GetResultTalbe.AsEnumerable().Where(x => x["eventCode"].ToString() == row["eventCode"].ToString()).ToList().Count;
                    int quantity        = Int32.Parse(row["quantity"].ToString());
                    // count user uid to prevent duplication
                    int bookedRecord = GetResultTalbe.AsEnumerable().Where(x => x["uid"].ToString() == row["uid"].ToString()).ToList().Count;
                    // < 0 earlier      > 0 later

                    if (DateTime.Compare(ballotDay, DateTime.Now) < 0 && numberOfRecords < quantity && bookedRecord == 0)
                    {
                        var status = "approved";
                        try
                        {
                            objNotificationBusiness.UpdateBallotResult(row["eventCode"].ToString(), Int32.Parse(row["uid"].ToString()), DateTime.Parse(row["date"].ToString()), status);
                            //send email upon successfully booked
                            var strSubject = "Success Booking On " + row["eventname"].ToString();
                            var strBody    = "you have successfully book event " + row["eventname"].ToString() + "on" + row["bookedDate"].ToString();
                            var Email      = row["email"].ToString();
                            SendEmail(strSubject, strBody, Email);
                            //send to admin
                            var strAdminSubject = "Booking On " + row["eventname"].ToString();
                            var strAdminBody    = row["eventname"].ToString() + "have successfully book event " + row["eventname"].ToString() + "on" + row["bookedDate"].ToString();
                            var adminEmail      = "*****@*****.**";
                            SendEmail(strAdminSubject, strAdminBody, adminEmail);
                        }
                        catch (Exception ex)
                        {
                            throw ex;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #7
0
        private async Task SendAlertFor(Alert alert)
        {
            if (alert.TypeOfNotification == NotificationType.WebHook)
            {
                await NotificationBusiness.CallWebHookAsync(alert.Target);
            }
            else
            {
                var eventTypes = new List <string>();
                if ((alert.EventLevelValue & (int)EventLevel.Fatal) == (int)EventLevel.Fatal)
                {
                    eventTypes.Add("Fatal Errors");
                }

                if ((alert.EventLevelValue & (int)EventLevel.Error) == (int)EventLevel.Error)
                {
                    eventTypes.Add("Errors");
                }

                if ((alert.EventLevelValue & (int)EventLevel.Warning) == (int)EventLevel.Warning)
                {
                    eventTypes.Add("Warnings");
                }

                Application app = await ApplicationBusiness.GetByIdAsync(alert.AppId);

                string body =
                    "Dear {0}<br/>, You are receiving this alert because the number of received {1} events from application {2} has exceeded the configured threshold which is {3}.";

                try
                {
                    var          assembly     = Assembly.GetExecutingAssembly();
                    const string resourceName = "Logman.Business.Resources.Alert.html";
                    using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                        if (stream != null)
                        {
                            using (var reader = new StreamReader(stream))
                            {
                                body = reader.ReadToEnd();
                            }
                        }
                }
                catch
                {
                    // Exceptions are ignored because in case of an error, we use the plain text.
                }

                body = string.Format(body, alert.Target, string.Join(" and ", eventTypes), app.AppName, alert.Value);

                await NotificationBusiness.SendEmailAsync(alert.Target, body);
            }
        }
        public static void SendNotification(IEnumerable <Guid> users, Guid notificationId)
        {
            try
            {
                var notif = NotificationBusiness.GetById(notificationId);

                if (notif == null)
                {
                    LogBusiness.Warn(string.Format("[SignalRClientBusiness] SendNotification - Notificação não encontrada ({0})", notificationId));
                    return;
                }

                if ((notif.DateStartNotification > DateTime.Now.Date) ||
                    (notif.DateEndNotification != null && DateTime.Now.Date > notif.DateEndNotification))
                {
                    LogBusiness.Info(string.Format("[SignalRClientBusiness] SendNotification - Notificação fora do período programado ({0})", notificationId));
                    return;
                }

                var notifP = new Notification.Entity.SignalR.Notification()
                {
                    Id      = notif.Id,
                    Title   = notif.Title,
                    Message = notif.Message
                };

                var hubConnection = new HubConnection(UrlSignalRServer);
                var hub           = hubConnection.CreateHubProxy("notificationHub");

                hubConnection.Headers.Add("Authorization", "Basic " + Base64Encode(UserCredentialSignalRServer, PasswordCredentialSignalRServer));

                hubConnection.Start().Wait();

                int i     = 0;
                int total = users.Count();

                while (i < total)
                {
                    var ltU = users.Skip(i).Take(1000).ToList();
                    LogBusiness.Debug(string.Format("[SignalRClientBusiness] SendNotification - Enviando... ({0}-{1})", i, ltU.Count));
                    hub.Invoke("SendNotification", ltU, notifP).Wait();
                    i += 1000;
                }

                hubConnection.Stop();
            }
            catch (Exception exc)
            {
                LogBusiness.Error(exc);
                throw;
            }
        }
Beispiel #9
0
 public HttpResponseMessage SaveAction(NotificationAction entity)
 {
     try
     {
         NotificationBusiness.Action(filterActionUser.UserId, entity);
         return(Request.CreateResponse(HttpStatusCode.OK));
     }
     catch (Exception exc)
     {
         var logId = LogBusiness.Error(exc);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel(logId)));
     }
 }
Beispiel #10
0
 public EzTaskBusiness(AccountBusiness account,
                       ProjectBusiness project, SkillBusiness skill,
                       PhaseBusiness phase, TaskBusiness task,
                       NotificationBusiness notification,
                       ToDoListBusiness toDoList)
 {
     Account      = account;
     Project      = project;
     Skill        = skill;
     Phase        = phase;
     Task         = task;
     Notification = notification;
     ToDoList     = toDoList;
 }
        public IHttpActionResult Get()
        {
            try
            {
                var notificationBusiness = new NotificationBusiness();

                var notificationList = notificationBusiness.GetList();

                return(Ok(notificationList));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
Beispiel #12
0
        protected void Application_Start()
        {
            // ModelBinders.Binders.Add(typeof (Consultation), new DebugModelBinder());
            //Bootstrap.Configure();
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            InitializeBusiness.Initilize();
            var send    = new NotificationBusiness();
            var sendSMS = new SMSBusiness();

            send.sendNotification();
            sendSMS.sendSMS();
            //throw new Exception(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
        }
 public object DeleteNotificationType([FromBody] NotificationTypeUpdateParam PM)
 {
     try
     {
         NotificationBusiness b = new NotificationBusiness();
         var Result             = b.DeleteNotificationType(PM);
         return(Result);
     }
     catch (Exception e)
     {
         return(new Error()
         {
             IsError = true, Message = e.Message
         });
     }
 }
 public object AddNotificationType([FromBody] NotificationTypeParam obj)
 {
     try
     {
         NotificationBusiness save = new NotificationBusiness();
         var result = save.SaveNotificationType(obj);
         return(result);
     }
     catch (Exception e)
     {
         return(new Error()
         {
             IsError = true, Message = e.Message
         });
     }
 }
 protected void MakeOrderAccept_ServerClick(object sender, EventArgs e)
 {
     if (usernameTxt.Value != null && userPhoneTxt.Value != null && adressTxt.Value != null && amountTxt.Value != null && datePicker.Value != null)
     {
         OrderProduct         order                = new OrderProduct(usernameTxt.Value, userPhoneTxt.Value, adressTxt.Value, Convert.ToInt32(Session["IDP"]), Convert.ToInt32(amountTxt.Value), datePicker.Value);
         Notification         notification         = new Notification("Se ha realizado un nuevo pedido a nombre de " + usernameTxt.Value + ". Recuerde revisarla cuanto antes.", false);
         NotificationBusiness notificationBusiness = new NotificationBusiness();
         notificationBusiness.AddNotificationService(notification);
         resultMessage.InnerText = orderBusiness.CreateOrderBusiness(order);
     }
     else
     {
         resultMessage.InnerText = "Debe llenar todos los campos requeridos.";
     }
     ModalPopupExtender1.Show();
 }
        public object GetNotificationTypeInfo(UserCredential uc)
        {
            try
            {
                NotificationBusiness events = new NotificationBusiness();
                var Result = events.GetNotificationType(uc);

                return(Result);
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }
        public object UpdateNotificationType(NotificationTypeUpdateParam b)
        {
            try
            {
                NotificationBusiness type = new NotificationBusiness();
                var Result = type.NotificationTypeUpdate(b);

                return(Result);
            }
            catch (Exception e)
            {
                return(new Error()
                {
                    IsError = true, Message = e.Message
                });
            }
        }
        public void WorkProcess(object sender, System.Timers.ElapsedEventArgs e)
        {
            NotificationBusiness objNotificationBusiness = new NotificationBusiness();

            try
            {
                timeDelay.Enabled = false;
                BallotingProcess();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                timeDelay.Enabled = true;
            }
        }
Beispiel #19
0
        public HttpResponseMessage GetById(Guid id)
        {
            try
            {
                var result = NotificationBusiness.GetById(id);

                if (result == null)
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, result));
                }
            }
            catch (Exception exc)
            {
                var logId = LogBusiness.Error(exc);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel(logId)));
            }
        }
Beispiel #20
0
 public HttpResponseMessage Save2(Notification.Entity.API.Notification entity)
 {
     try
     {
         var notificationId = NotificationBusiness.Save(entity);
         return(Request.CreateResponse(HttpStatusCode.Created, notificationId));
     }
     catch (NotificationRecipientIsEmptyException exc)
     {
         return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, new ErrorModel(1, exc.Message)));
     }
     catch (NotificationWithoutRecipientException exc)
     {
         return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, new ErrorModel(2, exc.Message)));
     }
     catch (Exception exc)
     {
         var logId = LogBusiness.Error(exc);
         return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel(logId)));
     }
 }
Beispiel #21
0
        public HttpResponseMessage GetByUserId(Guid userId, bool read)
        {
            try
            {
                long total  = 0;
                var  result =
                    read ?
                    NotificationBusiness.GetReadByUserId(userId, filterActionPaginate.Page, filterActionPaginate.Size, out total) :
                    NotificationBusiness.GetNotReadByUserId(userId, filterActionPaginate.Page, filterActionPaginate.Size, out total);

                var response = Request.CreateResponse(HttpStatusCode.OK, result);
                response.Headers.Add("Total", total.ToString());

                return(response);
            }
            catch (Exception exc)
            {
                var logId = LogBusiness.Error(exc);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, new ErrorModel(logId)));
            }
        }
Beispiel #22
0
        public HttpResponseMessage GetById(Guid id)
        {
            try
            {
                long total   = 0;
                var  ltNotif = NotificationBusiness.GetNotReadByUserId(id, 0, 100, out total);
                var  users   = new List <Guid>();
                users.Add(id);

                foreach (var item in ltNotif)
                {
                    Business.Signal.SignalRClientBusiness.SendNotificationHangFire(users, item.Id);
                }

                var result = LogBusiness.GetById(id);
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception exc)
            {
                var logId = LogBusiness.Error(exc);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, logId));
            }
        }
 public NotificationController(NotificationBusiness notificationBusiness)
 {
     _notificationBusiness = notificationBusiness;
 }
Beispiel #24
0
        public object ViewAllNotification([FromBody] ParamNotificationView obj)
        {
            NotificationBusiness objnote = new NotificationBusiness();

            return(objnote.ViewAllNotification(obj));
        }
Beispiel #25
0
        public object SaveNotification([FromBody] ParamNotification obj)
        {
            NotificationBusiness objnote = new NotificationBusiness();

            return(objnote.SaveNotification(obj));
        }
 public NotificationProfileFacade(string connectionString) : base(connectionString)
 {
     rep = new NotificationBusiness(Connection);
 }
Beispiel #27
0
        public object UpdateNotification([FromBody] ParamNotificationUpdate obj)
        {
            NotificationBusiness objnote = new NotificationBusiness();

            return(objnote.UpdateNotification(obj));
        }
Beispiel #28
0
        public object ViewEventHoliday([FromBody] ParamNotificationView obj)
        {
            NotificationBusiness objnote = new NotificationBusiness();

            return(objnote.ViewEventHoliday(obj));
        }