Example #1
0
        private List <VetFarmTree> GetSpeciesForFarmTree(EditableList <VetFarmTree> farmTree)
        {
            IEnumerable <VetFarmTree> species = farmTree.Where(x => x.idfsPartyType == (long)PartyTypeEnum.Species);

            foreach (var item in species)
            {
                VetFarmTree parent = farmTree.Where(x => x.idfParty == item.idfParentParty).FirstOrDefault();
                item.strHerdName = parent.strHerdName;
            }
            return(species.OrderBy(x => x.strHerdName).ToList());
        }
Example #2
0
        public ActionResult RemoveSpecies(long rootKey, long speciesId)
        {
            var         vetCase = (VetCase)ModelStorage.Get(Session.SessionID, rootKey, null);
            VetFarmTree item    = vetCase.Farm.FarmTree.Where(x => x.idfParty == speciesId).SingleOrDefault();

            if (item != null)
            {
                vetCase.Farm.FarmTree.Remove(item);
            }
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = null
            });
        }
Example #3
0
        public ActionResult SpeciesDetails(long rootKey, string name, long?idfSpecies)
        {
            VetCase.Accessor vetCaseAccessor = VetCase.Accessor.Instance(null);
            ViewBag.CanUpdate = vetCaseAccessor.CanUpdate;
            ViewBag.RootKey   = rootKey;
            ViewBag.Name      = name;
            bool isNew = !idfSpecies.HasValue || idfSpecies.Value <= 0;

            ViewBag.IsNewSpecies = isNew;
            VetFarmTree           species      = VetFarmTreeProcessor.GetSpecies(Session.SessionID, rootKey, name, idfSpecies, HACode.Livestock);
            Int64                 selectedHerd = isNew ? 0 : species.idfParentParty.Value;
            List <SelectListItem> herds        = VetFarmTreeProcessor.GetHerdsOfCase(Session.SessionID, rootKey, selectedHerd).ToList();

            ViewBag.HerdsList = herds;
            return(View(species));
        }
Example #4
0
        public void FarmPanelCollection()
        {
            EidssUserContext.Init();
            DbManagerFactory.SetSqlFactory(Config.GetSetting("EidssConnectionString"));
            using (var context = ModelUserContext.Instance as EidssUserContext)
            {
                var target = new EidssSecurityManager();

                int result = target.LogIn(Organizaton, Admin, AdminPassword);
                Assert.AreEqual(0, result);

                using (var manager = DbManagerFactory.Factory.Create(context))
                {
                    var acc     = VetCase.Accessor.Instance(null);
                    var vetcase = (VetCase)acc.CreateNew(manager, null, (int)HACode.Livestock);

                    var panel = vetcase.Farm;

                    var         herdaccessor = VetFarmTree.Accessor.Instance(null);
                    VetFarmTree farm         = panel.FarmTree[0];
                    VetFarmTree herd         = herdaccessor.CreateHerd(manager, panel, farm);
                    VetFarmTree spec         = herdaccessor.CreateSpecies(manager, panel, herd);
                    spec.SpeciesType = spec.SpeciesTypeLookup.FirstOrDefault(c => c.idfsBaseReference == 837790000000);
                    //spec.idfsSpeciesTypeReference = 837790000000;
                    panel.FarmTree.Add(herd);
                    panel.FarmTree.Add(spec);

                    panel.Address.Region     = panel.Address.RegionLookup.FirstOrDefault();
                    panel.Address.Rayon      = panel.Address.RayonLookup.FirstOrDefault();
                    panel.Address.Settlement = panel.Address.SettlementLookup.FirstOrDefault();

                    var animal = (AnimalListItem)AnimalListItem.Accessor.Instance(null).CreateNew(manager, vetcase, (int)HACode.Livestock);
                    animal.idfSpecies = spec.idfParty;
                    animal.idfHerd    = herd.idfParty;
                    animal.idfCase    = vetcase.idfCase;

                    vetcase.AnimalList.Add(animal);
                    //vetcase.Validation += new ValidationEvent(panel_Validation);


                    //acc.Post(manager, vetcase);
                    //vetcase.Validation -= panel_Validation;
                }
            }
        }
