예제 #1
0
        public ActionResult UserSubscribe()
        {
            if (!TempData.ContainsKey(ReportId))
            {
                return(BlankView("There are not report or any fields to subscribe."));
            }

            var reportId     = (Guid)TempData[ReportId];
            var tableOrView  = TempData[TableOrView] as string;
            var sql          = TempData[Sql] as string;
            var sqlParameter = TempData[SqlParameter] as IDictionary <string, object>;
            var parameters   = StorageParameter.ConvertParameterToString(sqlParameter);
            var subscribers  = new List <SubscriberDto> {
                new SubscriberDto {
                    Email = this.LoginUser.Email
                }
            };

            var model = new AttachmentTopicDto
            {
                TopicName    = tableOrView,
                ReportId     = reportId,
                SqlStatement = CryptoFactory.AES.Encrypt(sql),
                Parameter    = CryptoFactory.AES.Encrypt(parameters),
                Subscribers  = subscribers
            };

            this.ViewBagTask();
            return(PartialView(model));
        }
예제 #2
0
        public void CreateAttachmentTopic(AttachmentTopicDto topicDto)
        {
            var topic = new AttachmentTopic(topicDto.TopicName, topicDto.Description,
                                            topicDto.Subject, topicDto.Body,
                                            topicDto.ReportId, topicDto.SqlStatement, topicDto.Parameter, topicDto.CreatedBy);
            var taskDtos = topicDto.TopicTasks;

            if (taskDtos != null)
            {
                var tasks = (from task in taskDtos
                             select new TopicTask(topic.ID, (TaskSchedule)task.TaskSchedule, task.Month, task.Week, task.Day, task.Hour));
                topic.AddTopicTasks(tasks.ToArray());
            }

            var subscribers = topicDto.Subscribers;

            if (subscribers != null)
            {
                var taskSubcribers = (from subscriber in subscribers
                                      select new Subscriber(topic.ID, subscriber.Email));
                topic.AddSubscribers(taskSubcribers.ToArray());
            }

            this._attachmentTopicRepository.Add(topic);
        }
예제 #3
0
        public ActionResult UserSubscribe(AttachmentTopicDto model)
        {
            if (model.TopicTasks == null || !model.TopicTasks.Any())
            {
                return(BlankView("Create the topic failure. there are not any topic task."));
            }

            var subscribers = this.GetValidSubscribers();

            if (subscribers == null || !subscribers.Any())
            {
                return(BlankView("Create the topic failure. there are not any subscriber."));
            }

            model.Subscribers = (from subscriber in subscribers
                                 select new SubscriberDto
            {
                Email = subscriber
            }).ToList();

            model.CreatedBy = this.LoginUser.Identity.Name;
            this.EncodeInput(model);
            model.SqlStatement = CryptoFactory.AES.Decrypt(model.SqlStatement);
            model.Parameter    = CryptoFactory.AES.Decrypt(model.Parameter);

            try
            {
                using (var service = ServiceLocator.Instance.Resolve <ISubscriberService>())
                {
                    service.CreateAttachmentTopic(model);
                }
            }
            catch (Exception)
            {
                return(BlankView("Create the topic failure."));
            }

            return(BlankView("Create the topic OK."));
        }
예제 #4
0
 /// <summary>
 /// 初始化一个新的<c>AttachmentJobHandler</c>实例
 /// </summary>
 /// <param name="attachmentTopic">附件主题对象</param>
 /// <param name="topicTasks">此时刻该附件正执行的任务集合</param>
 public AttachmentJobHandler(AttachmentTopicDto attachmentTopic, IEnumerable <TopicTaskDto> topicTasks)
 {
     this._attachmentTopic = attachmentTopic;
     this._topicTasks      = topicTasks;
 }
예제 #5
0
 /// <summary>
 /// 初始化一个新的<c>AttachmentJobHandler</c>实例
 /// </summary>
 /// <param name="attachmentTopic">附件主题对象</param>
 public AttachmentJobHandler(AttachmentTopicDto attachmentTopic)
 {
     this._attachmentTopic = attachmentTopic;
 }