Ejemplo n.º 1
0
        private BusinessLogic.interoperabilita.CalendarMail.MailRequest CreateMailRequest(string idamministrazione)
        {
            System.Data.DataSet ds;
            string smtp_user = string.Empty;
            string smtp_pwd  = string.Empty;

            BusinessLogic.interoperabilita.CalendarMail.MailRequest request = null;

            try
            {
                DocsPaDB.Query_Utils.Utils obj = new DocsPaDB.Query_Utils.Utils();
                obj.getSmtp(out ds, idamministrazione);

                if (ds.Tables["SERVER"].Rows.Count == 0)
                {
                    return(null);
                }

                string server = ds.Tables["SERVER"].Rows[0]["VAR_SMTP"].ToString();
                if (!ds.Tables["SERVER"].Rows[0]["VAR_USER_SMTP"].Equals(System.DBNull.Value))
                {
                    smtp_user = ds.Tables["SERVER"].Rows[0]["VAR_USER_SMTP"].ToString();
                }
                if (!ds.Tables["SERVER"].Rows[0]["VAR_PWD_SMTP"].Equals(System.DBNull.Value))
                {
                    smtp_pwd = DocsPaUtils.Security.Crypter.Decode(ds.Tables["SERVER"].Rows[0]["VAR_PWD_SMTP"].ToString(), smtp_user);
                }

                string port    = ds.Tables["SERVER"].Rows[0]["NUM_PORTA_SMTP"].ToString();
                string SmtpSsl = ds.Tables["SERVER"].Rows[0]["CHA_SMTP_SSL"].ToString();
                string SmtpSTA = ds.Tables["SERVER"].Rows[0]["CHA_SMTP_STA"].ToString();

                // Inserimento dati mittente
                request = new BusinessLogic.interoperabilita.CalendarMail.MailRequest()
                {
                    Body   = string.Empty,
                    Sender = new BusinessLogic.interoperabilita.CalendarMail.MailSender()
                    {
                        Host     = server,
                        Port     = int.Parse(port),
                        SSL      = SmtpSsl == "0" ? true : false,
                        UserName = smtp_user,
                        Password = smtp_pwd,
                    }
                };
            }
            catch (Exception)
            {
            }

            return(request);
        }
Ejemplo n.º 2
0
 private CMAttachment[] GetMailAttachment(BusinessLogic.interoperabilita.CalendarMail.MailRequest request)
 {
     return(new CMAttachment[]
     {
         new CMAttachment()
         {
             _data = Encoding.ASCII.GetBytes(request.AppointmentAsText),
             name = "appointment.ics",
             contentType = CALENDAR_TYPE,
             _method = request.Method
         }
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Invia un reminder
        /// </summary>
        /// <param name="reminder"></param>
        /// <param name="infoutente"></param>
        /// <returns></returns>
        public bool SendReminder(DocsPaVO.Task.Task task, DocsPaVO.utente.InfoUtente infoutente)
        {
            _logger.Info("BEGIN");
            bool ret = false;

            try
            {
                BusinessLogic.interoperabilita.CalendarMail.MailRequest request = CreateMailRequest(task.UTENTE_MITTENTE.idAmministrazione);

                request.Subject     = ComputeMailSubject(task);
                request.Appointment = new interoperabilita.CalendarMail.iCalendar.AppointmentInfo()
                {
                    Sequence       = 1,
                    UID            = BusinessLogic.interoperabilita.CalendarMail.iCalendar.UidGenerator.Create(),
                    OrganizerName  = task.UTENTE_MITTENTE.cognome,
                    OrganizerEMail = task.UTENTE_MITTENTE.email,
                    Method         = BusinessLogic.interoperabilita.CalendarMail.iCalendar.AppointmentMethodTypes.REQUEST,
                    Status         = BusinessLogic.interoperabilita.CalendarMail.iCalendar.AppointmentStatusTypes.CONFIRMED,
                    DtStamp        = DateTime.Now,
                    Summary        = request.Subject,
                    DtStart        = DateTime.Now,
                    DtEnd          = DateTime.Now,
                    Alert          = new interoperabilita.CalendarMail.iCalendar.AlertInfo()
                    {
                        TriggerDays = GetTriggerDays(task.STATO_TASK.DATA_SCADENZA),
                        Description = request.Subject
                    }
                };

                // Invio messaggio
                DispatchMail(request);

                // Salvo i dati su db
                CreateReminder(task, request.Subject, infoutente);

                ret = true;
            }
            catch (Exception e)
            {
                _logger.Error(e.Message);
            }

            return(ret);
        }