예제 #1
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool CaptureScreenShot(long stationID)
    {
        try
        {
            var container = new eAdDataContainer();

            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;
    }
예제 #2
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool SendMessageToGroup(long groupID, MessageViewModel message)
    {
        try
        {
            var container = new eAdDataContainer();

            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;
    }
예제 #3
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public List<MessageViewModel> GetAllMyMessages(long clientID)
    {
        var container = new eAdDataContainer();

        return (from c in
                (from s in container.Messages
                 where (s.StationID == clientID) && !s.Sent
                 select s).ToList<Message>()
                select c.CreateModel()).ToList<MessageViewModel>();
    }
예제 #4
0
파일: Service.cs 프로젝트: afrog33k/eAd
        public ScheduleModel Schedule(string serverKey, string hardwareKey, string version)
        {
            var container = new eAdDataContainer();
            Mosaic mosaic = null;
            Mosaic profilemosaic = null;
            if ((from s in container.Stations
                 where s.HardwareKey == hardwareKey
                 select s).FirstOrDefault<Station>() != 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 = container.Mosaics.Where(m => m.Type == "General").FirstOrDefault();
            }

            if (profilemosaic == null)
            {
                profilemosaic = container.Mosaics.Where(m => m.Type == "Profile").FirstOrDefault();
            }
            var schedule = new ScheduleModel()
            {
                Items = new List<ScheduleLayout>()
            {
                new ScheduleLayout()
                {
                    File = mosaic.MosaicID.ToString(),
                    FromDate = "2000-01-01 00:00:00",
                    ToDate = "2030-01-19 00:00:00",
                    ScheduleId = 0,
                    Priority = 0,
                    Default = true,
                    Type =mosaic.Type,
                    Hash = mosaic.Hash
                },
                 new ScheduleLayout()
                {
                    File = profilemosaic.MosaicID.ToString(),
                    FromDate = "2000-01-01 00:00:00",
                    ToDate = "2030-01-19 00:00:00",
                    ScheduleId = 0,
                    Priority = 0,
                    Default = true,
                    Type =profilemosaic.Type,
                    Hash = profilemosaic.Hash
                }
            }
            };


            return schedule;

        }
예제 #5
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
        public List <StationViewModel> GetAllStations()
        {
            var container = new eAdDataContainer();

            return((from c in container.Stations.ToList() select c.CreateModel()).ToList <StationViewModel>());
        }
예제 #6
0
파일: Service.cs 프로젝트: afrog33k/eAd
        public FilesModel RequiredFiles(string serverKey, string hardwareKey, string version)
        {
            lock (RequiredFilesLock)
            {
                // Get Mosaic For station
                var container = new eAdDataContainer();

                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
                });
                return(files);
            }
        }
