コード例 #1
0
 private void getBoxModuleProperties(IBoxModule boxModule)
 {
     Debug.WriteLine("enterint test get properties ...");
     PropertyInfo[] properties = boxModule.MadeInCreator.Properties;
     foreach (PropertyInfo property in properties)
     {
         string propertyName = property.name;
         Debug.WriteLine("try to get property " + propertyName);
         switch (property.typeClassIceId)
         {
             case "::Ferda::Modules::BoolT":
                 boxModule.GetPropertyBool(propertyName);
                 break;
             case "::Ferda::Modules::DateT":
                 boxModule.GetPropertyDate(propertyName);
                 break;
             case "::Ferda::Modules::DateTimeT":
                 boxModule.GetPropertyDateTime(propertyName);
                 break;
             case "::Ferda::Modules::DoubleT":
                 boxModule.GetPropertyDouble(propertyName);
                 break;
             case "::Ferda::Modules::FloatT":
                 boxModule.GetPropertyFloat(propertyName);
                 break;
             case "::Ferda::Modules::IntT":
                 boxModule.GetPropertyInt(propertyName);
                 break;
             case "::Ferda::Modules::LongT":
                 boxModule.GetPropertyLong(propertyName);
                 break;
             case "::Ferda::Modules::ShortT":
                 boxModule.GetPropertyShort(propertyName);
                 break;
             case "::Ferda::Modules::StringT":
                 boxModule.GetPropertyString(propertyName);
                 if (property.selectBoxParams != null && property.selectBoxParams.Length > 0)
                     boxModule.GetPropertyOptions(propertyName);
                 break;
             case "::Ferda::Modules::TimeT":
                 boxModule.GetPropertyTime(propertyName);
                 break;
             case "::Ferda::Modules::OtherT":
                 //TODO
                 break;
         }
     }
     Debug.WriteLine("leaving test get properties ...");
 }
