Пример #1
0
        //private static void SavePositions(List<PositionViewModel> positions)
        //{

        //    ThreadPool.QueueUserWorkItem(delegate(object r)
        //    {

        //        lock (PositionSaveLock)
        //        {

        //            string fileName = "positions.xml";

        //            XmlSerializer serializer = new XmlSerializer(typeof(List<PositionViewModel>));

        //            FileInfo info = new FileInfo(fileName);

        //            if (!File.Exists(fileName))
        //            {

        //                StreamWriter writer = info.CreateText();

        //                serializer.Serialize(writer, positions);

        //                writer.Close();

        //            }

        //            else
        //            {

        //                info.Delete();

        //                StreamWriter writer2 = info.CreateText();

        //                serializer.Serialize(writer2, positions);

        //                writer2.Close();

        //            }

        //        }

        //    });

        //}



        private static void SendMessageReceipt(MessageViewModel message, bool updateList = true)
        {
            var client = new ServiceClient();

            try
            {
                client.MessageRead(message.ID);
            }

            catch (TimeoutException exception)
            {
                Console.WriteLine("Got {0}", exception.GetType());
                client.Abort();
            }

            catch (CommunicationException exception2)
            {
                Console.WriteLine("Got {0}", exception2.GetType());
                client.Abort();
            }

            if (updateList)
            {
                UnProcessedMessages.Remove(message);
            }
        }
Пример #2
0
        private void ProcessInformationMessage(MessageViewModel message)
        {
            MessageBox.Show(this, message.Text, message.Type, MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);

            ServiceClient client = new ServiceClient();

            try
            {
                client.MessageRead(message.ID);
            }

            catch (TimeoutException exception)
            {
                Console.WriteLine("Got {0}", exception.GetType());

                client.Abort();
            }

            catch (CommunicationException exception2)
            {
                Console.WriteLine("Got {0}", exception2.GetType());

                client.Abort();
            }

            finally
            {
                if (client != null)
                {
                    //  client.Dispose();
                }
            }
        }
Пример #3
0
        private static bool CheckMessage(MessageViewModel message)
        {
            bool flag = false;

            if ((UnProcessedMessages.Where(m => (m.Command == message.Command) && (m.Text == message.Text))).Any())
            {
                SendMessageReceipt(message, false);

                return(false);
            }

            flag = true;

            UnProcessedMessages.Add(message);

            return(flag);
        }
Пример #4
0
        private void ProcessStatusMessage(MessageViewModel message)
        {
            string command = message.Command;

            if (command != null)
            {
                if (!(command == "Make UnAvailable"))
                {
                    if (command == "Make Available")
                    {
                        // Switcher.Switch(CustomerPage.Instance);
                        Charging.Instance.Update(20000); //20000
                        Switcher.Switch(Charging.Instance);

                        goto SendReceipt;
                    }

                    if (command == "Added Theme")
                    {
                        ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);

                        long mosaicIDForStation = client.GetMosaicIDForStationKey(new HardwareKey().Key);

                        //    Positions = client.GetPositionsForMosaic(mosaicIDForStation);

                        //      AdvertPlayer.Instance.LoadPositions(null);

                        goto SendReceipt;
                    }

                    if (command == "Removed Theme")
                    {
                        ServiceClient client2 = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);

                        long mosaicID = client2.GetMosaicIDForStationKey(new HardwareKey().Key);

                        //      Positions = client2.GetPositionsForMosaic(mosaicID);

                        //    AdvertPlayer.Instance.LoadPositions(null);

                        goto SendReceipt;
                    }

                    if (command == "Screenshot")
                    {
                        try
                        {
                            ThreadPool.QueueUserWorkItem(delegate
                            {
                                string filename = string.Concat(new object[]
                                                                { "Screenshot#", new HardwareKey().Key, "#", string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now), ".jpg" });

                                new ScreenCapture().CaptureScreenToFile(filename, ImageFormat.Jpeg);

                                NameValueCollection nvc = new NameValueCollection
                                {
                                    { "StationID", new HardwareKey().Key },
                                    { "btn-submit-photo", "Upload" }
                                };

                                //   WebUpload.HttpUploadFile(Constants.ServerUrl + "/Stations/UploadScreenshot", filename, "file", "image/jpeg", nvc);
                            });
                        }

                        catch (Exception)
                        {
                        }

                        goto SendReceipt;
                    }
                }

                else
                {
                    //    CustomerPage.CurrentRFID = message.Text;
                    Switcher.Switch(Charging.Instance);
                    CustomerPage.Instance.Update(60000); //60000

                    goto SendReceipt;
                }
            }

            MessageBox.Show(this, message.Text, message.Type, MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);

SendReceipt:
            SendMessageReceipt(message, true);
        }
