AnsweredAssumed Answered

Created element with analyses is not allways seen thdough AF Sdk

Question asked by VarbanVarbanov on Jan 12, 2017
Latest reply on Jan 13, 2017 by pthivierge

Hello, I am crating AF Elements along with AF Analysis which target these elements. Elements are allways cretaed in same root element. However sometimes these element cannot be seen in Pi System Explorer and through search of an element children elements though AF Sdk (using element.Elements where element is the root element). At the same time these elements, which cannot be seen are present in the PIFD and their parents can be verified to be the correct ones using ownerid column. Also these elements can be found if the analyse which is targeting them is found and their parent (element.Parent) is the mentioned root. I hope the explanation is not confusing, in summary - using same code - sometimes elements can be seen, more often they cannot but still thei are present in the db and their parent can be verified even through sdk (i.e, they are not in some other place). The code I use for creating is as follows (some not important parts missing):


    AFElement element;
               AFElement calculationRoot = GetOrCreateCalculationRoot();
               element = new AFElement(an.Name);
               if (calculationRoot.Elements[an.Name] != null)
                    throw new InvalidOperationException(
                        $@"Attempt for creating new analysis with name {an.Name} failed, because such already exists in default analysis root! 
                           Consider changing the name or sending currently existing analysis element path to perform an update instead.");
            AFAttribute att = element.Attributes.Add(AnalysisAttributeName);
            var anPlugin = _connection.PISystem.DataReferencePlugIns["Analysis"];
            if (anPlugin == null)
                throw new InvalidOperationException(
                    $"An attempt was made for creating af analysis: {an.Name}, but analyses reference plugin was not installed on the server: {_connection.PISystem.Name}. Please check the af analysis installation on the server");
            att.DataReferencePlugIn = anPlugin;
            existingAnalyse = new AFAnalysis(_afDatabase, an.Name);
            existingAnalyse.Target = element;
            existingAnalyse.AnalysisRulePlugIn = _connection.PISystem.AnalysisRulePlugIns["PerformanceEquation"];
            existingAnalyse.AnalysisRule.ConfigString = $"{OutputVariableName}{an.ExpressionString}";
            existingAnalyse.TimeRulePlugIn = _connection.PISystem.TimeRulePlugIns["Natural"];
            existingAnalyse.AnalysisRule.MapVariable("AnalysisOutput", AnalysisAttributeName);




I tried some changes in code like checking the element separately, but none of them worked (and as i said , the elements are actually present in Database).


Please help! What is wrong! I'll be very greatful for any fast suggestion.. Thank you in advance