Example #1
0
            public animalSummeringDataTypeAnimalStock Bind(int sheepKeepingTypeCode)
            {
                var target = new animalSummeringDataTypeAnimalStock
                {
                    animalCategory = AnimalTypeCode.FormatCodeToItemEnum <animalCategoryType>(),
                    creationDate   = LatestChangeDate,
                    localFarmId    = FarmKtidb,
                    localPersonId  = FarmPersonKtidp
                };
                var selfReportedData = new selfReportedSummeringDataType
                {
                    quantity               = Quantity.ToString(),
                    summeringDuration      = SummeringDuration.ToString(),
                    summeringTypeSpecified = sheepKeepingTypeCode != default(int)
                };

                if (sheepKeepingTypeCode != default(int))
                {
                    if (!AnimalTypeIsSheep && sheepKeepingTypeCode.In(1, 2, 3))
                    {
                        Log.Warning("EstiAnimal type {0} Farm {1}: summering type {2} is only available for sheep.", AnimalTypeCode, FarmKtidbAndName, sheepKeepingTypeCode);
                        sheepKeepingTypeCode = 0;
                    }
                    selfReportedData.summeringType = sheepKeepingTypeCode.FormatCodeToItemEnum <summeringTypeType>(codeFormat: "0");
                }

                target.Items = new List <object>(new[] { selfReportedData });
                return(target);
            }
Example #2
0
            public animalDataTypeAnimalStock Bind()
            {
                var target = new animalDataTypeAnimalStock
                {
                    animalCategory = AnimalTypeCode.FormatCodeToItemEnum <animalCategoryType>(),
                    surveyFarmId   = FarmKtidb,
                    creationDate   = LatestChangeDate,
                };
                var atdData = new atdDataType
                {
                    atdDataOriginal = new atdDataOriginalType
                    {
                        durationSumTotal   = DoDurationSumTotal.ToString(),
                        livestockUnitTotal = DoLiveStockUnitTotal,
                        quantityTotal      = DoQuantityTotal,
                        surveyFarmDetails  = new atdDataOriginalTypeSurveyFarmDetails
                        {
                            declarationDayQuantity = DoDeclarationDayQuantity.ToString(),
                            durationSum            = DoDurationSum.ToString(),
                            livestockUnit          = DoLiveStockUnit
                        },
                        summeringInlandDetails = new atdDataOriginalTypeSummeringInlandDetails
                        {
                            durationSum         = DoSiDurationSum.ToString(),
                            livestockUnit       = DoSiLiveStockUnit,
                            normedLivestockUnit = DoSiNormedLiveStockUnit
                        },
                        summeringAbroadDetails = new atdDataOriginalTypeSummeringAbroadDetails
                        {
                            durationSum   = DoSaDurationSum.ToString(),
                            livestockUnit = DoSaLiveStockUnit
                        }
                    },
                    atdDataFinal = new atdDataFinalType
                    {
                        livestockUnitTotal = FtLiveStockUnitTotal,
                        quantityTotal      = FtQuantityTotal,
                        surveyFarmDetails  = new atdDataFinalTypeSurveyFarmDetails
                        {
                            declarationDayQuantity = FtDeclarationDayQuantity.ToString(),
                            quantity      = FtQuantity,
                            livestockUnit = FtLiveStockUnit
                        },
                        summeringInlandDetails = new atdDataFinalTypeSummeringInlandDetails
                        {
                            livestockUnit       = FtSiLiveStockUnit,
                            normedLivestockUnit = FtSiNormedLiveStockUnit
                        },
                        summeringAbroadDetails = new atdDataFinalTypeSummeringAbroadDetails
                        {
                            livestockUnit = FtSaLiveStockUnit
                        }
                    }
                };

                target.Items = new List <object>(new[] { atdData });
                return(target);
            }
Example #3
0
            public animalDataTypeAnimalStock Bind()
            {
                if (AverageQuantity == 0 &&
                    DeclarationDayQuantity == 0 &&
                    SummeringPreviousYearDuration == 0 &&
                    SummeringPreviousYearQuantity == 0)
                {
                    return(null);
                }

                var target = new animalDataTypeAnimalStock
                {
                    animalCategory = AnimalTypeCode.FormatCodeToItemEnum <animalCategoryType>(),
                    surveyFarmId   = FarmKtidb,
                    creationDate   = LatestChangeDate,
                };
                var selfReportedData = new selfReportedDataType
                {
                    averageQuantity        = AverageQuantity.ToString(),
                    declarationDayQuantity = DeclarationDayQuantity.ToString(),
                    keepingTypeSpecified   = AnimalTypeNeedsStablingMethod,
                    summeringDuration      = SummeringPreviousYearDuration.ToString(),
                    summeringQuantity      = SummeringPreviousYearQuantity.ToString(),
                };

                if (selfReportedData.keepingTypeSpecified)
                {
                    if ((AnimalTypeNeedsPigsStablingMethod && PigsStablingMethodCode == default(int)) ||
                        (AnimalTypeNeedsPoultryStablingMethod && PoultryStablingMethodCode == default(int)))
                    {
                        Log.Warning("Farm {0} needs {1} keeping type but has none", FarmKtidb,
                                    AnimalTypeNeedsPigsStablingMethod ? "pigs" :
                                    AnimalTypeNeedsPoultryStablingMethod ? "poultry" :
                                    "no"
                                    );
                    }

                    var keepingCode = AnimalTypeNeedsPigsStablingMethod ? PigsStablingMethodCode : PoultryStablingMethodCode;

                    selfReportedData.keepingType = keepingCode.FormatCodeToItemEnum(animalKeepingType.Item0, "0");
                }
                target.Items = new List <object>(new[] { selfReportedData });
                return(target);
            }