internal override void AnalyzeCompilation(CompilationStartAnalysisContext compilationStartContext, PXContext pxContext)
 {
     compilationStartContext.RegisterSymbolAction(c => Analyze(c, pxContext),
                                                  SymbolKind.Method);
 }
Esempio n. 2
0
 private static ViewSymbolWithTypeCollection GetViewsFromGraphImpl(this ITypeSymbol graph, PXContext pxContext,
                                                                   bool includeViewsFromInheritanceChain = true)
 {
     if (includeViewsFromInheritanceChain)
     {
         return(graph.GetBaseTypesAndThis()
                .TakeWhile(baseGraph => !baseGraph.IsGraphBaseType())
                .Reverse()
                .SelectMany(baseGraph => GetAllViewSymbolsWithTypesFromPXGraphOrPXGraphExtensionImpl(baseGraph, pxContext)));
     }
     else
     {
         return(GetAllViewSymbolsWithTypesFromPXGraphOrPXGraphExtensionImpl(graph, pxContext));
     }
 }
Esempio n. 3
0
        private Task <Document> AddPrimaryKeyDeclarationToDacAsync(Document document, SyntaxNode root, ClassDeclarationSyntax dacNode, PXContext pxContext,
                                                                   INamedTypeSymbol dacTypeSymbol, CancellationToken cancellation)
        {
            cancellation.ThrowIfCancellationRequested();

            var dacSemanticModel           = DacSemanticModel.InferModel(pxContext, dacTypeSymbol, cancellation);
            List <DacPropertyInfo> dacKeys = dacSemanticModel?.DacProperties
                                             .Where(property => property.IsKey)
                                             .OrderBy(property => property.DeclarationOrder)
                                             .ToList(capacity: 4);

            if (dacKeys.IsNullOrEmpty() || dacKeys.Count > PXReferentialIntegritySymbols.MaxPrimaryKeySize)
            {
                return(Task.FromResult(document));
            }

            var primaryKeyNode = CreatePrimaryKeyNode(document, pxContext, dacSemanticModel, dacKeys);
            var newDacNode     = dacNode.WithMembers(
                dacNode.Members.Insert(0, primaryKeyNode));

            var changedRoot = root.ReplaceNode(dacNode, newDacNode);

            changedRoot = AddUsingsForReferentialIntegrityNamespace(changedRoot);
            var modifiedDocument = document.WithSyntaxRoot(changedRoot);

            return(Task.FromResult(modifiedDocument));
        }
Esempio n. 4
0
        /// <summary>
        /// Gets the graph type from graph extension type.
        /// </summary>
        /// <param name="graphExtension">The graph extension to act on.</param>
        /// <param name="pxContext">Context.</param>
        /// <returns>
        /// The graph from graph extension.
        /// </returns>
        public static ITypeSymbol GetGraphFromGraphExtension(this ITypeSymbol graphExtension, PXContext pxContext)
        {
            pxContext.ThrowOnNull(nameof(pxContext));

            if (graphExtension == null || !graphExtension.InheritsFrom(pxContext.PXGraphExtensionType))
            {
                return(null);
            }

            var baseGraphExtensionType = graphExtension.GetBaseTypesAndThis()
                                         .OfType <INamedTypeSymbol>()
                                         .FirstOrDefault(type => type.IsGraphExtensionBaseType());

            if (baseGraphExtensionType == null)
            {
                return(null);
            }

            var graphExtTypeArgs = baseGraphExtensionType.TypeArguments;

            if (graphExtTypeArgs.Length == 0)
            {
                return(null);
            }

            ITypeSymbol firstTypeArg = graphExtTypeArgs.Last();

            return(firstTypeArg.IsPXGraph(pxContext)
                                ? firstTypeArg
                                : null);
        }
Esempio n. 5
0
 public override bool ShouldAnalyze(PXContext pxContext, PXGraphSemanticModel graph) =>
 base.ShouldAnalyze(pxContext, graph) && graph.Type == GraphType.PXGraphExtension &&
 !graph.Symbol.InstanceConstructors.IsDefaultOrEmpty && !graph.Symbol.IsGraphExtensionBaseType();
