public PlansController()
        {
            roles = new RolesImpl();
            webSecurity = new WebSecurityImpl();

            messagequeue = new ObjectMessageQueue();
        }
        public PlansController(IGenericRepository<Plan> fakePlan, IGenericRepository<PlanCourse> fakePlanCourse, IGenericRepository<Semester> fakeSem, IGenericRepository<User> fakeUser, IGenericRepository<DegreeProgram> fakeDegree, IRoles fakeRoles, IWebSecurity fakeWebSecurity)
        {
            roles = fakeRoles;
            webSecurity = fakeWebSecurity;

            messagequeue = new ObjectMessageQueue();
        }
Esempio n. 3
0
 private static void DoMessage(Object obj)
 {
     GenericRequest gen_req = obj as GenericRequest;
     ObjectMessageQueue queue = new ObjectMessageQueue();
     queue.RequestGuid = gen_req.requester_guid;
     queue.RequestIP = gen_req.requester_ip;
     if (gen_req == null)
     {
         Console.WriteLine("Error processing request, it is not a request object!");
         queue.sendObject(null, ObjectMessageQueue.AUTH_RESPONSE);
     }
     else
     {
         Console.WriteLine("Fetching data...");
         AccountDBContext context = null;
         if (contextQueue.TryDequeue(out context) == false)
         {
             //Check if we are under the max count of contexts allowed
             bool createNew = false;
             lock (context_lock)
             {
                 if (context_count < 25)
                 {
                     context_count++;
                     createNew = true;
                 }
             }
             //If we are allowed, create a context for ourself and the pool.
             if (createNew)
             {
                 context = new AccountDBContext();
             }
             else //Else, wait for a context to be available
             {
                 while (contextQueue.TryDequeue(out context) == false)
                 {
                     Thread.Sleep(5);
                 }
             }
         }
         AuthProcessor parser = new AuthProcessor(context, gen_req);
         try
         {
             Object result = typeof(AuthProcessor).GetMethod(gen_req.Method.ToString()).Invoke(parser, null);
             Console.WriteLine("It worked!");
             queue.sendResponse(result, ObjectMessageQueue.AUTH_RESPONSE);
         }
         catch (SqlException)
         {
             Console.WriteLine("An error occurred.");
         }
         contextQueue.Enqueue(context);
     }
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetData("DataDirectory", Application.StartupPath);

            CourseDBContext context = new CourseDBContext();

            ObjectMessageQueue.InitializeQueue(ObjectMessageQueue.DB_REQUEST);
            ObjectMessageQueue queue = new ObjectMessageQueue();

            while (true)
            {
                try
                {
                    Object obj = queue.receiveObject(ObjectMessageQueue.DB_REQUEST);
                    GenericRequest gen_req = obj as GenericRequest;

                    if (gen_req == null)
                    {
                        Console.WriteLine("Error processing request, it is not a request object!");
                        queue.sendObject(null, ObjectMessageQueue.DB_RESPONSE);
                    }
                    else
                    {
                        Console.WriteLine("Fetching data...");
                        MessageProcessor parser = new MessageProcessor(context, gen_req);
                        try
                        {
                            Object result = typeof(MessageProcessor).GetMethod(gen_req.Method.ToString()).Invoke(parser, null);
                            Console.WriteLine("It worked!");
                            queue.sendResponse(result, ObjectMessageQueue.DB_RESPONSE);
                        }
                        catch (SqlException)
                        {
                            Console.WriteLine("An error occurred.");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    continue;
                }
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetData("DataDirectory", Application.StartupPath);

            context = new CourseDBContext();

            ObjectMessageQueue.InitializeQueue(ObjectMessageQueue.DB_REQUEST);
            queue = new ObjectMessageQueue();

            while (true)
            {
                try
                {
                    Object obj = queue.receiveObject(ObjectMessageQueue.DB_REQUEST);
                    new Thread(ProcessRequest).Start(obj);
                    //ProcessRequest(obj);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    continue;
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.SetData("DataDirectory", Application.StartupPath);

            AccountDBContext context = new AccountDBContext();

            ObjectMessageQueue queue = new ObjectMessageQueue();
            ObjectMessageQueue.InitializeQueue(ObjectMessageQueue.AUTH_REQUEST);

            contextQueue = new ConcurrentQueue<AccountDBContext>();
            context_lock = new object();
            context_count = 0;
            ThreadPool.SetMaxThreads(25, 0);
            ThreadPool.SetMinThreads(5, 0);

            while (true)
            {
                try
                {
                    Object obj = queue.receiveObject(ObjectMessageQueue.AUTH_REQUEST);
                    GenericRequest gen_req = obj as GenericRequest;
                    gen_req.requester_guid = queue.RequestGuid;
                    gen_req.requester_ip = queue.RequestIP;
                    ThreadPool.QueueUserWorkItem(DoMessage, obj);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                    continue;
                }
            }
        }
 /// <summary>
 /// Constructor used by the web application itself
 /// </summary>
 public DegreeProgramsController()
 {
     messagequeue = new ObjectMessageQueue();
 }
 /// <summary>
 /// Constructor for UnitTesting (allows passing in a fake repository)
 /// </summary>
 public DegreeProgramsController(IGenericRepository<DegreeProgram> fakeDegree, IGenericRepository<RequiredCourse> fakeRequired, IGenericRepository<ElectiveCourse> fakeElecCourse, IGenericRepository<ElectiveList> fakeElecList, IGenericRepository<Course> fakeCourse)
 {
     messagequeue = new ObjectMessageQueue();
 }
Esempio n. 9
0
        private static void DoMessage(Object obj)
        {
            GenericRequest gen_req = obj as GenericRequest;
            ObjectMessageQueue queue = new ObjectMessageQueue();
            queue.RequestGuid = gen_req.requester_guid;
            queue.RequestIP = gen_req.requester_ip;
            if (gen_req == null)
            {
                Console.WriteLine("Error processing request, it is not a request object!");
                queue.sendObject(null, ObjectMessageQueue.DB_RESPONSE);
            }
            else
            {
                Console.WriteLine("Fetching data...");
                Object result = null;
                if (gen_req.Method == MethodType.GetAll && getAll_cache.TryGetValue(gen_req.Type.ToString(), out result))
                {
                    Console.WriteLine("It worked! Found Cached Result!");
                    queue.sendResponse(result, ObjectMessageQueue.DB_RESPONSE);
                }
                else
                {
                    if (gen_req.Method == MethodType.Add || gen_req.Method == MethodType.Delete || gen_req.Method == MethodType.Update)
                    {
                        object n = null;
                        getAll_cache.TryRemove(gen_req.Type.ToString(), out n);
                    }
                    CourseDBContext context = null;
                    if (contextQueue.TryDequeue(out context) == false)
                    {
                        //Check if we are under the max count of contexts allowed
                        bool createNew = false;
                        lock (context_lock)
                        {
                            if (context_count < 25)
                            {
                                context_count++;
                                createNew = true;
                            }
                        }
                        //If we are allowed, create a context for ourself and the pool.
                        if (createNew)
                        {
                            context = new CourseDBContext();
                        }
                        else //Else, wait for a context to be available
                        {
                            while (contextQueue.TryDequeue(out context) == false)
                            {
                                Thread.Sleep(5);
                            }
                        }
                    }

                    MessageProcessor parser = new MessageProcessor(context, gen_req);
                    try
                    {
                        //Object result = typeof(MessageProcessor).GetMethod(gen_req.Method.ToString()).Invoke(parser, null);
                        result = typeof(MessageProcessor).GetMethod(gen_req.Method.ToString()).Invoke(parser, null);
                        Console.WriteLine("It worked!");
                        if (gen_req.Method == MethodType.GetAll)
                            getAll_cache.TryAdd(gen_req.Type.ToString(), result);
                        queue.sendResponse(result, ObjectMessageQueue.DB_RESPONSE);
                    }
                    catch (SqlException)
                    {
                        Console.WriteLine("An error occurred.");
                    }
                    contextQueue.Enqueue(context);
                }
            }
        }
 /// <summary>
 /// Constructor for UnitTesting (allows passing in a fake repository)
 /// </summary>
 /// <param name="fake">A "faked" course repository</param>
 public CoursesController(IGenericRepository<Course> fake, IGenericRepository<PrerequisiteCourse> fakePrereq)
 {
     messagequeue = new ObjectMessageQueue();
 }
 /// <summary>
 /// Constructor used by the web application itself
 /// </summary>
 public CoursesController()
 {
     CourseDBContext context = new CourseDBContext();
     context.Configuration.ProxyCreationEnabled = false;
     messagequeue = new ObjectMessageQueue();
 }
 /// <summary>
 /// Constructor for UnitTesting (allows passing in a fake repository)
 /// </summary>
 public ElectiveListsController(IGenericRepository<ElectiveList> fakeElecList, IGenericRepository<Course> fakeCourse, IGenericRepository<ElectiveListCourse> fakeElecListCourse)
 {
     messagequeue = new ObjectMessageQueue();
 }
 /// <summary>
 /// Constructor used by the web application itself
 /// </summary>
 public ElectiveListsController()
 {
     messagequeue = new ObjectMessageQueue();
 }