Esempio n. 1
0
        public double GetValueFromExpression(string expression)
        {
            double value = 0.0;

            //get the active document
            Document activeDocument = m_inventorApplication.ActiveDocument;

            //get the unit of measure object
            UnitsOfMeasure unitsOfMeasure = activeDocument.UnitsOfMeasure;

            //get the current length units of the user
            UnitsTypeEnum lengthUnitsType = unitsOfMeasure.LengthUnits;

            //convert the expression to the current length units of user
            try
            {
                object vVal;
                vVal  = unitsOfMeasure.GetValueFromExpression(expression, lengthUnitsType);
                value = System.Convert.ToDouble(vVal);
            }
            catch (System.Exception e)
            {
                string strErrorMsg = e.Message;

                value = 0.0;
                return(value);
            }
            return(value);
        }
Esempio n. 2
0
        public void FormatSpeed(bool isRawDataAsDBaseRequired, UnitsTypeEnum units, int speed, string expectedResult)
        {
            var userPreferences = new UserPreferences()
            {
                Units = (int)units
            };
            var csvUserPreference = AutoMapperUtility.Automapper.Map <CSVExportUserPreferences>(userPreferences);
            var formatter         = new CSVExportFormatter(csvUserPreference, OutputTypes.PassCountLastPass, isRawDataAsDBaseRequired);

            var result = formatter.FormatSpeed(speed);

            result.Should().Be(expectedResult);
        }
Esempio n. 3
0
        public PartDocument CreatePartDocument(string DetailName, UnitsTypeEnum LengthUnits, UnitsTypeEnum AngleUnits)
        {
            InventorApplication = (Inventor.Application)
                                  System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application");
            PartDocument part = InventorApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, "", true) as PartDocument;

            part.DisplayName = DetailName;
            part.UnitsOfMeasure.LengthUnits = LengthUnits;
            part.UnitsOfMeasure.AngleUnits  = AngleUnits;
            partCompDef = part.ComponentDefinition;
            transGeom   = InventorApplication.TransientGeometry;
            return(part);
        }
Esempio n. 4
0
        public void FormatElevationString
            (string decimalSeparator, string thousandsSeparator, UnitsTypeEnum units,
            bool isRawDataAsDBaseRequired,
            float value, string expectedResult
            )
        {
            var userPreferences = new UserPreferences()
            {
                DecimalSeparator = decimalSeparator, ThousandsSeparator = thousandsSeparator, Units = (int)units
            };
            var csvUserPreference = AutoMapperUtility.Automapper.Map <CSVExportUserPreferences>(userPreferences);

            OutputTypes outputType = OutputTypes.PassCountLastPass;
            var         formatter  = new CSVExportFormatter(csvUserPreference, outputType, isRawDataAsDBaseRequired);
            var         result     = formatter.FormatElevation(value);

            result.Should().Be(expectedResult);
        }
Esempio n. 5
0
        public void FormatterInitialization
            (string dateSeparator, string timeSeparator, string decimalSeparator, string thousandsSeparator,
            UnitsTypeEnum units,
            OutputTypes outputType, bool isRawDataAsDBaseRequired,
            string expectedNullString, double expectedDistanceConversionFactor,
            string expectedSpeedUnitString, double expectedSpeedConversionFactor,
            string expectedDistanceUnitString, string expectedExportDateTimeFormatString
            )
        {
            var userPreference = new UserPreferences()
                                 // veta should ignore separators
            {
                DateSeparator    = dateSeparator, TimeSeparator = timeSeparator,
                DecimalSeparator = decimalSeparator, ThousandsSeparator = thousandsSeparator,
                Units            = (int)units
            };
            var csvUserPreference = AutoMapperUtility.Automapper.Map <CSVExportUserPreferences>(userPreference);

            var formatter = new CSVExportFormatter(csvUserPreference, outputType, isRawDataAsDBaseRequired);

            formatter.UserPreference.DateSeparator.Should().Be(dateSeparator);
            formatter.UserPreference.TimeSeparator.Should().Be(timeSeparator);
            formatter.UserPreference.DecimalSeparator.Should().Be(decimalSeparator);
            formatter.UserPreference.ThousandsSeparator.Should().Be(thousandsSeparator);
            formatter.OutputType.Should().Be(outputType);
            formatter.IsRawDataAsDBaseRequired.Should().Be(isRawDataAsDBaseRequired);
            // this depends on isRawDataAsDBaseRequired
            formatter.NullString.Should().Be(expectedNullString);

            formatter.UserPreference.Units.Should().Be(units);
            formatter.DistanceConversionFactor.Should().Be(expectedDistanceConversionFactor);
            formatter.SpeedUnitString.Should().Be(expectedSpeedUnitString);
            formatter.SpeedConversionFactor.Should().Be(expectedSpeedConversionFactor);
            formatter.DistanceUnitString.Should().Be(expectedDistanceUnitString);
            formatter.ExportDateTimeFormatString.Should().Be(expectedExportDateTimeFormatString);
        }