Esempio n. 6
0
        private MethodDeclarationSyntax MakeFindMethodNode(SyntaxGenerator generator, PXContext pxContext, DacSemanticModel dacSemanticModel,
                                                           List <DacPropertyInfo> dacKeys)
        {
            var returnType     = generator.TypeExpression(dacSemanticModel.Symbol);
            var parameters     = MakeParameterNodesForFindMethod(generator, pxContext, dacSemanticModel, dacKeys);
            var findMethodNode = generator.MethodDeclaration(DelegateNames.PrimaryKeyFindMethod, parameters,
                                                             typeParameters: null, returnType,
                                                             Accessibility.Public, DeclarationModifiers.Static) as MethodDeclarationSyntax;

            if (findMethodNode.Body != null)
            {
                findMethodNode = findMethodNode.RemoveNode(findMethodNode.Body, SyntaxRemoveOptions.KeepNoTrivia);
            }

            var findByCallArguments = parameters.OfType <ParameterSyntax>()
                                      .Select(parameter => Argument(
                                                  IdentifierName(parameter.Identifier)));
            var findByInvocation =
                generator.InvocationExpression(
                    IdentifierName(DelegateNames.PrimaryKeyFindByMethod), findByCallArguments) as InvocationExpressionSyntax;

            bool statementTooLongForOneLine = dacKeys.Count > MaxNumberOfKeysForOneLineStatement;

            if (statementTooLongForOneLine)
            {
                var trivia = dacSemanticModel.Node.GetLeadingTrivia()
                             .Add(Whitespace("\t\t"))
                             .Where(trivia => trivia.IsKind(SyntaxKind.WhitespaceTrivia));

                findByInvocation = findByInvocation.WithLeadingTrivia(trivia);
            }

            var arrowExpression = ArrowExpressionClause(findByInvocation);

            if (statementTooLongForOneLine)
            {
                arrowExpression = arrowExpression.WithArrowToken(
                    Token(SyntaxKind.EqualsGreaterThanToken)
                    .WithTrailingTrivia(Whitespace(" "), EndOfLine(Environment.NewLine)));
            }

            return(findMethodNode.WithExpressionBody(arrowExpression)
                   .WithSemicolonToken(
                       Token(SyntaxKind.SemicolonToken)));
        }
 public override bool ShouldAnalyze(PXContext pxContext, DacSemanticModel dac) =>
 base.ShouldAnalyze(pxContext, dac) &&
 dac.DacType == DacType.DacExtension &&
 dac.Symbol.Name != TypeNames.PXCacheExtension && !dac.Symbol.InheritsFromOrEquals(pxContext.PXMappedCacheExtensionType);
Esempio n. 8
0
 public override bool ShouldAnalyze(PXContext pxContext, PXGraphSemanticModel graph) => graph.Type == GraphType.PXGraph;
Esempio n. 9
0
        /// <summary>
        /// Gets all declared view symbols and types from the graph and its base graphs,
        /// if there is a graphs class hierarchy and <paramref name="includeViewsFromInheritanceChain"/> parameter is <c>true</c>.
        /// </summary>
        /// <param name="graph">The graph to act on.</param>
        /// <param name="pxContext">Context.</param>
        /// <param name="includeViewsFromInheritanceChain">(Optional) True to include, false to exclude the views from inheritance chain.</param>
        /// <returns/>
        public static ViewOverridableCollection GetViewsWithSymbolsFromPXGraph(this ITypeSymbol graph, PXContext pxContext,
                                                                               bool includeViewsFromInheritanceChain = true)
        {
            pxContext.ThrowOnNull(nameof(pxContext));

            if (graph?.InheritsFrom(pxContext.PXGraph.Type) != true)
            {
                return(Enumerable.Empty <GraphOverridableItem <(ISymbol, INamedTypeSymbol)> >());
            }

            var viewsByName = new GraphOverridableItemsCollection <(ISymbol Symbol, INamedTypeSymbol Type)>();
            var graphViews  = GetViewsFromGraphImpl(graph, pxContext, includeViewsFromInheritanceChain);

            viewsByName.AddRangeWithDeclarationOrder(graphViews, startingOrder: 0,
                                                     keySelector: view => view.Symbol.Name);
            return(viewsByName.Items);
        }
