コード例 #1
0
        public void Can_Attach_1_Already_Zipped_And_1_File_To_Attach()
        {
            _file.Setup(f => f.TempFile(It.IsAny <string>())).Returns("attach.zip");
            _file.Setup(f => f.Exists(It.IsAny <string>())).Returns(true);

            var attacher = new Attacher(new ExceptionReportInfo {
                FilesToAttach = new[] { "file1.zip", "file2.txt" }
            })
            {
                File   = _file.Object,
                Zipper = _zip.Object
            };

            attacher.AttachFiles(_iAttach.Object);

            _iAttach.Verify(a => a.Attach("file1.zip"), Times.Once());
            _iAttach.Verify(a => a.Attach("attach.zip"), Times.Once());
        }
コード例 #2
0
ファイル: HtmlConverter.cs プロジェクト: SIRprise/i7n-pdfhtml
        /// <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));
        }
コード例 #3
0
        private static void HandleFieldLayout(Node target, Direction direction, VisualElement nodeContainer, Type type, Type portType, FieldInfo fieldInfo, BindableElement element, string path)
        {
            var port = CreatePort(direction, type, fieldInfo, path, portType);

            nodeContainer.Add(port);
            if (element != null)
            {
                var container = CreateContainer(element, direction == Direction.Input ? Direction.Output : Direction.Input, type, portType, path);
                port.RegisterCallback <PortUpdateEvent>(OnPortUpdateContainer);
                element.style.minWidth = 50;
                target.Add(container);
                Attacher attacher = new Attacher(container, port, direction == Direction.Input ? SpriteAlignment.LeftCenter : SpriteAlignment.RightCenter);
                attacher.Reattach();
                port.userData      = attacher;
                container.userData = attacher;
                port.RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
                container.RegisterCallback <DetachFromPanelEvent>(OnDetachFromPanel);
            }
        }
        Attacher CreateAttachedElement <T>(TestGraphViewWindow window) where T : VisualElement
        {
            T target = graphView.Q <T>();

            Attacher attacher = null;

            if (target != null)
            {
                VisualElement attached = new VisualElement();
                attached.SetLayout(new Rect(0, 0, 10, 10));
                attached.style.backgroundColor = Color.blue;

                target.parent.Add(attached);
                attacher          = new Attacher(attached, target, SpriteAlignment.LeftCenter);
                attached.userData = attacher;
            }

            return(attacher);
        }
コード例 #5
0
        public AttacherRuntimeTask(IProcessTask task, RuntimeArgumentCollection args, MEF mef)
            : base(task, args)
        {
            //All attachers must be marked as mounting stages, and therefore we can pull out the RAW Server and Name
            var mountingStageArgs = args.StageSpecificArguments;

            if (mountingStageArgs.LoadStage != LoadStage.Mounting)
            {
                throw new Exception("AttacherRuntimeTask can only be called as a Mounting stage process");
            }

            if (string.IsNullOrWhiteSpace(task.Path))
            {
                throw new ArgumentException("Path is blank for ProcessTask '" + task + "' - it should be a class name of type " + typeof(IAttacher).Name);
            }

            Attacher = mef.CreateA <IAttacher>(ProcessTask.Path);
            SetPropertiesForClass(RuntimeArguments, Attacher);
            Attacher.Initialize(args.StageSpecificArguments.RootDir, RuntimeArguments.StageSpecificArguments.DbInfo);
        }
コード例 #6
0
        public void Should_Not_Take_Screenshot_If_Already_Taken()
        {
            var screenshot = new Mock <IScreenshotTaker>();

            using (var bm = new Bitmap(1, 1))
            {
                var attacher =
                    new Attacher(new ExceptionReportInfo
                {
                    TakeScreenshot  = true,
                    ScreenshotImage = bm                                        // this makes the screenshot "already taken" ie exists
                })
                {
                    ScreenshotTaker = screenshot.Object,
                };

                attacher.AttachFiles(_iattach.Object);
            }

            screenshot.Verify(s => s.TakeScreenShot(), Times.Never);
        }