Esempio n. 6
0
        private void Create_Details_Click(object sender, RoutedEventArgs e)
        {
            UnitsTypeEnum[] LengthUnits = new UnitsTypeEnum[] { UnitsTypeEnum.kMillimeterLengthUnits,
                                                                UnitsTypeEnum.kCentimeterLengthUnits,
                                                                UnitsTypeEnum.kMeterLengthUnits };
            UnitsTypeEnum[] AngleUnits = new UnitsTypeEnum[] { UnitsTypeEnum.kRadianAngleUnits,
                                                               UnitsTypeEnum.kGradAngleUnits };

            CreateDetails pDoc = new CreateDetails(d, D, B, r, Dw);
            PartDocument  partDocument;

            partDocument = pDoc.CreatePartDocument("Внешнее кольцо подшипника", LengthUnits[0], AngleUnits[1]);
            partDocument.Views[1].GoHome();
            pDoc.Mirror_Obj(pDoc.Create_Revolve(pDoc.OutsideRing(), PartFeatureOperationEnum.kJoinOperation), partDocument);
            partDocument.SaveAs(@"C:\BearingDetails\Внешнее кольцо подшипника.ipt", false);
            partDocument = pDoc.CreatePartDocument("Внутреннее кольцо подшипника", LengthUnits[0], AngleUnits[1]);
            partDocument.Views[1].GoHome();
            pDoc.Mirror_Obj(pDoc.Create_Revolve(pDoc.InsideRing(), PartFeatureOperationEnum.kJoinOperation), partDocument);
            partDocument.SaveAs(@"C:\BearingDetails\Внутреннее кольцо подшипника.ipt", false);
            partDocument = pDoc.CreatePartDocument("Первый ряд шариков", LengthUnits[0], AngleUnits[1]);
            partDocument.Views[1].GoHome();
            pDoc.Create_Circular_Array(pDoc.Create_Revolve(pDoc.BallsRow1(), PartFeatureOperationEnum.kJoinOperation));
            partDocument.SaveAs(@"C:\BearingDetails\Первый ряд шариков.ipt", false);
            partDocument = pDoc.CreatePartDocument("Второй ряд шариков", LengthUnits[0], AngleUnits[1]);
            partDocument.Views[1].GoHome();
            pDoc.Create_Circular_Array(pDoc.Create_Revolve(pDoc.BallsRow2(), PartFeatureOperationEnum.kJoinOperation));
            partDocument.SaveAs(@"C:\BearingDetails\Второй ряд шариков.ipt", false);
            partDocument = pDoc.CreatePartDocument("Сепаратор1", LengthUnits[0], AngleUnits[1]);
            partDocument.Views[1].GoHome();
            pDoc.Separator(1);
            partDocument.SaveAs(@"C:\BearingDetails\Сепаратор1.ipt", false);
            partDocument = pDoc.CreatePartDocument("Сепаратор2", LengthUnits[0], AngleUnits[1]);
            partDocument.Views[1].GoHome();
            pDoc.Separator(-1);
            partDocument.SaveAs(@"C:\BearingDetails\Сепаратор2.ipt", false);
        }
Esempio n. 7
0
        public void CSVExportHelper_MapPassCountRequestToCommonExportRequest(string decimalSeparator, string thousandsSeparator, UnitsTypeEnum units,
                                                                             string dateSeparator, string timeSeparator, bool restrictOutputSize, bool rawDataAsDBase,
                                                                             string expectedDateSeparator, string expectedTimeSeparator)
        {
            var          projectUid     = Guid.NewGuid();
            FilterResult filter         = null;
            var          fileName       = "gotAFilename";
            var          coordType      = CoordType.LatLon;
            var          outputType     = OutputTypes.PassCountLastPass;
            var          userPreference = new UserPreferences()
            {
                DateSeparator      = dateSeparator,
                TimeSeparator      = timeSeparator,
                DecimalSeparator   = decimalSeparator,
                ThousandsSeparator = thousandsSeparator,
                Units = (int)units
            };

            var request = new CompactionPassCountExportRequest(
                projectUid, filter, fileName,
                coordType, outputType, userPreference, restrictOutputSize, rawDataAsDBase, null, null);

            request.Validate();
            var compactionCSVExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request);

            compactionCSVExportRequest.CoordType.Should().Be(coordType);
            compactionCSVExportRequest.OutputType.Should().Be(outputType);

            compactionCSVExportRequest.UserPreferences.DecimalSeparator.Should().Be(decimalSeparator);
            compactionCSVExportRequest.UserPreferences.DateSeparator.Should().Be(expectedDateSeparator);
            compactionCSVExportRequest.UserPreferences.TimeSeparator.Should().Be(expectedTimeSeparator);

            compactionCSVExportRequest.MachineNames.Length.Should().Be(0);
            compactionCSVExportRequest.RestrictOutputSize.Should().Be(restrictOutputSize);
            compactionCSVExportRequest.RawDataAsDBase.Should().Be(rawDataAsDBase);
        }