Пример #5
0
    //private static void SavePositions(List<PositionViewModel> positions)
    //{

    //    ThreadPool.QueueUserWorkItem(delegate(object r)
    //    {

    //        lock (PositionSaveLock)
    //        {

    //            string fileName = "positions.xml";

    //            XmlSerializer serializer = new XmlSerializer(typeof(List<PositionViewModel>));

    //            FileInfo info = new FileInfo(fileName);

    //            if (!File.Exists(fileName))
    //            {

    //                StreamWriter writer = info.CreateText();

    //                serializer.Serialize(writer, positions);

    //                writer.Close();

    //            }

    //            else
    //            {

    //                info.Delete();

    //                StreamWriter writer2 = info.CreateText();

    //                serializer.Serialize(writer2, positions);

    //                writer2.Close();

    //            }

    //        }

    //    });

    //}



    private static void SendMessageReceipt(MessageViewModel message, bool updateList = true)
    {

        var client = new ServiceClient();

        try
        {
            client.MessageRead(message.ID);
        }

        catch (TimeoutException exception)
        {
            Console.WriteLine("Got {0}", exception.GetType());
            client.Abort();
        }

        catch (CommunicationException exception2)
        {
            Console.WriteLine("Got {0}", exception2.GetType());
            client.Abort();
        }

        if (updateList)
        {
            UnProcessedMessages.Remove(message);
        }
    }
Пример #6
0
    private void ProcessStatusMessage(MessageViewModel message)
    {

        string command = message.Command;

        if (command != null)
        {

            if (!(command == "Make UnAvailable"))
            {

                if (command == "Make Available")
                {
                   // Switcher.Switch(CustomerPage.Instance);
                    Charging.Instance.Update(20000); //20000
                    Switcher.Switch(Charging.Instance);
                  
                    goto SendReceipt;

                }

                if (command == "Added Theme")
                {

                    ServiceClient client = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);

                    long mosaicIDForStation = client.GetMosaicIDForStationKey(new HardwareKey().Key);

                    //    Positions = client.GetPositionsForMosaic(mosaicIDForStation);

                    //      AdvertPlayer.Instance.LoadPositions(null);

                    goto SendReceipt;

                }

                if (command == "Removed Theme")
                {

                    ServiceClient client2 = new ServiceClient("BasicHttpBinding_IService", Constants.ServerAddress);

                    long mosaicID = client2.GetMosaicIDForStationKey(new HardwareKey().Key);

                    //      Positions = client2.GetPositionsForMosaic(mosaicID);

                    //    AdvertPlayer.Instance.LoadPositions(null);

                    goto SendReceipt;

                }

                if (command == "Screenshot")
                {

                    try
                    {

                        ThreadPool.QueueUserWorkItem(delegate
                        {

                            string filename = string.Concat(new object[]
                            { "Screenshot#", new HardwareKey().Key, "#", string.Format("{0:yyyy-MM-dd_hh-mm-ss-tt}", DateTime.Now), ".jpg"
                            });

                            new ScreenCapture().CaptureScreenToFile(filename, ImageFormat.Jpeg);

                            NameValueCollection nvc = new NameValueCollection
                            {
                                {"StationID", new HardwareKey().Key},
                                {"btn-submit-photo", "Upload"}
                            };

                            //   WebUpload.HttpUploadFile(Constants.ServerUrl + "/Stations/UploadScreenshot", filename, "file", "image/jpeg", nvc);

                        });

                    }

                    catch (Exception)
                    {

                    }

                    goto SendReceipt;

                }

            }

            else
            {

            //    CustomerPage.CurrentRFID = message.Text;
                Switcher.Switch(Charging.Instance);
                CustomerPage.Instance.Update(60000); //60000

                goto SendReceipt;

            }

        }

        MessageBox.Show(this, message.Text, message.Type, MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);

        SendReceipt:
        SendMessageReceipt(message, true);

    }
Пример #7
0
    private void ProcessInformationMessage(MessageViewModel message)
    {

        MessageBox.Show(this, message.Text, message.Type, MessageBoxButton.OKCancel, MessageBoxImage.Exclamation);

        ServiceClient client = new ServiceClient();

        try
        {

            client.MessageRead(message.ID);

        }

        catch (TimeoutException exception)
        {

            Console.WriteLine("Got {0}", exception.GetType());

            client.Abort();

        }

        catch (CommunicationException exception2)
        {

            Console.WriteLine("Got {0}", exception2.GetType());

            client.Abort();

        }

        finally
        {

            if (client != null)
            {

                //  client.Dispose();

            }

        }

    }
Пример #8
0
    private static bool CheckMessage(MessageViewModel message)
    {

        bool flag = false;

        if ((UnProcessedMessages.Where(m => (m.Command == message.Command) && (m.Text == message.Text))).Any())
        {

            SendMessageReceipt(message, false);

            return false;

        }

        flag = true;

        UnProcessedMessages.Add(message);

        return flag;

    }