Exemple #1
0
        public bool CheckIsLast(int noteid)
        {
            bool bRet = false;

            using (var repo = DMRepository.Get())
            {
                DeliveryNote note = repo.Get <DeliveryNote>(p => p.noteid == noteid);
                if (note != null)
                {
                    Spec <CustomerEntity> where = new Spec <CustomerEntity>();
                    where.And(p => p.customer == note.customer);
                    where.And(p => p.cyear == note.sdate.Year);
                    CustomerEntity customer = repo.Get <CustomerEntity>(where.Exp);
                    if (customer != null)
                    {
                        if (customer.sequence == note.deliverid)
                        {
                            bRet = true;
                        }
                    }
                }
            }


            return(bRet);
        }
Exemple #2
0
        public String Delete(int noteid, bool isdecrease)
        {
            String         bErr     = "";
            CustomerEntity customer = null;

            if (isdecrease)
            {
                using (var repo = DMRepository.Get())
                {
                    DeliveryNote note = repo.Get <DeliveryNote>(p => p.noteid == noteid);
                    if (note == null)
                    {
                        return("当前送货单不存在");
                    }

                    Spec <CustomerEntity> where = new Spec <CustomerEntity>();
                    where.And(p => p.customer == note.customer);
                    if (note.sdate.Year <= 1)
                    {
                        where.And(p => p.cyear == DateTime.Now.Year);
                    }
                    else
                    {
                        where.And(p => p.cyear == note.sdate.Year);
                    }
                    customer = repo.Get <CustomerEntity>(where.Exp);
                    if (customer == null)
                    {
                        return("系统中没有此客户信息");
                    }

                    if (customer.sequence != note.deliverid)
                    {
                        return("当前送货单已归档,不能删除");
                    }
                    customer.sequence = customer.sequence - 1;
                }
            }

            using (var dmt = DMContext.GetTransaction())
            {
                var trans = dmt.BeginTransaction();
                if (customer != null & isdecrease)
                {
                    DMContext.Update <CustomerEntity>(customer, p => p.cid == customer.cid, null, trans);
                }

                DMContext.Delete <DeliveryItem>(p => p.noteid == noteid, trans);
                DMContext.Delete <DeliveryNote>(p => p.noteid == noteid, trans);
                trans.Commit();
            }

            return(bErr);
        }
Exemple #3
0
        public DeliveryNote Select(int noteId)
        {
            DeliveryNote note;

            using (var repo = DMRepository.Get())
            {
                note       = repo.Get <DeliveryNote>(p => p.noteid == noteId);
                note.items = repo.GetList <DeliveryItem>(50, p => p.noteid == noteId, p => p.itemid.Asc());
            }

            return(note);
        }
        public Collection GetCollectionForProcessing(XmlNode siteData)
        {
            string     siteName   = siteData["Folder"].InnerText;
            CameraSite site       = SiteRepository.Find(s => s.Name == siteName).FirstOrDefault();
            Collection collection = null;

            if (site == null)
            {
                site               = new CameraSite();
                site.Name          = siteData["Folder"].InnerText;
                site.DirectoryName = siteData["Folder"].InnerText;
                site.ContainerID   = Guid.NewGuid().ToString();
                if (siteData["Location"].Attributes["latitude"].Value != String.Empty)
                {
                    site.Latitude  = Convert.ToDouble(siteData["Location"].Attributes["latitude"].Value);
                    site.Longitude = Convert.ToDouble(siteData["Location"].Attributes["longitude"].Value);
                }

                var county = siteData["County"].InnerText;
                var state  = siteData["State"].InnerText;
                site.CountyFips = DMRepository.GetFipsForCountyAndState(county, state);

                collection = new Collection()
                {
                    ContainerID = site.ContainerID,
                    Name        = site.Name,
                    Site        = site,
                    Status      = CollectionStatus.PROCESSING,
                    Type        = CollectionType.SITE
                };

                CollectionRepository.Insert(collection);
                SiteRepository.Insert(site);
            }
            else
            {
                collection        = CollectionRepository.Find(c => c.Site.ID == site.ID).FirstOrDefault();
                collection.Status = CollectionStatus.PROCESSING;
                CollectionRepository.Update(collection);
            }

            return(collection);
        }
        public ICollection <TimeLapseFrame> CreateTimeLapseFramesFromIDs(long[] photoIDs)
        {
            List <TimeLapseFrame> frames = new List <TimeLapseFrame>();
            long firstID = photoIDs[0]; // stupid LINQ

            USCounty county = DMRepository.GetCountyForFips(PhotoRepository.Find(p => p.ID == firstID, p => p.Site)
                                                            .FirstOrDefault().Site.CountyFips);

            var properties = PhotoRepo.GetPhotoProperties(photoIDs, new string[] { "ID", "Captured" });

            foreach (var property in properties)
            {
                var frame = new TimeLapseFrame()
                {
                    FrameTime = (DateTime)property["Captured"], PhotoID = (long)property["ID"]
                };
                frames.Add(frame);
            }

            return(frames);
        }