示例#1
0
        public MainWindows()
        {
            DBEngine.ConnectDB();
            DBScheduleEngine.ConnectDB();
            DBQueueEngine.ConnectDB();

            InitializeComponent();
            InitializeInterface();
            InitializeServer();
            InitializeWebService();
            InitializeSetCommand();
            InitializeWS();


            Task TaskPost = Task.Run(async() =>
            {
                while (true)
                {
                    IQueryable <AstroQueueImpl> IAstroQueues = DBQueueEngine.Find(QUEUE_STATUS.WAITINGSERVER, SENDING_STATUS.IDLE);

                    if (IAstroQueues.Count() > 0)
                    {
                        Dictionary <STATIONNAME, List <AstroQueueImpl> > dictionaryGroup = new Dictionary <STATIONNAME, List <AstroQueueImpl> >();

                        List <AstroQueueImpl> astroQueues = IAstroQueues.ToList();

                        foreach (AstroQueueImpl astroQueue in astroQueues)
                        {
                            if (!dictionaryGroup.ContainsKey(astroQueue.Target.StationName))
                            {
                                dictionaryGroup.Add(astroQueue.Target.StationName, new List <AstroQueueImpl>());
                            }

                            dictionaryGroup[astroQueue.Target.StationName].Add(astroQueue);
                        }

                        if (dictionaryGroup.Count() > 0)
                        {
                            foreach (KeyValuePair <STATIONNAME, List <AstroQueueImpl> > groupAstroQueues in dictionaryGroup)
                            {
                                StationHandler StationCommunication = AstroData.GetStationObject(groupAstroQueues.Key);

                                if (StationCommunication != null)
                                {
                                    StationCommunication.SendingNewTarget(groupAstroQueues.Value);
                                }
                            }
                        }
                    }


                    /*
                     * StationHandler StationCommunication = AstroData.GetStationObject(astroQueue.Target.StationName);
                     *
                     * if (StationCommunication != null)
                     * {
                     *  StationCommunication.SendingNewTarget(astroQueue);
                     * }
                     */

                    await Task.Delay(1000);
                }
            });

            /*
             * QueueStatus astroQueues2 = DBQueueEngine.FindLastestStatus(STATIONNAME.ASTROPARK, "5a4db62e30932557d4ba7445");
             * Console.WriteLine(astroQueues2);
             */
        }