Esempio n. 8
0
        public void CSVExportHelper_MapVetaRequestToCommonExportRequest(string decimalSeparator, string thousandsSeparator, UnitsTypeEnum units,
                                                                        string dateSeparator, string timeSeparator,
                                                                        string expectedDateSeparator, string expectedTimeSeparator)
        {
            var          projectUid     = Guid.NewGuid();
            FilterResult filter         = null;
            var          fileName       = "gotAFilename";
            var          coordType      = CoordType.LatLon;
            var          outputType     = OutputTypes.VedaAllPasses;
            var          theMachineName = "first machineName";
            var          machineNames   = new[] { theMachineName };
            var          userPreference = new UserPreferences()
            {
                DateSeparator    = dateSeparator, TimeSeparator = timeSeparator,
                DecimalSeparator = decimalSeparator, ThousandsSeparator = thousandsSeparator, Units = (int)units
            };

            var request = new CompactionVetaExportRequest(
                projectUid, filter, fileName, coordType, outputType, userPreference, machineNames, null, null);

            request.Validate();
            var compactionCsvExportRequest = AutoMapperUtility.Automapper.Map <CompactionCSVExportRequest>(request);

            compactionCsvExportRequest.CoordType.Should().Be(coordType);
            compactionCsvExportRequest.OutputType.Should().Be(outputType);

            compactionCsvExportRequest.UserPreferences.DecimalSeparator.Should().Be(decimalSeparator);
            compactionCsvExportRequest.UserPreferences.DateSeparator.Should().Be(expectedDateSeparator);
            compactionCsvExportRequest.UserPreferences.TimeSeparator.Should().Be(expectedTimeSeparator);

            compactionCsvExportRequest.MachineNames.Should().Equal(machineNames);
            compactionCsvExportRequest.RestrictOutputSize.Should().Be(false);
            compactionCsvExportRequest.RawDataAsDBase.Should().Be(false);
        }
Esempio n. 9
0
        public void CSVExportHelper_MapUserPreferences(string decimalSeparator, string thousandsSeparator, UnitsTypeEnum units,
                                                       string dateSeparator, string timeSeparator, TemperatureUnitEnum temperatureUnits,
                                                       string expectedDateSeparator, string expectedTimeSeparator)
        {
            var userPreference = new UserPreferences()
            {
                DateSeparator    = dateSeparator, TimeSeparator = timeSeparator,
                DecimalSeparator = decimalSeparator, ThousandsSeparator = thousandsSeparator,
                Units            = (int)units, TemperatureUnits = (int)temperatureUnits
            };

            var csvUserPreference = AutoMapperUtility.Automapper.Map <CSVExportUserPreferences>(userPreference);

            csvUserPreference.DecimalSeparator.Should().Be(decimalSeparator);
            csvUserPreference.ThousandsSeparator.Should().Be(thousandsSeparator);
            csvUserPreference.Units.Should().Be(units);
            csvUserPreference.TemperatureUnits.Should().Be(temperatureUnits);
            csvUserPreference.DateSeparator.Should().Be(expectedDateSeparator);
            csvUserPreference.TimeSeparator.Should().Be(expectedTimeSeparator);
        }
Esempio n. 10
0
        public void CSVExportHelper_MapCommonExportRequestToArgument(string decimalSeparator, string thousandsSeparator, UnitsTypeEnum units,
                                                                     string dateSeparator, string timeSeparator, bool restrictOutputSize, bool rawDataAsDBase,
                                                                     string expectedDateSeparator, string expectedTimeSeparator)
        {
            var          projectUid     = Guid.NewGuid();
            FilterResult filter         = null;
            var          fileName       = "gotAFilename";
            var          coordType      = CoordType.LatLon;
            var          outputType     = OutputTypes.VedaAllPasses;
            var          theMachineName = "first machineName";

            string[] machineNames   = new string[] { theMachineName };
            var      userPreference = new UserPreferences()
            {
                DateSeparator      = dateSeparator,
                TimeSeparator      = timeSeparator,
                DecimalSeparator   = decimalSeparator,
                ThousandsSeparator = thousandsSeparator,
                Units = (int)units
            };

            var request = new CompactionCSVExportRequest(
                projectUid, filter, fileName,
                coordType, outputType, userPreference, machineNames, restrictOutputSize, rawDataAsDBase);

            request.Validate();
            var csvExportRequestArgument = AutoMapperUtility.Automapper.Map <CSVExportRequestArgument>(request);

            csvExportRequestArgument.CoordType.Should().Be(coordType);
            csvExportRequestArgument.OutputType.Should().Be(outputType);

            csvExportRequestArgument.UserPreferences.DecimalSeparator.Should().Be(decimalSeparator);
            csvExportRequestArgument.UserPreferences.DateSeparator.Should().Be(expectedDateSeparator);
            csvExportRequestArgument.UserPreferences.TimeSeparator.Should().Be(expectedTimeSeparator);

            // these are mapped separately using CSVExportHelper.MapRequestedMachines()
            csvExportRequestArgument.MappedMachines.Count.Should().Be(0);
            csvExportRequestArgument.RawDataAsDBase.Should().Be(rawDataAsDBase);
        }
