Ejemplo n.º 1
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);
            }
        }