示例#1
0
        /// <summary>
        /// generates one item (parcial cedent) to XML string
        /// </summary>
        /// <param name="box">box of parcial cedent</param>
        /// <param name="rCFCedent">record with CF cedent</param>
        /// <param name="CedentType">cedent type</param>
        /// <returns>XML string</returns>
        private static string getOneItemXML(IBoxModule box, Rec_CF_cedent rCFCedent, string CedentType)
        {
            string resultStr = "";

            IBoxModule[] SubCedents = box.GetConnections(CedentType);
            // setting attribute "sub_cedent_cnt" (count of parcial cedents)
            rCFCedent.sub_cedent_cnt = SubCedents.Length;
            // adding CF cedent to XML
            if (rCFCedent.sub_cedent_cnt > 0)
            {
                resultStr = rCFCedent.ToXML(getOneCedentXML(SubCedents));
            }

            return(resultStr);
        }
        /// <summary>
        /// Returns XML string with all occurences of Active element "CF 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>";

            string[] BoxTypes = { "LISpMinerTasks.CFTask", "LISpMinerTasks.SDCFTask" }; // typy boxes (uloh), pro ktere se hledaji CFske cedents

            // searching all boxes of tasks
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, BoxTypes);

            #region Loop - processing of each task found

            foreach (IBoxModule box in TaskBoxes)
            {
                Rec_CF_cedent rCFCedent = new Rec_CF_cedent();
                counterID = 0;

                try
                {
                    // setting ID
                    rCFCedent.id = "cfcdnt" + box.ProjectIdentifier.ToString() + "_";

                    // 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");
                    rCFCedent.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");
                    rCFCedent.matrix_name = matrix_names[0].GetPropertyString("Name");

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

                    // processing of several type of Task
                    string id = rCFCedent.id;
                    switch (box.MadeInCreator.Identifier) // all available task types
                    {
                        case "LISpMinerTasks.CFTask":
                            rCFCedent.task_type = "CF Task";

                            // Antecedent
                            rCFCedent.id = id + counterID.ToString();
                            counterID++;
                            // Kodym - choose one of following possibilities (ZJISTI)
                            //rCFCedent.cedent_type = CedentEnum.Antecedent.ToString();
                            rCFCedent.cedent_type = "Attributes";
                            resultString += getOneItemXML(box, rCFCedent, "AntecedentSetting");
                            break;

                        case "LISpMinerTasks.SDCFTask":
                            rCFCedent.task_type = "SD-CF Task";

                            // Anecedent
                            rCFCedent.id = id + counterID.ToString();
                            counterID++;
                            // Kodym - choose one of following possibilities (ZJISTI)
                            //rCFCedent.cedent_type = CedentEnum.Antecedent.ToString();
                            rCFCedent.cedent_type = "Attributes";
                            resultString += getOneItemXML(box, rCFCedent, "AntecedentSetting");
                            break;
                    }

                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }

            #endregion

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

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

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

            return resultString;
        }
        /// <summary>
        /// generates one item (parcial cedent) to XML string
        /// </summary>
        /// <param name="box">box of parcial cedent</param>
        /// <param name="rCFCedent">record with CF cedent</param>
        /// <param name="CedentType">cedent type</param>
        /// <returns>XML string</returns>
        private static string getOneItemXML(IBoxModule box, Rec_CF_cedent rCFCedent, string CedentType)
        {
            string resultStr = "";
            IBoxModule[] SubCedents = box.GetConnections(CedentType);
            // setting attribute "sub_cedent_cnt" (count of parcial cedents)
            rCFCedent.sub_cedent_cnt = SubCedents.Length;
            // adding CF cedent to XML
            if (rCFCedent.sub_cedent_cnt > 0)
                resultStr = rCFCedent.ToXML(getOneCedentXML(SubCedents));

            return resultStr;
        }
示例#4
0
        /// <summary>
        /// Returns XML string with all occurences of Active element "CF 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>";

            string[] BoxTypes = { "LISpMinerTasks.CFTask", "LISpMinerTasks.SDCFTask" }; // typy boxes (uloh), pro ktere se hledaji CFske cedents

            // searching all boxes of tasks
            IBoxModule[] TaskBoxes = BoxesHelper.ListBoxesWithID(CFEsourcesTab.Sources[index] as CFEsource, BoxTypes);

            #region Loop - processing of each task found

            foreach (IBoxModule box in TaskBoxes)
            {
                Rec_CF_cedent rCFCedent = new Rec_CF_cedent();
                counterID = 0;

                try
                {
                    // setting ID
                    rCFCedent.id = "cfcdnt" + box.ProjectIdentifier.ToString() + "_";

                    // 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");
                    }
                    rCFCedent.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");
                    }
                    rCFCedent.matrix_name = matrix_names[0].GetPropertyString("Name");

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

                    // processing of several type of Task
                    string id = rCFCedent.id;
                    switch (box.MadeInCreator.Identifier) // all available task types
                    {
                    case "LISpMinerTasks.CFTask":
                        rCFCedent.task_type = "CF Task";

                        // Antecedent
                        rCFCedent.id = id + counterID.ToString();
                        counterID++;
                        // Kodym - choose one of following possibilities (ZJISTI)
                        //rCFCedent.cedent_type = CedentEnum.Antecedent.ToString();
                        rCFCedent.cedent_type = "Attributes";
                        resultString         += getOneItemXML(box, rCFCedent, "AntecedentSetting");
                        break;

                    case "LISpMinerTasks.SDCFTask":
                        rCFCedent.task_type = "SD-CF Task";

                        // Anecedent
                        rCFCedent.id = id + counterID.ToString();
                        counterID++;
                        // Kodym - choose one of following possibilities (ZJISTI)
                        //rCFCedent.cedent_type = CedentEnum.Antecedent.ToString();
                        rCFCedent.cedent_type = "Attributes";
                        resultString         += getOneItemXML(box, rCFCedent, "AntecedentSetting");
                        break;
                    }
                }
                catch (System.Exception e)
                {
                    ErrStr += "Box ProjectIdentifier=" + box.ProjectIdentifier.ToString() + ": " + e.Message + "\n";
                }
            }

            #endregion

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

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

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

            return(resultString);
        }