public void UploadPhoto(SiteMonitoring e, IEnumerable <HttpPostedFileBase> files, string[] noteList, bool?IsReview = null)
        {
            var l = PicasaRepository.I.UploadPhoto2(files, noteList);

            if (l == null)
            {
                return;
            }

            for (int i = 0; i < l.Count; i++)
            {
                var entry = l[i];
                if (entry != null)
                {
                    SiteMonitoringPhoto photo = new SiteMonitoringPhoto();

                    Helper.UpdateIPhoto(files.ElementAt(i), noteList[i], entry, photo);

                    photo.IsReview = IsReview;
                    e.SiteMonitoringPhotoes.Add(photo);

                    Save();

                    string title = string.Format("SMP_{0}_SM_{1}", photo.ID.ToString(), e.ID.ToString());

                    PicasaRepository.I.UpdateTitle(photo.AtomUrl, title);
                }
            }
        }
        public SiteMonitoring Create(Action <SiteMonitoring> updateMethod, IEnumerable <HttpPostedFileBase> files, int?contractDetailID, string[] noteList)
        {
            var contractDetailRepository = new ContractDetailRepository()
            {
                DB = DB
            };

            var contractDetail = contractDetailRepository.Get(contractDetailID.Value);

            SiteMonitoring e = new SiteMonitoring();

            updateMethod(e);

            e.ContractDetail = contractDetail;

            Save();

            PicasaRepository picasaRepository = new PicasaRepository();

            picasaRepository.DB = DB;

            picasaRepository.UploadPhoto(e, files, noteList, false);

            Save();

            return(e);
        }
        public SiteMonitoring GetPrevious(int id)
        {
            var            v   = Get(id);
            SiteMonitoring pre = null;

            if (v != null)
            {
                pre = DB.SiteMonitorings.Where(r => r.ContractDetailID == v.ContractDetailID &&
                                               r.Order == v.Order - 1).FirstOrDefault();
            }

            return(pre);
        }
        public SiteMonitoring Find(ContractDetail contractDetail, DateTime?from, DateTime?to)
        {
            SiteMonitoring sm = null;

            List <SiteMonitoring> lst = contractDetail.SiteMonitorings.Where(
                r =>
                r.ContractDetail.ContractDetailTimelines.Where(rr => rr.Order == r.Order).ToList().Count > 0 && r.ContractDetail.ContractDetailTimelines.Where(rr => rr.Order == r.Order).ToList()[0].IsIn(from, to)
                ).ToList();// OrderByDescending(item => item.Order).First();

            if (lst.Count > 0)
            {
                sm = lst.OrderByDescending(item => item.Order).First();
            }

            return(sm);
        }
        public IEnumerable<SelectListItem> FilterOrder(SiteMonitoring e)
        {
            SiteMonitoringRepository siteMonitoringRepository = new SiteMonitoringRepository();

            var orderList = e.ContractDetail.SiteMonitorings.Select(r => r.Order).Distinct();

            var timelineList = e.ContractDetail.ContractDetailTimelines
                .ToList()
                .Where(r => !orderList.Contains(r.Order) || r.Order == e.Order)
                .Where(r => siteMonitoringRepository.ValidateOrder(e.ID, r.Order))
                .OrderBy(r => r.Order)
                .Select(r => new SelectListItem() { Value = r.Order.ToString(), Text = string.Format("{0}: {1} - {2}", r.Order, String.Format("{0:d}", r.FromDate), String.Format("{0:d}", r.ToDate)) });
            ;

            return timelineList;
        }
