Ejemplo n.º 1
0
        public DatabaseObjectTemplate[] CompaniesFoundInPicture(string filePath)
        {
            var matches      = getMatches(filePath);
            var allCompanies = DatabaseInterface.GetAllCompanies();

            List <DatabaseObjectTemplate> output = new List <DatabaseObjectTemplate>();

            for (int x = 0; x < allCompanies.Length; x++)
            {
                for (int y = 0; y < matches.Count(); y++)
                {
                    if (allCompanies[x].CompanyName.Equals(matches[y]))
                    {
                        //if it already contains is don't add it again
                        if (!output.Contains(allCompanies[x]))
                        {
                            output.Add(allCompanies[x]);
                        }
                    }
                }
            }
            return(output.ToArray());
        }
Ejemplo n.º 2
0
        private DatabaseObjectTemplate[] SortCompanies(string name)
        {
            var allCompanies = DatabaseInterface.GetAllCompanies();

            if (name == null)
            {
                return(allCompanies);
            }

            name = name.Trim().ToLower();

            ListClassHolder[] lists = new ListClassHolder[8];

            for (int x = 0; x < lists.Length; x++)
            {
                lists[x] = new ListClassHolder();
            }

            for (int x = 0; x < allCompanies.Length; x++)
            {
                string compName = allCompanies[x].CompanyName.ToLower();

                if (compName == name)
                {
                    lists[0].output.Add(allCompanies[x]);
                }
                else if (compName.Contains(name))
                {
                    lists[1].output.Add(allCompanies[x]);
                }
                else if (name.Contains(compName))
                {
                    lists[2].output.Add(allCompanies[x]);
                }
                else if (compName.Contains(name.Remove(name.Length / 2)))
                {
                    lists[3].output.Add(allCompanies[x]);
                }
                else if (name.Contains(compName.Remove(compName.Length / 2)))
                {
                    lists[4].output.Add(allCompanies[x]);
                }
                else if (compName.Contains(name.Remove(0, name.Length / 2)))
                {
                    lists[5].output.Add(allCompanies[x]);
                }
                else if (name.Contains(compName.Remove(0, compName.Length / 2)))
                {
                    lists[6].output.Add(allCompanies[x]);
                }
                else
                {
                    lists[7].output.Add(allCompanies[x]);
                }
            }

            List <DatabaseObjectTemplate> mainOutput = new List <DatabaseObjectTemplate>();

            for (int x = 0; x < lists.Length; x++)
            {
                mainOutput.AddRange(lists[x].output);
            }
            for (int x = 0; x < mainOutput.Count(); x++)
            {
                if (mainOutput[x] == null)
                {
                    mainOutput.RemoveAt(x);
                }
            }

            return(mainOutput.ToArray());
        }
Ejemplo n.º 3
0
 private void AddCompany(string companyName, string description, string[] tags, string alternative)
 {
     DatabaseInterface.CreateNewCompany(companyName, description, tags, alternative);
 }