Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var fieldTest = new FieldTests();

            fieldTest.TestReadCppObject();

            var inheritTest = new InheritanceTests();

            inheritTest.TestManagedOverride1();
            inheritTest.TestManagedOverride2();

            inheritTest.TestMultipleBases();
            inheritTest.TestMultipleVirtualBases();
            inheritTest.TestNonVirtualCallOnVirtualBaseClass();
            inheritTest.TestRoundtripManagedOverride();
            inheritTest.TestVirtualCall();
            inheritTest.TestVirtualCallOnBaseClass();
            inheritTest.TestVirtualCallOnVirtualBaseClass();

            var marshalingTest = new MarshalingTests();

            marshalingTest.TestByRefReturn();
            marshalingTest.TestClassArg();
            marshalingTest.TestClassArgByval();

            marshalingTest.TestClassArgByvalNull();

            marshalingTest.TestClassArgNull();
            marshalingTest.TestClassReturn();
            marshalingTest.TestPrimitiveReturn();

            var templateTest = new TemplateTests();

            templateTest.TestDoubleTemplate();
            templateTest.TestFloatTemplate();
            templateTest.TestIntTemplate();
            templateTest.TestShortTemplate();

            var tests = new ManglingTests();

            tests.TestCompression();
            tests.TestNamespace();
            tests.TestNamespace2();
            tests.TestNamespace3();
            tests.TestNamespace4();
            tests.TestNamespaced2();
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="needCopyFF"></param>
        /// <param name="needCopySamples"></param>
        /// <param name="needCopyFT"></param>
        /// <returns></returns>
        public Vector CopyVector(DbManagerProxy manager, bool needCopyFF, bool needCopySamples, bool needCopyFT)
        {
            if (needCopyFT)
            {
                needCopySamples = true;
            }

            //создаём новый объект и добавляем туда всё нужное из старого
            var accVector = Accessor.Instance(null);
            var vectorNew = accVector.CreateWithParamsT(manager, Session, Session.GetParamsAction(typeof(Vector)));

            vectorNew.VectorType        = VectorType;
            vectorNew.idfsVectorSubType = idfsVectorSubType;
            vectorNew.CopyLocation(Location);

            //vectorNew.RecalculateLocation();
            vectorNew.intElevation         = intElevation;
            vectorNew.Surrounding          = Surrounding;
            vectorNew.BasisOfRecord        = BasisOfRecord;
            vectorNew.idfHostVector        = idfHostVector;
            vectorNew.CollectedByOffice    = CollectedByOffice;
            vectorNew.idfCollectedByOffice = idfCollectedByOffice;
            vectorNew.strCollectedByOffice = strCollectedByOffice;
            if (vectorNew.CollectedByOffice == null)
            {
                vectorNew.CollectedByOffice =
                    CollectedByOfficeLookup.FirstOrDefault(c => c.idfInstitution == vectorNew.idfCollectedByOffice);
            }
            vectorNew.Collector = Collector;
            vectorNew.strGEOReferenceSources = strGEOReferenceSources;
            vectorNew.CollectionMethod       = CollectionMethod;
            vectorNew.datCollectionDateTime  = datCollectionDateTime;
            vectorNew.DayPeriod = DayPeriod;
            vectorNew.idfsEctoparasitesCollected = idfsEctoparasitesCollected;
            vectorNew.intQuantity           = intQuantity;
            vectorNew.idfsSex               = idfsSex;
            vectorNew.IdentifiedByOffice    = IdentifiedByOffice;
            vectorNew.idfIdentifiedByOffice = idfIdentifiedByOffice;
            vectorNew.strIdentifiedByOffice = strIdentifiedByOffice;
            if (vectorNew.IdentifiedByOffice == null)
            {
                vectorNew.IdentifiedByOffice =
                    IdentifiedByOfficeLookup.FirstOrDefault(c => c.idfInstitution == vectorNew.idfIdentifiedByOffice);
            }

            vectorNew.Identifier            = Identifier;
            vectorNew.IdentificationMethod  = IdentificationMethod;
            vectorNew.datIdentifiedDateTime = datIdentifiedDateTime;

            if (needCopyFF)
            {
                var accessor = ActivityParameter.Accessor.Instance(null);
                vectorNew.FFPresenter.SetProperties(FFPresenter.CurrentTemplate.idfsFormTemplate, Session.idfVectorSurveillanceSession);
                foreach (var ap in FFPresenter.ActivityParameters)
                {
                    if (!ap.idfsParameter.HasValue)
                    {
                        continue;
                    }
                    if (!vectorNew.idfObservation.HasValue)
                    {
                        continue;
                    }
                    var apNew = accessor.Create(manager, null, ap.idfsParameter.Value, vectorNew.idfObservation.Value, vectorNew.FFPresenter.CurrentTemplate.idfsFormTemplate);
                    apNew.varValue     = ap.varValue;
                    apNew.strNameValue = ap.strNameValue;
                    vectorNew.FFPresenter.ActivityParameters.Add(apNew);
                }
                vectorNew.RecalculateVectorSpecificData();
            }

            if (needCopySamples)
            {
                var accSample    = VectorSample.Accessor.Instance(null);
                var accFieldTest = VectorFieldTest.Accessor.Instance(null);

                foreach (var sample in Samples)
                {
                    var sampleNew = accSample.CreateWithParamsT(manager, vectorNew, vectorNew.GetParamsAction(typeof(VectorSample)));
                    sampleNew.VectorType           = sample.VectorType;
                    sampleNew.VectorSubType        = sample.VectorSubType;
                    sampleNew.strVectorSubTypeName = sample.strVectorSubTypeName;
                    //sampleNew.idfParty = sample.idfParty;
                    //это не копируем (баг 8865)
                    //sampleNew.strFieldBarcode = sample.strFieldBarcode;
                    sampleNew.idfsSampleType            = sample.idfsSampleType;
                    sampleNew.datCollectionDateTime     = sample.datCollectionDateTime;
                    sampleNew.FieldCollectedByOffice    = sample.FieldCollectedByOffice;
                    sampleNew.idfFieldCollectedByOffice = sample.idfFieldCollectedByOffice;
                    //sampleNew.strFieldCollectedByOffice = sample.strFieldCollectedByOffice;
                    vectorNew.Samples.Add(sampleNew);

                    //перевешиваем его полевые тесты
                    if (needCopyFT)
                    {
                        var idMaterial = sampleNew.idfMaterial;
                        var fts        = FieldTests.Where(c => c.idfMaterial == sample.idfMaterial).ToList();
                        foreach (var fieldTest in fts)
                        {
                            var fieldTestNew = accFieldTest.CreateWithParamsT(manager, vectorNew, vectorNew.GetParamsAction(typeof(VectorFieldTest)));
                            fieldTestNew.idfMaterial         = idMaterial; //подвешен к новому семплу
                            fieldTestNew.idfsSampleType      = fieldTest.idfsSampleType;
                            fieldTestNew.strSampleName       = fieldTest.strSampleName;
                            fieldTestNew.idfsVectorType      = fieldTest.idfsVectorType;
                            fieldTestNew.idfsPensideTestName = fieldTest.idfsPensideTestName;
                            fieldTestNew.TestType            = fieldTest.TestType;
                            fieldTestNew.TestCategory        = fieldTest.TestCategory;
                            fieldTestNew.datTestDate         = fieldTest.datTestDate;
                            fieldTestNew.TestedByOffice      = fieldTest.TestedByOffice;
                            fieldTestNew.TestedByPerson      = fieldTest.TestedByPerson;
                            //по заданию копировать не надо
                            //fieldTestNew.TestResult = fieldTest.TestResult;
                            //fieldTestNew.Diagnosis = fieldTest.Diagnosis;
                            vectorNew.FieldTests.Add(fieldTestNew);
                        }
                    }
                }
            }

            //помечаем игнорирование валидации, чтобы специальным образом обработать Cancel на детальной форме векторов
            vectorNew.blnIgnoreValidation = true;

            return(vectorNew);
        }