Esempio n. 6
0
        public void UploadPhotoToBackupAlbum(SiteMonitoring e, Stream stream)
        {
            PicasaService service = InitPicasaService();

            if (string.IsNullOrEmpty(e.BackupAlbumUrl))
            {
                e.BackupAlbumUrl = CreateAlbum("M" + e.ID.ToString(), true);
            }

            Uri postUri = new Uri(e.BackupAlbumUrl.Replace("entry", "feed"));

            stream.Position = 0;

            PicasaEntry entry = new PhotoEntry();

            entry.MediaSource = new Google.GData.Client.MediaFileSource(stream, "backup", "image/jpeg");

            PicasaEntry createdEntry = service.Insert(postUri, entry);
        }
        public IEnumerable <SelectListItem> FilterOrder(SiteMonitoring e)
        {
            SiteMonitoringRepository siteMonitoringRepository = new SiteMonitoringRepository();

            var orderList = e.ContractDetail.SiteMonitorings.Select(r => r.Order).Distinct();

            var timelineList = e.ContractDetail.ContractDetailTimelines
                               .ToList()
                               .Where(r => !orderList.Contains(r.Order) || r.Order == e.Order)
                               .Where(r => siteMonitoringRepository.ValidateOrder(e.ID, r.Order))
                               .OrderBy(r => r.Order)
                               .Select(r => new SelectListItem()
            {
                Value = r.Order.ToString(), Text = string.Format("{0}: {1} - {2}", r.Order, String.Format("{0:d}", r.FromDate), String.Format("{0:d}", r.ToDate))
            });

            ;

            return(timelineList);
        }
        public SiteMonitoring InitWithDefaultValue(int?ContractDetailID)
        {
            SiteMonitoring e = new SiteMonitoring();

            e.ContractDetailID = ContractDetailID;

            e.Working = true;
            e.Clean   = true;
            e.CreativeGoodConditon = true;
            e.ExternalInterference = false;
            e.Vandalism            = false;
            ContractDetailRepository cdrepo = new ContractDetailRepository();
            ContractDetail           cd     = cdrepo.Get(ContractDetailID.ToInt());

            e.ContractDetail = cd;
            e.NoOfBullbs     = cd.Site.FrontlitNumerOfLamps;
            e.Site           = cd.Site;
            e.ProductID      = cd.ProductID;
            e.Product        = cd.Product;
            return(e);
        }
        public SiteMonitoring Update(int ID, Action <SiteMonitoring> updateMethod, IEnumerable <HttpPostedFileBase> files, List <int> DeletePhotoList, IEnumerable <HttpPostedFileBase> filesOfFixed, string[] noteList, string[] noteOfFixedList)
        {
            SiteMonitoring e = Get(ID);

            updateMethod(e);

            Save();

            PicasaRepository picasaRepository = new PicasaRepository();

            picasaRepository.DB = DB;

            picasaRepository.UploadPhoto(e, files, noteList, false);
            picasaRepository.UploadPhoto(e, filesOfFixed, noteOfFixedList, false, true);

            DeletePhoto(DeletePhotoList);

            Save();

            return(e);
        }
        public List <SiteMonitoring> ReportDetails(int contractID, DateTime?from, DateTime?to)
        {
            SiteMonitoringRepository siteMonitoringRepository = new SiteMonitoringRepository();
            List <SiteMonitoring>    details = new List <SiteMonitoring>();

            var contract = Get(contractID);

            if (contract != null)
            {
                foreach (OAMS.Models.ContractDetail cd in contract.ContractDetails.OrderBy(r => r.Type))
                {
                    SiteMonitoring sm = siteMonitoringRepository.Find(cd, from, to);

                    if (sm != null)
                    {
                        details.Add(sm);
                    }
                }
            }

            return(details);
        }
Esempio n. 11
0
        public SiteMonitoring Create(Action<SiteMonitoring> updateMethod, IEnumerable<HttpPostedFileBase> files, int? contractDetailID, string[] noteList)
        {
            var contractDetailRepository = new ContractDetailRepository() { DB = DB };

            var contractDetail = contractDetailRepository.Get(contractDetailID.Value);

            SiteMonitoring e = new SiteMonitoring();

            updateMethod(e);

            e.ContractDetail = contractDetail;

            Save();

            PicasaRepository picasaRepository = new PicasaRepository();
            picasaRepository.DB = DB;

            picasaRepository.UploadPhoto(e, files, noteList, false);

            Save();

            return e;
        }
