示例#1
0
        public TagInfoExpr(XElement element, TagModeEnum mode, Report report)
            : base(element, mode, report)
        {
            XAttribute exprAttr = element.Attribute("expr");

            XAttribute sampleTypeAttr = element.Attribute("sampleType");
            String sampleTypeStr = sampleTypeAttr != null ? sampleTypeAttr.Value : "stInterval";
            TagSampleType = (PISDK.SampleTypeConstants)Enum.Parse(typeof(PISDK.SampleTypeConstants), sampleTypeStr, true);

            TagSampleInterval = element.Attribute("sampleInterval") != null ? element.Attribute("sampleInterval").Value : "1m";

            this.Expr = exprAttr != null ? report.processReplaceString(exprAttr.Value) : "0";
            //this.Expr = "'sinusoid'*'sinusoidu'";
        }
示例#2
0
文件: TagInfoPI.cs 项目: rj128x/PIMVC
        public TagInfoPI(XElement element, TagModeEnum mode, Report report)
            : base(element,mode,report)
        {
            XAttribute serverNameAttr = element.Attribute("serverName");
                XAttribute scaleMultAttr = element.Attribute("scaleMult");
                XAttribute scaleDivAttr = element.Attribute("scaleDiv");

                XAttribute summariesTypeAttr = element.Attribute("summariesType");
            String summariesTypeStr = summariesTypeAttr != null ? summariesTypeAttr.Value : "asAverage";
            TagSummariesType = (PISDK.ArchiveSummariesTypeConstants)Enum.Parse(typeof(PISDK.ArchiveSummariesTypeConstants), summariesTypeStr, true);

            XAttribute calculationBasisAttr = element.Attribute("calculationBasis");
            String calculationBasisStr = calculationBasisAttr != null ? calculationBasisAttr.Value : "cbEventWeightedExcludeEarliestEvent";
            TagCalculationBasis = (PISDK.CalculationBasisConstants)Enum.Parse(typeof(PISDK.CalculationBasisConstants), calculationBasisStr, true);

            this.ServerName = serverNameAttr != null ? serverNameAttr.Value : "DEFAULT";
            this.ScaleDiv = scaleDivAttr != null ? Double.Parse(scaleDivAttr.Value) : 1.0;
            this.ScaleMult = scaleMultAttr != null ? Double.Parse(scaleMultAttr.Value) : 1.0;

            server = PIServerInfo.getPIServer(ServerName);
        }
示例#3
0
        public TagInfoTag(XElement element, TagModeEnum mode, Report report)
            : base(element,mode,report)
        {
            XAttribute tagNameAttr = element.Attribute("tagName");

            this.TagName = tagNameAttr != null ? report.processReplaceString(tagNameAttr.Value) : "NO_TAG_NAME";

            if ((this.AutoID) && (!report.TagsIDS.Values.Contains(this.TagName))) {
                this.ID = TagName;
            }

            try {
                Point = server.PIPoints[TagName];
                if (this.AutoTitle) {
                    this.Title = Point.Name;
                }
            } catch (Exception e){
                Logger.error(String.Format("Не найден тэг {0}, Исключение: {1}",TagName,e.Message));
                Point = null;
                //Point=server.PIPoints["sinusoid"];
            }
        }
