コード例 #1
0
 private SymbolID ConvertElementToObject(SElement sElement)
 {
     SymbolID localObject = new SymbolID();
     localObject.Location.A = sElement.ObjectId;
     localObject.Names = sElement.ObjectName;
     return localObject;
 }
コード例 #2
0
ファイル: SymbolItem.cs プロジェクト: profimedica/SYKYO
 public SymbolItem(Location Location, Multiplicity Multiplicity, string Name)
 {
     // TODO: Complete member initialization
     this.ID = new SymbolID(Location, Multiplicity);
     this.Name = Name;
     this.Location = Location;
     this.Multiplicity = Multiplicity;
 }
コード例 #3
0
ファイル: SymbolCollection.cs プロジェクト: profimedica/SYKYO
 public SymbolCollection(SymbolID ID)
 {
     if (ID.Exists)
     {
         List<string> ReturnedElements = serverAccess.GetSymbolNamesByID(ID, 1);
         if (ReturnedElements.Count > 0)
         {
             this.ID = ID;
             this.Name = ReturnedElements[0];
         }
     }
 }
コード例 #4
0
ファイル: SymbolCollection.cs プロジェクト: profimedica/SYKYO
        internal List<SymbolID> GetSymbolByID(SymbolID ID)
        {
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            List<SymbolID> ReturnedElements = new List<SymbolID>();
            if (ID.Exists)
            {
                List<string> ReturnedStrings = serverAccess.GetSymbolNamesByID(ID, 1);
                if (ReturnedStrings.Count > 0)
                {
                    foreach (string Name in ReturnedStrings)
                    {
                        ReturnedElements.Add(new SymbolID(ID.Location, ID.Multiplicity, Name));// this.ID = ID;
                        //this.Name = ReturnedElements[0];
                    }
                }
                else
                {
                    ReturnedElements.Add(SymbolID.Null);
                }
            }
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelRelations;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                thisMethod.ElementName = stackTrace.GetFrame(0).GetMethod().ToString().Replace(stackTrace.GetFrame(0).GetMethod().Name.ToString(), "<span style='color: red'>" + stackTrace.GetFrame(0).GetMethod().Name.ToString() + "</span>");
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "int[] ID", ID.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID rl in ReturnedElements)
                {
                    result += "{" + rl.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG

            return ReturnedElements;
        }
コード例 #5
0
ファイル: TestServer.cs プロジェクト: profimedica/SYKYO
        /// <summary>
        /// Start form evaluation
        /// </summary>
        private void Evaluate()
        {
            if (!string.IsNullOrEmpty(IDTextBox.Text.Trim()) && !string.IsNullOrEmpty(NameTextBox.Text.Trim()))
            {

                // If both SymbolName and SymbolID fields are filled create alias

                SymbolID ID = new SymbolID();
                int.TryParse(IDTextBox.Text.Trim(), out ID.Location.A);
                List<SymbolID> ReturnedElements = serverAccess.CreateSymbolAlias(NameTextBox.Text.Trim(), ID.Location.A);
                Display(ReturnedElements);
            }
            else if (!string.IsNullOrEmpty(IDTextBox.Text))
            {

                // If only SymbolID filled find SymbolName

                List<SymbolID> ReturnedElements = new List<SymbolID>();
                SymbolID symbol = new SymbolID();
                int.TryParse(IDTextBox.Text.Trim(), out symbol.Location.A);
                symbol.Names = serverAccess.GetSymbolNamesByID(symbol, 0);
                ReturnedElements.Add(symbol);
                Display(ReturnedElements);
            }
            else
            {
                // If only SymbolName filled find SymbolID

                List<SymbolID> ReturnedElements = new List<SymbolID>();
                if (!string.IsNullOrEmpty(NameTextBox.Text.Trim()))
                {
                    Name = NameTextBox.Text.Trim();
                    if (DuplicateCheckBox.Checked)
                    {
                        ReturnedElements = serverAccess.CreateSymbolByName(Name, true); // Create anyway
                    }
                    else if (CreateCheckBox.Checked)
                    {
                        ReturnedElements = serverAccess.CreateSymbolByName(Name, false); // Create if needed
                    }
                    else
                    {
                        ReturnedElements = serverAccess.GetSymbolsByName(Name, 0, 0); // Check for existence
                    }
                }
                Display(ReturnedElements);
            }
            
        }
コード例 #6
0
        public List<SymbolID> getLeafsByRelation(SymbolID symbol, RelationItem relation)
        {
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            List<SymbolID> returnedSymbols = new List<SymbolID>();
            List<int[]> listID = new List<int[]>();
            //listID = serverAccess.getLeafsByRelation(relation.RelationID, symbol.SymbolID, 0);
            foreach (int[] ID in listID)
            {
                //listSymbol.Add(new Symbol(ID));
            }
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelRelations;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                thisMethod.ElementName = stackTrace.GetFrame(0).GetMethod().ToString().Replace(stackTrace.GetFrame(0).GetMethod().Name.ToString(), "<span style='color: red'>" + stackTrace.GetFrame(0).GetMethod().Name.ToString() + "</span>");
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "SymbolID symbol", symbol.ToString() });
                thisMethod.Parameters.Add(new string[] { "RelationItem relation", relation.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID SymbolID in returnedSymbols)
                {
                    result += "{" + SymbolID.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return returnedSymbols;
        }
コード例 #7
0
ファイル: SymbolCollection.cs プロジェクト: profimedica/SYKYO
 internal List<SymbolID> GetSymbolByID(SymbolID ID)
 {
     List<SymbolID> ReturnedElements = new List<SymbolID>();
     if (ID.Exists)
     {
         List<string> ReturnedStrings = ServerAccess.GetSymbolNamesByID(ID, 1);
         if (ReturnedStrings.Count > 0)
         {
             foreach (string Name in ReturnedStrings)
             {
                 ReturnedElements.Add(new SymbolID(ID.Location, ID.Multiplicity, Name));// this.ID = ID;
                 //this.Name = ReturnedElements[0];
             }
         }
         else
         {
             ReturnedElements.Add(SymbolID.Null);
         }
     }
     return ReturnedElements;
 }
コード例 #8
0
 private void EvaluateExpression(string expression)
 {
     string[] sentences = expression.Split(';');
     StringBuilder sb = new StringBuilder();
     foreach (string sentence in sentences)
     {
         string[] simbolStrings = sentence.Split(' ');
         List<SymbolID> symbols = new List<SymbolID>();
         foreach (string simbolString in simbolStrings)
         {
             if (simbolString.StartsWith("[") && simbolString.EndsWith("]") && simbolString.Length > 2)
             {
                 string[] components = simbolString.Substring(1, simbolString.Length-2).Split(':');
                 SymbolID symbolID = new SymbolID(new Location(1));
                 if (components.Length > 0)
                 {
                     int.TryParse(components[0], out symbolID.Location.A);
                 }
                 symbolID.Names = serverAccess.GetSymbolNamesByID(symbolID);
                 symbols.Add(symbolID);
             }
         }
         foreach (SymbolID symbolID in symbols)
         {
             if (symbolID.Names.Count > 0)
             {
                 sb.Append(symbolID.Names[0]);
             }
             else
             {
                 sb.Append(symbolID.ToString());
             }
         }
     }
     richTextBox2.Text = sb.ToString();
 }
コード例 #9
0
 internal List<SymbolID> GetLeafsByRelation(SymbolID rootSymbol, OperatorID relation)
 {
     List<SymbolID> resultedSymbols = new List<SymbolID>();
     List<SymbolID> ReturnedIDs = serverAccess.GetContent(relation, rootSymbol, 1000);
     foreach (SymbolID ints in ReturnedIDs)
     {
         if (ints.Exists)
         {
             //=// ints.Names = serverAccess.GetSymbolNamesByID(ID, 1);
             resultedSymbols.Add(ints);
         }
         else
         {
             resultedSymbols.Add(SymbolID.Null);
         }
     }
     if (resultedSymbols.Count < 1)
     {
         resultedSymbols.Add(SymbolID.Null);
     }
     return resultedSymbols;
 }
コード例 #10
0
 private List<SymbolID> SetRelation(SymbolID a, OperatorID r, SymbolID b)
 {
     List<SymbolID> resultedSymbols = new List<SymbolID>();
     List<SymbolID> ReturnedIDs = new List<SymbolID>();//=//  serverAccess.CreateRelation(r, a.Location, b.Location);
     foreach (SymbolID ints in ReturnedIDs)
     {
         resultedSymbols.Add(new SymbolID(ints.Location, ints.Multiplicity, ""));
     }
     return resultedSymbols;
 }
コード例 #11
0
 private List<SymbolID> IsTransitive(OperatorID operatorId, SymbolID symbolFrom, SymbolID symbolTo, int limit)
 {
     List<SymbolID> resultedSymbols = new List<SymbolID>();
     List<SymbolID> ReturnedIDs = new List<SymbolID>();//=// serverAccess.IsTransitive(new List<Location>(), operatorId.Location, symbolFrom.Location, symbolTo.Location, limit);
     foreach (SymbolID ints in ReturnedIDs)
     {
         if (ints.Exists)
         {
             resultedSymbols.Add(new SymbolID(ints.Location, ints.Multiplicity, ""));
         }
         else
         {
             resultedSymbols.Add(SymbolID.Null);
         }
     }
     if (resultedSymbols.Count < 1)
     {
         resultedSymbols.Add(SymbolID.Null);
     }
     return resultedSymbols;
 }
コード例 #12
0
        RelationItem SymbolToRel(SymbolID s)
        {

            SymbolCollection symbolCollectionA = new SymbolCollection();
            symbolCollectionA.AddRange(new List<SymbolID>() { s });
            //return new RelationItem(0, new int[] { 0, 0 }, s.ID, new int[] { 0, 0 }, new int[] { 0, 0 }, string.Empty);
            //return new RelationItem(0, new int[] { 0, 0 }, s.ID, new int[] { 0, 0 }, new int[] { 0, 0 }, string.Empty);
            return null;//=//  new RelationItem(symbolCollectionA, new OperatorID(), new SymbolCollection());
        }
コード例 #13
0
ファイル: WebView.cs プロジェクト: profimedica/SYKYO
 void RegenerateTree(TreeView treeView, SymbolID rootSymbol)
 {
     this.treeView1.Nodes.Clear();
     TreeNode root = treeView.Nodes.Add(rootSymbol.Names[0]);
     root.Tag = rootSymbol;
     //prepare relation for leafs
     //prepare leafs
     List<OperatorID> operatorIds = null;
     if (comboBox1.Tag != null)
     {
         operatorIds = relationCollection.operatorCollection;
     }
     else
     {
         OperatorID relation = (OperatorID)comboBox1.Tag;//new Relation(new int[] { 2, 100, 9998, 1 }); // simbol include leafs
         operatorIds = new List<OperatorID> { relation };
     }
     int i =0;
     foreach (OperatorID operatorId in operatorIds)
     {
         List<SymbolID> listSymbol = relationCollection.GetLeafsByRelation(rootSymbol, operatorId);
         List<SymbolID> listSymbol2 = new List<SymbolID>();
         foreach (SymbolID leaf in listSymbol)
         {
             listSymbol2.Add(symbolCollection.GetSymbolByID(leaf).FirstOrDefault());
         }
         foreach (SymbolID leaf in listSymbol2)
         {
             if (leaf == null) return;
             TreeNode newRoot = root.Nodes.Add(leaf.Names[0]);
             newRoot.Tag = leaf;
             string type = "class";// logics.getFirstType(leaf).FirstOrDefault().Name;
             while (type.IndexOf(' ') > 0)
                 type = type.Substring(type.IndexOf(' ') + 1);
             newRoot.ImageIndex = i;
             //newRoot.ImageKey = wantedMappedTitles.IndexOf(type.ToLower());
             attachLeaf(newRoot, leaf, 0);
         }
         i++;
     }
 }
コード例 #14
0
        /// <summary>
        /// check if the relation is transitive
        /// </summary>
        /// <param name="path">path so far</param>
        /// <param name="operatorID">Given operator</param>
        /// <param name="symbolID1">from symbol A</param>
        /// <param name="symbolID2">to symbol B</param>
        /// <param name="limitOfResults">Maximum capacity accepted for the result set</param>
        /// <returns>the symbols succession from A to B</returns>
        public List<SymbolID> IsTransitive(List<SymbolID> path, OperatorID operatorID, SymbolID symbolID1, SymbolID symbolID2, int limitOfResults) 
        {
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            List<SymbolID> LocalReturnList = new List<SymbolID>();
            List<SymbolID> returnList = new List<SymbolID>();
            bool solved = false;
            try
            {
                string commandString;
                if (false) // ($t1[0]=='?x')
                {
                    commandString = "SELECT `ID`, `g`, `h` FROM `" + DB + "`.`s" + symbolID1.Location.A.ToString("") + "` WHERE `a` = " + symbolID1.Location.A + " AND `c` LIKE " + operatorID.Location.Var + " AND `e` = " + symbolID2.Location.A + " ";
                }
                else
                {
                    commandString = "SELECT `ID`, `g`, `h` FROM `" + DB + "`.`s" + symbolID1.Location.A.ToString("") + "` WHERE `a` = " + symbolID1.Location.A + " AND `c` = " + operatorID.Location.Var + " AND `e` = " + symbolID2.Location.A + " ";
                }
                if (limitOfResults > 0) { commandString += " Limit " + limitOfResults; }
                MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                MySqlDataReader myReader = mySqlCommand.ExecuteReader();
                if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                if (myReader.HasRows)
                {
                    solved = true;
                    while (myReader.Read())
                    {
                        if (!string.IsNullOrEmpty(myReader.GetString(0)))
                        {
                            int[] multipplicity = new int[] {0, 0 };
                            int.TryParse(myReader.GetString(1), out multipplicity[0]);
                            int.TryParse(myReader.GetString(2), out multipplicity[1]);
                            //if (multipplicity[0] != 0 || multipplicity[1] != 0)
                            //{
                            //    ReturnList.Add(symbID);
                            //}
                            SymbolID symbID = new SymbolID();
                            symbID.Location.A = symbolID1.Location.A;
                            int.TryParse(myReader.GetString(0), out symbID.Location.A);
                            int.TryParse(myReader.GetString(1), out symbID.Location.B);
                            //int.TryParse(myReader.GetString(2), out symbID[3]);
                            if (symbID.Exists)
                            {
                                returnList.Add(symbID);
                            }
                        }
                    }
                    myReader.Close();
                }
                else
                {
                    myReader.Close();
                    if (true) // ($t1[0]=='?x')
                    {
                        commandString = "SELECT `ID`, `e`, `f`, `g`, `h` FROM `" + DB + "`.`s" + symbolID1.Location.A.ToString("") + "` WHERE `a` = " + symbolID1.Location.A + " AND `c` = " + operatorID.Location.IR + " ";
                    }
                    else
                    {
                        commandString = "SELECT `ID`, `e`, `f`, `g`, `h` FROM `" + DB + "`.`s" + symbolID1.Location.A.ToString("") + "` WHERE `a` = " + symbolID1.Location.A + " AND `c`< 5000 ";
                    }
                    if (limitOfResults > 0) { commandString += " Limit " + limitOfResults; }
                    MySql.Data.MySqlClient.MySqlCommand mySqlCommand2 = new MySqlCommand(commandString, mySQLConnection);
                    MySqlDataReader myReader2 = mySqlCommand2.ExecuteReader();
                    if (MySqlTrace) SQLView.Log(mySqlCommand2.CommandText);
                    List<SymbolID> toTry = new List<SymbolID>();
                    while (myReader2.Read())
                    {
                        if (!string.IsNullOrEmpty(myReader2.GetString(0)))
                        {
                            SymbolID symbID = new SymbolID();
                            int.TryParse(myReader2.GetString(0), out symbID.Location.A);
                            int.TryParse(myReader2.GetString(1), out symbID.Location.B);
                            //int.TryParse(myReader2.GetString(2), out symbID[2]);
                            if (symbID.Exists)
                            {
                                toTry.Add(symbID);
                            }
                        }

                    }
                    myReader2.Close();
                    for (int i = 0; i < toTry.Count; i++)
                    {
                        if (!solved)
                        {
                            foreach (SymbolID symbID in toTry)
                            {
                                if (symbID.Exists)
                                {
                                    SymbolID newSymbolID = symbID;
                                    LocalReturnList = IsTransitive(LocalReturnList, operatorID, newSymbolID, symbolID2, limitOfResults);
                                }
                                if (LocalReturnList.Count > 0)
                                {
                                    //int[] ToAdd = new int[] { a[0], symbID[0] };
                                    //ReturnList.Add(new int[] { symbID[1], symbID[2] });
                                    SymbolID newSymbolID = symbID;
                                    newSymbolID.Location.A = symbolID1.Location.A;
                                    newSymbolID.Location.B = symbID.Location.A;
                                    returnList.Add(newSymbolID);
                                    returnList.AddRange(LocalReturnList);
                                    solved = true;
                                }
                            }
                        }
                    }

                }
            }
            catch (MySqlException retrieveSymbolIndexException)
            {
                Console.WriteLine("Error: {0}", retrieveSymbolIndexException.ToString());
            }
            if (MyResultsTrace)
            {
                string ResultLog = "";
                foreach (SymbolID i in returnList)
                {
                    ResultLog += " [" + i.Location.A + ":" + i.Location.B + "]";
                }
                SQLView.LogResult(new string[] { ResultLog });
            }
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                // , , int[] , int[] , int[] , int[] , int 
                thisMethod.Parameters.Add(new string[] { "List<int[]> path", path.ToString() });
                thisMethod.Parameters.Add(new string[] { "int[] relationID", operatorID.ToString() });
                thisMethod.Parameters.Add(new string[] { "int[] symbolID1", symbolID1.ToString() });
                thisMethod.Parameters.Add(new string[] { "int[] symbolID2", symbolID2.ToString() });
                thisMethod.Parameters.Add(new string[] { "int limitOfResults", limitOfResults.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID symbolItem in returnList)
                {
                    result += "{" + symbolItem.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return returnList;
        }
コード例 #15
0
ファイル: SymbolCollection.cs プロジェクト: profimedica/SYKYO
        internal List<SymbolID> GetSynonimesCollection(SymbolID symbol)
        {
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            List<SymbolID> ReturnedSymbols = new List<SymbolID>();
            if (symbol.Exists)
            {
                List<string> ReturnedElements = serverAccess.GetSymbolNamesByID(symbol, 0);
                if (ReturnedElements.Count > 0)
                {
                    foreach (string Name in ReturnedElements)
                    {
                        if (symbol.Exists)
                        {
                            symbol.Names.Add(Name);
                            ReturnedSymbols.Add(symbol);
                        }
                    }
                }
            }
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelRelations;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                thisMethod.ElementName = stackTrace.GetFrame(0).GetMethod().ToString().Replace(stackTrace.GetFrame(0).GetMethod().Name.ToString(), "<span style='color: red'>" + stackTrace.GetFrame(0).GetMethod().Name.ToString() + "</span>");
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "SymbolID symbol", symbol.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID rl in ReturnedSymbols)
                {
                    result += "{" + rl.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return ReturnedSymbols;
        }
コード例 #16
0
ファイル: WebView.cs プロジェクト: profimedica/SYKYO
        void attachLeaf(TreeNode root, SymbolID symbol, int level)
        {

            //prepare relation for leafs
           // SymbolID relation = (SymbolID)comboBox1.Tag;//new Relation(new int[] { 2, 100, 9998, 1 }); // simbol include leafs
            //prepare leafs
            List<SymbolID> listSymbol = new List<SymbolID>();//=//  relationCollection.GetLeafsByRelation(symbol, relation);
            foreach (SymbolID leaf in listSymbol)
            {
                //if  (leaf.ID[0] == 408 || leaf.Name.Equals("Windows.Forms.Application1.Symbol")) return ;
                TreeNode newRoot = root.Nodes.Add(leaf.Names[0]);
                newRoot.Tag = leaf;
                if (leaf.Names[0] != root.Text && leaf.Names[0] != "InexistentSymbol")
                {
                    level++;
                    if (newRoot.Level < 4)
                    {
                        if (visibleSymbols.Where(p => p.Location.A == leaf.Location.A && p.Location.B == leaf.Location.B).FirstOrDefault() == null)
                        {
                            if (leaf.Names[0] == "Muscle") 
                            {
                            }
                            visibleSymbols.Add(leaf);
                            attachLeaf(newRoot, leaf, level++);
                        }
                    }
                }
            }
        }
コード例 #17
0
ファイル: QueryEvaluator.cs プロジェクト: profimedica/SYKYO
        public string Decode(string str)
        {
            string result = "";
            List<int[]> ids = decodePhrase.Decode(str);
            List<int[]> ids2 = new List<int[]>();
            bool many = false;
            foreach (int[] id in ids)
            {
                if (id.Count() == 1 && id[0] >1)
                {
                    result += id[0] + " ";
                    if (id[0] != 0)
                    {
                        many = true;
                    }
                }
                if (id.Count() > 1 && id[1] != 0)
                {
                    int symbNr = id[0];
                    int offset = id[1];
                    ids2.AddRange(relation.getRecord(symbNr, offset));
                }
                if (id.Count() > 1 && id[1] == 0)
                {
                    SymbolID d = new SymbolID();
                    d.Location.A = id[0];
                    List<SymbolID> symb = symbol.GetSymbolByID(d);
                    result += symb[0].Names[0];
                    if (many)
                    {
                        result += "s";
                    }
                    result += " ";
                }
            } 
            if (result=="")
            foreach (int[] id in ids2)
            {
                if (id.Count() > 1 && id[1] != 0)
                {
                    int symbNr = id[0];
                    int offset = id[1];
                    ids2 = relation.getRecord(symbNr, offset);
                }
                if (id.Count() > 1 && id[1] == 0)
                {
                    try
                    {

                        SymbolID d = new SymbolID();
                        d.Location.A = id[0];
                        List<SymbolID> symb = symbol.GetSymbolByID(d);
                        if (!symb[0].Names[0].Equals(" * "))
                        {
                            result += symb[0].Names[0] + " ";
                        }
                    }
                    catch (Exception t) { }
                }
            }
            return result;

        }
コード例 #18
0
        /// <summary>
        /// Get symbolIDs from a partial symbol name (according to search mode options). 
        /// </summary>
        /// <param name="symbolNamePart">The partial name of the symbol to find</param>
        /// <param name="searchMode">Search mode according to the related enumeration</param>
        /// <param name="limitOfResults">Maximum capacity accepted for the result set</param>
        /// <returns>The existent symbolIDs associated with the symbol name OR the new created symbol if there was no symbol and if the permissions are right</returns>
        public List<SymbolID> GetSymbolsByName(string symbolNamePart, int searchMode, int limitOfResults = 10)
        {
            // Start logging
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            // Prepare result set
            List<SymbolID> resultedSymbolIDs = new List<SymbolID>();

            try
            {
                string commandString;
                switch (searchMode)
                {
                    case (int)SearchMode.ExactMatch: // strict
                        commandString = "SELECT `IR` FROM `" + DB + "`.`simbs` WHERE `En` LIKE '" + symbolNamePart + "' ";
                        break;
                    case (int)SearchMode.StartWith: //
                        commandString = "SELECT `IR` FROM `" + DB + "`.`simbs` WHERE `En` LIKE '" + symbolNamePart + "%' ";
                        break;
                    case (int)SearchMode.Containing: //
                        commandString = "SELECT `IR` FROM `" + DB + "`.`simbs` WHERE `En` LIKE '%" + symbolNamePart + "%' ";
                        break;
                    case (int)SearchMode.EndingWith: //
                        commandString = "SELECT `IR` FROM `" + DB + "`.`simbs` WHERE `En` LIKE '%" + symbolNamePart + "' ";
                        break;
                    default:
                        commandString = "SELECT `IR` FROM `" + DB + "`.`simbs` WHERE `En` LIKE '" + symbolNamePart + "' ";
                        break;
                }
                if (limitOfResults != 0) { commandString += " Limit " + limitOfResults + " "; }
                MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                MySqlDataReader myReader = mySqlCommand.ExecuteReader();
                while (myReader.Read())
                {
                    if (!string.IsNullOrEmpty(myReader.GetString(0))) //TO DO null value
                    {
                        SymbolID symbolID = new SymbolID();
                        int.TryParse(myReader.GetString(0), out symbolID.Location.A);
                        if (symbolID.Exists)
                        {
                            resultedSymbolIDs.Add(symbolID);
                        }
                    }
                }
                myReader.Close();
            }
            catch (MySqlException retrieveSymbolIndexException)
            {
                Console.WriteLine("Error: {0}", retrieveSymbolIndexException.ToString());
            }

            // If no symbol was found and there was provided the holl name of the symbol and permisions are right then create the wanted symbol name and return it`s symbolID
            if (resultedSymbolIDs.Count < 1 && searchMode == (int)SearchMode.ExactMatch && AcceptSymbols)
            {
                resultedSymbolIDs = CreateSymbolByName(symbolNamePart, true); // set AcceptDuplicates to avoid other check for existence
            }

            if (MyResultsTrace)
            {
                string ResultLog = "";
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    ResultLog += " [" + itemSymbolID.Location.A + ":" + "0" + "]";
                }
                SQLView.LogResult(new string[] { ResultLog });
            }

            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "string symbolNamePart", symbolNamePart });
                thisMethod.Parameters.Add(new string[] { "int mode", searchMode.ToString() });
                thisMethod.Parameters.Add(new string[] { "int limitOfResults", limitOfResults.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    result += "{" + itemSymbolID.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return resultedSymbolIDs;
        }
コード例 #19
0
        /// <summary>
        /// Get symbol names by symbolID
        /// </summary>
        /// <param name="symbolID">The given symbolID to search for</param>
        /// <param name="limitOfResults">Maximum capacity accepted for the result set</param>
        /// <returns>ResultSet: The list of names associated with the given symbolID</returns>
        public List<string> GetSymbolNamesByID(SymbolID symbolID, int limitOfResults = 10)
        {
            // Start logging
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            // Prepare result set
            List<string> resultedSymbolNames = new List<string>();
            try
            {
                string commandString;
                commandString = "SELECT `En` FROM `" + DB + "`.`simbs` WHERE `IR` = " + symbolID.Location.A + " ";
                if (limitOfResults != 0) { commandString += " Limit " + limitOfResults + " "; }
                MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                MySqlDataReader myReader = mySqlCommand.ExecuteReader();
                while (myReader.Read())
                {
                    if (!string.IsNullOrEmpty(myReader.GetString(0)))
                    {
                        string symbolName;
                        symbolName = myReader.GetString(0).ToString();
                        if (!string.IsNullOrEmpty(symbolName))
                        {
                            resultedSymbolNames.Add(symbolName);
                        }
                    }
                }
                myReader.Close();
            }
            catch (MySqlException retrieveSymbolIndexException)
            {
                Console.WriteLine("Error: {0}", retrieveSymbolIndexException.ToString());
            }

            // Log result
            if (MyResultsTrace)
            {
                string ResultLog = "";
                foreach (string i in resultedSymbolNames)
                {
                    ResultLog += "" + i + "/";
                }
                SQLView.LogResult(new string[] { ResultLog });
            }
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "int[] symbolID", symbolID.ToString() });
                thisMethod.Parameters.Add(new string[] { "int limitOfResults", limitOfResults.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (string symbolName in resultedSymbolNames)
                {
                    result += "{" + symbolName + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG

            return resultedSymbolNames;
        }
コード例 #20
0
        /// <summary>
        /// Create a nonexistent table and rezerve first line with id 1
        /// </summary>
        /// <param name="symbolPosition">position of table reference in simbols table can be used to decode the table  name</param>
        private void CreateSymbolTable(SymbolID symbolID)
        {
            //=== CUSTOM LOGGER===================================================================================
            if (LoggingSystem.TraceCode)
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                LoggingSystem.LogMessage = "<div class='CodeElementNamespace'>  " + this.GetType().Namespace + " <span class='CodeElementClass'> " + this.GetType().Name + " </span>&gt; " + stackTrace.GetFrame(0).GetMethod().ToString().Replace(stackTrace.GetFrame(0).GetMethod().Name, "<span class='CodeElementMethod'>" + stackTrace.GetFrame(0).GetMethod().Name + "</span>");
                LoggingSystem.LogMessage = "<span class='specialChaer'>(" + "<span class='CodeElementParameter'>int[] symbolPosition = </span> " + "<span class='CodeElementValue'>" + symbolID.ToString() + "</span>)</div>";
            }
            //====================================================================================================

            string commandString = "CREATE TABLE IF NOT EXISTS `" + DB + "`.`s" + symbolID.Location.A.ToString() + "` ( `ID` INT NOT NULL AUTO_INCREMENT , `a` INT NULL , `b` INT NULL , `c` INT NULL , `d` INT NULL , `e` INT NULL , `f` INT NULL , `g` INT NULL , `h` INT NULL , PRIMARY KEY (`ID`) );";
            MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
            mySqlCommand.ExecuteNonQuery();
            if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
            commandString = "INSERT INTO `" + DB + "`.`s" + symbolID.Location.A.ToString() + "` (`a`, `b`, `c`, `d`, `e`, `f`, `g`, `h`) VALUES (0,0,0,0,0,0,0,0) ;";
            mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
            mySqlCommand.ExecuteNonQuery();
            if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
        }
コード例 #21
0
        /// <summary>
        /// Create new relation
        /// </summary>
        /// <param name="operatorID">relation type</param>
        /// <param name="symbolID1">preoperand symbol</param>
        /// <param name="symbolID2">postoperand symbol</param>
        /// <returns>ResultSet: The new created relation</returns>
        public List<SymbolID> CreateRelation(OperatorID operatorID, SymbolID symbolID1, SymbolID symbolID2)
        {
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            List<SymbolID> relationPositions = new List<SymbolID>();
            SymbolID relationPosition = new SymbolID();
            try
            {
                string commandString = commandString = "INSERT INTO `" + DB + "`.`s" + symbolID2.Location.A.ToString("") + "` (`a`, `b`, `c`, `d`, `e`, `f`) VALUES (" + symbolID2.Location.A + ", " + symbolID2.Location.B + "," + operatorID.Location.IR2 + ", " + operatorID.Location.Var2 + "," + symbolID1.Location.A + ", " + symbolID1.Location.A + ", " + operatorID.Location.IR2 + ", " + operatorID.Location.Var2 + " ) ;";
                //string commandString = commandString = "INSERT INTO `" + DB + "`.`s" + symbolID2[0].ToString() + "` (`a`, `b`, `c`, `d`, `e`, `f`, `g`, `h`) VALUES (" + symbolID2[0] + ", " + symbolID2[1] + "," + relationID[4] + ", " + relationID[5] + "," + symbolID1[0] + ", " + symbolID1[1] + ", " + relationID[2] + ", " + relationID[3] + " ) ;";
                MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                //if (mySQLConnection.
                mySqlCommand.ExecuteNonQuery();
                if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                commandString = commandString = "INSERT INTO `" + DB + "`.`s" + symbolID1.Location.A.ToString("") + "` (`a`, `b`, `c`, `d`, `e`, `f`) VALUES (" + symbolID1.Location.A + ", " + symbolID1.Location.B + ", " + operatorID.Location.IR + ", " + operatorID.Location.Var + ", " + symbolID2.Location.A + ", " + symbolID2.Location.B + ", " + operatorID.Location.IR2 + ", " + operatorID.Location.Var2 + " ) ;";
                //commandString = commandString = "INSERT INTO `" + DB + "`.`s" + symbolID1[0].ToString() + "` (`a`, `b`, `c`, `d`, `e`, `f`, `g`, `h`) VALUES (" + symbolID1[0] + ", " + symbolID1[1] + ", " + relationID[0] + ", " + relationID[1] + ", " + symbolID2[0] + ", " + symbolID2[1] + ", " + relationID[2] + ", " + relationID[3] + " ) ;";
                mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                mySqlCommand.ExecuteNonQuery();
                if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                if (mySqlCommand.LastInsertedId > 0)
                {
                    relationPosition.Location.A = symbolID1.Location.A;
                    relationPosition.Location.B = (int)mySqlCommand.LastInsertedId;
                }
            }
            catch (MySqlException retrieveRelationIndexException)
            {
                Console.WriteLine("Error: {0}", retrieveRelationIndexException.ToString());
            }
            if (MyResultsTrace) SQLView.LogResult(relationPosition.ToString());
            relationPositions.Add(relationPosition);
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "int[] relationID", operatorID.ToString() });
                // thisMethod.Parameters.Add(new string[] { "int[] multiplicityA", ArrayToString(multiplicityA) });
                thisMethod.Parameters.Add(new string[] { "int[] symbolID1", symbolID1.ToString() });
                // thisMethod.Parameters.Add(new string[] { "int[] multiplicityB", ArrayToString(multiplicityB) });
                thisMethod.Parameters.Add(new string[] { "int[] symbolID2", symbolID2.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID symbolItem in relationPositions)
                {
                    result += "{" + symbolItem.Location.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return relationPositions;
        }
コード例 #22
0
        public List<SymbolID> SolveRelation(SymbolID symbol1, OperatorID operatorID,  SymbolID symbol2, int limit = 10)
        {
            // Algebric logics
            // null        == [ 0,  0]   // nothing, ignorance
            // measure     == [ 0,+/-]   // levels, needs, satisfacrion, states
            // event       == [ +,  -]   // decisions, state modifiers
            // object      == [ +,0/+]   // static objects, existence
            // incertitude == [ -,  +]   // cumulator, unoriented, unknown
            // collision   == [ -,  -]   // collision, boundary, buffer, meta
            List<SymbolID> resultNULL = new List<SymbolID>();


            // CASE 0:
            // relation is unknown
            if (operatorID.Location.IR == 0 && operatorID.Location.Var == 0 && operatorID.Multiplicity.Direction == 0 && operatorID.Multiplicity.Level == 0) // SOMETHING ? SOMETHING
            {
                List<SymbolID> result = new List<SymbolID>();
                return result;
            }

            // CASE 1:
            // both operands are nulls
            if (symbol1.Location.A == 0 && symbol1.Location.B == 0 && symbol2.Location.A == 0 && symbol2.Location.B == 0) // [ 0,  0] => [ 0,  0]  // NULL => NULL
            {
                List<SymbolID> result = new List<SymbolID>();
                result.Add(SymbolID.Null);
                return result; // NULL
            }

            // CASE 2:
            // first operand is null
            if ((symbol1.Location.A == 0 && symbol1.Location.B == 0) && (symbol2.Location.A > 0 && symbol2.Location.B >= 0)) // [ 0,  0] => [ +,  +]  // NULL => SOMETHING
            {
                List<SymbolID> result = new List<SymbolID>();
                result.Add(SymbolID.Null);
                return result; // NULL
            }

            // CASE 3:
            // second operand is null
            if ((symbol1.Location.A > 0 && symbol1.Location.B >= 0) && (symbol2.Location.A == 0 && symbol2.Location.B == 0)) // [ +,  +] => [ 0,  0] // SOMETHING => NULL
            {
                List<SymbolID> result = new List<SymbolID>();
                result.Add(SymbolID.Null);
                return result; // NULL
            }

            // CASE 4:
            // both operands are not-nulls
            if ((symbol1.Location.A < 0 && symbol1.Location.B > 0) && (symbol2.Location.A < 0 || symbol2.Location.B > 0)) // [ -,  +] => [ -,  +]  // ? => ?
            {
                List<SymbolID> result = new List<SymbolID>();
                result.Add(SymbolID.Null);
                return result; // NULL
            }

            // CASE 5:
            // unknown preoperand
            if ((symbol1.Location.A < 0 && symbol1.Location.B > 0) && (symbol2.Location.A > 0 || symbol2.Location.B >= 0)) // [ -,  +] => [ +,  +]  // ? => SOMETHING
            {
                //return FindContainer(r, a, b, limit);
            }

            // CASE 6:
            // both unknown postoperand
            if ((symbol1.Location.A > 0 && symbol1.Location.B >= 0) && (symbol2.Location.A < 0 && symbol2.Location.B > 0)) // [ +,  +] => [ -,  +]  // SOMETHING => ?
            {
                //return FindContent(r, a, b, limit);
            }

            // CASE 4:
            // both operands are not-nulls
            if ((symbol1.Location.A > 0 && symbol1.Location.B >= 0) && (symbol2.Location.A > 0 || symbol2.Location.B >= 0)) // [ +,  +] => [ -,  +]  // SOMETHING => SOMETHING
            {
                return IsTransitive(operatorID, symbol1, symbol2, 10);
            }

            return resultNULL;
        }
コード例 #23
0
        /// <summary>
        /// Get the proprieties of a symbol restricted to a relation type if provided
        /// </summary>
        /// <param name="operatorID">The relation to restrict the resultset if provided</param>
        /// <param name="multiplicationOrder">the multiplication order requested if provided</param>
        /// <param name="symbolID">The symbolID to expore for properties</param>
        /// <param name="limitOfResults">>Maximum capacity accepted for the result set</param>
        /// <returns>ResultSet: The descriptopn of the given symbol restricted to the relation if provided</returns>
        public List<SymbolID> GetContent(OperatorID operatorID, SymbolID symbolID, int limitOfResults)
        {
            // TODO Use multiplicationOrder parameter

            // Start logging
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            // Prepare result set
            List<SymbolID> resultedSymbolIDs = new List<SymbolID>();
            try
            {
                string commandString = string.Empty;
                if (operatorID.hasMultiplicity)
                {
                    commandString = "SELECT `e`, `f` FROM `" + DB + "`.`s" + symbolID.Location.A.ToString() + "` WHERE `a` = " + symbolID.Location.A + " AND `b` = " + symbolID.Location.B + " AND `c` = " + operatorID.Location.IR + " AND `d` = " + operatorID.Location.Var + " ";
                }
                else
                {
                    commandString = "SELECT `e`, `f` FROM `" + DB + "`.`s" + symbolID.Location.A.ToString() + "` WHERE `a` = " + symbolID.Location.A + " AND `b` = " + symbolID.Location.B + " AND `c` = " + operatorID.Location.IR +" AND `d` = " + operatorID.Location.Var + " ";
                //    commandString = "SELECT `e`, `f` FROM `" + DB + "`.`s" + symbolID.Location.A.ToString() + "` WHERE `a` = " + symbolID.Location.A + " AND `b` = " + symbolID.Location.B + " ";
                }
                if (limitOfResults != 0) { commandString += " Limit " + limitOfResults; }
                MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                MySqlDataReader myReader = mySqlCommand.ExecuteReader();
                while (myReader.Read())
                {
                    if (!string.IsNullOrEmpty(myReader.GetString(0)))
                    {
                        SymbolID newSymbolID = new SymbolID();
                        int.TryParse(myReader.GetString(0), out newSymbolID.Location.A);
                        try
                        {
                            int.TryParse(myReader.GetString(1), out newSymbolID.Location.B);
                        }
                        catch
                        {
                        }
                        //int.TryParse(myReader.GetString(2), out symbID[2]);
                        //int.TryParse(myReader.GetString(3), out symbID[3]);
                        if (newSymbolID.Exists)
                        {
                            resultedSymbolIDs.Add(newSymbolID);
                        }
                    }
                }
                myReader.Close();
            }
            catch (MySqlException retrieveSymbolIndexException)
            {
                Console.WriteLine("Error: {0}", retrieveSymbolIndexException.ToString());
            }
            if (MyResultsTrace)
            {
                string ResultLog = "";
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    ResultLog += " [" + itemSymbolID.Location.A + ":" + itemSymbolID.Location.B + "]";
                }
                SQLView.LogResult(new string[] { ResultLog });
            }
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "int[] relationID", operatorID.ToString() });
                thisMethod.Parameters.Add(new string[] { "int[] symbolID", symbolID.ToString() });
                thisMethod.Parameters.Add(new string[] { "int limitOfResults", limitOfResults.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    result += "{" + itemSymbolID.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return resultedSymbolIDs;
        }
コード例 #24
0
ファイル: SymbolCollection.cs プロジェクト: profimedica/SYKYO
 // Count Sinonymes
 public int Count(SymbolID ID)
 {
     List<string> ReturnedElements = serverAccess.GetSymbolNamesByID(ID, 10001);
     return ReturnedElements.Count;
 }
コード例 #25
0
        /// <summary>
        /// Create symbol by name. If duplicates are not accepted return the existent symbolID. If the name does not exist or duplicates are accepted insert the name  and return it`s symbolID
        /// </summary>
        /// <param name="symbolName">The exact name of the symbol to find</param>
        /// <param name="acceptDuplicates">True if duplicates are permitted</param>
        /// <returns>ResultSet: 1) The existent symbolID if it exists and duplicates are not permited 2) The new created symbolID</returns>
        public List<SymbolID> CreateSymbolByName(string symbolName, bool acceptDuplicates)
        {
            // TODO FLORIN: Create duplicates does not return also the existent IDs. But if not permited it will. Please check for consistency.

            // Start logging
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            // Prepare result set
            List<SymbolID> resultedSymbolIDs = new List<SymbolID>();
            
            if (!acceptDuplicates)
            {
                // If duplicates does not exists, check if the symbol is already in the database
                resultedSymbolIDs = GetSymbolsByName(symbolName, 0, 10);
            }

            // Because creation of duplicate symbols is not permited and there are already symbols with the given name, return the existent symbols
            if (resultedSymbolIDs.Count < 1)
            {
                SymbolID symbolID = new SymbolID();
                try
                {
                    // Add symbol name to simbs table
                    string commandString = "INSERT INTO `" + DB + "`.`simbs` (`ID`, `En`) VALUES (NULL, '" + symbolName + "');";
                    MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                    if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                    mySqlCommand.ExecuteNonQuery();
                    if (mySqlCommand.LastInsertedId > 0)
                    {
                        // Update IR with the ID value
                        string commandString2 = "UPDATE `" + DB + "`.`simbs` SET `IR` = `ID` WHERE `ID` = " + (int)mySqlCommand.LastInsertedId + " ;";
                        MySql.Data.MySqlClient.MySqlCommand mySqlCommand2 = new MySqlCommand(commandString2, mySQLConnection);
                        mySqlCommand2.ExecuteNonQuery();
                        symbolID.Location.A = (int)mySqlCommand.LastInsertedId;
                        resultedSymbolIDs.Add(symbolID);
                    }
                }
                catch (MySqlException retrieveSymbolIndexException)
                {
                    Console.WriteLine("Error: {0}", retrieveSymbolIndexException.ToString());
                }

                // Create the coresponding symbol table
                CreateSymbolTable(symbolID);
            }

            if (MyResultsTrace)
            {
                string ResultLog = "";
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    ResultLog += " [" + itemSymbolID.Location.A + ":" + "0" + "]";
                }
                SQLView.LogResult(new string[] { ResultLog });
            }

            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "string symbolName", symbolName.ToString() });
                thisMethod.Parameters.Add(new string[] { "bool acceptDuplicates", acceptDuplicates ? "True" : "False" });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    result += "{" + itemSymbolID.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return resultedSymbolIDs;
        }