Esempio n. 12
0
 /// <summary>
 /// Create a new SiteMonitoring object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static SiteMonitoring CreateSiteMonitoring(global::System.Int32 id)
 {
     SiteMonitoring siteMonitoring = new SiteMonitoring();
     siteMonitoring.ID = id;
     return siteMonitoring;
 }
Esempio n. 13
0
        public SiteMonitoring InitWithDefaultValue(int? ContractDetailID)
        {
            SiteMonitoring e = new SiteMonitoring();
            e.ContractDetailID = ContractDetailID;

            e.Working = true;
            e.Clean = true;
            e.CreativeGoodConditon = true;
            e.ExternalInterference = false;
            e.Vandalism = false;
            ContractDetailRepository cdrepo = new ContractDetailRepository();
            ContractDetail cd = cdrepo.Get(ContractDetailID.ToInt());
            e.ContractDetail = cd;
            e.NoOfBullbs = cd.Site.FrontlitNumerOfLamps;
            e.Site = cd.Site;
            e.ProductID = cd.ProductID;
            e.Product = cd.Product;
            return e;
        }
Esempio n. 14
0
        public void UploadPhotoToBackupAlbum(SiteMonitoring e, Stream stream)
        {
            PicasaService service = InitPicasaService();

            if (string.IsNullOrEmpty(e.BackupAlbumUrl))
            {
                e.BackupAlbumUrl = CreateAlbum("M" + e.ID.ToString(), true);
            }

            Uri postUri = new Uri(e.BackupAlbumUrl.Replace("entry", "feed"));

            stream.Position = 0;

            PicasaEntry entry = new PhotoEntry();
            entry.MediaSource = new Google.GData.Client.MediaFileSource(stream, "backup", "image/jpeg");

            PicasaEntry createdEntry = service.Insert(postUri, entry);
        }
Esempio n. 15
0
        public void UploadPhoto(SiteMonitoring e, IEnumerable<HttpPostedFileBase> files, string[] noteList, bool isCheckDate = true, bool? IsReview = null)
        {
            if (files == null
                || files.Count() == 0
                || files.Where(r => r != null).Count() == 0)
            {
                return;
            }

            PicasaService service = InitPicasaService();

            if (string.IsNullOrEmpty(e.AlbumUrl))
            {
                e.AlbumUrl = CreateAlbum("M" + e.ID.ToString());
            }

            Uri postUri = new Uri(e.AlbumUrl.Replace("entry", "feed"));

            for (int i = 0; i < files.Count(); i++)
            {
                var item = files.ElementAt(i);
                if (item != null)
                {
                    DateTime? takenDate = GetMetadata_TakenDate(item);

                    ContractDetailTimeline timeline = e.ContractDetail.ContractDetailTimelines.Where(r => r.Order == e.Order).FirstOrDefault();
                    if (
                        !isCheckDate ||
                        (timeline != null
                        && takenDate.HasValue
                        && timeline.Contains(takenDate))
                        )
                    {
                        MemoryStream mStream = new MemoryStream();

                        item.InputStream.Position = 0;
                        item.InputStream.CopyTo(mStream);
                        mStream.Position = 0;

                        //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, mStream, "image/jpeg", "");
                        //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, item.InputStream, "image/jpeg", "");
                        //photoUriList.Add(entry.Media.Content.Url);

                        PicasaEntry entry = new PhotoEntry();
                        entry.MediaSource = new Google.GData.Client.MediaFileSource(mStream, Path.GetFileName(item.FileName), "image/jpeg");
                        entry.Title = new AtomTextConstruct(AtomTextConstructElementType.Title, noteList[i]);
                        entry.Summary = new AtomTextConstruct(AtomTextConstructElementType.Summary, noteList[i]);

                        //service.InsertAsync(postUri, entry, new { SiteID = e.ID, AM = asyncManager });
                        PicasaEntry createdEntry = service.Insert(postUri, entry);

                        if (createdEntry != null)
                        {
                            SiteMonitoringPhoto photo = new SiteMonitoringPhoto();

                            photo.Url = createdEntry.Media.Content.Url;
                            photo.AtomUrl = createdEntry.EditUri.Content;
                            photo.TakenDate = takenDate;
                            photo.Note = noteList[i];
                            photo.IsReview = IsReview;

                            e.SiteMonitoringPhotoes.Add(photo);
                        }
                    }
                }
            }
        }
