public void OverwriteTimelineForDetail(int ID)
        {
            var r = Get(ID);

            if (r != null &&
                r.ContractTimelines.Count > 0)
            {
                foreach (var item in r.ContractDetails)
                {
                    var detailList = item.ContractDetailTimelines.ToList();

                    foreach (var tl in detailList)
                    {
                        DB.DeleteObject(tl);
                    }

                    foreach (var tl in r.ContractTimelines)
                    {
                        ContractDetailTimeline contractDetailTimeline = new ContractDetailTimeline();
                        contractDetailTimeline.FromDate = tl.FromDate;
                        contractDetailTimeline.ToDate   = tl.ToDate;
                        contractDetailTimeline.Order    = tl.Order;

                        item.ContractDetailTimelines.Add(contractDetailTimeline);
                    }
                }
                DB.SaveChanges();
            }
        }
        public ContractDetailTimeline Update(ContractDetailTimeline e)
        {
            //var r = Get(e.ID);
            //if (r != null)
            //{
            //    r.FromDate = e.FromDate;
            //    r.ToDate = e.ToDate;

            //    if (ValidConflictTimeline(r))
            //    {
            //        Save();
            //        e = r;
            //    }
            //}
            //return e;

            DB.ContractDetailTimelines.Attach(e);
            if (ValidConflictTimeline(e))
            {
                DB.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified);
                Save();
            }

            return(e);
        }
        public ContractDetailTimeline Update(ContractDetailTimeline e)
        {
            //var r = Get(e.ID);
            //if (r != null)
            //{
            //    r.FromDate = e.FromDate;
            //    r.ToDate = e.ToDate;

            //    if (ValidConflictTimeline(r))
            //    {
            //        Save();
            //        e = r;
            //    }
            //}
            //return e;

            DB.ContractDetailTimelines.Attach(e);
            if (ValidConflictTimeline(e))
            {
                DB.ObjectStateManager.ChangeObjectState(e, System.Data.EntityState.Modified);
                Save();
            }

            return e;
        }
        public bool ValidConflictTimeline(ContractDetailTimeline e)
        {
            bool isValid = true;

            ContractDetailTimeline preTimeline  = Get(e.ContractDetailID, e.Order - 1);
            ContractDetailTimeline nextTimeline = Get(e.ContractDetailID, e.Order + 1);

            if (preTimeline != null)
            {
                if (preTimeline.IsJoin(e))
                {
                    isValid = false;
                }
            }

            if (nextTimeline != null)
            {
                if (nextTimeline.IsJoin(e))
                {
                    isValid = false;
                }
            }

            return(isValid);
        }
Ejemplo n.º 5
0
        public void OverwriteTimelineForDetail(int ID)
        {
            var r = Get(ID);
            if (r != null
                && r.ContractTimelines.Count > 0)
            {
                foreach (var item in r.ContractDetails)
                {
                    var detailList = item.ContractDetailTimelines.ToList();

                    foreach (var tl in detailList)
                    {
                        DB.DeleteObject(tl);
                    }

                    foreach (var tl in r.ContractTimelines)
                    {
                        ContractDetailTimeline contractDetailTimeline = new ContractDetailTimeline();
                        contractDetailTimeline.FromDate = tl.FromDate;
                        contractDetailTimeline.ToDate = tl.ToDate;
                        contractDetailTimeline.Order = tl.Order;

                        item.ContractDetailTimelines.Add(contractDetailTimeline);
                    }
                }
                DB.SaveChanges();
            }
        }