コード例 #2
0
        /// <summary>
        /// Returns XML string with all occurences of Active element "Boolean cedent".
        /// </summary>
        /// <param name="index">index of data source in FEplugin data sources table</param>
        /// <returns>XML string</returns>
        public static string getList(int index)
        {
            string resultString = ""; // result XML string
            string ErrStr       = ""; // error reports
            int    counterID    = 0;

            // loading DTD to resultString
            try { resultString = XMLHelper.loadDTD(); }
            catch (Exception e)
            {
#if (LADENI)
                MessageBox.Show("error while loading DTD: " + e.Message);
#endif
                return(resultString);
            }

            // root element
            resultString += "<active_list>";

            List <TaskTypeStruct> TypyTask        = new List <TaskTypeStruct>();
            CedentTypeStruct[]    Typycedent4FT   = { new CedentTypeStruct("Antecedent", "AntecedentSetting"), new CedentTypeStruct("Succedent", "SuccedentSetting"), new CedentTypeStruct("Condition", "ConditionSetting") };
            CedentTypeStruct[]    TypycedentSD4FT = { new CedentTypeStruct("Antecedent", "AntecedentSetting"), new CedentTypeStruct("Succedent", "SuccedentSetting"), new CedentTypeStruct("Condition", "ConditionSetting"), new CedentTypeStruct("FirstSet", "Cedent1"), new CedentTypeStruct("SecondSet", "Cedent2") };
            CedentTypeStruct[]    TypycedentKL    = { new CedentTypeStruct("Condition", "ConditionSetting") };
            CedentTypeStruct[]    TypycedentSDKL  = { new CedentTypeStruct("Condition", "ConditionSetting"), new CedentTypeStruct("FirstSet", "Cedent1"), new CedentTypeStruct("SecondSet", "Cedent2") };
            CedentTypeStruct[]    TypycedentCF    = { new CedentTypeStruct("Condition", "ConditionSetting") };
            CedentTypeStruct[]    TypycedentSDCF  = { new CedentTypeStruct("Condition", "ConditionSetting"), new CedentTypeStruct("FirstSet", "Cedent1"), new CedentTypeStruct("SecondSet", "Cedent2") };
            TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.FFTTask", "4FT Task", Typycedent4FT));
            TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.SDFFTTask", "SD-4FT Task", TypycedentSD4FT));
            TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.KLTask", "KL Task", TypycedentKL));
            TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.SDKLTask", "SD-KL Task", TypycedentSDKL));
            TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.CFTask", "CF Task", TypycedentCF));
            TypyTask.Add(new TaskTypeStruct("LISpMinerTasks.SDCFTask", "SD-CF Task", TypycedentSDCF));

            #region Loop - processing of each type of Task

            foreach (TaskTypeStruct TT in TypyTask)
            {
                // searching all boxes of tasks
                IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, TT.TaskTypeID);

                #region Loop - processing of each found Task

                foreach (IBoxModule box in TaskBoxes)
                {
                    #region Loop - processing of each type of cedent of given Task

                    counterID = 0;
                    foreach (CedentTypeStruct Typcedent in TT.Cedents)
                    {
                        Rec_bool_cedent rBoolCedent = new Rec_bool_cedent();
                        // setting ID
                        string id = "cdnt" + box.ProjectIdentifier.ToString() + "_";


                        try
                        {
                            // searching data source name (database)
                            IBoxModule[] db_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.Database");
                            if (db_names.GetLength(0) != 1)  // searched more than one data source or neither one
                            {
                                throw new System.Exception("found " + db_names.GetLength(0).ToString() + " databases");
                            }
                            rBoolCedent.db_name = db_names[0].GetPropertyString("DatabaseName");

                            // searching data matrix name
                            IBoxModule[] matrix_names = BoxesHelper.ListAncestBoxesWithID(box, "DataMiningCommon.DataMatrix");
                            if (matrix_names.GetLength(0) != 1)  // searched more than one data source or neither one
                            {
                                throw new System.Exception("found " + matrix_names.GetLength(0).ToString() + " data matrixes");
                            }
                            rBoolCedent.matrix_name = matrix_names[0].GetPropertyString("Name");

                            // searching task name
                            rBoolCedent.task_name = box.UserName;


                            // filling the "task_type"
                            rBoolCedent.task_type = TT.TaskTypeLabel;

                            // filling the "cedent_type"
                            rBoolCedent.cedent_type = Typcedent.CedentTypeLabel;

                            // searching all parcial cedent
                            IBoxModule[] Subcedents = box.GetConnections(Typcedent.CedentTypeID);

                            foreach (IBoxModule Subcedent in Subcedents)
                            {
                                Rec_bool_cedent rBoolCedent1 = rBoolCedent;

                                // filling the ID
                                rBoolCedent1.id = id + counterID.ToString();
                                counterID++;

                                // setting "name"
                                rBoolCedent1.name = Subcedent.UserName;
                                // setting "length"
                                rBoolCedent1.length = Subcedent.GetPropertyLong("MinLen").ToString() + " - " + Subcedent.GetPropertyLong("MaxLen").ToString();
                                // searching all literals
                                IBoxModule[] literals = BoxesHelper.ListDirectAncestBoxesWithID(Subcedent, "DataMiningCommon.LiteralSetting");
                                // setting attribute "literal_cnt" (count of literals of parcial cedent)
                                rBoolCedent1.literal_cnt = literals.Length;

                                List <Rec_literal> rLiterals = new List <Rec_literal>();

                                #region Loop - processing of each literal of parcial cedent

                                foreach (IBoxModule litBox in literals)
                                {
                                    Rec_literal rLiteral = new Rec_literal();
                                    // setting attribute "literal_type" {Basic/Remaining}
                                    rLiteral.literal_type = litBox.GetPropertyString("LiteralType");
                                    // setting attribute "gace" {Positive/Negative/Both}
                                    rLiteral.gace = litBox.GetPropertyString("GaceType");

                                    // searching atom
                                    IBoxModule[] atoms = BoxesHelper.ListDirectAncestBoxesWithID(litBox, "DataMiningCommon.AtomSetting");
                                    if (atoms.Length != 1) // just one atom should be found
                                    {
                                        ErrStr += "Literal ID=" + litBox.ProjectIdentifier.ToString() + " : nalezeno " + atoms.Length.ToString() + " atom\n";
                                        continue; // processing of next literal
                                    }
                                    IBoxModule atomBox = atoms[0].Clone();

                                    // setting attribute "coefficient_type" {Interval/Subset/Cut/....}
                                    rLiteral.coefficient_type = atomBox.GetPropertyString("CoefficientType");
                                    // setting attribute "length"
                                    rLiteral.length = atomBox.GetPropertyLong("MinLen").ToString() + " - " + atomBox.GetPropertyLong("MaxLen").ToString();

                                    // searching attribute
                                    string[]     AttrIDs = { "DataMiningCommon.Attributes.Attribute",
                                                             "DataMiningCommon.Attributes.EquifrequencyIntervalsAttribute",
                                                             "DataMiningCommon.Attributes.EquidistantIntervalsAttribute",
                                                             "DataMiningCommon.Attributes.EachValueOneCategoryAttribute" };
                                    IBoxModule[] attributes = BoxesHelper.ListDirectAncestBoxesWithID(atomBox, AttrIDs);
                                    if (attributes.Length != 1) //just one attribute should be found
                                    {
                                        ErrStr += "Literal ID=" + litBox.ProjectIdentifier.ToString() + " : nalezeno " + attributes.Length.ToString() + " attribute\n";
                                        continue; // processing of next literal
                                    }
                                    IBoxModule attrBox = attributes[0].Clone();

                                    // setting attribute "underlying_attribute"
                                    rLiteral.underlying_attribute = attrBox.GetPropertyString("NameInLiterals");
                                    // setting attribute "category_cnt"
                                    rLiteral.category_cnt = attrBox.GetPropertyLong("CountOfCategories");
                                    // setting attribute "missing_type"
                                    rLiteral.missing_type = attrBox.GetPropertyString("IncludeNullCategory");

                                    // adding literal to list
                                    rLiterals.Add(rLiteral);
                                }
                                #endregion

                                // generating boolean cedent to XML
                                resultString += rBoolCedent1.ToXML(rLiterals);
                            }
                        }
                        catch (System.Exception e)
                        {
                            ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                        }
                    }
                    #endregion
                }

                #endregion
            }
            #endregion
            // root element
            resultString += "</active_list>";

#if (LADENI)
            // Kody - storing output to file "XMLBool_cedentExample.xml" in directory
            XMLHelper.saveXMLexample(resultString, "../XML/XMLBool_cedentExample.xml");

            if (ErrStr != "") // LADICI
            {
                MessageBox.Show("Chyby pri generating seznamu Boolskych cedent:\n" + ErrStr);
            }
#endif

            return(resultString);
        }