コード例 #1
0
        public List<string> GetNotificationModesForTenant(string tenantID, string eventType)
        {
            Guid tenantId = Guid.Parse(tenantID);
            string strfileUploadStatus = eventType;

            if (tenantId != Guid.Parse("{00000000-0000-0000-0000-000000000000}"))
            {
                try
                {
                    var notificationModes = from nots in context.Notification
                                            join fus in context.FileUploadStatus
                                            on nots.StatusId equals fus.Id
                                            join nm in context.NotificationMode
                                            on nots.NotificationModeId equals nm.Id
                                            where nots.TenantId == tenantId && fus.UploadStatus == strfileUploadStatus
                                            select nm.Mode;

                    return notificationModes.ToList<string>();
                }
                catch (Exception ex)
                {
                    eZeeFlowTraceListener traceListener = new eZeeFlowTraceListener();
                    traceListener.WriteLog(Categories.Error, "Eventing", ex.Message.ToString(), ex.StackTrace.ToString(), tenantId.ToString());

                }
            }
            return null;
        }
コード例 #2
0
        public void Notify(List<Common.Models.NotificationDetails> notificationDetails)
        {
            eZeeFlowTraceListener traceListener = new eZeeFlowTraceListener();
            DataStorageHelper objStorageHelper = new DataStorageHelper();
            try
            {
                foreach (var nd in notificationDetails)
                {
                    if (!string.IsNullOrEmpty(nd.NotificationMode))
                    {
                        if (nd.NotificationMode == eZeeFlow.Notification.Gateway.Constants.HTTPRequest)
                        {
                            nd.RecipientDetails = PostFileUploadedSuccessUri;
                            var tenantId = nd.TenantID.ToString();

                            ProcessedFileDetail objFileDetail = new ProcessedFileDetail();
                            objFileDetail.FileId = nd.FileID.ToString();
                            objFileDetail.FileUrl = nd.FileURI;

                            HttpWebRequest httpWebRequest = WebRequest.Create(PostFileUploadedSuccessUri) as HttpWebRequest;
                            httpWebRequest.ContentType = "text/json";
                            httpWebRequest.Method = "POST";
                            string serializedObj = JsonConvert.SerializeObject(objFileDetail).Replace(@"\", "-");

                            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                            {
                                streamWriter.Write(serializedObj);
                            }

                            string response = new StreamReader(httpWebRequest.GetResponse().GetResponseStream()).ReadToEnd();

                            traceListener.WriteLog(Categories.Info, "Eventing - HTTP Notification", response, string.Empty, tenantId);

                        }
                    }
                }

                GatewayFactory objGF = new GatewayFactory();
                objGF.WriteNotificationToStorage(notificationDetails, true, Constants.HTTPRequest);

                //// TODO: Though we send out multiple notifications, there is a single column for the status -- db structure needs to be updated to support granular tracking.
                var isNotificationUpdated = objGF.UpdateNotificationStatus(notificationDetails, true);

            }
            catch (Exception ex)
            {
                traceListener.WriteLog(Categories.Error, "Eventing", ex.Message.ToString(), ex.StackTrace.ToString());
            }
        }
コード例 #3
0
        public bool UpdateNotificationStatus(bool notificationStatus, string strTenantID, string strFileID)
        {
            Guid tenantId = Guid.Parse(strTenantID);
            Guid fileId = Guid.Parse(strFileID);
            if (tenantId != Guid.Parse("{00000000-0000-0000-0000-000000000000}") && fileId != Guid.Parse("{00000000-0000-0000-0000-000000000000}"))
            {
                try
                {
                    var fileUploadDetails = (FileUploadDetails)context.FileUploadDetails.Where(t => t.TenantId == tenantId && t.FileId == fileId).FirstOrDefault();
                    fileUploadDetails.IsNotified = notificationStatus;
                    context.SaveChanges();
                    return true;

                }
                catch (Exception ex)
                {
                    eZeeFlowTraceListener traceListener = new eZeeFlowTraceListener();
                    traceListener.WriteLog(Categories.Error, "Eventing", ex.Message.ToString(), ex.StackTrace.ToString(), strTenantID.ToString());
                }

            }
            return false;
        }
コード例 #4
0
        /// <summary>
        /// Sends a mail
        /// </summary>
        public void Notify(List<NotificationDetails> notificationDetails)
        {
            eZeeFlowTraceListener traceListener = new eZeeFlowTraceListener();
            try
            {
                var mail = new MailMessage();
                var subject = string.Empty;
                var body = string.Empty;
                if (!string.IsNullOrEmpty(_smtpMailFrom)) mail.From = new MailAddress(_smtpMailFrom);
                foreach (var notificationDetail in notificationDetails)
                {
                    if (!string.IsNullOrEmpty(notificationDetail.NotificationMode))
                    {
                        if (notificationDetail.NotificationMode == eZeeFlow.Notification.Gateway.Constants.EMail)
                        {
                            mail.To.Add(new MailAddress(notificationDetail.RecipientDetails));
                        }
                    }
                }

                mail.Subject = GetSubjectForMail(notificationDetails);
                mail.Body = CreateMailBody(notificationDetails);

                var client = new SmtpClient(_smtpGatewayUrl, _smtpGatewayPort);
                client.UseDefaultCredentials = false;
                client.EnableSsl = true;
                var credential = new System.Net.NetworkCredential(_smtpUserName, _smtpPassword);
                client.Credentials = credential;
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Send(mail);
                GatewayFactory objGF = new GatewayFactory();
                objGF.WriteNotificationToStorage(notificationDetails, true, Constants.EMail);

                //// TODO: Though we send out multiple notifications, there is a single column for the status -- db structure needs to be updated to support granular tracking.

                var isNotificationUpdated = objGF.UpdateNotificationStatus(notificationDetails, true);

                if (!string.IsNullOrEmpty(_messageToLog))
                {
                    traceListener.WriteLog(Categories.Error, "Eventing", "[Notification] Message is empty.");
                }
                mail.Dispose();
            }
            catch (Exception ex)
            {
                traceListener.WriteLog(Categories.Error, "Eventing", ex.Message.ToString(), ex.StackTrace.ToString());
            }
        }