예제 #1
0
        public ActionResult Create(Theme theme)
        {
            if (ModelState.IsValid)
            {
                db.Themes.AddObject(theme);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(theme));
        }
예제 #2
0
        public ActionResult Create(Station station)
        {
            if (ModelState.IsValid)
            {
                db.Stations.AddObject(station);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(station));
        }
예제 #3
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.AddObject(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
예제 #4
0
        public ActionResult Create(Mosaic mosaic)
        {
            if (ModelState.IsValid)
            {
                db.Mosaics.AddObject(mosaic);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(mosaic));
        }
예제 #5
0
        public ActionResult Create(Message message)
        {
            if (ModelState.IsValid)
            {
                db.Messages.AddObject(message);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StationID = new SelectList(db.Stations, "StationID", "Name", message.StationID);
            return(View(message));
        }
예제 #6
0
        public ActionResult Create(Car car)
        {
            if (ModelState.IsValid)
            {
                db.Cars.AddObject(car);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Name", car.CustomerID);
            return(View(car));
        }
예제 #7
0
        public ActionResult Create(Medium medium)
        {
            if (ModelState.IsValid)
            {
                medium.Created = DateTime.Now;
                _db.Media.AddObject(medium);
                _db.SaveChanges();

                UploadedContent upload;



                var location = UploadRepository.GetFileUrl(this.HttpContext, medium.MediaID.ToString(),
                                                           medium.MediaID.ToString(), UploadType.Media, out upload);


                if (upload != null)
                {
                    if (medium.Duration == TimeSpan.Zero)
                    {
                        medium.Duration = new TimeSpan(upload.Duration.Ticks);
                    }
                    else
                    {
                    }
                }

                if (location != null && location[0] != null)
                {
                    medium.Location = location[0];
                    using (var fs = new FileStream(Server.MapPath("~/" + location[0]), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        medium.Hash = Hashes.MD5(fs);
                    }
                    if (location.Length > 1)
                    {
                        medium.ThumbnailUrl = location[1];
                    }
                }


                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(medium));
        }
예제 #8
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();
        }
예제 #9
0
        public ActionResult Create(Grouping grouping)
        {
            if (ModelState.IsValid)
            {
                grouping.MosaicID = 1;
                db.Groupings.AddObject(grouping);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(grouping));
        }
예제 #10
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);
        }
예제 #11
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");
        }
예제 #12
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);
        }
예제 #13
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);
        }
예제 #14
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);
        }
예제 #15
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);
        }
예제 #16
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;
    }
예제 #17
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;
            }
        }
예제 #18
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;
    }
예제 #19
0
        public ActionResult EditPartial(Mosaic mosaic)
        {
            if (ModelState.IsValid)
            {
                if (!String.IsNullOrEmpty(mosaic.Background))
                {
                    var name  = Path.GetFileName(mosaic.Background).Replace("/eAd.Website", "").Replace("Thumb", "");
                    var media = db.Media.Where(m => m.Location.Contains(name)).Single();
                    mosaic.Background = media.Location;
                }
                mosaic.Updated = DateTime.Now;

                var mosaicToSave = db.Mosaics.Where(m => m.MosaicID == mosaic.MosaicID).SingleOrDefault();
                if (mosaicToSave != null)
                {
                    mosaicToSave.Name       = mosaic.Name;
                    mosaicToSave.Background = mosaic.Background;
                    mosaicToSave.Updated    = mosaic.Updated;
                    mosaicToSave.Width      = mosaic.Width;
                    mosaicToSave.Height     = mosaic.Height;
                }


                //   db.Mosaics.Attach(mosaic);
                //   db.ObjectStateManager.ChangeObjectState(mosaic, EntityState.Modified);
                db.SaveChanges();
                return(Json("Successfully Saved Mosaic"));
            }
            return(Json("Please Check your inputs and save again"));
        }
예제 #20
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;
    }
예제 #21
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";
    }
예제 #22
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;
    }
예제 #23
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();
    }
예제 #24
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;
    }
예제 #25
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);
            }
        }
