protected override bool Process(Package package) { var account = package.Account; if (account.IncomingProcessing != true || account.CreateActivity != true) { return false; } var message = package.Message; if (message.IsIncome != true) return false; if (message.RefNoteID != null) return false; PXSelect<Contact, Where<Contact.eMail, Equal<Required<Contact.eMail>>>>. Clear(package.Graph); var contact = (Contact)PXSelect<Contact, Where<Contact.eMail, Equal<Required<Contact.eMail>>>>. SelectWindowed(package.Graph, 0, 1, package.Address); if (contact != null && contact.ContactID != null) { PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>. Clear(package.Graph); var accountNoteId = contact.BAccountID. With(_ => (BAccount)PXSelect<BAccount, Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>. Select(package.Graph, _.Value)). With(_ => _.NoteID); message.RefNoteID = contact.NoteID; message.ParentRefNoteID = accountNoteId; return true; } return false; }
public void Transform(Engine engine, Package package) { TemplatingLogger log = TemplatingLogger.GetLogger(GetType()); RepositoryLocalObject context; if (package.GetByName(Package.PageName) != null) { context = (RepositoryLocalObject)engine.GetObject(package.GetByName(Package.PageName)); log.Debug("Setting context to page with ID " + context.Id); } else { log.Info("This template building block should only run on a page. Exiting."); return; } if (!(context is Page)) return; Page page = (Page)context; package.PushItem(SiteEditPageContext, package.CreateStringItem(ContentType.Text, page.OwningRepository.Id)); package.PushItem(SiteEditPublishContext, package.CreateStringItem(ContentType.Text, page.ContextRepository.Id)); if (page.ComponentPresentations.Count <= 0) return; Component component = page.ComponentPresentations[0].Component; package.PushItem(SiteEditComponentContext, package.CreateStringItem(ContentType.Text, component.OwningRepository.Id)); }
//they asked to pop up the Package Configurations dialog, so replace the Microsoft functionality so we can control the popup form void cmdEvent_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { if (Enabled) { try { if (this.ApplicationObject.ActiveWindow == null || this.ApplicationObject.ActiveWindow.ProjectItem == null) return; ProjectItem pi = this.ApplicationObject.ActiveWindow.ProjectItem; if (!pi.Name.ToLower().EndsWith(".dtsx")) return; IDesignerHost designer = this.ApplicationObject.ActiveWindow.Object as IDesignerHost; if (designer == null) return; EditorWindow win = (EditorWindow)designer.GetService(typeof(Microsoft.DataWarehouse.ComponentModel.IComponentNavigator)); Package package = (Package)win.PropertiesLinkComponent; this.packageForFixButton = package; this.pathForPackageForFixButton = pi.get_FileNames(1); DtsConfigurationsForm form = new DtsConfigurationsForm(package); if (win.SelectedIndex == 0) { //control flow EditorWindow.EditorView view = win.SelectedView; System.Reflection.BindingFlags getflags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Instance; Control viewControl = (Control)view.GetType().InvokeMember("ViewControl", getflags, null, view, null); IWin32Window parentWin; #if DENALI || SQL2014 parentWin = viewControl; #else DdsDiagramHostControl diagram = viewControl.Controls["panel1"].Controls["ddsDiagramHostControl1"] as DdsDiagramHostControl; if (diagram == null || diagram.DDS == null) return; parentWin = diagram.DDS; #endif Button editSelectedButton = (Button)form.Controls["editSelectedConfiguration"]; Control packageConfigurationsGridControl1 = form.Controls["packageConfigurationsGridControl1"]; Button btnRelativePaths = new Button(); btnRelativePaths.Text = "Fix All Relative Paths"; btnRelativePaths.Width = 140; btnRelativePaths.Left = packageConfigurationsGridControl1.Left; btnRelativePaths.Top = editSelectedButton.Top; btnRelativePaths.Height = editSelectedButton.Height; btnRelativePaths.Anchor = AnchorStyles.Left | AnchorStyles.Bottom; btnRelativePaths.Click += new EventHandler(btnRelativePaths_Click); form.Controls.Add(btnRelativePaths); if (DesignUtils.ShowDialog((Form)form, parentWin, (IServiceProvider)package.Site) == DialogResult.OK) { SSISHelpers.MarkPackageDirty(package); } CancelDefault = true; } } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); } } }
public void Transform(Engine engine, Package package) { TemplatingLogger log = TemplatingLogger.GetLogger(GetType()); if (package.GetByName(Package.ComponentName) == null) { log.Info("This template should only be used with Component Templates. Could not find component in package, exiting"); return; } var c = (Component)engine.GetObject(package.GetByName(Package.ComponentName)); var container = (Folder)c.OrganizationalItem; var filter = new OrganizationalItemItemsFilter(engine.GetSession()) { ItemTypes = new[] { ItemType.Component } }; // Always faster to use GetListItems if we only need limited elements foreach (XmlNode node in container.GetListItems(filter)) { string componentId = node.Attributes["ID"].Value; string componentTitle = node.Attributes["Title"].Value; } // If we need more info, use GetItems instead foreach (Component component in container.GetItems(filter)) { // If your filter is messed up, GetItems will return objects that may // not be a Component, in which case the code will blow up with an // InvalidCastException. Be careful with filter.ItemTypes[] Schema componentSchema = component.Schema; SchemaPurpose purpose = componentSchema.Purpose; XmlElement content = component.Content; } }
public void SendPackage(Package package) { var dt = DateTime.Now; _writer.Write(dt.ToString("mm:ss.fff") + " : "); _writer.WriteLine(package.ToString()); _writer.Flush(); }
public void Transform(Engine engine, Package package) { TemplatingLogger log = TemplatingLogger.GetLogger(GetType()); if (package.GetByName(Package.PageName) == null) { log.Info("Do not use this template building block in Component Templates"); return; } Page page = (Page)engine.GetObject(package.GetByName(Package.PageName)); string output; if (page.Title.ToLower().Contains("index")) output = StripNumbersFromTitle(page.OrganizationalItem.Title); else { output = GetLinkToSgIndexPage((StructureGroup)page.OrganizationalItem, engine.GetSession()) + Separator + StripNumbersFromTitle(page.Title); } foreach (OrganizationalItem parent in page.OrganizationalItem.GetAncestors()) { output = GetLinkToSgIndexPage((StructureGroup)parent, engine.GetSession()) + Separator + output; } package.PushItem("breadcrumb", package.CreateStringItem(ContentType.Html, output)); }
public void TheCtorSortsPackageVersionsProperly() { var package = new Package { Dependencies = Enumerable.Empty<PackageDependency>().ToList(), PackageRegistration = new PackageRegistration { Owners = Enumerable.Empty<User>().ToList(), } }; package.PackageRegistration.Packages = new Package[] { new Package {Version = "1.0.0alpha2", PackageRegistration = package.PackageRegistration}, new Package {Version = "1.0.0", PackageRegistration = package.PackageRegistration}, new Package {Version = "1.0.0alpha", PackageRegistration = package.PackageRegistration}, new Package {Version = "1.0.0beta", PackageRegistration = package.PackageRegistration}, new Package {Version = "1.0.2beta", PackageRegistration = package.PackageRegistration}, new Package {Version = "1.0.2", PackageRegistration = package.PackageRegistration}, new Package {Version = "1.0.10", PackageRegistration = package.PackageRegistration} }; var packageVersions = new DisplayPackageViewModel(package).PackageVersions.ToList(); // Descending Assert.Equal("1.0.0alpha", packageVersions[6].Version); Assert.Equal("1.0.0alpha2", packageVersions[5].Version); Assert.Equal("1.0.0beta", packageVersions[4].Version); Assert.Equal("1.0.0", packageVersions[3].Version); Assert.Equal("1.0.2beta", packageVersions[2].Version); Assert.Equal("1.0.2", packageVersions[1].Version); Assert.Equal("1.0.10", packageVersions[0].Version); }
/// <summary> /// Adds package to the database /// </summary> /// <param name="package">Package value represents package object with necessary information.</param> public Training AddPackage(Package package) { PackageItemIdentifier packageId; ValidationResults importLog; using (PackageReader packageReader = package.GetPackageReader()) { AddPackageResult result = PStore.AddPackage(packageReader, new PackageEnforcement(false, false, false)); packageId = result.PackageId; importLog = result.Log; } // fill in the application-specific columns of the PackageItem table LearningStoreJob job = LStore.CreateJob(); Dictionary<string, object> properties = new Dictionary<string, object>(); properties[Schema.PackageItem.Owner] = new UserItemIdentifier(package.Owner); properties[Schema.PackageItem.FileName] = package.FileName; properties[Schema.PackageItem.UploadDateTime] = package.UploadDateTime; job.UpdateItem(packageId, properties); job.Execute(); // retrieve information about the package job = LStore.CreateJob(); RequestMyTraining(job, packageId); DataTable dataTableResults = job.Execute<DataTable>(); Training training = new Training(dataTableResults.Rows[0]); return training; }
protected virtual void Parameterize(IEnumerable<EtlParameter> parameters, ref Package package) { foreach (var param in parameters) { package.Parameters[param.Name].Value = param.StringValue; } }
public WebOperationResult CreatePackage(Package package) { var result = cdManager.CreatePackage(package); return new WebOperationResult(result.Result, result.Result ? "Package created successfully" : result.Message, "", result.ResultCode); }
public VariablesMove(Package package, string selectedContainerId, int selectedVariablesCount) { this.selectedContainerId = selectedContainerId; InitializeComponent(); IterateContainers(package, this.treeView.Nodes, selectedContainerId); // Expand root node, the package this.treeView.Nodes[0].Expand(); this.Icon = BIDSHelper.Resources.Common.Copy; // Change caption based on count of selected variables, // makes form less clutered and easier to read. if (selectedVariablesCount > 1) { this.radCopy.Text = "Copy variables to..."; this.radMove.Text = "Move variables to..."; } else { this.radCopy.Text = "Copy variable to..."; this.radMove.Text = "Move variable to..."; } }
public void Transform(Engine engine, Package package) { if (package.GetByName(Package.PageName) == null) return; Page page = (Page)engine.GetObject(package.GetByName(Package.PageName)); bool hasHeader = false; bool hasFooter = false; foreach (CP cp in page.ComponentPresentations) { if (cp.ComponentTemplate.Title.ToLower().Contains("header")) hasHeader = true; if (cp.ComponentTemplate.Title.ToLower().Contains("footer")) hasFooter = true; } if (!hasHeader) { ComponentTemplate headerCt = (ComponentTemplate)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + HeaderComponentTemplateUrl); Component header = (Component)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + HeaderComponentUrl); package.PushItem("headerCP", package.CreateStringItem(ContentType.Html, string.Format("<tcdl:ComponentPresentation type=\"Dynamic\" componentURI=\"{0}\" templateURI=\"{1}\" />", header.Id, headerCt.Id))); } if (!hasFooter) { ComponentTemplate footerCt = (ComponentTemplate)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + FooterComponentTemplateUrl); Component footer = (Component)engine.GetObject(page.ContextRepository.RootFolder.WebDavUrl + FooterComponentUrl); package.PushItem("footerCP", package.CreateStringItem(ContentType.Html, string.Format("<tcdl:ComponentPresentation type=\"Dynamic\" componentURI=\"{0}\" templateURI=\"{1}\" />", footer.Id, footerCt.Id))); } }
public void Transform(Engine engine, Package package) { if (package.GetByName(Package.PageName) == null) return; comm.Page page = (comm.Page)engine.GetObject(package.GetByName(Package.PageName)); Dictionary<string, List<ComponentPresentation>> lists = new Dictionary<string, List<ComponentPresentation>>(); string matchTokens = package.GetValue("ComponentTemplateTitleMatchTokens"); if (!String.IsNullOrEmpty(matchTokens)) { foreach (string token in matchTokens.Split(',')) { _matchTokens.Add(token.Trim()); } } foreach (comm.ComponentPresentation cp in page.ComponentPresentations) { string ct = GetPresentationType(cp.ComponentTemplate.Title); if (!lists.ContainsKey(ct)) lists.Add(ct, new List<ComponentPresentation>()); lists[ct].Add(new ComponentPresentation(cp.Component.Id, cp.ComponentTemplate.Id)); } foreach (string token in lists.Keys) { Item item = package.CreateStringItem(ContentType.ComponentArray, ComponentPresentationList.ToXml(lists[token])); package.PushItem(token + "Components", item); } }
public void SendPackage(Package.Package package) { using (var client = CreateClient()) { var task = client.PostAsJsonAsync(client.BaseAddress, package).Result; } }
public void CreateNuGetExeDownloadExtractsFileIfItDoesNotExist() { // Arrange var fileStorage = new Mock<IFileStorageService>(MockBehavior.Strict); fileStorage.Setup(s => s.FileExists("downloads", "nuget.exe")).Returns(false); fileStorage.Setup(s => s.SaveFile("downloads", "nuget.exe", It.IsAny<Stream>())) .Verifiable(); fileStorage.Setup(s => s.CreateDownloadFileActionResult("downloads", "nuget.exe")) .Returns(Mock.Of<ActionResult>()) .Verifiable(); var package = new Package { Version = "2.0.0" }; var packageService = new Mock<IPackageService>(MockBehavior.Strict); packageService.Setup(s => s.FindPackageByIdAndVersion("NuGet.CommandLine", null, false)) .Returns(package) .Verifiable(); var packageFileSvc = new Mock<IPackageFileService>(MockBehavior.Strict); packageFileSvc.Setup(s => s.DownloadPackageFile(package)) .Returns(CreateCommandLinePackage) .Verifiable(); // Act var downloaderSvc = GetDownloaderService(packageService, packageFileSvc, fileStorage); downloaderSvc.CreateNuGetExeDownloadActionResult(); // Assert packageFileSvc.Verify(); packageService.Verify(); }
public override object Read(object target, Package package, BinaryReader reader, long end) { var rootObject = (RootObject)target; if (rootObject.Export != null && rootObject.Export.ObjectClassReference != null) return AttributeDictionary.Load(package, reader); return null; }
public void Should_Generate_HTML_References_with_pre_and_post_text() { // Arrange var compilers = new[] { new JQueryTemplateCompiler(), }; var referencer = new LABjsScriptReference(); var package = new Package(".", compilers, referencer); var references = new[] { new SystemReference(new DirectoryInfo("C:/Root/"), new FileInfo("C:/Root/Scripts/depper1.js"), "depper1.js") { Type = Reference.TypeEnum.App } }; // Act var result = package.GenerateReferences(references, new HelperOptions { GenerateHeaderAndFooter = true }); // Assert result.ShouldBe( @"<script> $LAB .script(""/hotglue.axd/Scripts/depper1.js-app""); </script> "); }
public void TestWithParts() { // Create a derivative asset with asset parts var project = new Package(); var assets = new List<TestAssetWithParts>(); var assetItems = new List<AssetItem>(); assets.Add(new TestAssetWithParts() { Parts = { new AssetPart(Guid.NewGuid()), new AssetPart(Guid.NewGuid()) } }); assetItems.Add(new AssetItem("asset-0", assets[0])); project.Assets.Add(assetItems[0]); var childAsset = (TestAssetWithParts)assetItems[0].CreateChildAsset(); // Check that child asset has a base Assert.NotNull(childAsset.Base); // Check base asset Assert.AreEqual(assets[0].Id, childAsset.Base.Id); // Check that base is correctly setup for the part Assert.AreEqual(assets[0].Parts[0].Id, childAsset.Parts[0].BaseId); }
private static void DownloadPackage(Package package, int index, int count) { var http_response = package.Download (); if (http_response == null) { throw new IOException (); } Directory.CreateDirectory (Path.GetDirectoryName (package.RelativeLocation)); File.Delete (package.RelativeLocation); var xfer_stats = new RepoTransferStatistics () { Label = package.Name, Index = index, Count = count, TotalSize = http_response.ContentLength }; using (var http_stream = http_response.GetResponseStream ()) { using (var file_stream = File.OpenWrite (package.RelativeLocation)) { http_stream.TransferTo (file_stream, (total_read, final_block, block, block_size) => xfer_stats.CommitNewBlock (block, block_size, final_block)); } File.SetCreationTime (package.RelativeLocation, package.FileTime); File.SetLastWriteTime (package.RelativeLocation, package.FileTime); File.SetLastAccessTime (package.RelativeLocation, package.FileTime); } }
public void Transform(Engine engine, Package package) { this.package = package; this.engine = engine; if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery)) { if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery)) { log.Debug("template is rendered by a DynamicDelivery page template, will not convert from XML to java"); return; } } Item outputItem = package.GetByName("Output"); String inputValue = package.GetValue("Output"); if (inputValue == null || inputValue.Length == 0) { log.Warning("Could not find 'Output' in the package, nothing to transform"); return; } String minimizeSettings = package.GetValue("MinimizeSettings"); string outputValue = XmlMinimizer.Convert(inputValue, minimizeSettings); // replace the Output item in the package package.Remove(outputItem); outputItem.SetAsString(outputValue); package.PushItem("Output", outputItem); }
public void CreateNuGetExeDownloadExtractsFileIfItExistsButIsNotRecent() { // Arrange var fileSystem = new Mock<IFileSystemService>(MockBehavior.Strict); fileSystem.Setup(s => s.FileExists(_exePath)).Returns(true); fileSystem.Setup(s => s.GetCreationTimeUtc(_exePath)) .Returns(DateTime.UtcNow.Subtract(TimeSpan.FromHours(32))); fileSystem.Setup(s => s.OpenWrite(_exePath)).Returns(Stream.Null); var package = new Package { Version = "2.0.0" }; var packageService = new Mock<IPackageService>(MockBehavior.Strict); packageService.Setup(s => s.FindPackageByIdAndVersion("NuGet.CommandLine", null, false)) .Returns(package) .Verifiable(); var packageFileSvc = new Mock<IPackageFileService>(MockBehavior.Strict); packageFileSvc.Setup(s => s.DownloadPackageFile(package)) .Returns(CreateCommandLinePackage) .Verifiable(); // Act var downloaderSvc = GetDownloaderService(packageService, packageFileSvc, fileSystem); var result = downloaderSvc.CreateNuGetExeDownloadActionnResult(); // Assert packageFileSvc.Verify(); packageService.Verify(); AssertActionResult(result); }
public EditPackageDialog(Package package, bool bCreateNew) : base() { InitializeComponent(); InitializeDialogPanel(true/*bModal*/, x_Name); base.Closed += OnDialogClosed; m_Title = x_Title; m_ParentSearch = null; m_DataGrid = x_DataGrid; m_ListControl = x_ListControl; m_Prev = x_Prev; m_Next = x_Next; m_RootPackageOrig = package; m_RootPackage = m_RootPackageOrig.DeepClone(); m_bCreateNew = bCreateNew; if (m_bCreateNew) { ProfileDate startProfileDate = ProfileCode.StartOfPlan.ToProfileDate();// or App.Model.ProfileHolder.Profile.StartProfileDate, or DateTime.Now.ToJulian() ProfileDate endProfileDate = ProfileCode.EndOfPlan.ToProfileDate();// or App.Model.ProfileHolder.Profile.EndProfileDate; m_RootPackage.SetDates(startProfileDate, endProfileDate); m_RootPackage.MustHaveATransaction(); } m_TitleFormat = (m_bCreateNew ? "Add" : "Edit") + " the '{0}' spending source"; }
public void BuildPackageDirectory_RemapsCustomNodePaths() { var files = new[] { @"C:\file1.dyf", @"C:\file2.dyf" }; var pkg = new Package(@"C:\pkg", "Foo", "0.1.0", "MIT"); var fs = new RecordedFileSystem((fn) => files.Contains(fn)); var pr = new Mock<IPathRemapper>(); var remappedPaths = new List<Tuple<string, string>>(); pr.Setup(x => x.SetPath(files[0], It.IsAny<string>())) .Callback((string f, string s) => remappedPaths.Add(new Tuple<string, string>(f, s))); pr.Setup(x => x.SetPath(files[1], It.IsAny<string>())) .Callback((string f, string s) => remappedPaths.Add(new Tuple<string, string>(f, s))); var db = new PackageDirectoryBuilder(fs, pr.Object); var pkgsDir = @"C:\dynamopackages"; db.BuildDirectory(pkg, pkgsDir, files); var dyfDir = Path.Combine(pkgsDir, pkg.Name, PackageDirectoryBuilder.CustomNodeDirectoryName); Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[0] && x.Item2 == dyfDir)); Assert.IsTrue(remappedPaths.Any(x => x.Item1 == files[1] && x.Item2 == dyfDir)); }
public void TestUpdateAssetUrl() { var projectDir = new UFile(Path.Combine(Environment.CurrentDirectory, "testxk")); // Create a project with an asset reference a raw file var project = new Package { FullPath = projectDir }; var assetItem = new AssetItem("test", new AssetObjectTest() { Reference = new AssetReference<AssetObjectTest>(Guid.Empty, "good/location")}); project.Assets.Add(assetItem); var goodAsset = new AssetObjectTest(); project.Assets.Add(new AssetItem("good/location", goodAsset)); // Add the project to the session to make sure analysis will run correctly var session = new PackageSession(project); // Create a session with this project var analysis = new PackageAnalysis(project, new PackageAnalysisParameters() { IsProcessingAssetReferences = true, ConvertUPathTo = UPathType.Absolute, IsProcessingUPaths = true }); var result = analysis.Run(); Assert.IsFalse(result.HasErrors); Assert.AreEqual(1, result.Messages.Count); Assert.IsTrue(result.Messages[0].ToString().Contains("changed")); var asset = (AssetObjectTest)assetItem.Asset; Assert.AreEqual(goodAsset.Id, asset.Reference.Id); Assert.AreEqual("good/location", asset.Reference.Location); }
public FixedType(PredefinedTypeSyntax syntax, Package containingPackage, int bitLength, bool isSigned, int fractionalBits) : base(syntax, containingPackage, bitLength, isSigned) { Requires.That(fractionalBits <= bitLength, nameof(fractionalBits), "Must be less than bit length"); FractionalBits = fractionalBits; }
private void SavePackage() { packagesManager = new PackagesManager(this); package = new Package(); originalPackage = new Package(); if (!String.IsNullOrEmpty(Request["PackageId"])) { originalPackage = packagesManager.GetPackages(Convert.ToInt32(Request["PackageId"])); package.CopyPropertiesFrom(originalPackage); } package.Name = txtName.Text; package.NumberItems = Convert.ToInt32(txtNumberItems.Text); package.NumberUsers = Convert.ToInt32(txtNumberUsers.Text); package.Price = Convert.ToDecimal(ucCurrFieldPrice.CurrencyValue); package.ProductPrice = ucCurrFieldProductPrice.CurrencyValue; package.SetupFee = ucCurrFieldSetupFee.CurrencyValue; package.UserPerHourPrice = ucCurrFieldValueByHour.CurrencyValue; package.IsActive = chkIsActive.Checked; if (String.IsNullOrEmpty(Request["PackageId"])) { packagesManager.Insert(package); Response.Redirect("Package.aspx?PackageId=" + package.PackageId); } else packagesManager.Update(originalPackage, package); }
private void btnAdd_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txtTrackNumber.Text)) { Package p = new Package() { Alias = txtAlias.Text, TrackNumber = txtTrackNumber.Text }; if (!_monitor.Packages.Contains(p, Package.CompararPorTrackNumber)) { _monitor.Packages.Add(p); RefreshPackages(); } else { throw new ApplicationException("Código de rastreio já existente"); } } else throw new ApplicationException("Preencha o código de rastreio"); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public override void Transform(Engine engine, Package package) { Initialize(engine, package); Component comp = GetComponent(); if (IsPageTemplate() || comp == null) { Logger.Error("No Component found (is this a Page Template?)"); return; } Item outputItem = package.GetByName(Package.OutputName); if (outputItem == null) { Logger.Error("No Output package item found (is this TBB placed at the end?)"); return; } _metaFieldNames = (package.GetValue("multimediaLinkAttributes") ?? String.Empty).Split(',').Select(s => s.Trim()).ToList(); // resolve rich text fields XmlDocument doc = new XmlDocument(); string output = outputItem.GetAsString(); doc.LoadXml(output); var fields = doc.SelectNodes("//Field[@FieldType='Xhtml']/Values/string"); foreach (XmlElement field in fields) { field.InnerXml = ResolveXhtml(field.InnerXml); } package.Remove(outputItem); package.PushItem(Package.OutputName, package.CreateXmlDocumentItem(ContentType.Xml, doc)); }
public void Transform(Engine engine, Package package) { this.package = package; this.engine = engine; if (engine.PublishingContext.RenderContext != null && engine.PublishingContext.RenderContext.ContextVariables.Contains(BasePageTemplate.VariableNameCalledFromDynamicDelivery)) { if (engine.PublishingContext.RenderContext.ContextVariables[BasePageTemplate.VariableNameCalledFromDynamicDelivery].Equals(BasePageTemplate.VariableValueCalledFromDynamicDelivery)) { log.Debug("template is rendered by a DynamicDelivery page template, will not convert from XML to java"); return; } } Item outputItem = package.GetByName("Output"); String inputValue = package.GetValue("Output"); if (inputValue == null || inputValue.Length == 0) { log.Warning("Could not find 'Output' in the package, nothing to transform"); return; } // Combine the 'to lower' and 'to java' functions, since there is no reason to have one without the other. // Note: it is still possible (for backwards compatibility) to have a separate ToLower TBB in your templates. // In that case, the first letter of each element will be converted into lower case twice, which doesn't do any harm. string outputValue = LowerCaseConverter.Convert(inputValue); outputValue = XmlToJavaConverter.Convert(outputValue); // outputValue = XmlMinimizer.Convert(outputValue); // replace the Output item in the package package.Remove(outputItem); outputItem.SetAsString(outputValue); package.PushItem("Output", outputItem); }
protected override bool Process(Package package) { var account = package.Account; if (account.IncomingProcessing != true) { return false; } var message = package.Message; if (message.IsIncome != true) return false; if (message.RefNoteID == null) return false; var graph = package.Graph; PXSelect<CROpportunity, Where<CROpportunity.noteID, Equal<Required<CROpportunity.noteID>>>>. Clear(graph); var opportunity = (CROpportunity)PXSelect<CROpportunity, Where<CROpportunity.noteID, Equal<Required<CROpportunity.noteID>>>>. Select(graph, message.RefNoteID); if (opportunity == null || opportunity.OpportunityID == null) return false; return true; }
public override void DragAndDrop_HoverEnter(Package p, int x, int y) { m_DrawHover = true; }
public override void DragAndDrop_Hover(Package p, int x, int y) { Point pos = CanvasPosToLocal(new Point(x, y)); Dock dir = GetDroppedTabDirection(pos.X, pos.Y); if (dir == Dock.Fill) { if (null == m_DockedTabControl) { m_HoverRect = Rectangle.Empty; return; } m_HoverRect = InnerBounds; return; } m_HoverRect = RenderBounds; int helpBarWidth; if (dir == Dock.Left) { helpBarWidth = (int)(m_HoverRect.Width * 0.25f); m_HoverRect.Width = helpBarWidth; } if (dir == Dock.Right) { helpBarWidth = (int)(m_HoverRect.Width * 0.25f); m_HoverRect.X = m_HoverRect.Width - helpBarWidth; m_HoverRect.Width = helpBarWidth; } if (dir == Dock.Top) { helpBarWidth = (int)(m_HoverRect.Height * 0.25f); m_HoverRect.Height = helpBarWidth; } if (dir == Dock.Bottom) { helpBarWidth = (int)(m_HoverRect.Height * 0.25f); m_HoverRect.Y = m_HoverRect.Height - helpBarWidth; m_HoverRect.Height = helpBarWidth; } if ((dir == Dock.Top || dir == Dock.Bottom) && !m_DropFar) { if (m_Left != null && !m_Left.IsCollapsed) { m_HoverRect.X += m_Left.ActualWidth; m_HoverRect.Width -= m_Left.ActualWidth; } if (m_Right != null && !m_Right.IsCollapsed) { m_HoverRect.Width -= m_Right.ActualWidth; } } if ((dir == Dock.Left || dir == Dock.Right) && !m_DropFar) { if (m_Top != null && !m_Top.IsCollapsed) { m_HoverRect.Y += m_Top.ActualHeight; m_HoverRect.Height -= m_Top.ActualHeight; } if (m_Bottom != null && !m_Bottom.IsCollapsed) { m_HoverRect.Height -= m_Bottom.ActualHeight; } } }
protected XElement GetManifest() { return(Package.Descendants().Where(o => o.Name.LocalName == "manifest").First()); }
public override void DragAndDrop_HoverLeave(Package p) { m_DrawHover = false; }
/// <summary> /// Construct a graph /// </summary> /// <param name="application">Application in which the graph is loaded</param> /// <param name="package">Package which this graph corresponds to</param> /// <param name="fileName">Filename of graph</param> public Graph(Application application, Package package, string fileName, Options.Options options) { Application = application; Package = package; FileName = fileName; Options = options; // TODO: Future implementation should work with multiple executables TaskHost th = (TaskHost)package.Executables[0]; //pick specific task // MainPipe equals a Data Flow Task if (th.InnerObject is MainPipe) { MainPipe dataFlowTask = (MainPipe)th.InnerObject; _pipe = dataFlowTask; Vertices = new List <Vertex>(); Edges = new List <Edge>(); AttributeTable = new AttrTable(); //======================= // 1st iteration //======================= // Iteration of vertices/components and edges/paths // Instanciate all vertexes foreach (IDTSComponentMetaData100 dfComponent in dataFlowTask.ComponentMetaDataCollection) { // Vertex is given a transformation type string componentName = application.PipelineComponentInfos[dfComponent.ComponentClassID].Name; Vertex vertex = CreateClass(componentName); // Reference to SSIS component + name vertex.ComponentRef = dfComponent; vertex.Name = dfComponent.Name; // Add vertex to graph Vertices.Add(vertex); } // Get all the edges foreach (IDTSPath100 path in dataFlowTask.PathCollection) { Edge edge = new Edge(path) { //Find the source + destination vertex Source = Vertices.Find(v => v.ComponentRef.ID == path.StartPoint.Component.ID), Destination = Vertices.Find(v => v.ComponentRef.ID == path.EndPoint.Component.ID) }; // Add edge to graph, which connects two vertices Edges.Add(edge); } //======================= // 2nd iteration //======================= // Iterate through every single vertex in topological order, and set their dependencies and properties Vertices = TopologicalSort(ColumnChanges.None); Vertices.ForEach(v => v.MapDependenciesAndProperties()); //VisualizeGraph(); //Program.VisualGraph.Draw(fileName); //Program.VisualGraph.Open(); } }
private XElement GetSpine() { return(Package.Descendants().Where(o => o.Name.LocalName == "spine").First()); }
internal static PackagePart CreateOrGetSettingsPart(Package package) { PackagePart settingsPart; Uri settingsUri = new Uri("/word/settings.xml", UriKind.Relative); if (!package.PartExists(settingsUri)) { settingsPart = package.CreatePart(settingsUri, "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", CompressionOption.Maximum); PackagePart mainDocumentPart = package.GetParts().Single(p => p.ContentType.Equals(DOCUMENT_DOCUMENTTYPE, StringComparison.CurrentCultureIgnoreCase) || p.ContentType.Equals(TEMPLATE_DOCUMENTTYPE, StringComparison.CurrentCultureIgnoreCase)); mainDocumentPart.CreateRelationship(settingsUri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings"); XDocument settings = XDocument.Parse (@"<?xml version='1.0' encoding='utf-8' standalone='yes'?> <w:settings xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:r='http://schemas.openxmlformats.org/officeDocument/2006/relationships' xmlns:m='http://schemas.openxmlformats.org/officeDocument/2006/math' xmlns:v='urn:schemas-microsoft-com:vml' xmlns:w10='urn:schemas-microsoft-com:office:word' xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' xmlns:sl='http://schemas.openxmlformats.org/schemaLibrary/2006/main'> <w:zoom w:percent='100' /> <w:defaultTabStop w:val='720' /> <w:characterSpacingControl w:val='doNotCompress' /> <w:compat /> <w:rsids> <w:rsidRoot w:val='00217F62' /> <w:rsid w:val='001915A3' /> <w:rsid w:val='00217F62' /> <w:rsid w:val='00A906D8' /> <w:rsid w:val='00AB5A74' /> <w:rsid w:val='00F071AE' /> </w:rsids> <m:mathPr> <m:mathFont m:val='Cambria Math' /> <m:brkBin m:val='before' /> <m:brkBinSub m:val='--' /> <m:smallFrac m:val='off' /> <m:dispDef /> <m:lMargin m:val='0' /> <m:rMargin m:val='0' /> <m:defJc m:val='centerGroup' /> <m:wrapIndent m:val='1440' /> <m:intLim m:val='subSup' /> <m:naryLim m:val='undOvr' /> </m:mathPr> <w:themeFontLang w:val='en-IE' w:bidi='ar-SA' /> <w:clrSchemeMapping w:bg1='light1' w:t1='dark1' w:bg2='light2' w:t2='dark2' w:accent1='accent1' w:accent2='accent2' w:accent3='accent3' w:accent4='accent4' w:accent5='accent5' w:accent6='accent6' w:hyperlink='hyperlink' w:followedHyperlink='followedHyperlink' /> <w:shapeDefaults> <o:shapedefaults v:ext='edit' spidmax='2050' /> <o:shapelayout v:ext='edit'> <o:idmap v:ext='edit' data='1' /> </o:shapelayout> </w:shapeDefaults> <w:decimalSymbol w:val='.' /> <w:listSeparator w:val=',' /> </w:settings>" ); XElement themeFontLang = settings.Root.Element(XName.Get("themeFontLang", DocX.w.NamespaceName)); themeFontLang.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), CultureInfo.CurrentCulture); // Save the settings document. using (TextWriter tw = new StreamWriter(settingsPart.GetStream())) settings.Save(tw); } else { settingsPart = package.GetPart(settingsUri); } return(settingsPart); }
protected XElement GetMetadata() { return(Package.Descendants().Where(o => o.Name.LocalName == "metadata").First()); }
public PackageTemplateGeneratorParameters(TemplateGeneratorParameters parameters, Package package) : base(parameters) { Package = package; }
public static void Initialize(Package package) { Instance = new ResetCommand(package); }
private void BackgroundCreateRCADDB_DTS(object sender, DoWorkEventArgs args) { if (args.Argument == null) { return; } CreateRCADDBArgs createArgs = args.Argument as CreateRCADDBArgs; bool? retValue = null; if (createArgs != null) { if (createArgs.TargetInstance == null || createArgs.RCADDatabaseName == null || createArgs.LoadRCADDBPackage == null || createArgs.InstallDirectory == null || createArgs.RCADConnectionString == null || createArgs.DataDirectory == null) { args.Cancel = true; return; } Database rCADDB = null; try { //Create the new rCAD Database rCADDB = new Database(createArgs.TargetInstance, createArgs.RCADDatabaseName); rCADDB.Create(); //Run the SSIS Package Application ssisRCADLoaderApp = new Application(); SSISEventListener eventListener = new SSISEventListener(); Package ssisRCADLoader = ssisRCADLoaderApp.LoadPackage(createArgs.LoadRCADDBPackage, eventListener); ssisRCADLoader.Variables["rCADInstallDirectory"].Value = createArgs.InstallDirectory; ssisRCADLoader.Variables["rCADConnectionString"].Value = createArgs.RCADConnectionString; ssisRCADLoader.Variables["rCADDataDirectory"].Value = createArgs.DataDirectory; DTSExecResult result = ssisRCADLoader.Execute(null, null, eventListener, null, null); if (result == DTSExecResult.Success) { retValue = true; } else { using (StreamWriter output = new StreamWriter(new FileStream(Path.GetTempPath() + "rCADCreator.ssis_errors.out", FileMode.Create))) { output.Write(eventListener.ErrorLog); output.Flush(); } retValue = false; //rCADDB.Drop(); } } catch { retValue = false; //rCADDB.Drop(); } args.Result = retValue; } }
public ImportSSLCertificatesCommand(Package package) : base(package) { }
/// <summary> /// Singleton pattern: use AsmDudeTools.Instance for the instance of this class /// </summary> private AsmDudeTools() { //AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor"); ThreadHelper.ThrowIfNotOnUIThread(); #region Initialize ErrorListProvider IServiceProvider serviceProvider = new ServiceProvider(Package.GetGlobalService(typeof(Microsoft.VisualStudio.OLE.Interop.IServiceProvider)) as Microsoft.VisualStudio.OLE.Interop.IServiceProvider); this._errorListProvider = new ErrorListProvider(serviceProvider) { ProviderName = "Asm Errors", ProviderGuid = new Guid(EnvDTE.Constants.vsViewKindCode) }; #endregion this._threadPool = new SmartThreadPool(); #region load Signature Store and Performance Store string path = AsmDudeToolsStatic.Get_Install_Path() + "Resources" + Path.DirectorySeparatorChar; { string filename_Regular = path + "signature-dec2018.txt"; string filename_Hand = path + "signature-hand-1.txt"; this._mnemonicStore = new MnemonicStore(filename_Regular, filename_Hand); } { this._performanceStore = new PerformanceStore(path + "Performance" + Path.DirectorySeparatorChar); } #endregion this.Init_Data(); this._mnemonics_switched_on = new HashSet <Mnemonic>(); this.UpdateMnemonicSwitchedOn(); this._register_switched_on = new HashSet <Rn>(); this.UpdateRegisterSwitchedOn(); #region Experiments if (false) { string filename2 = AsmDudeToolsStatic.Get_Install_Path() + "Resources" + Path.DirectorySeparatorChar + "mnemonics-nasm.txt"; MnemonicStore store2 = new MnemonicStore(filename2, null); ISet <string> archs = new SortedSet <string>(); IDictionary <string, string> signaturesIntel = new Dictionary <string, string>(); IDictionary <string, string> signaturesNasm = new Dictionary <string, string>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { IEnumerable <AsmSignatureElement> intel = this._mnemonicStore.GetSignatures(mnemonic); IEnumerable <AsmSignatureElement> nasm = store2.GetSignatures(mnemonic); signaturesIntel.Clear(); signaturesNasm.Clear(); int intelCount = 0; foreach (AsmSignatureElement e in intel) { intelCount++; string instruction = e.Mnemonic.ToString() + " " + e.Operands_Str; if (signaturesIntel.ContainsKey(instruction)) { AsmDudeToolsStatic.Output_WARNING("Intel " + instruction + ": is already present with arch " + signaturesIntel[instruction] + "; new arch " + e.Arch_Str); } else { signaturesIntel.Add(instruction, e.Arch_Str); } } int nasmCount = 0; foreach (AsmSignatureElement e in nasm) { nasmCount++; string instruction = e.Mnemonic.ToString() + " " + e.Operands_Str; if (signaturesNasm.ContainsKey(instruction)) { // AsmDudeToolsStatic.Output_WARNING("Nasm " + instruction + ": is already present with arch " + signaturesNasm[instruction] + "; new arch " + e.archStr); } else { signaturesNasm.Add(instruction, e.Arch_Str); } } foreach (AsmSignatureElement e in intel) { string instruction = e.Mnemonic.ToString() + " " + e.Operands_Str; //AsmDudeToolsStatic.Output_INFO("Intel " + instruction + ": arch" + e.archStr); if ((e.Arch_Str == null) || (e.Arch_Str.Length == 0)) { if (signaturesNasm.ContainsKey(instruction)) { AsmDudeToolsStatic.Output_INFO("Intel " + instruction + " has no arch, but NASM has \"" + signaturesNasm[instruction] + "\"."); } else { if (signaturesNasm.Count == 1) { AsmDudeToolsStatic.Output_INFO("Intel " + instruction + " has no arch, but NASM has \"" + signaturesNasm.GetEnumerator().Current + "\"."); } else { AsmDudeToolsStatic.Output_INFO("Intel " + instruction + " has no arch:"); foreach (KeyValuePair <string, string> pair in signaturesNasm) { AsmDudeToolsStatic.Output_INFO("\tNASM has " + pair.Key + ": \"" + pair.Value + "\"."); } AsmDudeToolsStatic.Output_INFO(" ----"); } } } } if (false) { if (intelCount != nasmCount) { foreach (AsmSignatureElement e in intel) { AsmDudeToolsStatic.Output_INFO("INTEL " + mnemonic + ": " + e); } foreach (AsmSignatureElement e in nasm) { AsmDudeToolsStatic.Output_INFO("NASM " + mnemonic + ": " + e); } } } } foreach (string str in archs) { AsmDudeToolsStatic.Output_INFO("INTEL arch " + str); } } if (false) { foreach (Arch arch in Enum.GetValues(typeof(Arch))) { int counter = 0; ISet <Mnemonic> usedMnemonics = new HashSet <Mnemonic>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { if (this.Mnemonic_Store.GetArch(mnemonic).Contains(arch)) { //AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor: arch="+arch+"; mnemonic=" + mnemonic); counter++; usedMnemonics.Add(mnemonic); } } string str = ""; foreach (Mnemonic mnemonic in usedMnemonics) { str += mnemonic.ToString() + ","; } AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor: Architecture Option " + arch + " enables mnemonics " + str); } } if (false) { foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { string keyword = mnemonic.ToString().ToUpper(); if (this._description.ContainsKey(keyword)) { string description = this._description[keyword]; string reference = this.Get_Url(keyword); this.Mnemonic_Store.SetHtmlRef(mnemonic, reference); } } AsmDudeToolsStatic.Output_INFO(this.Mnemonic_Store.ToString()); } if (false) { ISet <string> archs = new HashSet <string>(); foreach (Mnemonic mnemonic in Enum.GetValues(typeof(Mnemonic))) { if (!this._mnemonicStore.HasElement(mnemonic)) { AsmDudeToolsStatic.Output_INFO("AsmDudeTools constructor: mnemonic " + mnemonic + " is not present"); } foreach (AsmSignatureElement e in this._mnemonicStore.GetSignatures(mnemonic)) { foreach (string s in e.Arch_Str.Split(',')) { archs.Add(s.Trim()); } } } foreach (string s in archs) { AsmDudeToolsStatic.Output_INFO(s + ","); } } #endregion }
public static IComponentModel GetComponentModel() { return((IComponentModel)Package.GetGlobalService(typeof(SComponentModel))); }