Beispiel #1
0
        /// <summary>
        /// Formats a quantity assuming it is given in kg.
        /// </summary>
        /// <param name="rawAmount">Quantity in kg</param>
        /// <param name="conf">if true a null value will be marked "CONFIDENTIAL"</param>
        private static string formatMethod(double?rawAmount, bool conf)
        {
            string result = string.Empty;

            if (rawAmount == null)
            {
                result = ConfidentialFormat.Format(result, conf);
            }
            else
            {
                double amount = (double)rawAmount;

                if (amount < 0)
                {
                    throw new ArgumentException("Negative Amount provided", "rawAmount");
                }

                else if (amount >= 100000)
                {
                    result = "" + Math.Round((amount / 1000), 0).ToString("n0") + " " + Resources.GetGlobal("LOV_UNIT", "TNE");
                }
                else if (amount >= 10000 && amount < 100000)
                {
                    result = "" + Math.Round((amount / 1000), 1).ToString("n1") + " " + Resources.GetGlobal("LOV_UNIT", "TNE");
                }
                else if (amount >= 1000 && amount < 10000)
                {
                    result = "" + Math.Round((amount / 1000), 2).ToString("n2") + " " + Resources.GetGlobal("LOV_UNIT", "TNE");
                }
                else if (amount >= 100 && amount < 1000)
                {
                    result = "" + Math.Round((amount), 0).ToString("n0") + " " + Resources.GetGlobal("LOV_UNIT", "KGM");
                }
                else if (amount >= 10 && amount < 100)
                {
                    result = "" + Math.Round((amount), 1).ToString("n1") + " " + Resources.GetGlobal("LOV_UNIT", "KGM");
                }
                else if (amount >= 1 && amount < 10)
                {
                    result = "" + Math.Round((amount), 2).ToString("n2") + " " + Resources.GetGlobal("LOV_UNIT", "KGM");
                }
                else if (amount == 0.00)
                {
                    result = "0";
                }
                else if (amount * 10 >= 1 && amount * 10 < 10)
                {
                    result = "" + Math.Round((amount * 1000), 0).ToString("n0") + " " + Resources.GetGlobal("LOV_UNIT", "GRM");;
                }
                else if (amount * 100 >= 1 && amount * 100 < 10)
                {
                    result = "" + Math.Round((amount * 1000), 1).ToString("n1") + " " + Resources.GetGlobal("LOV_UNIT", "GRM");;
                }
                else if (amount * 1000 < 10 && amount > 0)
                {
                    result = "" + Math.Round((amount * 1000), 3).ToString("n3") + " " + Resources.GetGlobal("LOV_UNIT", "GRM");;
                }
            }
            return(result);
        }
Beispiel #2
0
 private static string formatMethod(double?rawAmount, QuantityUnit unit, bool conf)
 {
     if (rawAmount == null)
     {
         return(ConfidentialFormat.Format(null, conf));
     }
     else
     {
         if (unit == QuantityUnit.Unknown)
         {
             string result = ((double)rawAmount).ToString("#,0.#");
             return(ConfidentialFormat.Format(result, conf));
         }
         else if (unit == QuantityUnit.Tonnes)
         {
             //tranfer to kilos
             return(formatMethod(rawAmount * 1000, conf));
         }
         else
         {
             //kilo
             return(formatMethod(rawAmount, conf));
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// Returnes a combined address string. The country will be translated.
        /// </summary>
        /// <param name="address">adress, i.e. steetname incl. buildingnumber</param>
        /// <param name="city"></param>
        /// <param name="postalCode"></param>
        /// <param name="countryCode">The LOV code for the country</param>
        /// <param name="confidential">True if confidentality is claimed</param>
        public static string Format(string address, string city, string postalCode, string countryCode, bool confidential)
        {
            string result = address;

            result = addString(result, postalCode);
            result = addString(result, city);
            result = addString(result, LOVResources.CountryName(countryCode));

            return(ConfidentialFormat.Format(result, confidential));
        }
Beispiel #4
0
        /// <summary>
        /// Formats the methods used for a given pollutant or waste. Notice that each of these can have multiple methods reported
        /// Each method will be seperated by linebreaks to be uused in tooltips (&#13;)

        /*public static string MethodFormatToolTip(string typeCodes, string designations, bool confidential)
         * {
         *  return format(typeCodes, designations, confidential, "&#13;");
         * }*/


        /// <summary>
        /// formats the methods used
        /// </summary>
        private static string format(string typeCodes, string designations, bool confidential, string delimiter)
        {
            string result = string.Empty;

            string[] designationSplit = null;
            string[] typecodeSplit    = null;


            //designations will never be given without type codes.
            if (String.IsNullOrEmpty(typeCodes))
            {
                return(ConfidentialFormat.Format(null, confidential));
            }
            else
            {
                typecodeSplit = typeCodes.Split(DELIMITER, StringSplitOptions.None);

                if (!String.IsNullOrEmpty(designations))
                {
                    designationSplit = designations.Split(DELIMITER, StringSplitOptions.None);
                }

                for (int i = 0; i < typecodeSplit.Length; i++)
                {
                    string typeCode    = typecodeSplit[i];
                    string designation = designationSplit != null ? designationSplit[i] : null;

                    if (!String.IsNullOrEmpty(typeCode))
                    {
                        //CEN/ISO is removed as this is also part of the designation
                        if (!typeCode.ToUpper().Equals("CEN/ISO"))
                        {
                            result += String.Format("<abbr title=\"{0}\"> {1} </abbr>", LOVResources.MethodTypeName(typeCode), typeCode);
                        }

                        if (!String.IsNullOrEmpty(designation))
                        {
                            result += " " + String.Format("<span title=\"{0}\">{0}</span>", designation);
                        }

                        result += delimiter;
                    }
                }
            }

            return(result);
        }