コード例 #7
0
ファイル: Maestro.cs プロジェクト: vbfox/AttachR
        private bool RunSingleTarget(bool debug, DebuggingTargetViewModel target, Process visualStudioProcess, out RunResult run)
        {
            var psi = new ProcessStartInfo(target.Executable, target.CommandLineArguments)
            {
                WorkingDirectory = target.WorkingDirectory
            };
            var process     = Process.Start(psi);
            var localTarget = target;

            if (process != null && debug)
            {
                process.Exited += (_, __) => localTarget.CurrentProcess = null;

                try
                {
                    var engineModes = localTarget.DebuggingEngines.Where(x => x.Selected).Select(x => x.Name).ToArray();
                    localTarget.LastError = "";
                    var result = Retrier.RunWithRetryOnException(() => Attacher.AttachVisualStudioToProcess(visualStudioProcess, process, target.UseCustomDebuggingEngines, engineModes));
                    localTarget.LastError = GetError(result);
                }
                catch (AggregateException ex)
                {
                    localTarget.LastError = ex.Message;

                    {
                        run = new RunResult
                        {
                            Message =
                                $"Errors while attaching process {target.Executable} to VS.NET. Errors : {string.Join(". ", ex.InnerExceptions.Select(e => e.Message).ToArray())}"
                        };
                        return(false);
                    }
                }
            }

            target.CurrentProcess = process;
            run = new RunResult();
            return(true);
        }
コード例 #8
0
ファイル: StructureBlock.cs プロジェクト: L1nde/FortMaster
    public void move()
    {
        Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        pos.z = 0;
        transform.position = pos;
        Attacher closestAttacher = ConstructionManager.instance.getClosestStructureAttacherInRange(pos, 0.33f);

        if (Equals(closestAttacher, null))
        {
            transform.position = pos;
            transform.rotation = new Quaternion();
        }
        else
        {
            Transform parent = closestAttacher.transform.parent.transform;

            float dir = Mathf.Deg2Rad * parent.rotation.eulerAngles.z;
            if (Mathf.Abs(closestAttacher.transform.localPosition.x) > Mathf.Abs(closestAttacher.transform.localPosition.y))
            {
                dir += Mathf.Atan2(0, closestAttacher.transform.localPosition.x);
            }
            else
            {
                dir += Mathf.Atan2(closestAttacher.transform.localPosition.y, 0);
            }

            Vector3 pPos = new Vector3();
            float   dist = 0.25f;
            pPos.x = dist * Mathf.Cos(dir);
            pPos.y = dist * Mathf.Sin(dir);


            transform.position = closestAttacher.transform.position + pPos;
            transform.rotation = parent.rotation;
        }
    }
コード例 #9
0
 void OnEnable()
 {
     attacher         = (Attacher)target;
     objectListEditor = new AttachObjectListEditor(serializedObject, "_objects", "_strategy");
     objectListEditor.OnEnable();
 }
コード例 #10
0
 protected MailSender(ExceptionReportInfo reportInfo, IReportSendEvent sendEvent, IScreenShooter screenShooter)
 {
     _config    = reportInfo;
     _sendEvent = sendEvent;
     _attacher  = new Attacher(reportInfo, screenShooter);
 }
コード例 #11
0
 protected MailSender(ExceptionReportInfo reportInfo, IReportSendEvent sendEvent)
 {
     _config    = reportInfo;
     _sendEvent = sendEvent;
     _attacher  = new Attacher(reportInfo);
 }
コード例 #12
0
 public override void LoadCompletedSoDispose(ExitCodeType exitCode, IDataLoadEventListener postLoadEventListener)
 {
     Attacher.LoadCompletedSoDispose(exitCode, postLoadEventListener);
 }
コード例 #13
0
        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"));
                }
            }
        }
コード例 #14
0
 public override void Check(ICheckNotifier checker)
 {
     new MandatoryPropertyChecker(Attacher).Check(checker);
     Attacher.Check(checker);
 }