コード例 #1
0
ファイル: Program.cs プロジェクト: Ricium/Wetu
        static void Main(string[] args)
        {
            //...Set Data Senisitivity
            int Sensitivity = 2;
            int SocialHistoryDays = 1;
            int InteractionSensitivity = 5;
            int InteractionTimeSensitivity = 3;

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Project Wetu: Estrous Behaviour Processor");
            Console.WriteLine("-----------------------------------------------------");

            DateTime Start = DateTime.Now;

            Console.WriteLine("Starting Data Polling @ " + Start.ToString());

            Setup Service = new Setup(Sensitivity, SocialHistoryDays, InteractionSensitivity, InteractionTimeSensitivity);
            Service.WriteLog(LogMessages.START_SERVICE, EventTypes.Information, EventCategories.SERVICE_EVENT);

            List<SocialGroup> SocialGroups = Service.GetSocialGroups();
            List<SocialGroup> SocialGroupsLast = Service.GetSocialGroupsLast();

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Animals showing Estrous Behaviour");
            Console.WriteLine("-----------------------------------------------------");

            List<int> EstrousAnimals = Service.GetEstrousAnimals();
            Console.WriteLine(EstrousAnimals.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " based on Social Groups @ " + DateTime.Now.ToString());

            List<InteractionCount> InteractionCounts = Service.GetInteractionCounts();
            Console.WriteLine(InteractionCounts.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " based on Number of Interactions @ " + DateTime.Now.ToString());

            List<InteractionCount> InteractionTimes = Service.GetInteractionTimes();
            Console.WriteLine(InteractionTimes.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " based on Length of Interactions @ " + DateTime.Now.ToString());

            List<int> MostLikeyEstrous = Service.GetAnimalsShowingEstrousBehaviour();
            Console.WriteLine(MostLikeyEstrous.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " Shows Estrous Activity  @ " + DateTime.Now.ToString());

            Service.WriteLog(MostLikeyEstrous.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " Shows Estrous Activity", EventTypes.Information, EventCategories.DATABASE_EVENT);

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Notifying Users");
            Console.WriteLine("-----------------------------------------------------");

            if(MostLikeyEstrous.Count > 0)
            {
                Console.WriteLine(MostLikeyEstrous.Count.ToString() + " Animal show Estrous Behaviour");

                ManagementService manage;
                foreach(int animal in MostLikeyEstrous)
                {
                    manage = new ManagementService(animal);
                    string Message = manage.ManageAnimal();

                    //...Notify
                    Service.SendNotifications(animal, Message, NotificationTitles.ESTROUS_MESSAGE);
                }

                Service.WriteLog(LogMessages.NOTIFY, EventTypes.Information, EventCategories.NOTIFICATION_EVENT);
            }
            else
            {
                Console.WriteLine("No Animals show Estrous Behaviour");
            }

            DateTime End = DateTime.Now;
            double Dif = (End - Start).TotalSeconds;

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Finish Processing Data @ " + End.ToString());
            Console.WriteLine("Total Processing Time: " + Dif.ToString() + " Seconds");
            Console.WriteLine("-----------------------------------------------------");

            Console.ReadKey();
            Service.WriteLog(LogMessages.STOP_SERVICE, EventTypes.Information, EventCategories.SERVICE_EVENT);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //...Set Data Senisitivity
            int Sensitivity                = 2;
            int SocialHistoryDays          = 1;
            int InteractionSensitivity     = 5;
            int InteractionTimeSensitivity = 3;

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Project Wetu: Estrous Behaviour Processor");
            Console.WriteLine("-----------------------------------------------------");

            DateTime Start = DateTime.Now;

            Console.WriteLine("Starting Data Polling @ " + Start.ToString());

            Setup Service = new Setup(Sensitivity, SocialHistoryDays, InteractionSensitivity, InteractionTimeSensitivity);

            Service.WriteLog(LogMessages.START_SERVICE, EventTypes.Information, EventCategories.SERVICE_EVENT);

            List <SocialGroup> SocialGroups     = Service.GetSocialGroups();
            List <SocialGroup> SocialGroupsLast = Service.GetSocialGroupsLast();

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Animals showing Estrous Behaviour");
            Console.WriteLine("-----------------------------------------------------");

            List <int> EstrousAnimals = Service.GetEstrousAnimals();

            Console.WriteLine(EstrousAnimals.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " based on Social Groups @ " + DateTime.Now.ToString());

            List <InteractionCount> InteractionCounts = Service.GetInteractionCounts();

            Console.WriteLine(InteractionCounts.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " based on Number of Interactions @ " + DateTime.Now.ToString());

            List <InteractionCount> InteractionTimes = Service.GetInteractionTimes();

            Console.WriteLine(InteractionTimes.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " based on Length of Interactions @ " + DateTime.Now.ToString());

            List <int> MostLikeyEstrous = Service.GetAnimalsShowingEstrousBehaviour();

            Console.WriteLine(MostLikeyEstrous.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                              + " Shows Estrous Activity  @ " + DateTime.Now.ToString());

            Service.WriteLog(MostLikeyEstrous.Count.ToString() + " Animals of " + Service.Animals.Count.ToString()
                             + " Shows Estrous Activity", EventTypes.Information, EventCategories.DATABASE_EVENT);

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Notifying Users");
            Console.WriteLine("-----------------------------------------------------");

            if (MostLikeyEstrous.Count > 0)
            {
                Console.WriteLine(MostLikeyEstrous.Count.ToString() + " Animal show Estrous Behaviour");

                ManagementService manage;
                foreach (int animal in MostLikeyEstrous)
                {
                    manage = new ManagementService(animal);
                    string Message = manage.ManageAnimal();

                    //...Notify
                    Service.SendNotifications(animal, Message, NotificationTitles.ESTROUS_MESSAGE);
                }

                Service.WriteLog(LogMessages.NOTIFY, EventTypes.Information, EventCategories.NOTIFICATION_EVENT);
            }
            else
            {
                Console.WriteLine("No Animals show Estrous Behaviour");
            }

            DateTime End = DateTime.Now;
            double   Dif = (End - Start).TotalSeconds;

            Console.WriteLine("-----------------------------------------------------");
            Console.WriteLine("Finish Processing Data @ " + End.ToString());
            Console.WriteLine("Total Processing Time: " + Dif.ToString() + " Seconds");
            Console.WriteLine("-----------------------------------------------------");



            Console.ReadKey();
            Service.WriteLog(LogMessages.STOP_SERVICE, EventTypes.Information, EventCategories.SERVICE_EVENT);
        }