Ejemplo n.º 6
0
        public void CopyTimeline(int id)
        {
            var r = Get(id);

            if (r.ContractDetailTimelines.Count == 0)
            {
                foreach (var item in r.Contract.ContractTimelines)
                {
                    var newItem = new ContractDetailTimeline();
                    newItem.ContractDetailID = id;
                    newItem.Order            = item.Order;
                    newItem.FromDate         = item.FromDate;
                    newItem.ToDate           = item.ToDate;

                    DB.ContractDetailTimelines.AddObject(newItem);
                }

                DB.SaveChanges();
            }
        }
        public ContractDetailTimeline Add(int contractDetailID, int timeCount, string timeUnit)
        {
            timeCount = timeCount < 1 ? 1 : timeCount;
            ContractDetailRepository contractDetailRepo = new ContractDetailRepository()
            {
                DB = DB
            };
            var contractDetail = contractDetailRepo.Get(contractDetailID);

            var lastTimeline = contractDetail.ContractDetailTimelines.OrderByDescending(r => r.Order).FirstOrDefault();

            var newTimeline = new ContractDetailTimeline();

            if (lastTimeline == null)
            {
                newTimeline.Order    = 1;
                newTimeline.FromDate = contractDetail.EffectiveDate.HasValue ? contractDetail.EffectiveDate : DateTime.Now.Date;
            }
            else
            {
                newTimeline.Order    = lastTimeline.Order + 1;
                newTimeline.FromDate = lastTimeline.ToDate.Value.AddDays(1);
            }

            if (timeUnit.ToLower() == "day")
            {
                newTimeline.ToDate = newTimeline.FromDate.Value.AddDays(timeCount).AddDays(-1);
            }
            else if (timeUnit.ToLower() == "month")
            {
                newTimeline.ToDate = newTimeline.FromDate.Value.AddMonths(timeCount).AddDays(-1);
            }

            newTimeline.ContractDetailID = contractDetailID;

            DB.AddToContractDetailTimelines(newTimeline);

            Save();

            return(newTimeline);
        }
        public ContractDetailTimeline Add(int contractDetailID, int timeCount, string timeUnit)
        {
            timeCount = timeCount < 1 ? 1 : timeCount;
            ContractDetailRepository contractDetailRepo = new ContractDetailRepository() { DB = DB };
            var contractDetail = contractDetailRepo.Get(contractDetailID);

            var lastTimeline = contractDetail.ContractDetailTimelines.OrderByDescending(r => r.Order).FirstOrDefault();

            var newTimeline = new ContractDetailTimeline();

            if (lastTimeline == null)
            {
                newTimeline.Order = 1;
                newTimeline.FromDate = contractDetail.EffectiveDate.HasValue ? contractDetail.EffectiveDate : DateTime.Now.Date;
            }
            else
            {
                newTimeline.Order = lastTimeline.Order + 1;
                newTimeline.FromDate = lastTimeline.ToDate.Value.AddDays(1);
            }

            if (timeUnit.ToLower() == "day")
            {
                newTimeline.ToDate = newTimeline.FromDate.Value.AddDays(timeCount).AddDays(-1);
            }
            else if (timeUnit.ToLower() == "month")
            {
                newTimeline.ToDate = newTimeline.FromDate.Value.AddMonths(timeCount).AddDays(-1);
            }

            newTimeline.ContractDetailID = contractDetailID;

            DB.AddToContractDetailTimelines(newTimeline);

            Save();

            return newTimeline;
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Deprecated Method for adding a new object to the ContractDetailTimelines EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToContractDetailTimelines(ContractDetailTimeline contractDetailTimeline)
 {
     base.AddObject("ContractDetailTimelines", contractDetailTimeline);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Create a new ContractDetailTimeline object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 public static ContractDetailTimeline CreateContractDetailTimeline(global::System.Int32 id)
 {
     ContractDetailTimeline contractDetailTimeline = new ContractDetailTimeline();
     contractDetailTimeline.ID = id;
     return contractDetailTimeline;
 }
        public bool ValidConflictTimeline(ContractDetailTimeline e)
        {
            bool isValid = true;

            ContractDetailTimeline preTimeline = Get(e.ContractDetailID, e.Order - 1);
            ContractDetailTimeline nextTimeline = Get(e.ContractDetailID, e.Order + 1);

            if (preTimeline != null)
            {
                if (preTimeline.IsJoin(e))
                    isValid = false;
            }

            if (nextTimeline != null)
            {
                if (nextTimeline.IsJoin(e))
                    isValid = false;
            }

            return isValid;
        }
Ejemplo n.º 12
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);
                        }
                    }
                }
            }
        }