/// <summary> /// u can pass here sqlLogic, if you use this method in cycle or/and already have opened one. /// if not, new sqlLogic instance will be opened. /// </summary> public static ValueOperatorPair[] GetValueOperatorPairs(tblFilter filter, ISqlLogic sqlLogic = null) { //try { if (filter.autoUpdatedList.HasValue && filter.autoUpdatedList.Value) { var ValsOps = sqlLogic.FetchDataDistinct(new[] { filter.Key }, filter.tblRecepientFilter.tblRecepientFilterTableName.Name) .Select(x => new ValueOperatorPair(x[filter.Key].ToString(), "=", filter.Type)).ToArray(); return(ValsOps); } else { var vals = JsonConvert.DeserializeObject <string[]>(filter.ValuesJSON); var ops = JsonConvert.DeserializeObject <string[]>(filter.OperatorsJSON); var ValsOps = new ValueOperatorPair[vals.Length]; for (int i = 0; i < vals.Length; i++) { ValsOps[i] = new ValueOperatorPair(vals[i], ops[i], filter.Type); } return(ValsOps); } //} //catch { // return new ValueOperatorPair[1]; //} }
private BatchCreationManager(DateTime controlledPeriodStart, DateTime controlledPeriodEnd, MessagesModuleLogic Logic, ISqlLogic SqlLogic) { this.SqlLogic = SqlLogic; this.Logic = Logic ?? new MessagesModuleLogic(); AutoDisposeLogic = Logic == null; periodStart = controlledPeriodStart; periodEnd = controlledPeriodEnd; stack.Add(this); }
public MessageSchedulesController(ISqlLogic logic) { sqllogic = logic; }
public RFilterTableController(ISqlLogic sqlLogic) { this.sqlLogic = sqlLogic; }
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); } } }
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); } }
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); } }
public TemplatesController(ISqlLogic logic) { sqllogic = logic; }
public FiltersController(ISqlLogic logic) { sqllogic = logic; }
/// <summary> /// Creates new instance without control period. No data about job period will written to db. /// GetActualMessageSchedules() will throw error if called. /// If no MessagesModuleLogic passed, new instance of it will be created and disposed after usage. /// </summary> public static BatchCreationManager NewInstance(ISqlLogic SqlLogic, MessagesModuleLogic Logic = null) { return(new BatchCreationManager(default(DateTime), default(DateTime), Logic, SqlLogic) .ClearPeriod() .DontMakeTimeStamp()); }
/// <summary> /// Creates new instance on control period. /// Period start on start INCLUDE, and ends on end INCLUDE. /// If no MessagesModuleLogic passed, new instance of it will be created and disposed after usage. /// </summary> public static BatchCreationManager NewInstance(DateTime controlledPeriodStart, DateTime controlledPeriodEnd, ISqlLogic SqlLogic, MessagesModuleLogic Logic = null) { return(new BatchCreationManager(controlledPeriodStart, controlledPeriodEnd, Logic, SqlLogic)); }
/// <summary> /// Creates new instance on control period. /// Start of control period is getted from DB, end is: start+checkMinutesFromLastInvoke. /// Period start on start INCLUDE, and ends on end INCLUDE. /// If no MessagesModuleLogic passed, new instance of it will be created and disposed after usage. /// </summary> public static BatchCreationManager NewInstance(DateTime startDate, int checkMinutesFromLastInvoke, ISqlLogic SqlLogic, MessagesModuleLogic Logic = null) { throw new NotImplementedException(); //TODO add logic to compare given period with period from db... DateTime controlledPeriodStart = getStartDate(); DateTime controlledPeriodEnd = controlledPeriodStart.AddMinutes(checkMinutesFromLastInvoke); return(new BatchCreationManager(controlledPeriodStart, controlledPeriodEnd, Logic, SqlLogic)); }