Esempio n. 10
0
        /// <summary>
        /// Get all views from graph or graph extension and its base graphs and base graph extensions (extended via Acumatica Customization).
        /// </summary>
        /// <param name="graphOrExtension">The graph Or graph extension to act on.</param>
        /// <param name="pxContext">Context.</param>
        /// <returns/>
        public static ViewOverridableCollection GetViewsFromGraphOrGraphExtensionAndBaseGraph(this ITypeSymbol graphOrExtension, PXContext pxContext)
        {
            pxContext.ThrowOnNull(nameof(pxContext));
            graphOrExtension.ThrowOnNull(nameof(graphOrExtension));

            bool isGraph = graphOrExtension.IsPXGraph(pxContext);

            if (!isGraph && !graphOrExtension.IsPXGraphExtension(pxContext))
            {
                return(Enumerable.Empty <GraphOverridableItem <(ISymbol, INamedTypeSymbol)> >());
            }

            return(isGraph
                                ? graphOrExtension.GetViewsWithSymbolsFromPXGraph(pxContext)
                                : graphOrExtension.GetViewsFromGraphExtensionAndBaseGraph(pxContext));
        }
Esempio n. 11
0
        private static IEnumerable <GraphOverridableItem <T> > GetViewInfoFromGraphExtension <T>(ITypeSymbol graphExtension, PXContext pxContext,
                                                                                                 AddViewInfoWithOrderDelegate <T> addGraphViewInfo,
                                                                                                 AddViewInfoWithOrderDelegate <T> addGraphExtensionViewInfo)
        {
            var empty = Enumerable.Empty <GraphOverridableItem <T> >();

            if (!graphExtension.InheritsFrom(pxContext.PXGraphExtensionType) || !graphExtension.BaseType.IsGenericType)
            {
                return(empty);
            }

            var graphType = graphExtension.GetGraphFromGraphExtension(pxContext);

            if (graphType == null)
            {
                return(empty);
            }

            var allExtensionsFromBaseToDerived = graphExtension.GetGraphExtensionWithBaseExtensions(pxContext, SortDirection.Ascending,
                                                                                                    includeGraph: false);

            if (allExtensionsFromBaseToDerived.IsNullOrEmpty())
            {
                return(empty);
            }

            var infoByView       = new GraphOverridableItemsCollection <T>();
            int declarationOrder = addGraphViewInfo(infoByView, graphType, startingOrder: 0);

            foreach (ITypeSymbol extension in allExtensionsFromBaseToDerived)
            {
                declarationOrder = addGraphExtensionViewInfo(infoByView, extension, declarationOrder);
            }

            return(infoByView.Items);
        }
Esempio n. 12
0
        /// <summary>
        /// Get the view delegates symbols and syntax nodes from the graph.
        /// The <paramref name="viewsByName"/> must have <see cref="StringComparer.OrdinalIgnoreCase"/> comparer.
        /// </summary>
        /// <param name="graph">The graph to act on</param>
        /// <param name="viewsByName">The views of the graph dictionary with <see cref="StringComparer.OrdinalIgnoreCase"/> comparer</param>
        /// <param name="pxContext">Context</param>
        /// <param name="cancellation">Cancellation token</param>
        /// <param name="inheritance">If true includes view delegates from the graph inheritance chain</param>
        /// <returns></returns>
        public static DataViewDelegatesOverridableCollection GetViewDelegatesFromGraph(this ITypeSymbol graph,
                                                                                       IDictionary <string, DataViewInfo> viewsByName,
                                                                                       PXContext pxContext, CancellationToken cancellation,
                                                                                       bool inheritance = true)
        {
            graph.ThrowOnNull(nameof(graph));
            viewsByName.ThrowOnNull(nameof(viewsByName));
            pxContext.ThrowOnNull(nameof(pxContext));

            if (!graph.IsPXGraph(pxContext))
            {
                return(Enumerable.Empty <GraphOverridableItem <(MethodDeclarationSyntax, IMethodSymbol)> >());
            }

            var viewDelegatesByName = new GraphOverridableItemsCollection <(MethodDeclarationSyntax Node, IMethodSymbol Symbol)>();
            var graphViewDelegates  = GetViewDelegatesFromGraphImpl(graph, viewsByName, pxContext, inheritance, cancellation);

            viewDelegatesByName.AddRangeWithDeclarationOrder(graphViewDelegates, startingOrder: 0, keySelector: viewDel => viewDel.Symbol.Name);
            return(viewDelegatesByName.Items);
        }
