/// <summary> /// Called during creation of the <see cref="IScheduler"/> in order to give /// the <see cref="ISchedulerPlugin"/> a chance to initialize. /// </summary> /// <param name="pluginName">The name.</param> /// <param name="scheduler">The scheduler.</param> /// <throws>SchedulerConfigException </throws> public virtual async Task Initialize(string pluginName, IScheduler scheduler) { Name = pluginName; Scheduler = scheduler; typeLoadHelper = new SimpleTypeLoadHelper(); typeLoadHelper.Initialize(); Log.Info("Registering Quartz Job Initialization Plug-in."); // Create JobFile objects var tokens = FileNames.Split(FileNameDelimiter).Select(x => x.TrimStart()); foreach (string token in tokens) { JobFile jobFile = new JobFile(this, token); await jobFile.Initialize(); jobFiles.Add(new KeyValuePair <string, JobFile>(jobFile.FilePath, jobFile)); } }
public IBaseMessage Execute(IPipelineContext pContext, IBaseMessage pInMsg) { if (!Enabled) { return(pInMsg); } string errorMessage; if (!Validate(out errorMessage)) { throw new ArgumentException(errorMessage); } IBaseMessageFactory messageFactory = pContext.GetMessageFactory(); IBaseMessage newMsg = messageFactory.CreateMessage(); newMsg.Context = pInMsg.Context; MemoryStream ms = new MemoryStream(); //Create Html body IBaseMessagePart bodyPart = messageFactory.CreateMessagePart(); if (ApplyXsltOnBodyPart) { if (string.IsNullOrEmpty(XSLTFilePath)) { throw new ArgumentNullException("XsltFilePath is null"); } if (!File.Exists(XSLTFilePath)) { throw new FileNotFoundException(string.Format("Cannot find the xslt file '{0}'.", XSLTFilePath)); } XslCompiledTransform transform = new XslCompiledTransform(); transform.Load(XSLTFilePath); Stream originalStream = pInMsg.BodyPart.GetOriginalDataStream(); if (!originalStream.CanSeek || !originalStream.CanRead) { originalStream = new ReadOnlySeekableStream(originalStream); } XmlReader reader = XmlReader.Create(originalStream); transform.Transform(reader, null, ms); originalStream.Seek(0, SeekOrigin.Begin); pInMsg.BodyPart.Data = originalStream; } else { byte[] buff = Encoding.UTF8.GetBytes(EmailBody); ms.Write(buff, 0, buff.Length); } ms.Seek(0, SeekOrigin.Begin); bodyPart.Data = ms; bodyPart.Charset = "UTF-8"; bodyPart.ContentType = "text/html"; newMsg.AddPart("body", bodyPart, true); //Add all message parts as attachments int i = 0; string[] filenames = FileNames.Split('|'); while (i < pInMsg.PartCount & i < filenames.Length) { if (!string.IsNullOrEmpty(filenames[i])) { string partName = ""; IBaseMessagePart part = pInMsg.GetPartByIndex(i, out partName), newPart = messageFactory.CreateMessagePart(); Stream originalStream = part.GetOriginalDataStream(); newPart.Data = originalStream; newPart.Charset = part.Charset; newPart.ContentType = "text/xml"; newPart.PartProperties.Write("FileName", "http://schemas.microsoft.com/BizTalk/2003/mime-properties", filenames[i]); newMsg.AddPart(filenames[i], newPart, false); } i++; } return(newMsg); }