Esempio n. 11
0
        private VariableInfoType RowToVariable(UsgsDbDailyValues.VariablesRow vRow)
        {
            VariableInfoType vit;
            String           vCode = vRow.IsVariableCodeNull() ? null : vRow.VariableCode;
            String           vName = vRow.IsVariableNameNull() ? null : vRow.VariableName;
            //String vDescr =
            String uName   = vRow.IsUnitsNull() ? null : vRow.Units;
            String uAbbrev = vRow.IsUnitAbbreviationNull() ? null : vRow.UnitAbbreviation;
            String uType   = vRow.IsUnitTypeNull() ? null : vRow.UnitType;
            String uCode   = null; // ID is code

            if (!vRow.IsVariableUnitsIDNull())
            {
                uCode = vRow.VariableUnitsID.ToString();
            }

            UnitsTypeEnum uTypeEnum = (UnitsTypeEnum)CoreBuilder.GetTextAsEnum(uType, typeof(UnitsTypeEnum));

            units vUnit = CuahsiBuilder.CreateUnitsElement(
                uTypeEnum,
                uCode, uAbbrev, uName);

            /* this needs to be fixed to accept value type and data type
             *  and time options
             */
            vit = CuahsiBuilder.CreateVariableInfoType(
                null,   // don't want variable ID exposed in the NWIS service
                "NWIS",
                vRow.VariableCode,
                vRow.VariableName,
                null,
                vUnit // units
                );

            CoreBuilder.SetEnumFromText(vit, vRow, "valueType", typeof(valueTypeEnum));
            CoreBuilder.SetEnumFromText(vit, vRow, "dataType", typeof(dataTypeEnum));

            // add usgs statistic code options
            if (!vRow.Isstat_cdNull())
            {
                List <option> opts = new List <option>(1);
                option        opt  = new option();
                opt.name       = "statistic";
                opt.optionCode = vRow.stat_cd;
                opts.Add(opt);
                vit.options = opts.ToArray();
            }

            if (!vRow.IsisRegularNull() && vRow.isRegular)
            {
                vit.timeSupport                    = new VariableInfoTypeTimeSupport();
                vit.timeSupport.isRegular          = vRow.isRegular;
                vit.timeSupport.isRegularSpecified = true;

                // add time support

                // check to be sure we've got some vaild stuff
                if (!vRow.IsTimeSupportNull())
                {
                    int timeInterval;
                    if (Int32.TryParse(vRow.TimeSupport, out timeInterval))
                    {
                        vit.timeSupport.timeInterval          = timeInterval;
                        vit.timeSupport.timeIntervalSpecified = true;
                    }
                }
                if (!vRow.IsTimeUnitsIDNull())
                {
                    vit.timeSupport.unit                  = new UnitsType();
                    vit.timeSupport.unit.UnitID           = 104;
                    vit.timeSupport.unit.UnitIDSpecified  = true;
                    vit.timeSupport.unit.UnitDescription  = "day";
                    vit.timeSupport.unit.UnitAbbreviation = "d";
                    vit.timeSupport.unit.UnitType         = (UnitsTypeEnum)CoreBuilder.GetTextAsEnum("Time", typeof(UnitsTypeEnum));;
                }
            }

            return(vit);
        }
Esempio n. 12
0
 public string GetStringFromType(UnitsTypeEnum unitsType)
 {
     return InternalGetStringFromType( unitsType);
 }
Esempio n. 13
0
 private string InternalGetStringFromType(UnitsTypeEnum unitsType)
 {
     return UnitsOfMeasureInstance.GetStringFromType( unitsType);
 }
Esempio n. 14
0
 public string GetStringFromType(UnitsTypeEnum unitsType)
 {
     return(InternalGetStringFromType(unitsType));
 }
Esempio n. 15
0
 private string InternalGetStringFromType(UnitsTypeEnum unitsType)
 {
     return(UnitsOfMeasureInstance.GetStringFromType(unitsType));
 }