Esempio n. 13
0
        private static ViewSymbolWithTypeCollection GetAllViewSymbolsWithTypesFromPXGraphOrPXGraphExtensionImpl(ITypeSymbol graphOrExtension,
                                                                                                                PXContext pxContext)
        {
            foreach (ISymbol member in graphOrExtension.GetMembers())
            {
                if (!(member is IFieldSymbol field) || field.DeclaredAccessibility != Accessibility.Public)
                {
                    continue;
                }

                if (!(field.Type is INamedTypeSymbol fieldType) || !fieldType.InheritsFrom(pxContext.PXSelectBase.Type))
                {
                    continue;
                }

                yield return(field, fieldType);
            }
        }
            void IPrefetchable <PXWizardSiteMapProvider> .Prefetch(PXWizardSiteMapProvider provider)
            {
                PXContext.SetSlot("PrefetchSiteMap", true);

                Dictionary <Guid, WZScenario> wizardScenarios = GetWizardScenarios();

                base.Prefetch(provider); // Main site map

                if (!PXSiteMap.IsPortal)
                {
                    foreach (Guid scenarioID in wizardScenarios.Keys)
                    {
                        List <string> scenarioRole = new List <string>();
                        if (!String.IsNullOrEmpty(wizardScenarios[scenarioID].Rolename))
                        {
                            scenarioRole.Add(wizardScenarios[scenarioID].Rolename);
                        }

                        // If scenario is not active we should use different graph
                        bool scenarioIsActive = wizardScenarios[scenarioID].Status == WizardScenarioStatusesAttribute._ACTIVE;

                        PXSiteMapNode node, rootScenarioNode;

                        if (scenarioIsActive)
                        {
                            node = base.FindSiteMapNodesFromGraphType(typeof(WizardScenarioMaint).FullName, false).FirstOrDefault();
                        }
                        else
                        {
                            node = base.FindSiteMapNodesFromGraphType(typeof(WizardNotActiveScenario).FullName, false).FirstOrDefault();
                        }


                        string url = PXSiteMap.DefaultFrame;
                        if (node != null)
                        {
                            url = String.Format("{0}?ScenarioID={1}", node.Url,
                                                System.Web.HttpUtility.UrlEncode(scenarioID.ToString()));
                        }

                        rootScenarioNode = base.FindSiteMapNodesFromScreenID(WizardRootNode, false).FirstOrDefault();

                        PXSiteMapNode scenarioNode = CreateWizardNode(provider,
                                                                      scenarioID,
                                                                      url,
                                                                      wizardScenarios[scenarioID].Name,
                                                                      wizardScenarios[scenarioID].Name,
                                                                      new PXRoleList(scenarioRole.Count == 0 ? null : scenarioRole, null, null),
                                                                      null,
                                                                      false,
                                                                      "WZ201500");

                        if (wizardScenarios[scenarioID].NodeID != Guid.Empty)
                        {
                            if (scenarioIsActive)
                            {
                                if (rootScenarioNode != null &&
                                    rootScenarioNode.NodeID == (Guid)wizardScenarios[scenarioID].NodeID)
                                {
                                    PXSiteMapNode DummyNode = base.FindSiteMapNodesFromScreenID("WZ000001", false).FirstOrDefault();

                                    if (DummyNode == null)
                                    {
                                        DummyNode = CreateWizardNode(provider,
                                                                     Guid.NewGuid(),
                                                                     PXSiteMap.DefaultFrame,
                                                                     "Work Area",
                                                                     "Work Area",
                                                                     null,
                                                                     null,
                                                                     true,
                                                                     "WZ000001");
                                        AddNode(DummyNode, rootScenarioNode.NodeID);
                                    }

                                    AddNode(scenarioNode, DummyNode.NodeID);
                                }
                                else
                                {
                                    AddNode(scenarioNode, (Guid)wizardScenarios[scenarioID].NodeID);
                                }
                            }
                            else
                            {
                                PXSiteMapNode HiddenNode = base.FindSiteMapNodesFromScreenID("HD000000", false).FirstOrDefault();
                                AddNode(scenarioNode, HiddenNode.NodeID);
                            }
                        }
                        else
                        {
                            if (scenarioIsActive)
                            {
                                if (rootScenarioNode != null)
                                {
                                    PXSiteMapNode DummyNode =
                                        base.FindSiteMapNodesFromScreenID("WZ000001", false).FirstOrDefault();

                                    if (DummyNode == null)
                                    {
                                        DummyNode = CreateWizardNode(provider,
                                                                     Guid.NewGuid(),
                                                                     PXSiteMap.DefaultFrame,
                                                                     "Work Area",
                                                                     "Work Area",
                                                                     null,
                                                                     null,
                                                                     true,
                                                                     "WZ000001");

                                        AddNode(DummyNode, rootScenarioNode.NodeID);
                                    }

                                    AddNode(scenarioNode, DummyNode.NodeID);
                                }
                            }
                            else
                            {
                                PXSiteMapNode HiddenNode = base.FindSiteMapNodesFromScreenID("HD000000", false).FirstOrDefault();
                                AddNode(scenarioNode, HiddenNode.NodeID);
                            }
                        }
                    }
                }

                PXContext.SetSlot("PrefetchSiteMap", false);
            }
        private static void CheckIdentifierForUnderscores(SyntaxToken identifier, SymbolAnalysisContext context, PXContext pxContext)
        {
            if (!identifier.ValueText.Contains("_"))
            {
                return;
            }

            bool registerCodeFix = !IdentifierContainsOnlyUnderscores(identifier.ValueText);

            var diagnosticProperties = new Dictionary <string, string>
            {
                { DiagnosticProperty.RegisterCodeFix, registerCodeFix.ToString() }
            }.ToImmutableDictionary();

            context.ReportDiagnosticWithSuppressionCheck(
                Diagnostic.Create(Descriptors.PX1026_UnderscoresInDacDeclaration, identifier.GetLocation(), diagnosticProperties),
                pxContext.CodeAnalysisSettings);
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        // remove unum parameter
        PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

        // make collection editable
        isreadonly.SetValue(this.Request.QueryString, false, null);
        this.Request.QueryString.Remove(PXUrl.UNum);
        isreadonly.SetValue(this.Request.QueryString, true, null);

        this.usrCaption.CustomizationAvailable = false;

        var date = PXContext.GetBusinessDate();

        PX.Common.PXContext.SetBusinessDate((DateTime?)date);

        if ((this.viewer.SchemaUrl = this.Request.QueryString["ID"]) == null)
        {
            this.viewer.SchemaUrl = ReportID;
        }

        if (SiteMap.CurrentNode != null)
        {
            this.Title = PXSiteMap.CurrentNode.Title;
            _screenID  = PXSiteMap.CurrentNode.ScreenID;
        }
        else
        {
            string url;
            if (Request.ApplicationPath != "/")
            {
                url = Request.Path.Replace(Request.ApplicationPath, "~") + "?ID=" + this.viewer.SchemaUrl;
            }
            else if (Request.Path.StartsWith("/"))
            {
                url = "~" + Request.Path;
            }
            else
            {
                url = Request.Path;
            }
            PXSiteMapNode node = SiteMap.Provider.FindSiteMapNode(url) as PXSiteMapNode;
            if (node != null)
            {
                this.Title = node.Title;
                this.usrCaption.ScreenTitle = node.Title;
                this.usrCaption.ScreenID    = PX.Common.Mask.Format(">CC.CC.CC.CC", node.ScreenID);
                _screenID = node.ScreenID;
            }
            else
            {
                using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>(
                           new PXDataField("ScreenID"),
                           new PXDataFieldValue("Url", PXDbType.VarChar, 512, url)
                           ))
                {
                    if (record != null)
                    {
                        _screenID = record.GetString(0);
                        if (!String.IsNullOrEmpty(_screenID) && !PXAccess.VerifyRights(_screenID))
                        {
                            throw new PXSetPropertyException(ErrorMessages.NotEnoughRights, this.viewer.SchemaUrl);
                        }
                    }
                }
            }
        }
        if (String.IsNullOrEmpty(PX.Common.PXContext.GetScreenID()))
        {
            if (String.IsNullOrEmpty(_screenID) && !String.IsNullOrEmpty(this.viewer.SchemaUrl))
            {
                string schema = this.viewer.SchemaUrl;
                if (schema.EndsWith(".rpx", StringComparison.OrdinalIgnoreCase))
                {
                    schema = schema.Substring(0, schema.Length - 4);
                }
                if (schema.Length == 8)
                {
                    _screenID = schema;
                }
            }
            if (!String.IsNullOrEmpty(_screenID))
            {
                PX.Common.PXContext.SetScreenID(PX.Common.Mask.Format(">CC.CC.CC.CC", _screenID));
            }
        }
        if (_canSendEmail)
        {
            viewer.EmailSend += new PXReportViewer.EmailSendHandler(viewer_EmailSend);
        }
        else
        {
            viewer.AllowSendEmails = false;
        }
    }
