Exemplo n.º 1
0
    public bool CaptureScreenShot(long stationID)
    {
        try
        {
            var container = new eAdEntities();

            var station = (from s in container.Stations
                           where s.StationID == stationID
                           select s).FirstOrDefault<Station>();

            if (station != null)
            {
                station.Available = true;

                var entity = new Message
                {
                    StationID = stationID,
                    Text = "",
                    Command = "Screenshot",
                    Type = "Status",
                    UserID = 1L,
                    DateAdded = DateTime.Now
                };

                container.Messages.AddObject(entity);

                container.SaveChanges();
            }
        }

        catch (Exception)
        {
            return false;
        }

        return true;
    }
Exemplo n.º 2
0
    public void SetStationStatus(long stationID, string status)
    {
        var container = new eAdEntities();

        foreach (Station station in from s in container.Stations
                 where s.StationID == stationID
                 select s)
        {
            station.Status = status;
        }

        container.SaveChanges();
    }
Exemplo n.º 3
0
    public bool SendMessageToStation(long stationID, MessageViewModel message)
    {
        try
        {
            var container = new eAdEntities();

            var station = (from s in container.Stations
                           where s.StationID == stationID
                           select s).FirstOrDefault<Station>();

            if (station != null)
            {
                station.Available = false;

                var entity = new Message
                {
                    StationID = station.StationID,
                    DateAdded = DateTime.Now,
                    Text = message.Text,
                    Command = message.Command,
                    Type = message.Type,
                    UserID = message.UserID
                };

                container.Messages.AddObject(entity);
            }

            container.SaveChanges();
        }

        catch (Exception)
        {
            return false;
        }

        return true;
    }
Exemplo n.º 4
0
    public bool SendMessageToGroup(long groupID, MessageViewModel message)
    {
        try
        {
            var container = new eAdEntities();

            var grouping = (from s in container.Groupings
                            where s.GroupingID == groupID
                            select s).FirstOrDefault<Grouping>();

            if (grouping != null)
            {
                foreach (Station station in grouping.Stations)
                {
                    station.Available = false;

                    var entity = new Message
                    {
                        DateAdded = DateTime.Now,
                        StationID = station.StationID,
                        Text = message.Text,
                        Command = message.Command,
                        Type = message.Type,
                        UserID = message.UserID
                    };

                    container.Messages.AddObject(entity);
                }
            }

            container.SaveChanges();
        }

        catch (Exception)
        {
            return false;
        }

        return true;
    }
Exemplo n.º 5
0
    public string SayHiKey(string hardwareKey)
    {
        var container = new eAdEntities();

        var station = (from s in container.Stations
                       where s.HardwareKey == hardwareKey
                       select s).FirstOrDefault<Station>();

        if (station != null)
        {
            station.Available = false;

            station.LastCheckIn = DateTime.Now;

            container.SaveChanges();

            return "Hi there";
        }

        return "Invalid";
    }
Exemplo n.º 6
0
    public bool MessageRead(long messageID)
    {
        var container = new eAdEntities();

        IQueryable<Message> queryable = from s in container.Messages
                                        where (s.MessageID == messageID) && !s.Sent
                                        select s;

        foreach (Message message in queryable)
        {
            message.Sent = true;

            message.DateReceived = DateTime.Now;
        }

        container.SaveChanges();

        return true;
    }
Exemplo n.º 7
0
    public bool MakeStationUnAvailable(long stationID, string rfidCode = "")
    {
        try
        {
            var container = new eAdEntities();

            var station = (from s in container.Stations
                           where s.StationID == stationID
                           select s).FirstOrDefault<Station>();

            if (station != null)
            {
                station.Available = false;

                var entity = new Message
                {
                    StationID = stationID,
                    Text = rfidCode,
                    Command = "Make UnAvailable",
                    Type = "Status",
                    UserID = 1L,
                    DateAdded = DateTime.Now
                };

                container.Messages.AddObject(entity);

                container.SaveChanges();
            }
        }

        catch (Exception)
        {
            return false;
        }

        return true;
    }
Exemplo n.º 8
0
        public FilesModel RequiredFiles(string serverKey, string hardwareKey, string version)
        {
            lock (RequiredFilesLock)
            {


                // Get Mosaic For station
                var container = new eAdEntities();

                var thisStation = (from s in container.Stations
                                   where s.HardwareKey == hardwareKey
                                   select s).FirstOrDefault<Station>();

                if (thisStation == null)
                {
                    thisStation = new Station();
                    thisStation.HardwareKey = hardwareKey;
                    thisStation.Name = hardwareKey;
                    thisStation.LastCheckIn = DateTime.Now;
                    thisStation.Status = "Registered";
                    container.Stations.AddObject(thisStation);
                    container.SaveChanges();
                }
                else
                {
                    thisStation.LastCheckIn = DateTime.Now;
                    thisStation.Status = "Online";
                    container.SaveChanges();
                }

                Mosaic mosaic = null;
                Mosaic profilemosaic = null;
                if (thisStation != null)
                {
                    var grouping = (from m in container.Groupings
                                    where m.Mosaic != null
                                    select m).FirstOrDefault<Grouping>();

                    if (grouping != null)
                    {
                        mosaic = grouping.Mosaic;
                        profilemosaic = container.Mosaics.Where(mo => mo.MosaicID == grouping.ProfileMosaicID).FirstOrDefault();
                    }
                }

                if (mosaic == null)
                {
                    mosaic = (from m in container.Mosaics
                              where m.Name.Contains("as")
                              select m).FirstOrDefault();
                }

                if (profilemosaic == null)
                {
                    profilemosaic = container.Mosaics.Where(m => m.Type == "Profile").FirstOrDefault();
                }

                var mosaicCache = AppPath + "Layouts\\" + mosaic.MosaicID + ".mosaic";
                var profilemosaicCache = AppPath + "Layouts\\" + profilemosaic.MosaicID + ".mosaic";

                if (File.Exists(mosaicCache))
                {
                    if (new FileInfo(mosaicCache).CreationTime < mosaic.Updated)
                    {
                        UpdateMosaicCache(mosaic, mosaicCache);

                    }


                }
                else
                {
                    UpdateMosaicCache(mosaic, mosaicCache);

                }

                if (File.Exists(profilemosaicCache))
                {
                    if (new FileInfo(profilemosaicCache).CreationTime < mosaic.Updated)
                    {
                        UpdateMosaicCache(profilemosaic, profilemosaicCache);

                    }


                }
                else
                {
                    UpdateMosaicCache(profilemosaic, profilemosaicCache);

                }


                container.SaveChanges();
                var files = CreateFileModel(new List<Mosaic> { mosaic, profilemosaic });
                container.SaveChanges();
                return files;
            }
        }