Example #5
0
        public ActionResult ClinicalSigns(long rootKey, string name, long idfSpecies)
        {
            VetCase.Accessor vetCaseAccessor = VetCase.Accessor.Instance(null);
            ViewBag.CanUpdate = vetCaseAccessor.CanUpdate;

            ViewBag.RootKey    = rootKey;
            ViewBag.Name       = name;
            ViewBag.IdfSpecies = idfSpecies;

            var vetCase = (VetCase)ModelStorage.Get(Session.SessionID, rootKey, null);
            EditableList <VetFarmTree> farmTree = ModelStorage.Get(Session.SessionID, rootKey, m_FarmTreeSessionKey) as EditableList <VetFarmTree>;

            if (farmTree == null && vetCase.Farm.FarmTree != null)
            {
                ModelStorage.Put(Session.SessionID, rootKey, rootKey, m_FarmTreeSessionKey, vetCase.Farm.FarmTree);
            }

            ViewBag.ReturnMethodName = vetCase._HACode == (int)HACode.Livestock ? "HerdDetails" : "FlockDetails";

            VetFarmTree species = VetFarmTreeProcessor.GetSpecies(Session.SessionID, rootKey, name, idfSpecies, HACode.Livestock);

            ViewBag.SpeciesName = species.SpeciesType.name;

            if (vetCase._HACode == (int)HACode.Livestock)
            {
                ViewBag.IsHerdDetails = true;
                ViewBag.HerdName      = species.strHerdName;
            }
            else
            {
                ViewBag.IsHerdDetails = false;
                ViewBag.FlockName     = species.strHerdName;
            }

            Session["ReturnUrl"] = Url.Action("ClinicalSigns", "VetCase", new { rootKey = ViewBag.RootKey, name = ViewBag.Name, idfSpecies = ViewBag.IdfSpecies });

            return(View());
        }
Example #6
0
        internal static void Register()
        {
            Mapper.CreateMap <eidss.openapi.contract.Herd, eidss.model.Schema.VetFarmTree>()
            .ConstructUsing(context =>
            {
                var source = context.SourceValue as eidss.openapi.contract.Herd;
                var vc     = context.Parent.Parent.DestinationValue as eidss.model.Schema.VetCase;
                var o      = vc.Farm.FarmTree.SingleOrDefault(i => i.idfParty == source.RecordID);
                if (o == null)
                {
                    if (source.RecordID == 0)
                    {
                        using (var manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
                        {
                            VetFarmTree parent = vc.Farm.FarmTree.SingleOrDefault(i => i.idfsPartyType == (long)PartyTypeEnum.Farm);
                            o = eidss.model.Schema.VetFarmTree.Accessor.Instance(null).CreateHerd(manager, vc, parent);
                        }
                    }
                    else
                    {
                        throw new ObjectNotFoundException(source.RecordID);
                    }
                }
                return(o);
            })
            .ForMember(c => c.idfParty, e => e.MapFrom(m => m.RecordID))
            .ForMember(c => c.idfParentParty, e => e.MapFrom(m => m.FarmRecordID))
            .ForMember(c => c.intDeadAnimalQty, e => e.MapFrom(m => m.NumberOfDeadAnimals))
            .ForMember(c => c.intSickAnimalQty, e => e.MapFrom(m => m.NumberOfSickAnimals))
            .ForMember(c => c.intTotalAnimalQty, e => e.MapFrom(m => m.TotalNumberOfAnimals))


            // ignore
            .ForMember(p => p.idfFarm, e => e.Ignore())
            .ForMember(p => p.idfMonitoringSession, e => e.Ignore())
            .ForMember(p => p.idfsPartyType, e => e.Ignore())
            .ForMember(p => p.strName, e => e.Ignore())
            .ForMember(p => p.idfCase, e => e.Ignore())
            .ForMember(p => p.idfObservation, e => e.Ignore())
            .ForMember(p => p.idfsFormTemplate, e => e.Ignore())
            .ForMember(p => p.strAverageAge, e => e.Ignore())
            .ForMember(p => p.datStartOfSignsDate, e => e.Ignore())
            .ForMember(p => p.strNote, e => e.Ignore())
            .ForMember(p => p.FFPresenterCs, e => e.Ignore())
            .ForMember(p => p.SpeciesType, e => e.Ignore())
            .ForMember(p => p.SpeciesTypeLookup, e => e.Ignore())
            .ForMember(p => p.idfsSpeciesTypeReference, e => e.Ignore())
            .ForMember(p => p.Case, e => e.Ignore())
            .ForMember(p => p.VetFarmTreeList, e => e.Ignore())
            .ForMember(p => p.idfsDiagnosisForCs, e => e.Ignore())
            .ForMember(p => p.strHerdName, e => e.Ignore())
            .ForMember(p => p._HACode, e => e.Ignore())
            .ForMember(p => p.Parent, e => e.Ignore())
            .ForMember(p => p.ReadOnly, e => e.Ignore())
            .ForMember(p => p.NotifyChanges, e => e.Ignore())
            .ForMember(p => p.Environment, e => e.Ignore())
            .ForAllMembers(e => e.Condition(AutoConverter.CheckReadOnly <eidss.model.Schema.VetFarmTree>))
            ;
            Mapper.CreateMap <eidss.model.Schema.VetFarmTree, eidss.openapi.contract.Herd>()
            .ForMember(c => c.RecordID, e => e.MapFrom(m => m.idfParty))
            .ForMember(c => c.FarmRecordID, e => e.MapFrom(m => m.idfParentParty))
            .ForMember(c => c.NumberOfDeadAnimals, e => e.MapFrom(m => m.intDeadAnimalQty))
            .ForMember(c => c.NumberOfSickAnimals, e => e.MapFrom(m => m.intSickAnimalQty))
            .ForMember(c => c.TotalNumberOfAnimals, e => e.MapFrom(m => m.intTotalAnimalQty))
            ;
        }