Esempio n. 17
0
 public Rewriter(PXContext pxContext, Document document, SemanticModel semanticModel)
 {
     _pxContext     = pxContext;
     _document      = document;
     _semanticModel = semanticModel;
 }
Esempio n. 18
0
            public DiagnosticWalker(SymbolAnalysisContext context, SemanticModel semanticModel, PXContext pxContext,
                                    ImmutableArray <ILocalSymbol> rowVariables, // variables which were assigned with e.Row
                                    params object[] messageArgs)
            {
                pxContext.ThrowOnNull(nameof(pxContext));
                semanticModel.ThrowOnNull(nameof(semanticModel));

                _context       = context;
                _semanticModel = semanticModel;
                _pxContext     = pxContext;
                _rowVariables  = rowVariables.ToImmutableHashSet();
                _messageArgs   = messageArgs;

                _variableMemberAccessWalker = new VariableMemberAccessWalker(_rowVariables, semanticModel);
            }
Esempio n. 19
0
    //---------------------------------------------------------------------------
    /// <summary>
    /// The page Init event handler.
    /// </summary>
    protected void Page_Init(object sender, EventArgs e)
    {
        var lifetimeScope = this.Context.GetLifetimeScope();

        if (lifetimeScope != null)
        {
            screenRepository = lifetimeScope.Resolve <IScreenRepository>();
        }
        else
        {
            var serviceLocator = ServiceLocator.Current;
            screenRepository = serviceLocator.GetInstance <IScreenRepository>();
        }
        JSManager.RegisterModule(new MSScriptRenderer(Page.ClientScript), typeof(AppJS), AppJS.PageTitle);

        if (screenID == null)
        {
            this.screenID = ControlHelper.GetScreenID();
        }
        if (screenTitle == null)
        {
            if (System.Web.SiteMap.CurrentNode != null)
            {
                if (company == null || System.Web.SiteMap.CurrentNode.ParentNode != null)
                {
                    screenTitle = PXSiteMap.CurrentNode.Title;
                }
                else
                {
                    screenTitle = company;
                }
            }
        }

        string hide = this.Page.Request.QueryString[PXUrl.HidePageTitle];

        if (!string.IsNullOrEmpty(hide))
        {
            this.Visible = false; return;
        }

        this.Page.InitComplete += new EventHandler(Page_InitComplete);
        PXCallbackManager.GetInstance().PreGetCallbackResult += PreGetCallbackResult;

        tlbPath.Items["syncTOC"].Visible = false;
        tlbPath.Items["branch"].Visible  = false;
        if (!this.Page.IsCallback)
        {
            ((WebControl)LabelScreen.Parent).CssClass = "pageTitleCont";
        }

        if (PXDataSource.RedirectHelper.IsPopupPage(Page))
        {
            if (!PXList.Provider.HasList(PXSiteMap.CurrentNode.ScreenID))
            {
                tlbPath.Items["syncTOC"].Visible = false;
            }
            this.FavoriteAvailable = false;
            if (!PXDataSource.RedirectHelper.IsPopupInline(Page))
            {
                GetBranchCombo().Enabled = false;
            }
        }

        if (PXSiteMap.IsPortal)
        {
            this.CustomizationAvailable = PXAccess.GetAdministratorRoles().Any(System.Web.Security.Roles.IsUserInRole);
            this.BranchAvailable        = false;
            this.FavoriteAvailable      = false;
            pnlTBR.CssClass             = "panelTBRSP";
        }

        if (PXContext.PXIdentity.Authenticated)
        {
            userName = PXContext.PXIdentity.IdentityName;
            string branch = PXAccess.GetBranchCD();
            if (!string.IsNullOrEmpty(branch))
            {
                userName += ":" + branch;
            }
        }

        var date = PXContext.GetBusinessDate();

        if (date != null)
        {
            PXDateTimeEdit.SetDefaultDate((DateTime)date);
        }

        if (!Page.IsCallback)
        {
            Session.Remove("StoredSearch");
        }

        Page.Header.Controls.Add(
            new System.Web.UI.LiteralControl("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + ResolveUrl("~/Content/AcuInsight.css") + "\" />"));
    }
