/// <summary>
        /// This function is called when the client navigates to *hostname*/CompanyListings/Search
        /// </summary>
        /// <returns>A view to be sent to the client</returns>
        public ActionResult Search(string textCompanyName)
        {
            if (Globals.isLoggedIn() == false)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            ServiceBusConnection connection = ConnectionManager.getConnectionObject(Globals.getUser());

            if (connection == null)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            CompanySearchRequest request = new CompanySearchRequest(textCompanyName);

            CompanySearchResponse response = connection.searchCompanyByName(request);

            if (response.result == false)
            {
                return(RedirectToAction("Index", "Authentication"));
            }

            ViewBag.Companylist = response.list;

            return(View("Index"));
        }
Пример #2
0
        /// <summary>
        /// This function is called when the client navigates to *hostname*/CompanyListings
        /// </summary>
        /// <returns>A view to be sent to the client</returns>
        public ActionResult Index()
        {
            if (Globals.isLoggedIn())
            {
                ViewBag.Companylist = null;
                ViewBag.Index       = true;

                ServiceBusConnection connection = ConnectionManager.getConnectionObject(Globals.getUser());
                if (connection == null)
                {
                    return(RedirectToAction("Index", "Authentication"));
                }

                CompanySearchRequest  request  = new CompanySearchRequest("");
                CompanySearchResponse response = connection.searchCompanyByName(request);

                if (response.result)
                {
                    ViewBag.Companylist = response.list.companyNames;
                }

                return(View("Index"));
            }
            return(RedirectToAction("Index", "Authentication"));
        }
Пример #3
0
        /// <summary>
        /// Searches the db for the company, and returns its results back to the calling endpoint.
        /// </summary>
        /// <param name="message">Information about the echo</param>
        /// <param name="context">Used to access information regarding the endpoints used for this handle</param>
        /// <returns>The response to be sent back to the calling process</returns>
        public Task Handle(CompanySearchRequest request, IMessageHandlerContext context)
        {
            //Save the echo to the database
            CompanySearchResponse response = CompanyDirectoryServiceDatabase.getInstance().searchCompanyInfo(request.searchDeliminator);

            //The context is used to give a reply back to the endpoint that sent the request
            return(context.Reply(response));
        }
Пример #4
0
        /// <summary>
        /// Saves the echo to the database, reverses the data, and returns it back to the calling endpoint.
        /// </summary>
        /// <param name="message">Information about the echo</param>
        /// <param name="context">Used to access information regarding the endpoints used for this handle</param>
        /// <returns>The response to be sent back to the calling process</returns>
        public Task Handle(CompanySearchRequest message, IMessageHandlerContext context)
        {
            //Save the echo to the database
            CompanySearchResponse resp = DirectoryServiceDatabase.getInstance().searchCompany(message);

            // Do something here and return a COMPANYSEARCHRESPONSE

            //The context is used to give a reply back to the endpoint that sent the request
            return(context.Reply(resp));
        }
        ///<summary>
        ///Searches for companies
        ///</summary>
        ///<param name="compo">Information about what to search for</param>
        public CompanySearchResponse searchCompany(CompanySearchRequest compo)
        {
            if (openConnection() == true)
            {
                CompanySearchResponse toReturn = new CompanySearchResponse(false, "Issue searching for companies.", null);

                try
                {
                    string query = @"SELECT companyName FROM " + databaseName + @".Companies " +
                                   @"WHERE companyName LIKE '%" + compo.searchDeliminator + @"%';";

                    MySqlCommand    command    = new MySqlCommand(query, connection);
                    MySqlDataReader dataReader = command.ExecuteReader();
                    CompanyList     results    = new CompanyList();
                    ArrayList       res        = new ArrayList();
                    for (int i = 0; dataReader.Read() == true; i++)
                    {
                        res.Add(dataReader.GetString("companyName"));
                    }
                    dataReader.Close();
                    results.companyNames = new string[res.Count];
                    res.CopyTo(results.companyNames);

                    toReturn = new CompanySearchResponse(true, "Sucessfully retrieved company information.", results);
                }
                catch (Exception a)
                {
                    Console.WriteLine("Issue searching for companies.");
                    Console.WriteLine(a.Message);
                }
                finally
                {
                    closeConnection();
                }

                return(toReturn);
            }
            else
            {
                Debug.consoleMsg("Unable to connect to database");
                return(new CompanySearchResponse(false, "Could not find any company information.", null));
            }
        }
Пример #6
0
        /// <summary>
        /// Searches the Company Directory Service database for any company's that match the description given in the command object
        /// </summary>
        /// <param name="message">The command object that was sent</param>
        /// <param name="context">Contains information relevent to the current command being handled.</param>
        /// <returns>An object containing a list of companies matching the given description</returns>
        public Task Handle(CompanySearchRequest message, IMessageHandlerContext context)
        {
            CompanySearchResponse dbResponse = CompanyDirectoryDB.getInstance().searchByName(message);

            return(context.Reply(dbResponse));
        }