/// <summary>
        /// Replace the items in my items list, which is the list passed in by the caller, with
        /// the options returned for the 'category_id' field of the 'email' module.
        /// </summary>
        public override void Perform()
        {
            eField field = clsSuiteCRMHelper.GetFieldsForModule("Emails").moduleFields.FirstOrDefault(x => x.name == "category_id");

            if (field != null)
            {
                items.IsImplemented = true;
                items.Clear();
                items.AddRange(field.Options.Keys.OrderBy(x => x));
            }
            else
            {
                /* the CRM instance does not have the category_id field in its emails module */
                items.IsImplemented = false;
            }
        }
Exemple #2
0
 // Generates key for cache
 private int Key(eUnits u, eField f)
 {
     return ((int)u * 100) + (int)f;
 }
Exemple #3
0
        // ///////////////////////////////////////////////////////////////////////////
        protected string getUnits(eField fld)
        {
            const string strDegrees = " degrees";
            const string strRevsPerDay = " revs / day";

            switch (fld)
            {
                case eField.FLD_I:
                case eField.FLD_RAAN:
                case eField.FLD_ARGPER:
                case eField.FLD_M:
                    return strDegrees;

                case eField.FLD_MMOTION:
                    return strRevsPerDay;

                default:
                    return string.Empty;
            }
        }
Exemple #4
0
        // what units to convert to
        // ///////////////////////////////////////////////////////////////////////////
        // Convert the given field into the requested units. It is assumed that
        // the value being converted is in the TLE format's "native" form.
        protected double ConvertUnits(double valNative, // value to convert
            eField fld,       // what field the value is
            eUnits units)
        {
            if (fld == eField.FLD_I ||
                fld == eField.FLD_RAAN ||
                fld == eField.FLD_ARGPER ||
                fld == eField.FLD_M)
            {
                // The native TLE format is DEGREES
                if (units == eUnits.U_RAD)
                    return valNative * Globals.RADS_PER_DEG;
            }

            return valNative; // return value in unconverted native format
        }
Exemple #5
0
        // /////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Returns the requested TLE data field as a double or 
        /// as a text string in the units requested. 
        /// </summary>
        /// <remarks>
        /// The numeric return values are cached; requesting the same field 
        /// repeatedly incurs minimal overhead.
        /// </remarks>
        /// <param name="fld">The TLE field to retrieve</param>
        /// <param name="units">Specifies the units desired</param>
        /// <param name="str">If non-null, the field is returned as
        /// a string.</param>
        /// <param name="AppendUnits">
        /// If true, units are appended to text string.
        /// </param>
        /// <returns>
        /// The requested field, converted to the requested units if necessary.
        /// </returns>
        public double getField(eField fld,
            eUnits units,
            ref string str,
            bool AppendUnits)
        {
            if (str != null)
            {
                // Return requested field in string form.
                str = m_Field[fld].ToString();

                if (AppendUnits)
                    str += getUnits(fld);

                return 0.0;
            }
            else
            {
                // Return requested field in floating-point form.
                // Return cache contents if it exists, else populate cache.
                int key = Key(units, fld);

                if (m_Cache.ContainsKey(key))
                {
                    // return cached value
                    return (double)m_Cache[key];
                }
                else
                {
                    // Value not in cache; add it
                    double valNative = Double.Parse(m_Field[fld].ToString());
                    double valConv = ConvertUnits(valNative, fld, units);
                    m_Cache[key] = valConv;

                    return valConv;
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Returns the requested TLE data field.
        /// </summary>
        /// <param name="fld">The field to return</param>
        /// <returns>The requested field, in native format</returns>
        public double getField(eField fld)
        {
            string strTemp = null;

            return getField(fld, eUnits.U_NATIVE, ref strTemp, false);
        }