Esempio n. 16
0
 public ActionResult Edit(int id, FormCollection collection, IEnumerable<HttpPostedFileBase> files, List<int> DeletePhotoList, SiteMonitoring siteMonitoring, IEnumerable<HttpPostedFileBase> filesOfFixed, string[] noteList, string[] noteOfFixedList)
 {
     SiteMonitoring e = repo.Update(id, UpdateModel, files, DeletePhotoList, filesOfFixed, noteList, noteOfFixedList);
     return RedirectToAction("Edit", "Contract", new { id = e.ContractDetail.ContractID });
 }
Esempio n. 17
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SiteMonitorings EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSiteMonitorings(SiteMonitoring siteMonitoring)
 {
     base.AddObject("SiteMonitorings", siteMonitoring);
 }
        public Rpt01_Model_SiteMonitoring Report(int contractID, DateTime?from, DateTime?to)
        {
            SiteMonitoringRepository   siteMonitoringRepository = new SiteMonitoringRepository();
            Rpt01_Model_SiteMonitoring rpt = new Rpt01_Model_SiteMonitoring();

            rpt.From    = from;
            rpt.To      = to;
            rpt.Details = new List <Rpt01_Model_SiteMonitoringDetail>();

            var contract = Get(contractID);

            if (contract != null)
            {
                int index = 1;

                foreach (OAMS.Models.ContractDetail cd in contract.ContractDetails.OrderBy(r => r.Type))
                {
                    Rpt01_Model_SiteMonitoringDetail detail = new Rpt01_Model_SiteMonitoringDetail();

                    DateTime?lastDate = null;

                    SiteMonitoring sm = siteMonitoringRepository.Find(cd, from, to);
                    sm = sm ?? new SiteMonitoring();

                    lastDate = sm.SiteMonitoringPhotoes
                               .OrderByDescending(r => r.TakenDate)
                               .Select(r => r.TakenDate)
                               .FirstOrDefault();

                    detail.ID                   = index;
                    detail.SiteCode             = cd.Site.Code;
                    detail.Supplier             = contract.Contractor != null ? contract.ContractorName : cd.Site.ContractorName;
                    detail.Province             = cd.Site.Geo1 != null ? cd.Site.Geo1.FullName : "";
                    detail.District             = cd.Site.Geo2 != null ? cd.Site.Geo2.Name : "";
                    detail.Street               = string.Format("{0} {1} {2}", cd.Site.AddressLine1, cd.Site.AddressLine2, cd.Site.Geo3 == null ? "" : cd.Site.Geo3.Name);
                    detail.Size                 = string.Format("{0}m x {1}m", cd.Width.ToString(), cd.Height.ToString());
                    detail.Product              = sm.Product == null ? "" : sm.Product.Name;
                    detail.Client               = sm.Product == null ? "" : sm.Product.NewClientName;
                    detail.SiteType             = cd.Type;
                    detail.CurrentCreative      = sm.CurrentCreative;
                    detail.SiteFormat           = cd.Format;
                    detail.SiteScore            = cd.Site.Score;
                    detail.LastestPhotoDate     = lastDate;
                    detail.BackFront            = cd.Site.BacklitFormat != null ? "Backlit" : "Frontlit";
                    detail.Working              = sm.Working;
                    detail.NumOfBulbs           = sm.NoOfBullbs;
                    detail.BulbsWorking         = sm.BullsWorking;
                    detail.Issue                = sm.Issues;
                    detail.Clean                = sm.Clean;
                    detail.CreativeGoodConditon = sm.CreativeGoodConditon;
                    detail.ExternalInterference = sm.ExternalInterference;
                    detail.Vandalism            = sm.Vandalism;
                    detail.Comments             = sm.Comments;
                    detail.RequiredFollowUp     = sm.RequiredFollowUp;
                    detail.Action               = sm.Action;
                    detail.DateOfProblem        = sm.DateOfProblem;
                    detail.NowFixed             = sm.NowFixed;

                    index++;
                    if (sm.Working.HasValue && sm.Working.Value)
                    {
                        rpt.TotalWorking++;
                    }
                    if (sm.Issues != null)
                    {
                        rpt.TotalIssues++;
                    }
                    if (sm.Clean.HasValue && sm.Clean.Value)
                    {
                        rpt.TotalClean++;
                    }
                    if (sm.CreativeGoodConditon.HasValue && sm.CreativeGoodConditon.Value)
                    {
                        rpt.TotalCreativeGoodCondition++;
                    }
                    if (sm.ExternalInterference.HasValue && sm.ExternalInterference.Value)
                    {
                        rpt.TotalExternnalInterference++;
                    }
                    if (sm.Vandalism.HasValue && sm.Vandalism.Value)
                    {
                        rpt.TotalVandalism++;
                    }
                    if (sm.RequiredFollowUp.HasValue && sm.RequiredFollowUp.Value)
                    {
                        rpt.TotalRequiredFollowUp++;
                    }
                    if (sm.NowFixed.HasValue && sm.NowFixed.Value)
                    {
                        rpt.TotalNowFixed++;
                    }

                    rpt.Details.Add(detail);
                }
            }

            return(rpt);
        }