Esempio n. 20
0
 public Walker(SymbolAnalysisContext context, PXContext pxContext, SemanticModel semanticModel)
 {
     _context       = context;
     _pxContext     = pxContext;
     _semanticModel = semanticModel;
 }
Esempio n. 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        applicationName = Request.ApplicationPath.TrimEnd('/');
        pageUrl         = SharedFunctions.GetWebMethodPath(Request.Path);

        DateTime?startDateBridge;
        var      date = PXContext.GetBusinessDate();

        startDateBridge = (date != null) ? date : PXTimeZoneInfo.Now;

        // Filter By RefNbr
        RefNbr = Request.QueryString["RefNbr"];

        // External CustomerID
        CustomerID = Request.QueryString["CustomerID"];

        // Employee
        ExternalEmployee = String.IsNullOrEmpty(Request.QueryString["EmployeeID"]) == false ? Request.QueryString["EmployeeID"] : Request.QueryString["bAccountID"];

        // External SMEquipmentID
        SMEquipmentID = Request.QueryString["SMEquipmentID"];

        // Focus unassigned Appointment Tab
        AppSource = Request.QueryString["AppSource"];

        ExternalBranchID = Request.QueryString["branchID"];

        ExternalBranchLocationID = Request.QueryString["branchLocationID"];

        // Date
        try
        {
            if (!String.IsNullOrEmpty(Request.QueryString["Date"]))
            {
                startDateBridge = Convert.ToDateTime(Request.QueryString["Date"]);
            }
        }
        catch (Exception)
        {
        }

        var graphExternalControls = PXGraph.CreateInstance <ExternalControls>();
        var results = graphExternalControls.EmployeeSelected.Select();

        startDate = ((DateTime)startDateBridge).ToString("MM/dd/yyyy h:mm:ss tt", new CultureInfo("en-US"));

        PXResult <EPEmployee, Contact> result = (PXResult <EPEmployee, Contact>)results;

        EPEmployee epEmployeeRow = result;

        if (epEmployeeRow != null)
        {
            DefaultEmployee = epEmployeeRow.BAccountID.ToString();
        }

        if (string.IsNullOrEmpty(ExternalEmployee) && epEmployeeRow != null)
        {
            ExternalEmployee = DefaultEmployee;
        }

        // Load Appointment's Body to be used in index.aspx
        StreamReader streamReader = new StreamReader(Server.MapPath("../../Shared/templates/EventTemplate.html"));

        appointmentBodyTemplate = streamReader.ReadToEnd();
        streamReader.Close();

        // Load Service Order's ToolTip to be used in index.aspx
        streamReader = new StreamReader(Server.MapPath("../../Shared/templates/TooltipServiceOrder.html"));
        toolTipTemplateServiceOrder = streamReader.ReadToEnd();
        streamReader.Close();

        // Load Appointment's ToolTip to be used in index.aspx
        streamReader = new StreamReader(Server.MapPath("../../Shared/templates/TooltipAppointment.html"));
        toolTipTemplateAppointment = streamReader.ReadToEnd();
        streamReader.Close();
    }
Esempio n. 22
0
        private List <SyntaxNode> MakeParameterNodesForFindMethod(SyntaxGenerator generator, PXContext pxContext,
                                                                  DacSemanticModel dacSemanticModel, List <DacPropertyInfo> dacKeys)
        {
            const string graphParameterName = "graph";
            var          graphParameter     = generator.ParameterDeclaration(graphParameterName,
                                                                             generator.TypeExpression(pxContext.PXGraph.Type));
            var parameters = new List <SyntaxNode>(capacity: dacKeys.Count + 1)
            {
                graphParameter
            };

            foreach (DacPropertyInfo keyProperty in dacKeys)
            {
                DacFieldInfo keyField      = dacSemanticModel.FieldsByNames[keyProperty.Name];
                var          parameterType = generator.TypeExpression(keyProperty.PropertyType);
                var          parameterNode = generator.ParameterDeclaration(keyField.Name, parameterType);

                parameters.Add(parameterNode);
            }

            return(parameters);
        }
 public override bool ShouldAnalyze(PXContext pxContext, PXGraphSemanticModel graph) =>
 base.ShouldAnalyze(pxContext, graph) && graph.Type != GraphType.None;
Esempio n. 24
0
        /// <summary>
        /// Get declared primary DAC from graph or graph extension.
        /// </summary>
        /// <param name="graphOrExtension">The graph or graph extension to act on.</param>
        /// <param name="pxContext">Context.</param>
        /// <returns>
        /// The declared primary DAC from graph or graph extension.
        /// </returns>
        public static ITypeSymbol GetDeclaredPrimaryDacFromGraphOrGraphExtension(this ITypeSymbol graphOrExtension, PXContext pxContext)
        {
            pxContext.ThrowOnNull(nameof(pxContext));
            bool isGraph = graphOrExtension?.InheritsFrom(pxContext.PXGraph.Type) ?? false;

            if (!isGraph && !graphOrExtension?.InheritsFrom(pxContext.PXGraphExtensionType) != true)
            {
                return(null);
            }

            ITypeSymbol graph = isGraph
                                ? graphOrExtension
                                : graphOrExtension.GetGraphFromGraphExtension(pxContext);

            var baseGraphType = graph.GetBaseTypesAndThis()
                                .OfType <INamedTypeSymbol>()
                                .FirstOrDefault(type => IsGraphWithPrimaryDacBaseGenericType(type)) as INamedTypeSymbol;

            if (baseGraphType == null || baseGraphType.TypeArguments.Length < 2)
            {
                return(null);
            }

            ITypeSymbol primaryDacType = baseGraphType.TypeArguments[1];

            return(primaryDacType.IsDAC() ? primaryDacType : null);
        }
 public ParametersCounterSyntaxWalker(SyntaxNodeAnalysisContext aSyntaxContext, PXContext aPxContext)
 {
     _syntaxContext     = aSyntaxContext;
     _cancellationToken = _syntaxContext.CancellationToken;
     ParametersCounter  = new ParametersCounter(aPxContext);
 }
Esempio n. 26
0
 public Walker(SymbolAnalysisContext context, PXContext pxContext, EventType eventType)
     : base(context, pxContext)
 {
     _eventType = eventType;
 }
Esempio n. 27
0
 public void Dispose()
 {
     PXContext.SetSlot <RunningSelectingScope <DAC> >(_Previous);
 }
Esempio n. 28
0
        private static (AttributeData PXDefaultAttribute, bool HasPersistingCheckNothing) GetPXDefaultInfo(PXContext pxContext, DacPropertyInfo property)
        {
            var defaultAttributes = property.Attributes.Where(a => a.IsDefaultAttribute).ToList();

            if (defaultAttributes.Count != 1)                   //We don't check in case of multiple pxdefault
            {
                return(null, false);
            }

            var pxDefaultAttribute        = defaultAttributes[0].AttributeData;
            var hasPersistingCheckNothing = (from arg in pxDefaultAttribute.NamedArguments
                                             where TypeNames.PersistingCheck.Equals(arg.Key, StringComparison.Ordinal)
                                             select arg.Value.Value)
                                            .Any(value => value is int persistingCheck &&
                                                 persistingCheck == (int)PXPersistingCheckValues.Nothing);

            return(pxDefaultAttribute, hasPersistingCheckNothing);
        }
Esempio n. 29
0
        /// <summary>
        /// Get all view symbols and types from the graph extension and its base graph
        /// </summary>
        /// <param name="graphExtension">The graph extension to act on</param>
        /// <param name="pxContext">Context</param>
        /// <returns></returns>
        public static ViewOverridableCollection GetViewsFromGraphExtensionAndBaseGraph(this ITypeSymbol graphExtension, PXContext pxContext)
        {
            graphExtension.ThrowOnNull(nameof(graphExtension));
            pxContext.ThrowOnNull(nameof(pxContext));

            return(GetViewInfoFromGraphExtension <(ISymbol, INamedTypeSymbol)>(graphExtension, pxContext, AddViewsFromGraph, AddViewsFromGraphExtension));


            int AddViewsFromGraph(GraphOverridableItemsCollection <(ISymbol Symbol, INamedTypeSymbol Type)> views,
                                  ITypeSymbol graph, int startingOrder)
            {
                var graphViews = graph.GetViewsFromGraphImpl(pxContext);

                return(views.AddRangeWithDeclarationOrder(graphViews, startingOrder, keySelector: v => v.Symbol.Name));
            }

            int AddViewsFromGraphExtension(GraphOverridableItemsCollection <(ISymbol Symbol, INamedTypeSymbol Type)> views,
                                           ITypeSymbol graphExt, int startingOrder)
            {
                var extentionsViews = GetAllViewSymbolsWithTypesFromPXGraphOrPXGraphExtensionImpl(graphExt, pxContext);

                return(views.AddRangeWithDeclarationOrder(extentionsViews, startingOrder, keySelector: v => v.Symbol.Name));
            }
        }