예제 #26
0
        public void DownloadInfo(HttpContextBase httpContext, string xmlUrl, string stationID, bool start = true)
        {
            try
            {
                Station  station;
                Customer customer;
                Car      car;

                StreamReader  reader        = new StreamReader(WebRequest.Create(xmlUrl).GetResponse().GetResponseStream());
                XmlSerializer xSerializer   = new XmlSerializer(typeof(proton));
                proton        greenlotsInfo = (proton)xSerializer.Deserialize(reader);

                if (db.Stations.Where(s => s.UniqueID == stationID).Count() <= 0)
                {
                    station = new Station {
                        UniqueID = stationID
                    };
                    db.Stations.AddObject(station);
                    db.SaveChanges();
                }
                else
                {
                    station = db.Stations.Where(s => s.UniqueID.Trim() == stationID.Trim()).FirstOrDefault();
                }



                string path = httpContext.Server.MapPath("~/Logs/GreenLots/" + "log.txt");



                if (station != null)
                {
                    station.Name       = greenlotsInfo.Location.information[0].name;
                    station.Address    = greenlotsInfo.Location.information[0].address + "\n" + greenlotsInfo.Location.information[0].address1 + "\n" + greenlotsInfo.Location.information[0].address2;
                    station.PostalCode = greenlotsInfo.Location.information[0].postal;
                    try
                    {
                        station.Rate = Convert.ToDouble(greenlotsInfo.Location.information[0].rate);
                    }
                    catch (Exception ex)
                    {
                    }
                }

                var customerInfo = greenlotsInfo.User.information[0];
                if (db.Customers.Where(s => s.Email == customerInfo.email).Count() <= 0)
                {
                    customer       = new Customer();
                    customer.Email = greenlotsInfo.User.information[0].email;
                    db.Customers.AddObject(customer);
                    db.SaveChanges();
                }
                else
                {
                    customer = db.Customers.Where(s => s.Email == customerInfo.email).FirstOrDefault();
                }

                if (customer != null)
                {
                    customer.Picture    = customerInfo.image;
                    customer.Name       = customerInfo.firstname + " " + customerInfo.lastname;
                    customer.Address    = customerInfo.address + " " + customerInfo.address1 + " " + customerInfo.address2;
                    customer.Language   = customerInfo.language;
                    customer.SMSAlert   = customerInfo.sms_alert == "1";
                    customer.EmailAlert = customerInfo.email_alert == "1";
                    customer.Phone      = customerInfo.contact;
                    customer.Balance    = customerInfo.credit_balance;
                }


                var carInfo = greenlotsInfo.Vehicle.information[0];
                var history = greenlotsInfo.History.session[0];
                if (db.Cars.Where(s => s.RFID == carInfo.rfid).Count() <= 0)
                {
                    car      = new Car();
                    car.RFID = carInfo.rfid;
                    if (customer != null)
                    {
                        car.CustomerID = customer.CustomerID;
                    }
                    db.Cars.AddObject(car);
                    db.SaveChanges();
                }
                else
                {
                    car = db.Cars.Where(s => s.RFID == carInfo.rfid).FirstOrDefault();
                }

                if (car != null)
                {
                    car.License = carInfo.license_plate;
                    car.Make    = carInfo.make;
                    car.Model   = carInfo.model;
                    try
                    {
                        car.TotalUsage   = Convert.ToDouble(carInfo.total_usage);
                        car.BatteryCycle = Convert.ToDouble(carInfo.battery_cycle);
                    }
                    catch (Exception ex)
                    {
                    }
                    //Fix up date
                    var datetxt = history.end;
                    try
                    {
                        datetxt = datetxt.Replace("Today", DateTime.Now.Date.ToShortDateString());
                        datetxt = datetxt.Replace("Yesterday", DateTime.Now.Date.ToShortDateString());
                        car.LastRechargeDate = DateTime.Parse(datetxt);
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            DateTime.ParseExact(datetxt, "dd/MM/yyyy HH:mm", null);
                        }
                        catch (Exception ex1)
                        {
                            Logger.WriteLine(path, "\nInvalid Date Format Detected");
                        }
                    }
                }



                Logger.WriteLine(path, "\n--------------- Data Received  ---------------");
                Logger.WriteLine(path, (string)greenlotsInfo.User.information[0].address);
                //   Logger.WriteLine(path, greenlotsInfo.email);
                Logger.WriteLine(path, "\n--------------- Data Received End---------------");

                db.SaveChanges();

                if (start)
                {
                    if (station != null && car != null)
                    {
                        Service.MakeStationUnAvailable(station.StationID, car.RFID);
                    }
                }
                else
                {
                    if (station != null)
                    {
                        Service.MakeStationAvailable(station.StationID);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }