コード例 #1
0
ファイル: Program.cs プロジェクト: JaFex/IS_Project
        private static void timer_park_information_and_update(object stateInfo)
        {
            mutex.WaitOne();
            Console.WriteLine("######################Update Excel Information###########################");
            foreach (LocationExcel locationExcel in locationCampus)
            {
                locationExcel.updateIfNeedUpdate();
            }
            Console.WriteLine("####################END-Update Excel Information#########################");

            Console.WriteLine("######################Park Information###########################");
            //List<Provider> providersLocal = (List<Provider>)stateInfo;
            XmlDocument    doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);
            XmlElement listNote = doc.CreateElement("list");

            foreach (Provider provider in providers)
            {
                ParkingInformation parkingInformation = new ParkingInformation(provider.parkInfoID, provider.parkInfoDescription, provider.parkInfoNumberOfSpots, provider.parkInfoNumberOfSpecialSpots, provider.parkInfoOperatingHours);
                listNote.AppendChild(parkingInformation.ToXML(doc));
            }

            doc.AppendChild(listNote);

            Console.WriteLine(FunctionHelper.formatXmlToUnminifierString(doc));

            Console.WriteLine("Sending information...");
            Mosquitto.publishMosquitto(mClient, new string[] { "ParkDACE\\" }, doc.OuterXml);
            Console.WriteLine("######################END-Park Information#####################\n\n");
            mutex.ReleaseMutex();
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: JaFex/IS_Project
        private static void timer_SOAP(object stateInfo)
        {
            mutex.WaitOne();
            Console.WriteLine("#######################SOAP########################");
            Provider       provider = (Provider)stateInfo;
            Random         random   = new Random();
            XmlDocument    doc      = new XmlDocument();
            XmlDeclaration dec      = doc.CreateXmlDeclaration("1.0", null, null);

            doc.AppendChild(dec);

            Location location = null;

            foreach (LocationExcel le in locationCampus)
            {
                if (le.parkingID.Equals(provider.parkInfoID))
                {
                    location = le.giveLocation(random.Next(0, provider.parkInfoNumberOfSpots));
                }
            }
            if (location == null)
            {
                Console.WriteLine("Erro try to get spot location from " + provider.parkInfoGeoLocationFile);
                Console.WriteLine("######################END-SOAP#####################\n\n");
                return;
            }
            string xmlString = "";

            try
            {
                xmlString = dynamicWebServiceCall(provider.endpoint, "GetSensorDataString", location.name).ToString();
            } catch (Exception e)
            {
                Console.WriteLine("Fail to comunicate wich " + provider.endpoint);
                Console.WriteLine("######################END-SOAP#####################\n\n");
                return;
            }
            doc.LoadXml(xmlString);
            XmlNode locationNode = doc.SelectSingleNode("//location");

            locationNode.InnerXml = location.ToXML(doc).InnerXml;

            Console.WriteLine(FunctionHelper.formatXmlToUnminifierString(doc));

            Console.WriteLine("Sending information...");
            Mosquitto.publishMosquitto(mClient, new string[] { "ParkDACE\\all", "ParkDACE\\" + provider.parkInfoID }, doc.OuterXml);
            Console.WriteLine("######################END-SOAP#####################\n\n");
            mutex.ReleaseMutex();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: JaFex/IS_Project
        public static void ComputeResponse(string str)
        {
            mutex.WaitOne();
            Console.WriteLine("########################DLL########################");
            string[] strs = str.Split(';');
            //string[] ids = { "ParkID", "SpotID", "Timestamp", "ParkingSpotStatus", "BatteryStatus" };

            XmlDocument doc       = new XmlDocument();
            string      xmlString = CreateXMLSpot(strs[0], strs[1], strs[3], strs[2], strs[4]);

            doc.LoadXml(xmlString);

            Console.WriteLine(FunctionHelper.formatXmlToUnminifierString(doc));
            Console.WriteLine("Sending information...");
            Mosquitto.publishMosquitto(mClient, new string[] { "ParkDACE\\all", "ParkDACE\\" + strs[0] }, doc.OuterXml);
            Console.WriteLine("######################END-DLL######################\n\n");
            mutex.ReleaseMutex();
        }