Пример #1
0
        private void GenerateNotificationsFromDB(ERP_DB ctx, int notificationID)
        {
            List <SpisWezwania> NotificationsDB;

            NotificationsDB = ctx.SpisWezwania.Where(n => n.ID == notificationID).ToList();


            foreach (SpisWezwania wezwanie in NotificationsDB)
            {
                var AcceptedTypes = new List <int>()
                {
                    1, 2
                };                                            //tmp
                var ActiveWithoutOT = wezwanie.SchouldBeAvailableIfNoOtVisualization;

                if (ActiveWithoutOT)
                {
                    AcceptedTypes.Add(-1);
                }

                Notification notification = new Notification(this)
                {
                    AcceptedTypes    = AcceptedTypes,
                    TemplateMail     = wezwanie.TemplateMail,
                    TemplateSMS      = wezwanie.TemplateSMS,
                    TemplateVoice    = wezwanie.TemplateVoice,
                    NotificationId   = wezwanie.ID,
                    NeedConfirmation = wezwanie.NeedConfirmation,
                    Nazwa            = wezwanie.Nazwa
                };
                NotificationsList.Add(notification);
            }
        }
Пример #2
0
 public void DoNotificationRequest(ERP_DB ctx, Dictionary <string, string> holders, int notificationID)
 {
     try
     {
         GenerateNotificationsFromDB(ctx, notificationID);
         ExecuteNotifications(ctx, holders, notificationID);
     }
     catch (Exception ex)
     {
         Console.WriteLine("NotificationsGenerator exception: " + ex.ToString());
     }
 }
Пример #3
0
        internal override void GetAndFillTemplate(ERP_DB ctx, Dictionary <string, string> holders, int notificationId)
        {
            var spisWezwania = ctx.SpisWezwania.Find(notificationId);

            if (holders != null)
            {
                NotificationBody = spisWezwania.TemplateSMS;
                foreach (var h in holders)
                {
                    NotificationBody = NotificationBody.Replace("{" + h.Key + "}", h.Value);
                }
            }
            else
            {
                NotificationBody = "Puste wezwanie";
            }
        }
Пример #4
0
        public void ExecuteNotification(ERP_DB _chartsCtx, Dictionary <string, string> holders, int notificationId)
        {
            NotificationEmail  Email  = null;
            NotificationSMS    SMS    = null;
            NotificationVoice  Voice  = null;
            NotificationVerbal Verbal = null;

            foreach (var tmp in RawOperators)
            {
                if (tmp.SendMail)
                {
                    AddRecipient(tmp.SpisPracownikowID, /*test*/ "*****@*****.**", ref Email);
                }
                if (tmp.SendSMS)
                {
                    AddRecipient(tmp.SpisPracownikowID, /*test*/ "691884748", ref SMS);
                }
                if (tmp.SendVoice)
                {
                    AddRecipient(tmp.SpisPracownikowID, /*test*/ "691884748", ref Voice);
                }
                if (!tmp.SendMail && !tmp.SendSMS && !tmp.SendSMS)
                {
                    AddRecipient(tmp.SpisPracownikowID, "", ref Verbal);
                }
            }

            if (Email != null)
            {
                Email.NameForTitle = Nazwa;
                Email.Template     = TemplateMail;
            }
            if (SMS != null)
            {
                SMS.Template = TemplateSMS;
            }
            if (Voice != null)
            {
                Voice.Template = TemplateVoice;
            }

            ListToSend.ForEach(x => x.SendNotifications(_chartsCtx, holders, notificationId));
        }
        internal void DoRequest(ERP_DB ctx, ref Dictionary <string, string> holders, int notificationID, string plant)
        {
            var userFromPlaceHolders = holders.SingleOrDefault(holder => holder.Key != null && holder.Key.Equals("user")).Value;
            var phoneNumber          = ctx.SpisPracownikow.FirstOrDefault(user => user.ImieNaziwsko != null && user.ImieNaziwsko.Equals(userFromPlaceHolders)).Telefon;

            var typWezwania = ctx.SpisWezwania.SingleOrDefault(sw => sw.ID == notificationID).TypyWezwanID;
            var voiceType   = 2; //tmp

            if (typWezwania == voiceType)
            {
                var notifVoice = new NotificationVoice();
                notifVoice.GetAndFillTemplate(ctx, holders, notificationID);
                VoiceRequest(phoneNumber, notifVoice.NotificationBody);
            }
            else
            {
                var notifSms = new NotificationSMS();
                notifSms.GetAndFillTemplate(ctx, holders, notificationID);
                SmsRequest(phoneNumber, notifSms.NotificationBody);
            }
        }
Пример #6
0
 public EventsController()
 {
     ctx = new ERP_DB();
 }
Пример #7
0
 internal virtual void GetAndFillTemplate(ERP_DB ctx, Dictionary <string, string> holders, int notificationId)
 {
     throw new NotImplementedException("Function GetAndFillTemplate in base class is not overrided.");
 }
Пример #8
0
        internal void SendNotifications(ERP_DB ctx, Dictionary <string, string> holders, int notificationId)
        {
            GetAndFillTemplate(ctx, holders, notificationId);

            SendNotificationsSpecified();
        }
Пример #9
0
 private void ExecuteNotifications(ERP_DB ctx, Dictionary <string, string> holders, int notificationId)
 {
     NotificationsList.ForEach(x => x.ExecuteNotification(ctx, holders, notificationId));
 }
Пример #10
0
 public ZlecenieController()
 {
     ctx = new ERP_DB();
 }
 public TraceabilityController()
 {
     ctx = new ERP_DB();
 }
Пример #12
0
 public ChartsController()
 {
     ctx = new ERP_DB();
 }
 public TechnologController()
 {
     ctx = new ERP_DB();
 }
 public HomeController()
 {
     ctx = new ERP_DB();
 }
 public KontrolaJakosciController()
 {
     ctx = new ERP_DB();
 }
 public SpisPracownikowController()
 {
     ctx = new ERP_DB();
 }