Esempio n. 19
0
        public void UploadPhoto(SiteMonitoring e, IEnumerable <HttpPostedFileBase> files, string[] noteList, bool isCheckDate = true, bool?IsReview = null)
        {
            if (files == null ||
                files.Count() == 0 ||
                files.Where(r => r != null).Count() == 0)
            {
                return;
            }

            PicasaService service = InitPicasaService();

            if (string.IsNullOrEmpty(e.AlbumUrl))
            {
                e.AlbumUrl = CreateAlbum("M" + e.ID.ToString());
            }

            Uri postUri = new Uri(e.AlbumUrl.Replace("entry", "feed"));

            for (int i = 0; i < files.Count(); i++)
            {
                var item = files.ElementAt(i);
                if (item != null)
                {
                    DateTime?takenDate = GetMetadata_TakenDate(item);

                    ContractDetailTimeline timeline = e.ContractDetail.ContractDetailTimelines.Where(r => r.Order == e.Order).FirstOrDefault();
                    if (
                        !isCheckDate ||
                        (timeline != null &&
                         takenDate.HasValue &&
                         timeline.Contains(takenDate))
                        )
                    {
                        MemoryStream mStream = new MemoryStream();

                        item.InputStream.Position = 0;
                        item.InputStream.CopyTo(mStream);
                        mStream.Position = 0;

                        //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, mStream, "image/jpeg", "");
                        //PicasaEntry entry = (PicasaEntry)service.Insert(postUri, item.InputStream, "image/jpeg", "");
                        //photoUriList.Add(entry.Media.Content.Url);


                        PicasaEntry entry = new PhotoEntry();
                        entry.MediaSource = new Google.GData.Client.MediaFileSource(mStream, Path.GetFileName(item.FileName), "image/jpeg");
                        entry.Title       = new AtomTextConstruct(AtomTextConstructElementType.Title, noteList[i]);
                        entry.Summary     = new AtomTextConstruct(AtomTextConstructElementType.Summary, noteList[i]);

                        //service.InsertAsync(postUri, entry, new { SiteID = e.ID, AM = asyncManager });
                        PicasaEntry createdEntry = service.Insert(postUri, entry);

                        if (createdEntry != null)
                        {
                            SiteMonitoringPhoto photo = new SiteMonitoringPhoto();

                            photo.Url       = createdEntry.Media.Content.Url;
                            photo.AtomUrl   = createdEntry.EditUri.Content;
                            photo.TakenDate = takenDate;
                            photo.Note      = noteList[i];
                            photo.IsReview  = IsReview;

                            e.SiteMonitoringPhotoes.Add(photo);
                        }
                    }
                }
            }
        }