示例#1
0
 public static List <Message> GetDemoMessages(MessagesModuleLogic logic, IMessageTemplate tmpl, ISqlLogic sqlLogic, bool isSms, int MaxCount = 0)
 {
     using (var mng = BatchCreationManager.NewInstance(sqlLogic, logic)) {
         var cltr     = new MessageDataCollector(mng);
         var msgData  = cltr.Collect(tmpl);
         var producer = new MessageProducer(tmpl, null, new DefaultMarkUpSpecification {
             NewLineSymbol = "\n"
         });
         List <Message> result  = new List <Message>();
         int            counter = 0;
         foreach (var data in msgData)
         {
             producer.ChangeWildCards(data.wildCards);
             foreach (var textData in data.TextProductionData)
             {
                 result.Add(producer.Produce(textData, isSms ? MessageType.Sms : MessageType.Sms));
                 counter++;
                 if (counter == MaxCount)
                 {
                     return(result);
                 }
             }
         }
         return(result);
     }
 }
 protected BatchCreationComponent(BatchCreationManager manager)
 {
     if (manager.IsDisposed)
     {
         throw new InvalidOperationException("Cannot create BatchCreationComponent:" + GetType() + " on Disposed BatchCreationManager");
     }
     Manager = manager;
 }
示例#3
0
 public static BatchCreationResult RunImmediateBatchCreation(tblMessageSchedule Schedule, int Priority, ISqlLogic SqlLogic, MessagesModuleLogic Logic)
 {
     lock (ImmediateBatchCreation_L) {
         using (var manager = BatchCreationManager.NewInstance(SqlLogic, Logic)) {
             var creator = new BatchCreator(manager);
             var result  = creator.CreateBatch(Schedule, Priority);
             manager.SaveResultsToDB(new[] { result });
             return(result);
         }
     }
 }
示例#4
0
        public static void RunScheduledBatchCreation(DateTime StartDate, int minutesPeriod, ISqlLogic sqlLogic)
        {
            if (minutesPeriod < 1)
            {
                throw new ArgumentOutOfRangeException("minutesPeriod should be greater or equal to 1");
            }

            using (var manager = BatchCreationManager.NewInstance(StartDate, minutesPeriod, sqlLogic)) {
                var shedules = manager.GetActualMessageSchedules();
                var creator  = new BatchCreator(manager);
                var results  = new List <BatchCreationResult>();
                foreach (var sched in shedules)
                {
                    results.Add(creator.CreateBatch(sched, 0));
                }
                manager.SaveResultsToDB(results);
            }
        }
示例#5
0
 public MessageDataCollector(BatchCreationManager manager) : base(manager)
 {
 }
 public BatchCreator(BatchCreationManager manager) : base(manager)
 {
 }