예제 #7
0
파일: Service.cs 프로젝트: afrog33k/eAd
        private static FilesModel CreateFileModel(List <Mosaic> mosaics)
        {
            FilesModel files = new FilesModel();

            var list = new List <RequiredFileModel>();

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



            foreach (var mosaic in mosaics)
            {
                var mosaicCache = AppPath + "Layouts\\" + mosaic.MosaicID + ".mosaic";
                var allMedia    = mosaic.Positions.SelectMany(p => p.Media);

                foreach (var medium in allMedia)
                {
                    if (list.Where(l => l.Id == medium.MediaID).Count() <= 0)
                    {
                        bool shouldCalculatenewHash = false;

                        if (medium.Hash == null || medium.Size == 0)
                        {
                            shouldCalculatenewHash = true;
                        }

                        // Calculate new hash/size
                        if (shouldCalculatenewHash)
                        {
                            try
                            {
                                using (
                                    var fs =
                                        new FileStream(
                                            System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + ServerPath +
                                            medium.Location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                                {
                                    medium.Hash = Hashes.MD5(fs);
                                    medium.Size =
                                        new FileInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +
                                                     ServerPath + medium.Location).Length;
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }

                        list.Add(new RequiredFileModel()
                        {
                            FileType = "media",
                            Path     = medium.Location,
                            Id       = medium.MediaID,
                            Size     = (long)medium.Size,
                            MD5      = medium.Hash
                        });
                    }
                }

                if (!String.IsNullOrEmpty(mosaic.Background))
                {
                    if (list.Where(l => l.Path == mosaic.Background).Count() <= 0)
                    // Add Background to list if not already there
                    {
                        var allmedia = (from s in container.Media
                                        where s.Location == mosaic.Background
                                        select s).FirstOrDefault();

                        if (allmedia != null)
                        {
                            list.Add(new RequiredFileModel
                            {
                                FileType = "media",
                                Path     = mosaic.Background,
                                Id       = mosaic.MosaicID,
                                Size     = allmedia.Size,
                                //    (long)
                                //    new FileInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +
                                //               ServerPath + mosaic.Background).Length,
                                MD5 = allmedia.Hash
                                      //    Hashes.MD5(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +
                                      //    ServerPath + mosaic.Background)
                            });
                        }
                    }
                }

                list.Add(new RequiredFileModel
                {
                    FileType = "layout",
                    Path     = "Layouts\\" + Path.GetFileName(mosaicCache),
                    Id       = mosaic.MosaicID,
                    Size     = (long)mosaic.Size,
                    MD5      = mosaic.Hash
                });
            }

            files.Items = new List <RequiredFileModel>(list.ToArray());
            return(files);
        }
예제 #8
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool DoIHaveUpdates(long stationID)
    {
        var container = new eAdDataContainer();

        return ((from s in container.Messages
                 where (s.StationID == stationID) && !s.Sent
                 select s).Count<Message>() > 0);
    }
예제 #9
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public long GetMosaicIDForStationKey(string hardwareKey)
    {
        // Get Mosaic For station
        var container = new eAdDataContainer();

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

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

            if (grouping != null)
            {
                return grouping.MosaicID;
            }
        }

        return (from m in container.Mosaics
                where m.Name.Contains("as")
                select m).FirstOrDefault<Mosaic>().MosaicID;

    }
예제 #10
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public long GetMosaicIDForStation(long stationID)
    {
        var container = new eAdDataContainer();

        if ((from s in container.Stations
                where s.StationID == stationID
                select s).FirstOrDefault<Station>() != null)
        {
            var grouping = (from m in container.Groupings
                            where m.Mosaic != null
                            select m).FirstOrDefault<Grouping>();

            if (grouping != null)
            {
                return grouping.MosaicID;
            }
        }

        return (from m in container.Mosaics
                where m.Name.Contains("as")
                select m).FirstOrDefault<Mosaic>().MosaicID;
    }
예제 #11
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public string GetMediaLocation(long mediaID)
    {
        var container = new eAdDataContainer();

        return (from s in container.Media
                where s.MediaID == mediaID
                select s).FirstOrDefault<Medium>().Location;
    }
예제 #12
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public TimeSpan GetMediaDuration(long mediaID)
    {
        var container = new eAdDataContainer();

        return (from s in container.Media
                where s.MediaID == mediaID
                select s).FirstOrDefault<Medium>().Duration.Value;
    }
예제 #13
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public CustomerViewModel GetCustomerByRFID(string tag)
    {
        var container = new eAdDataContainer();

        var car = (from e in container.Cars
                   where e.RFID == tag
                   select e).FirstOrDefault<Car>();

        if (car != null)
        {
            Customer customer = car.Customer;

            if (customer != null)
            {
                return customer.CreateModel();
            }
        }

        return CustomerViewModel.Empty;
    }
예제 #14
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public List<StationViewModel> GetAllStations()
    {
        var container = new eAdDataContainer();

        return (from c in container.Stations.ToList() select c.CreateModel()).ToList<StationViewModel>();
    }
예제 #15
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public List<MessageViewModel> GetAllMyMessagesKey(string hardwareKey)
    {
        var container = new eAdDataContainer();

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

        //Compress up messages

        //TODO:

        return (container.Messages.Where(s => (s.StationID == thisStation.StationID) && !s.Sent)).ToList<Message>().Select(c => c.CreateModel()).ToList();
    }
예제 #16
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool SendMessageToStation(long stationID, MessageViewModel message)
    {
        try
        {
            var container = new eAdDataContainer();

            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;
    }
예제 #17
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public void SetStationStatus(long stationID, string status)
    {
        var container = new eAdDataContainer();

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

        container.SaveChanges();
    }
예제 #18
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public List<MediaListModel> GetMyMedia(long stationID)
    {
        var container = new eAdDataContainer();

        var source = new List<MediaListModel>();

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

        if (station != null)
        {
            EntityCollection<Grouping> groupings = station.Groupings;

            foreach (Grouping grouping in groupings)
            {
                foreach (Theme theme in grouping.Themes)
                {
                    using (IEnumerator<Medium> enumerator3 = theme.Media.GetEnumerator())
                    {
                        Func<MediaListModel, bool> predicate = null;

                        Medium media;

                        while (enumerator3.MoveNext())
                        {
                            media = enumerator3.Current;

                            if (predicate == null)
                            {
                                predicate = l => l.MediaID == media.MediaID;
                            }

                            if (source.Where(predicate).Count<MediaListModel>() <= 0)
                            {
                                var item = new MediaListModel
                                {
                                    MediaID = media.MediaID,
                                    DisplayLocation = media.Location,
                                    Duration = media.Duration.Value
                                };

                                source.Add(item);
                            }
                        }
                    }
                }
            }
        }

        return source;
    }
예제 #19
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool DoIHaveUpdatesKey(string hardwareKey)
    {
        var container = new eAdDataContainer();

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

        return ((from s in container.Messages
                 where (thisStation.StationID == s.StationID) && !s.Sent
                 select s).Count<Message>() > 0);
    }
예제 #20
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public List<PositionViewModel> GetPositionsForMosaic(long mosaicID)
    {
        var container = new eAdDataContainer();

        List<PositionViewModel> list = new List<PositionViewModel>();
        var firstOrDefault = (container.Mosaics.Where(m => m.MosaicID == mosaicID)).FirstOrDefault();
        if (firstOrDefault != null)
            foreach (Position p in firstOrDefault.Positions)
                list.Add(p.CreateModel());
        return list;
    }
예제 #21
0
파일: Service.cs 프로젝트: afrog33k/eAd
        public ScheduleModel Schedule(string serverKey, string hardwareKey, string version)
        {
            var    container     = new eAdDataContainer();
            Mosaic mosaic        = null;
            Mosaic profilemosaic = null;

            if ((from s in container.Stations
                 where s.HardwareKey == hardwareKey
                 select s).FirstOrDefault <Station>() != 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 = container.Mosaics.Where(m => m.Type == "General").FirstOrDefault();
            }

            if (profilemosaic == null)
            {
                profilemosaic = container.Mosaics.Where(m => m.Type == "Profile").FirstOrDefault();
            }
            var schedule = new ScheduleModel()
            {
                Items = new List <ScheduleLayout>()
                {
                    new ScheduleLayout()
                    {
                        File       = mosaic.MosaicID.ToString(),
                        FromDate   = "2000-01-01 00:00:00",
                        ToDate     = "2030-01-19 00:00:00",
                        ScheduleId = 0,
                        Priority   = 0,
                        Default    = true,
                        Type       = mosaic.Type,
                        Hash       = mosaic.Hash
                    },
                    new ScheduleLayout()
                    {
                        File       = profilemosaic.MosaicID.ToString(),
                        FromDate   = "2000-01-01 00:00:00",
                        ToDate     = "2030-01-19 00:00:00",
                        ScheduleId = 0,
                        Priority   = 0,
                        Default    = true,
                        Type       = profilemosaic.Type,
                        Hash       = profilemosaic.Hash
                    }
                }
            };


            return(schedule);
        }
예제 #22
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool MakeStationUnAvailable(long stationID, string rfidCode = "")
    {
        try
        {
            var container = new eAdDataContainer();

            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;
    }
예제 #23
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
        public List <CustomerViewModel> GetAllCustomers()
        {
            var container = new eAdDataContainer();

            return((from c in container.Customers.ToList() select c.CreateModel()).ToList <CustomerViewModel>());
        }
예제 #24
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public bool MessageRead(long messageID)
    {
        var container = new eAdDataContainer();

        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;
    }
예제 #25
0
파일: Service.cs 프로젝트: afrog33k/eAd
        private static FilesModel CreateFileModel(List<Mosaic> mosaics)
        {


            FilesModel files = new FilesModel();

            var list = new List<RequiredFileModel>();

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



            foreach (var mosaic in mosaics)
            {

                var mosaicCache = AppPath + "Layouts\\" + mosaic.MosaicID + ".mosaic";
                var allMedia = mosaic.Positions.SelectMany(p => p.Media);

                foreach (var medium in allMedia)
                {
                    if (list.Where(l => l.Id == medium.MediaID).Count() <= 0)
                    {
                        bool shouldCalculatenewHash = false;

                        if (medium.Hash == null || medium.Size == 0)
                        {
                            shouldCalculatenewHash = true;
                        }

                        // Calculate new hash/size
                        if (shouldCalculatenewHash)
                        {
                            try
                            {


                                using (
                                    var fs =
                                        new FileStream(
                                            System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + ServerPath +
                                            medium.Location, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                                {
                                    medium.Hash = Hashes.MD5(fs);
                                    medium.Size =
                                        new FileInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +
                                                     ServerPath + medium.Location).Length;
                                }
                            }
                            catch (Exception)
                            {


                            }
                        }

                        list.Add(new RequiredFileModel()
                                     {
                                         FileType = "media",
                                         Path = medium.Location,
                                         Id = medium.MediaID,
                                         Size = (long)medium.Size,
                                         MD5 = medium.Hash
                                     });
                    }
                }

                if (!String.IsNullOrEmpty(mosaic.Background))
                    if (list.Where(l => l.Path == mosaic.Background).Count() <= 0)
                    // Add Background to list if not already there
                    {
                        var allmedia = (from s in container.Media
                                        where s.Location == mosaic.Background
                                        select s).FirstOrDefault();

                        if (allmedia != null)
                            list.Add(new RequiredFileModel
                                         {
                                             FileType = "media",
                                             Path = mosaic.Background,
                                             Id = mosaic.MosaicID,
                                             Size = allmedia.Size,
                                             //    (long)
                                             //    new FileInfo(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +
                                             //               ServerPath + mosaic.Background).Length,
                                             MD5 = allmedia.Hash
                                             //    Hashes.MD5(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath +
                                             //    ServerPath + mosaic.Background)
                                         });
                    }

                list.Add(new RequiredFileModel
                             {
                                 FileType = "layout",
                                 Path = "Layouts\\" + Path.GetFileName(mosaicCache),
                                 Id = mosaic.MosaicID,
                                 Size = (long)mosaic.Size,
                                 MD5 = mosaic.Hash
                             });
            }

            files.Items = new List<RequiredFileModel>(list.ToArray());
            return files;

        }
예제 #26
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public string SayHiKey(string hardwareKey)
    {
        var container = new eAdDataContainer();

        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";
    }
예제 #27
0
파일: Service.cs 프로젝트: afrog33k/eAd
        public FilesModel RequiredFiles(string serverKey, string hardwareKey, string version)
        {
            lock (RequiredFilesLock)
            {


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

                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 });
                return files;
            }
        }
예제 #28
0
파일: Service.svc.cs 프로젝트: afrog33k/eAd
    public List<CustomerViewModel> GetAllCustomers()
    {
        var container = new eAdDataContainer();

        return (from c in container.Customers.ToList() select c.CreateModel()).ToList<CustomerViewModel>();
    }