public static string GetResult(WeightUnits method)
        {
            if (method == WeightUnits.Kilograms)
            {
                return("kg");
            }
            else if (method == WeightUnits.Milligrams)
            {
                return("mg");
            }
            else if (method == WeightUnits.Grams)
            {
                return("gr");
            }
            else if (method == WeightUnits.Ounces)
            {
                return("oz");
            }
            else if (method == WeightUnits.Pounds)
            {
                return("lb");
            }

            return("");
        }
        private void ChangeToWeight(object sender, SelectionChangedEventArgs e)
        {
            var selectedIndex = ToWeight.SelectedIndex;

            if (selectedIndex == 0)
            {
                ToWeightUnit = WeightUnits.Milligrams;
            }
            else if (selectedIndex == 1)
            {
                ToWeightUnit = WeightUnits.Grams;
            }
            else if (selectedIndex == 2)
            {
                ToWeightUnit = WeightUnits.Kilograms;
            }
            else if (selectedIndex == 3)
            {
                ToWeightUnit = WeightUnits.Ounces;
            }
            else if (selectedIndex == 4)
            {
                ToWeightUnit = WeightUnits.Pounds;
            }
        }
Ejemplo n.º 3
0
        public override int GetRoundToDecimalsValue()
        {
            WeightUnits toUnit = (WeightUnits)ToUnit;

            switch (toUnit)
            {
            case WeightUnits.Pound:
            case WeightUnits.Ounce:
            case WeightUnits.Carrat:
            case WeightUnits.Kilogram:
            case WeightUnits.Gram:
            case WeightUnits.Milligram:
                return(3);

            case WeightUnits.MetricTon:
            case WeightUnits.ShortTon:
            case WeightUnits.LongTon:
                return(2);

            case WeightUnits.AtomicMassUnit:
                return(1);
            }

            throw new Exception("The 'TO' unit enum was improperly defined.");
        }
Ejemplo n.º 4
0
        public WeightConversions(WeightUnits from, WeightUnits to)
        {
            base.FromUnit = from;
            base.ToUnit   = to;

            ConversionFactors = GetConversionFactors();
        }
Ejemplo n.º 5
0
        public static string GetResult(string input, WeightUnits form, WeightUnits to)
        {
            var weightForm = WeightUnitAsString.GetResult(form);
            var weightTo   = WeightUnitAsString.GetResult(to);

            //convert input to mxParser string;
            input = $"{input}*[{weightForm}] / [{weightTo}]";

            Expression e = new Expression(input);

            return(e.calculate().ToString());
        }
Ejemplo n.º 6
0
 private decimal ConvertWeightToKilogram(decimal weight, WeightUnits weightUnit)
 {
     return(weight / new Dictionary <WeightUnits, decimal>()
     {
         { WeightUnits.None, 0m },
         { WeightUnits.Milligram, 1000000m },
         { WeightUnits.Gram, 1000m },
         { WeightUnits.Kilogram, 1m },
         { WeightUnits.Carats, 5000m },
         { WeightUnits.Taels, 26.4555m },
         { WeightUnits.Grains, 15432.4m },
         { WeightUnits.Pennyweights, 643.015m },
         { WeightUnits.MetricTon, 0.001m },
         { WeightUnits.AvoirTon, 0.000984207m },
         { WeightUnits.TroyOunce, 32.1507m },
         { WeightUnits.Ounce, 35.274m },
         { WeightUnits.Pound, 2.20462m }
     }[weightUnit]);
 }
Ejemplo n.º 7
0
        private static decimal ReadWeight(HidDevice hidDevice, out WeightUnits weightUnit)
        {
            const int  decimalBase = 10;
            const int  readTimeout = 250;
            const byte eightBits   = 8;
            decimal    weight      = 0;

            weightUnit = WeightUnits.None;

            HidReport hidReport = hidDevice.ReadReport(readTimeout);

            if (ValidateReport(hidReport))
            {
                // Ref: http://www.usb.org/developers/hidpage/pos1_02.pdf
                byte[] data = hidReport.Data;

                // Unpack weight word
                int lowOrderbyte  = data[(int)ScaleData.DataWeightLSB];
                int highOrderbyte = data[(int)ScaleData.DataWeightMSB] << eightBits;

                // Data scaling uses a signed byte value
                sbyte dataScaling = (sbyte)data[(int)ScaleData.DataScaling];

                // Weight = (High Order Byte + Low Order Byte) * (10 ^ Scale Factor)
                weight = (highOrderbyte + lowOrderbyte) * (decimal)Math.Pow(decimalBase, dataScaling);

                // Assign weight unit
                byte weightUnitCode = data[(int)ScaleData.WeightUnit];

                if (Enum.IsDefined(typeof(WeightUnits), weightUnitCode))
                {
                    weightUnit = (WeightUnits)weightUnitCode;
                }
                else
                {
                    throw new Exception(string.Format(Strings.InvalidScaleWeightUnit, weightUnitCode));
                }
            }

            return(weight);
        }