コード例 #26
0
ファイル: SymbolCollection.cs プロジェクト: profimedica/SYKYO
 internal List<SymbolID> GetSynonimesCollection(SymbolID symbol)
 {
     List<SymbolID> ReturnedSymbols = new List<SymbolID>();
     if (symbol.Exists)
     {
         List<string> ReturnedElements = ServerAccess.GetSymbolNamesByID(symbol, 0);
         if (ReturnedElements.Count > 0)
         {
             foreach (string Name in ReturnedElements)
             {
                 if (symbol.Exists)
                 {
                     ReturnedSymbols.Add(new SymbolID(symbol.Location, symbol.Multiplicity, Name));
                 }
             }
         }
     }
     return ReturnedSymbols;
 }
コード例 #27
0
ファイル: MSDNReader.cs プロジェクト: profimedica/SYKYO
        internal void Fetch(string URL, SymbolID parrent)
        {


            XDocument doc = LoadURL(URL);
            IEnumerable<XElement> elements = doc.Elements();
            List<ELEMENT> SYMBOLS = new List<ELEMENT>();
            foreach ( XElement elr in elements)
            {
                SYMBOLS.AddRange(ParsePage(elr, 0)); // extract hrefs from menu and add namespaces from content (not typed entries) <parsing content>
            }

            foreach (ELEMENT e in SYMBOLS)
            {
                List<SymbolID> syms = symbolCollection.ForceSymbolCollection(e.myName);
                relationCollection.GetAllOperators();
                //List<SymbolID> rels = relationCollection.SetRelation(new List<SymbolID> { parrent }, new List<OperatorItem> {rrr[0]}, syms);
                if (!string.IsNullOrEmpty(e.myURL))
                {
                    Fetch(e.myURL, syms[0]);
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Create a new alias for a given IR if the permissions are right and the given symbolID exists
        /// </summary>
        /// <param name="symbolAliasName">The new alias</param>
        /// <param name="existentID">The existent IR</param>
        /// <returns>ResultSet: 1) Empty set if IR does not exists or DB does not accept this change, 2) Existent symbol if already assigned, 3) The new symbol if DB accept this change</returns>
        public List<SymbolID> CreateSymbolAlias(string symbolAliasName, int existentID)
        {
            // Start logging
            System.Diagnostics.StackTrace stackTrace0 = new System.Diagnostics.StackTrace(); LoggingSystem.BranchName = stackTrace0.GetFrame(0).GetMethod().Name;

            // A flag to continue with log section
            bool evaluationSuspended = false;

            // Prepare result set
            List<SymbolID> resultedSymbolIDs = new List<SymbolID>();

            // Prepare given ID as a symbol ID
            SymbolID symbolID = new SymbolID();
            symbolID.Location.A = existentID;

            // TODO FLORIN: check about symbolPosition
            int[] symbolPosition = new int[] { 0, 0, 0, 1 };

            // Check if alias exists
            if (existentID != 0)
            {
                List<string> SymbolSynonimes = GetSymbolNamesByID(symbolID, 0);
                //int[] match = new int[] { 0, 0 };
                if (SymbolSynonimes.Count < 1)
                {
                    // Return empty result set because the given symbolID does not exist
                    evaluationSuspended = true;
                }
                if ((!evaluationSuspended) && SymbolSynonimes.Contains(symbolAliasName))
                {
                    resultedSymbolIDs.Add(symbolID);
                    // Return the existent symbolID already associated with the given Name
                    evaluationSuspended = true;
                }
            }

            // If the database accepts changes (accept new symbols) create the alias as the request. The symbolID exists in the database. The new alias will have the same IR
            if ((!evaluationSuspended) && AcceptSymbols)
            {
                try
                {
                    string commandString = "INSERT INTO `" + DB + "`.`simbs` (`ID`, `IR`, `En`) VALUES (NULL, " + existentID + ", '" + symbolAliasName + "');";
                    MySql.Data.MySqlClient.MySqlCommand mySqlCommand = new MySqlCommand(commandString, mySQLConnection);
                    if (MySqlTrace) SQLView.Log(mySqlCommand.CommandText);
                    mySqlCommand.ExecuteNonQuery();
                    if (mySqlCommand.LastInsertedId > 0)
                    {
                        symbolPosition[0] = (int)mySqlCommand.LastInsertedId;
                        resultedSymbolIDs.Add(symbolID);
                    }
                }
                catch (MySqlException retrieveSymbolIndexException)
                {
                    Console.WriteLine("Error: {0}", retrieveSymbolIndexException.ToString());
                }
            }
            if (MySqlTrace) SQLView.LogResult(resultedSymbolIDs.ToString());
            #region LOG
            //=== CUSTOM LOGGER===================================================================================
            ElementMethod thisMethod = new ElementMethod();
            int logLevel = -1; if (logingOptions != null) logLevel = logingOptions.levelNumbers;
            if (logLevel >= 3) // code
            {
                System.Diagnostics.StackTrace stackTrace; System.Diagnostics.StackFrame fr; stackTrace = new System.Diagnostics.StackTrace(); fr = stackTrace.GetFrame(0);
                thisMethod.ElementNamespaceName = this.GetType().Namespace;
                thisMethod.ElementClassName = this.GetType().Name;
                string methodName = fr.GetMethod().ToString();
                thisMethod.ElementName = fr.GetMethod().Name;
                thisMethod.ReturnType = methodName.Substring(0, methodName.IndexOf(" "));
            }
            if (logLevel >= 2) // parameters
            {
                thisMethod.Parameters.Add(new string[] { "string symbolAliasName", symbolAliasName.ToString() });
                thisMethod.Parameters.Add(new string[] { "int existentID", existentID.ToString() });
            }
            if (logLevel >= 1) // results
            {
                string result = string.Empty;
                foreach (SymbolID itemSymbolID in resultedSymbolIDs)
                {
                    result += "{" + itemSymbolID.ToString() + "}";
                }
                thisMethod.Result = result;
            }
            LoggingSystem.LogMethod = thisMethod;

            //====================================================================================================
            #endregion LOG
            return resultedSymbolIDs;
        }