示例#4
0
 public TagInfoCalc(XElement element, TagModeEnum mode, Report report)
     : base(element,mode,report)
 {
     calcFunction = defaultCalcFunction;
 }
    /// <summary>
    /// Asynchronously executes the <see cref="T:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper" /> with the given <paramref name="context" /> and
    /// <paramref name="outputTagHelper" />.
    /// </summary>
    /// <param name="context">Contains information associated with the current HTML tag.</param>
    /// <param name="outputTagHelper">A HTML element used to generate an HTML tag.</param>
    /// <remarks>
    /// By default this calls into <see cref="M:Microsoft.AspNetCore.Razor.TagHelpers.TagHelper.Process(Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext,Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput)" />.
    /// </remarks>
    public override async Task ProcessAsync(
        TagHelperContext context,
        TagHelperOutput outputTagHelper)
    {
        // **************************************
        // Variable
        // **************************************

        var isNullable    = false;
        var isboolean     = false;
        var isGenericType = For.Metadata.ModelType.IsGenericType;

        VhModelType = For.Metadata.ModelType;

        if (isGenericType)
        {
            isNullable = For.Metadata.ModelType.GetGenericTypeDefinition() == typeof(Nullable <>);

            if (isNullable)
            {
                VhModelType = Nullable.GetUnderlyingType(For.Metadata.ModelType);
                isboolean   = VhModelType == typeof(bool);
            }
        }
        else
        {
            isboolean = VhModelType == typeof(bool);
        }

        var isEnum = VhModelType.IsEnum;

        VhTemplateTypeEnum vhTemplateType;
        var booleanOption = VhBooleanRenderEnum.None;

        if (isboolean)
        {
            booleanOption = isboolean ? (isNullable ? VhBooleanRenderEnum.MultiStateRadio : VhBooleanRenderEnum.CheckBox) : VhBooleanRenderEnum.None;

            vhTemplateType = VhTemplateTypeEnum.VhBool;
        }
        else if (isEnum)
        {
            vhTemplateType = VhTemplateTypeEnum.VhEnum;
        }
        else
        {
            vhTemplateType = VhTemplateTypeEnum.VhProp;
        }

        // **************************************
        //  Class Append Attributes - set to empty string if null
        // **************************************

        ClassBsColl ??= string.Empty;
        ClassInput ??= string.Empty;
        ClassLabel ??= string.Empty;
        ClassValidate ??= string.Empty;
        LabelOverride ??= string.Empty;

        // **************************************
        // Set Classes
        // **************************************

        // Boolean Displays - Use Order:
        //   1) From Tag Helper on Page/View
        //   2) VhBooleanAttribute
        //   3) VfDefaults
        // --------------------------------------------------------------

        var oType = For.ModelExplorer.Metadata.ContainerMetadata.ModelType;
        var attrs = oType?.GetProperty(For.ModelExplorer.Metadata.Name)?.GetCustomAttributes(typeof(VhBooleanAttribute), false);
        var vhBooleanAttribute = (VhBooleanAttribute)attrs?.FirstOrDefault();

        // Use Page/View Inputs
        var boolTrue  = (BoolTrue ?? string.Empty).ToString();
        var boolFalse = (BoolFalse ?? string.Empty).ToString();
        var boolNull  = (BoolNull ?? string.Empty).ToString();

        // If property has  vhBooleanAttribute -- then use attribute if not set from Page/View Inputs
        if (vhBooleanAttribute != null)
        {
            if (string.IsNullOrWhiteSpace(boolTrue) && !string.IsNullOrWhiteSpace(vhBooleanAttribute.BooleanTrue))
            {
                boolTrue = vhBooleanAttribute.BooleanTrue;
            }

            if (string.IsNullOrWhiteSpace(boolFalse) && !string.IsNullOrWhiteSpace(vhBooleanAttribute.BooleanFalse))
            {
                boolTrue = vhBooleanAttribute.BooleanTrue;
            }

            if (string.IsNullOrWhiteSpace(boolNull) && !string.IsNullOrWhiteSpace(vhBooleanAttribute.BooleanNull))
            {
                boolTrue = vhBooleanAttribute.BooleanTrue;
            }
        }

        // Use Defaults if not set from viewBag or [VhBooleanAttribute]
        BoolTrue  = string.IsNullOrWhiteSpace(boolTrue) ? boolTrueDefault : boolTrue;
        BoolFalse = string.IsNullOrWhiteSpace(boolFalse) ? boolFalseDefault : boolFalse;
        BoolNull  = string.IsNullOrWhiteSpace(boolNull) ? boolNullDefault : boolNull;

        // Display String
        var displayString = For.Model?.ToString();

        procesTageMode = TagMode;

        // -------------------------------------------------
        // -------------------------------------------------
        // Start Application specific logic.
        // -------------------------------------------------
        // -------------------------------------------------

        attrs = oType?.GetProperty(For.ModelExplorer.Metadata.Name)?.GetCustomAttributes(typeof(ComputedAttribute), false);
        var computedAttribute = (ComputedAttribute)attrs?.FirstOrDefault();

        attrs = oType?.GetProperty(For.ModelExplorer.Metadata.Name)?.GetCustomAttributes(typeof(ComputedOptionallyAttribute), false);
        var computedOptionallyAttribute = (ComputedOptionallyAttribute)attrs?.FirstOrDefault();

        var isComputed           = computedAttribute != null;
        var isComputedOptionally = computedOptionallyAttribute != null;

        //isQualChar = qualCharAttribute != null;

        if (isComputed || isComputedOptionally)
        {
            switch (vhTemplateType)
            {
            case VhTemplateTypeEnum.VhBool:
                break;

            case VhTemplateTypeEnum.VhEnum:
            case VhTemplateTypeEnum.VhProp:

                if (isComputed)
                {
                    ClassInput = $"{VhClass.Computed} {ClassInput}";
                }
                else
                {
                    ClassInput = $"{VhClass.ComputedOptionally} {ClassInput}";
                }

                break;

            default:
                break;
            }
        }

        // -------------------------------------------------
        // -------------------------------------------------
        // END - Application specific logic.
        // -------------------------------------------------
        // -------------------------------------------------

        switch (vhTemplateType)
        {
        case VhTemplateTypeEnum.VhEnum:

            if (For.Model != null)
            {