Ejemplo n.º 8
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 13, Configuration.FieldSeparator),
                       Id,
                       SetIdBui.HasValue ? SetIdBui.Value.ToString(culture) : null,
                       BloodUnitIdentifier?.ToDelimitedString(),
                       BloodUnitType?.ToDelimitedString(),
                       BloodUnitWeight.HasValue ? BloodUnitWeight.Value.ToString(Consts.NumericFormat, culture) : null,
                       WeightUnits?.ToDelimitedString(),
                       BloodUnitVolume.HasValue ? BloodUnitVolume.Value.ToString(Consts.NumericFormat, culture) : null,
                       VolumeUnits?.ToDelimitedString(),
                       ContainerCatalogNumber,
                       ContainerLotNumber,
                       ContainerManufacturer?.ToDelimitedString(),
                       TransportTemperature?.ToDelimitedString(),
                       TransportTemperatureUnits?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Converts from 1 distance to another. By default, converts to Meter and then back to the other measurements
        /// </summary>
        /// <param name="value">The value of the from unit</param>
        /// <param name="from">From unit can be anything listed in DistanceUnits</param>
        /// <param name="to">To unit can be anything listed in DistanceUnits</param>
        /// <returns></returns>
        public override decimal Convert(decimal value, Enum from, Enum to)
        {
            WeightUnits fromDu = (WeightUnits)from;
            WeightUnits toDu = (WeightUnits)to;

            decimal conversion;

            if (!conversionMap.TryGetValue(fromDu, out conversion))
            {
                throw new InvalidUnitTypeException(fromDu.ToString());
            }
            // Convert from to Meter
            value /= conversion;

            // Convert meter to to.
            if (!conversionMap.TryGetValue(toDu, out conversion))
            {
                throw new InvalidUnitTypeException(toDu.ToString());
            }

            return value * conversion;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Unit Weight conversion function from Metric to Metric, Metric to English, or vice versa.
        /// </summary>
        /// <param name="toConvert">Original, operating, weight.</param>
        /// <param name="toConvertTo">Measurement unit to convert into (ie kg).</param>
        /// <returns>A new weight with correct type and numeric value.</returns>
        public static BaseWeightScalar ConvertToUnits(BaseWeightScalar toConvert, WeightUnits toConvertTo)
        {
            if (toConvert.UnitOfMeasure == toConvertTo)
            {
                return(toConvert);
            }

            double newVal = toConvert.NumericValue;

            if (toConvert.UnitOfMeasure == WeightUnits.Grams && toConvertTo == WeightUnits.Kilograms)
            {
                newVal /= 1000.0;
            }
            else if (toConvert.UnitOfMeasure == WeightUnits.Grams && toConvertTo == WeightUnits.Pounds)
            {
                newVal /= 453.592;
            }
            else if (toConvert.UnitOfMeasure == WeightUnits.Kilograms && toConvertTo == WeightUnits.Pounds)
            {
                newVal *= 2.205;
            }
            else if (toConvert.UnitOfMeasure == WeightUnits.Kilograms && toConvertTo == WeightUnits.Grams)
            {
                newVal *= 1000.0;
            }
            else if (toConvert.UnitOfMeasure == WeightUnits.Pounds && toConvertTo == WeightUnits.Grams)
            {
                newVal *= 453.592;
            }
            else if (toConvert.UnitOfMeasure == WeightUnits.Pounds && toConvertTo == WeightUnits.Kilograms)
            {
                newVal /= 2.205;
            }

            BaseWeightScalar toReturn = new BaseWeightScalar(toConvert.Symbol, newVal, toConvertTo);

            return(toReturn);
        }
Ejemplo n.º 11
0
        static int makeUnitTask(int varMin, int varMax)
        {
            //1-Distance
            double metre      = 1;
            double centimetre = metre * 0.01;
            double millimetre = metre * 0.001;
            //2-weight
            double kilogram = 1;
            double gram     = kilogram * 0.01;
            //3-volume
            double cubicMetre = 1;
            double litre      = cubicMetre * 0.001;



            Random r = new Random(Guid.NewGuid().GetHashCode());

            string        unit1 = "";
            string        unit2 = "";
            int           val;
            Units         unit     = (Units)r.Next(0, 2);
            DistanceUnits distance = (DistanceUnits)r.Next(0, 2);
            WeightUnits   weight   = (WeightUnits)r.Next(0, 1);
            VolumeUnits   volume   = (VolumeUnits)r.Next(0, 1);

            switch (unit)
            {
            case Units.Distance:
                switch (distance)
                {
                case DistanceUnits.Metre:
                    unit1 = "metre";
                    break;

                case DistanceUnits.Centimetre:
                    unit1 = "centimetre";
                    break;

                case DistanceUnits.Millimetre:
                    unit1 = "millimetre";
                    break;
                }
                distance = (DistanceUnits)r.Next(0, 3);

                switch (unit1)
                {
                case "metre":
                    while (unit2 == unit1 || unit2 == "")
                    {
                        switch (distance)
                        {
                        case DistanceUnits.Centimetre:
                            unit2 = "centimetre";
                            break;

                        case DistanceUnits.Millimetre:
                            unit2 = "millimetre";
                            break;

                        case DistanceUnits.Metre:
                            unit2 = "metre";
                            break;
                        }
                    }
                    break;

                case "centimetre":
                    while (unit2 == unit1 || unit2 == "")
                    {
                        switch (distance)
                        {
                        case DistanceUnits.Metre:
                            unit2 = "metre";
                            break;

                        case DistanceUnits.Millimetre:
                            unit2 = "millimetre";
                            break;

                        case DistanceUnits.Centimetre:
                            unit2 = "millimetre";
                            break;
                        }
                    }
                    break;

                case "millimetre":
                    switch (distance)
                    {
                    case DistanceUnits.Metre:
                        unit2 = "metre";
                        break;

                    case DistanceUnits.Centimetre:
                        unit2 = "centimetre";
                        break;

                    case DistanceUnits.Millimetre:
                        unit2 = "millimetre";
                        break;
                    }
                    break;
                }
                break;

            case Units.Weight:
                switch (weight)
                {
                case WeightUnits.Kilogram:
                    unit1 = "kilogram";
                    break;

                case WeightUnits.gram:
                    unit1 = "gram";
                    break;
                }
                switch (unit1)
                {
                case "kilogram":
                    unit2 = "gram";
                    break;

                case "gram":
                    unit2 = "kilogram";
                    break;
                }
                break;

            case Units.Volume:
                switch (volume)
                {
                case VolumeUnits.Cubicmetre:
                    unit1 = "cubicmetre";
                    break;

                case VolumeUnits.Litre:
                    unit1 = "litre";
                    break;
                }
                switch (unit1)
                {
                case "cubicmetre":
                    unit2 = "litre";
                    break;

                case "litre":
                    unit2 = "cubicmetre";
                    break;
                }
                break;
            }

            val = r.Next(varMin, varMax);

            Console.WriteLine("how many {0}(s) is {1} {2}(s)", unit1, val, unit2);

            var mytask = new Task("funfunfunfunfun", "bretty gud");

            Console.WriteLine(mytask.Solution);
            Console.WriteLine(mytask.TaskDescription);

            return(0);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightOfSolidMatter"/> class.
 /// </summary>
 /// <param name="waterContent">w in w=W_w/W_s.</param>
 /// <param name="waterWeight">W_w in w=W_w/W_s.</param>
 /// <param name="units">Measurement unit to hold value after initial calculation (ie kg).</param>
 public WeightOfSolidMatter(WaterContent waterContent, WeightOfWater waterWeight, WeightUnits units)
     : this(BaseWeightScalar.ConvertToUnits(waterWeight, units).NumericValue / waterContent.NumericValue, units)
 {
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightOfSolidMatter"/> class.
 /// </summary>
 /// <param name="waterWeight">W_w in W=W_w+W_s.</param>
 /// <param name="totalWeight">W in W=W_w+W_s.</param>
 /// <param name="units">Measurement unit to hold value after initial calculation (ie kg).</param>
 public WeightOfSolidMatter(WeightOfWater waterWeight, TotalWeight totalWeight, WeightUnits units)
     : this(ConvertToUnits(totalWeight, units).NumericValue - ConvertToUnits(waterWeight, units).NumericValue, units)
 {
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightOfSolidMatter"/> class.
 /// </summary>
 /// <param name="numericalValue">Decimal value to use in calculation.</param>
 /// <param name="units">Measurement unit (ie kg).</param>
 public WeightOfSolidMatter(double numericalValue, WeightUnits units)
     : base("W_s", numericalValue, units)
 {
 }
Ejemplo n.º 15
0
        public static Task MakeUnitTask(int varMin, int varMax)
        {
            Random r = new Random(Guid.NewGuid().GetHashCode());

            string        unit1 = "";
            string        unit2 = "";
            double        val;
            string        answer   = "";
            Units         unit     = (Units)r.Next(0, 3);
            DistanceUnits distance = (DistanceUnits)r.Next(0, 3);
            WeightUnits   weight   = (WeightUnits)r.Next(0, 2);
            VolumeUnits   volume   = (VolumeUnits)r.Next(0, 2);

            switch (unit)
            {
            case Units.Distance:
                switch (distance)
                {
                case DistanceUnits.Metre:
                    unit1 = "metres";
                    break;

                case DistanceUnits.Centimetre:
                    unit1 = "centimetres";
                    break;

                case DistanceUnits.Millimetre:
                    unit1 = "millimetres";
                    break;
                }
                distance = (DistanceUnits)r.Next(0, 3);

                switch (unit1)
                {
                case "metres":
                    while (unit2 == unit1 || unit2 == "")
                    {
                        switch (distance)
                        {
                        case DistanceUnits.Centimetre:
                            unit2 = "centimetres";
                            break;

                        case DistanceUnits.Millimetre:
                            unit2 = "millimetres";
                            break;

                        case DistanceUnits.Metre:
                            distance = (DistanceUnits)r.Next(0, 3);
                            break;
                        }
                    }
                    break;

                case "centimetres":
                    while (unit2 == unit1 || unit2 == "")
                    {
                        switch (distance)
                        {
                        case DistanceUnits.Metre:
                            unit2 = "metres";
                            break;

                        case DistanceUnits.Millimetre:
                            unit2 = "millimetres";
                            break;

                        case DistanceUnits.Centimetre:
                            distance = (DistanceUnits)r.Next(0, 3);
                            break;
                        }
                    }
                    break;

                case "millimetres":
                    while (unit2 == unit1 || unit2 == "")
                    {
                        switch (distance)
                        {
                        case DistanceUnits.Metre:
                            unit2 = "metres";
                            break;

                        case DistanceUnits.Centimetre:
                            unit2 = "centimetres";
                            break;

                        case DistanceUnits.Millimetre:
                            distance = (DistanceUnits)r.Next(0, 3);
                            break;
                        }
                    }
                    break;
                }
                break;

            case Units.Weight:
                switch (weight)
                {
                case WeightUnits.Kilogram:
                    unit1 = "kilograms";
                    break;

                case WeightUnits.gram:
                    unit1 = "grams";
                    break;
                }
                switch (unit1)
                {
                case "kilograms":
                    unit2 = "gram";
                    break;

                case "grams":
                    unit2 = "kilogram";
                    break;
                }
                break;

            case Units.Volume:
                switch (volume)
                {
                case VolumeUnits.Cubicmetre:
                    unit1 = "cubicmetres";
                    break;

                case VolumeUnits.Litre:
                    unit1 = "litres";
                    break;
                }
                switch (unit1)
                {
                case "cubicmetres":
                    unit2 = "litres";
                    break;

                case "litres":
                    unit2 = "cubicmetres";
                    break;
                }
                break;
            }

            val = r.Next(varMin, varMax);
            string taskS = "";

            taskS += "How many " + unit1 + " is " + val + " " + unit2 + "?";

            //conversions
            if (unit1 == "metres" && unit2 == "centimetres")
            {
                val = val * 0.01;
            }
            else if (unit1 == "metres" && unit2 == "millimetres")
            {
                val = val * 0.001;
            }
            else if (unit1 == "centimetres" && unit2 == "metres")
            {
                val = val * 100;
            }
            else if (unit1 == "centimetres" && unit2 == "millimetres")
            {
                val = val * 0.1;
            }
            else if (unit1 == "millimetres" && unit2 == "metres")
            {
                val = val * 1000;
            }
            else if (unit1 == "millimetres" && unit2 == "centimetres")
            {
                val = val * 10;
            }
            else if (unit1 == "litres")
            {
                val = val * 1000;
            }
            else if (unit1 == "cubicmetres")
            {
                val = val * 0.001;
            }
            else if (unit1 == "gram")
            {
                val = val * 1000;
            }
            else if (unit1 == "kilogram")
            {
                val = val * 0.001;
            }

            answer = val.ToString();

            var task = new Task(taskS, answer);

            return(task);
        }
Ejemplo n.º 16
0
 public void InitializeWeightUnitTables()
 {
     WeightUnits = CloudTableClient.GetTableReference(Constants.StorageTableNames.WeightUnits);
     WeightUnits.CreateIfNotExists();
 }
Ejemplo n.º 17
0
 public Units(DistanceUnits distanceUnits, WeightUnits weightUnits)
 {
     this._distanceUnits = distanceUnits;
     this._weightUnits   = weightUnits;
 }
Ejemplo n.º 18
0
 public T SetWeight(string weight, WeightUnits units)
 {
     this._product.Weight     = weight;
     this._product.WeightUnit = (int)units;
     return((T)this);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TotalWeight"/> class.
 /// </summary>
 /// <param name="solidWeight">W_s in W=W_s+W_w.</param>
 /// <param name="waterWeight">W_w in W=W_s+W_w.</param>
 /// <param name="units">Measurement unit to hold value after initial calculation (ie kg). </param>
 public TotalWeight(WeightOfSolidMatter solidWeight, WeightOfWater waterWeight, WeightUnits units)
     : this(ConvertToUnits(solidWeight, units).NumericValue + ConvertToUnits(waterWeight, units).NumericValue, units)
 {
 }
Ejemplo n.º 20
0
 public IProductBuilder SetWeight(string weight, WeightUnits unit)
 {
     _builderProduct.Weight     = weight;
     _builderProduct.WeightUnit = (int)unit;
     return(this);
 }
 private WeightMeasurement CreateWeightMeasurement(DateTime date, WeightUnits weightUnits, double value)
 {
     return(new WeightMeasurement(date, value, weightUnits));
 }
 public WeightMeasurement(DateTime date, double value, WeightUnits units)
     : base(date, value)
 {
     this.weightUnits = units;
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TotalWeight"/> class.
 /// </summary>
 /// <param name="numericalValue">Decimal value to use in calculations.</param>
 /// <param name="units">Measurement unit (ie kg).</param>
 public TotalWeight(double numericalValue, WeightUnits units)
     : base("W", numericalValue, units)
 {
 }
Ejemplo n.º 24
0
        public Task Initialize(Progress <MonitorMessage> progress, CancellationToken cancellationToken)
        {
            _progress = progress;

            if (String.IsNullOrEmpty(Properties.Settings.Default.ScaleID))
            {
                _progress.Report(new MonitorMessage(Strings.ScaleConfigurationMissingWarning));
                return(null);
            }

            return(Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        if (cancellationToken.IsCancellationRequested)
                        {
                            LogoutFromAcumatica();
                            break;
                        }

                        decimal readWeight = 0m;
                        WeightUnits weightUnit = WeightUnits.None;
                        HidDevice hidDevice = HidDevices.Enumerate(Properties.Settings.Default.ScaleDeviceVendorId, Properties.Settings.Default.ScaleDeviceProductId).FirstOrDefault();

                        if (hidDevice != null)
                        {
                            using (hidDevice)
                            {
                                hidDevice.OpenDevice();
                                WaitForConnection(hidDevice);
                                readWeight = ReadWeight(hidDevice, out weightUnit);
                                hidDevice.CloseDevice();
                            }

                            if (!weightUnit.Equals(WeightUnits.None))
                            {
                                _progress.Report(new MonitorMessage(String.Format(Strings.ScaleWeightNotify, readWeight, WeightUnitToStringAbbreviation[weightUnit])));

                                if (_lastWeightSentToAcumatica != readWeight)
                                {
                                    if (_screen != null || LoginToAcumatica())
                                    {
                                        UpdateWeight(Properties.Settings.Default.ScaleID, ConvertWeightToKilogram(readWeight, weightUnit));
                                        _lastWeightSentToAcumatica = readWeight;
                                    }
                                }
                            }
                        }

                        System.Threading.Thread.Sleep(Properties.Settings.Default.ScaleReadInterval);
                    }
                    catch (Exception ex)
                    {
                        // Assume the server went offline or our session got lost - new login will be attempted in next iteration
                        _progress.Report(new MonitorMessage(String.Format(Strings.ScaleWeightError, ex.Message), MonitorMessage.MonitorStates.Error));
                        _screen = null;
                        System.Threading.Thread.Sleep(Properties.Settings.Default.ErrorWaitInterval);
                    }
                }
            }));
        }
Ejemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TotalWeight"/> class.
 /// </summary>
 /// <param name="massSpecificGravity">G_m in W=G_m*gamma_w*V.</param>
 /// <param name="unitWeightOfWater">gamma_w in W=G_m*gamma_w*V.</param>
 /// <param name="totalVolume">V in W=G_m*gamma_w*V.</param>
 /// <param name="units">Measurement unit to hold value after initial calculation (ie kg).</param>
 public TotalWeight(MassSpecificGravity massSpecificGravity, UnitWeightOfWater unitWeightOfWater, TotalVolume totalVolume, WeightUnits units)
     : this(ConvertToUnits(new BaseWeightScalar("𝛾", BaseUnitWeightScalar.ConvertToUnits(unitWeightOfWater, UnitWeightUnits.KilogramPerMeterCubed).NumericValue *BaseVolumeScalar.ConvertToUnits(totalVolume, VolumeUnits.CubicMeters).NumericValue *massSpecificGravity.NumericValue, WeightUnits.Kilograms), units).NumericValue, units)
 {
 }
Ejemplo n.º 26
0
 public abstract float ConvertTo(WeightUnits units);
Ejemplo n.º 27
0
        public string BuildXml()
        {
            string result = string.Empty;

            StringWriter  sw = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
            XmlTextWriter xw = new XmlTextWriter(sw);

            xw.Formatting  = Formatting.Indented;
            xw.Indentation = 2;

            xw.WriteStartDocument();

            //Preamble
            xw.WriteStartElement("FDXRateRequest");
            xw.WriteAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            xw.WriteAttributeString("xsi:noNamespaceSchemaLocation", "FDXRateRequest.xsd");

            RequestHeader.WriteToXml(xw, "RequestHeader");
            xw.WriteElementString("ReturnShipmentIndicator", ReturnType.ToString());
            xw.WriteElementString("ShipDate", ShipDate.ToString("yyyy-MM-dd"));
            xw.WriteElementString("DropoffType", this.globals.DefaultDropOffType.ToString());
            xw.WriteElementString("Service", Service.ToString());
            xw.WriteElementString("Packaging", Packaging.ToString());
            xw.WriteElementString("WeightUnits", WeightUnits.ToString());
            xw.WriteElementString("Weight", _Weight.ToString("0.0"));
            xw.WriteElementString("ListRate", globals.UseListRates ? "1" : "0");

            OriginAddress.WriteToXml(xw, "OriginAddress");
            DestinationAddress.WriteToXml(xw, "DestinationAddress");

            xw.WriteStartElement("Payment");
            xw.WriteElementString("PayorType", "SENDER");
            xw.WriteEndElement();

            if (Packaging == PackageType.YOURPACKAGING)
            {
                Dimensions.WriteToXml(xw, "Dimensions");
            }

            xw.WriteStartElement("DeclaredValue");
            xw.WriteElementString("Value", _DeclaredValue.ToString("0.00"));
            xw.WriteElementString("CurrencyCode", "USD");
            xw.WriteEndElement();

            if (ContainsAlcohol)
            {
                xw.WriteElementString("Alcohol", "1");
            }
            SpecialServices.WriteToXml(xw, "SpecialServices");
            xw.WriteElementString("PackageCount", PackageCount.ToString());

            //_RequestContact.WriteToXml(xw, "Contact")
            //_RequestAddress.WriteToXml(xw, "Address")

            xw.WriteEndDocument();

            xw.Flush();
            xw.Close();

            result = sw.GetStringBuilder().ToString();

            return(result);
        }
Ejemplo n.º 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeightOfWater"/> class.
 /// </summary>
 /// <param name="numericalValue">Decimal value to use in calculations.</param>
 /// <param name="units">Measurement unit (ie kg).</param>
 public WeightOfWater(double numericalValue, WeightUnits units)
     : base("W_w", numericalValue, units)
 {
 }
Ejemplo n.º 29
0
 public abstract decimal ConvertTo(WeightUnits units);
Ejemplo n.º 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BaseWeightScalar"/> class.
 /// </summary>
 /// <param name="symbol">LateX symbol for pretty print.</param>
 /// <param name="numericalValue">Decimal value used for calculations.</param>
 /// <param name="units">Measurement unit (ie kg).</param>
 public BaseWeightScalar(string symbol, double numericalValue, WeightUnits units)
 {
     this.UnitOfMeasure = units;
     this.Symbol        = symbol;
     this.NumericValue  = numericalValue;
 }