public override ExitCodeType Run(IDataLoadJob job, GracefulCancellationToken cancellationToken) { var beforeServer = RuntimeArguments.StageSpecificArguments.DbInfo.Server.Name; var beforeDatabase = RuntimeArguments.StageSpecificArguments.DbInfo.Server.GetCurrentDatabase().GetRuntimeName(); var beforeDatabaseType = RuntimeArguments.StageSpecificArguments.DbInfo.Server.DatabaseType; job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "About to run Task '" + ProcessTask.Name + "'")); job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Attacher class is:" + Attacher.GetType().FullName)); try { return(Attacher.Attach(job, cancellationToken)); } catch (Exception e) { job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Attach failed on job " + job + " Attacher was of type " + Attacher.GetType().Name + " see InnerException for specifics", e)); return(ExitCodeType.Error); } finally { var afterServer = RuntimeArguments.StageSpecificArguments.DbInfo.Server.Name; var afterDatabase = RuntimeArguments.StageSpecificArguments.DbInfo.Server.GetCurrentDatabase().GetRuntimeName(); var afterDatabaseType = RuntimeArguments.StageSpecificArguments.DbInfo.Server.DatabaseType; if (!(beforeServer.Equals(afterServer) && beforeDatabase.Equals(afterDatabase) && beforeDatabaseType == afterDatabaseType)) { job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Attacher " + Attacher.GetType().Name + " modified the ConnectionString during attaching")); } } }
/// <summary> /// Converts a /// <see cref="System.String"/> /// containing HTML to a /// <see cref="System.Collections.IList{E}"/> /// of /// iText objects ( /// <see cref="iText.Layout.Element.IElement"/> /// instances), using specific /// <see cref="ConverterProperties"/>. /// </summary> /// <param name="html"> /// the html in the form of a /// <see cref="System.String"/> /// </param> /// <param name="converterProperties"> /// a /// <see cref="ConverterProperties"/> /// instance /// </param> /// <returns>a list of iText building blocks</returns> public static IList <IElement> ConvertToElements(String html, ConverterProperties converterProperties) { ReflectionUtils.ScheduledLicenseCheck(); IXmlParser parser = new JsoupHtmlParser(); IDocumentNode doc = parser.Parse(html); return(Attacher.Attach(doc, converterProperties)); }
// void OnSceneGUI() { // // objectListEditor.OnSceneGUI(attacher.objects, attacher); // serializedObject.ApplyModifiedProperties(); // } public override void OnInspectorGUI() { serializedObject.Update(); SerializedProperty prop; if (attacher.strategy == null) { EditorGUILayout.HelpBox("An Attach Strategy describes how objects will attach. You can create one " + "from the menu in Assets->Create->Clingy.", MessageType.Warning); } EditorGUI.BeginChangeCheck(); AttachStrategy newStrategy = (AttachStrategy)EditorGUILayout.ObjectField("Attach Strategy", attacher.strategy, typeof(AttachStrategy), false); if (EditorGUI.EndChangeCheck()) { attacher.strategy = newStrategy; } prop = serializedObject.FindProperty("_request"); objectListEditor.OnInspectorGUI(prop, attacher.isActive); DrawPropertiesExcluding(serializedObject, new string[] { "m_Script", "_strategy" }); // EditorGUILayout.PropertyField(serializedObject.FindProperty("attachOnStart")); EditorGUI.BeginChangeCheck(); int executionOrder = EditorGUILayout.IntField("Execution Order", ((Attacher)target).executionOrder); if (EditorGUI.EndChangeCheck()) { ((Attacher)target).executionOrder = executionOrder; } EditorGUILayout.Space(); EditorGUILayout.PropertyField(serializedObject.FindProperty("events")); EditorGUI.BeginDisabledGroup(!EditorApplication.isPlaying); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Attach", GUILayout.Width(100))) { attacher.Attach(); } if (GUILayout.Button("Detach", GUILayout.Width(100))) { attacher.Detach(); } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Converts HTML obtained from an /// <see cref="System.IO.Stream"/> /// to objects that /// will be added to a /// <see cref="iText.Kernel.Pdf.PdfDocument"/> /// , using specific /// <see cref="ConverterProperties"/> /// , /// returning a /// <see cref="iText.Layout.Document"/> /// instance. /// </summary> /// <param name="html"> /// the html in the form of a /// <see cref="System.String"/> /// </param> /// <param name="pdfDocument"> /// the /// <see cref="iText.Kernel.Pdf.PdfDocument"/> /// instance /// </param> /// <param name="converterProperties"> /// a /// <see cref="ConverterProperties"/> /// instance /// </param> /// <returns> /// a /// <see cref="iText.Layout.Document"/> /// instance /// </returns> public static Document ConvertToDocument(String html, PdfDocument pdfDocument, ConverterProperties converterProperties ) { ReflectionUtils.ScheduledLicenseCheck(); if (pdfDocument.GetReader() != null) { throw new Html2PdfException(Html2PdfException.PdfDocumentShouldBeInWritingMode); } IXmlParser parser = new JsoupHtmlParser(); IDocumentNode doc = parser.Parse(html); return(Attacher.Attach(doc, pdfDocument, converterProperties)); }
/// <summary> /// Converts HTML obtained from an /// <see cref="System.IO.Stream"/> /// to objects that /// will be added to a /// <see cref="iText.Kernel.Pdf.PdfDocument"/> /// , using specific /// <see cref="ConverterProperties"/> /// , /// returning a /// <see cref="iText.Layout.Document"/> /// instance. /// </summary> /// <param name="htmlStream"> /// the /// <see cref="System.IO.Stream"/> /// with the source HTML /// </param> /// <param name="pdfDocument"> /// the /// <see cref="iText.Kernel.Pdf.PdfDocument"/> /// instance /// </param> /// <param name="converterProperties"> /// a /// <see cref="ConverterProperties"/> /// instance /// </param> /// <returns> /// a /// <see cref="iText.Layout.Document"/> /// instance /// </returns> /// <exception cref="System.IO.IOException">Signals that an I/O exception has occurred.</exception> public static Document ConvertToDocument(Stream htmlStream, PdfDocument pdfDocument, ConverterProperties converterProperties ) { try { String licenseKeyClassName = "iText.License.LicenseKey, itext.licensekey"; String licenseKeyProductClassName = "iText.License.LicenseKeyProduct, itext.licensekey"; String licenseKeyFeatureClassName = "iText.License.LicenseKeyProductFeature, itext.licensekey"; String checkLicenseKeyMethodName = "ScheduledCheck"; Type licenseKeyClass = GetClass(licenseKeyClassName); if (licenseKeyClass != null) { Type licenseKeyProductClass = GetClass(licenseKeyProductClassName); Type licenseKeyProductFeatureClass = GetClass(licenseKeyFeatureClassName); Array array = Array.CreateInstance(licenseKeyProductFeatureClass, 0); object[] objects = new object[] { Html2PdfProductInfo.PRODUCT_NAME, Html2PdfProductInfo.MAJOR_VERSION, Html2PdfProductInfo.MINOR_VERSION, array }; Object productObject = System.Activator.CreateInstance(licenseKeyProductClass, objects); MethodInfo m = licenseKeyClass.GetMethod(checkLicenseKeyMethodName); m.Invoke(System.Activator.CreateInstance(licenseKeyClass), new object[] { productObject }); } } catch (Exception e) { if (!Kernel.Version.IsAGPLVersion()) { throw; } } if (pdfDocument.GetReader() != null) { throw new Html2PdfException(Html2PdfException.PdfDocumentShouldBeInWritingMode); } IXmlParser parser = new JsoupHtmlParser(); IDocumentNode doc = parser.Parse(htmlStream, converterProperties != null ? converterProperties.GetCharset( ) : null); return(Attacher.Attach(doc, pdfDocument, converterProperties)); }