Ejemplo n.º 1
0
        /// <summary>
        /// Checks if MetaTag is valid known metatag 
        /// </summary>
        /// <returns></returns>
        private static bool IsValidMetatag(string metaTagKey, ConfigUtils.MetatagMode ? inMode)
        {
            bool result = false;
            //if (ConfigUtils.GlobalConfig.GlobalParameters.Contains(metaTagKey)
            //    ||
            //    MetaTagReplacerFunctions.ReplacerFunctions.ContainsKey(metaTagKey))
            //    return true;

            ConfigUtils.MetatagMode mode = ConfigUtils.MetatagMode.All;
            if (inMode != null)
                mode = (ConfigUtils.MetatagMode)inMode;

            if (ConfigUtils.GlobalConfig.GlobalParameters.Contains(metaTagKey) &&
                    (mode == ConfigUtils.MetatagMode.Environment || mode == ConfigUtils.MetatagMode.All))
            {
                result = true;
            }

            if (MetaTagReplacerFunctions.ReplacerFunctions.ContainsKey(metaTagKey) &&
                    (mode != ConfigUtils.MetatagMode.Environment || mode == ConfigUtils.MetatagMode.All) 
                )
            {
                result = true;
            }

            return result;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This method is the sole method responsible for assigning values to job's Dynamic Properties.
        /// It does this based on one of the [only] two types of metatags (Environment or RunTime)
        /// </summary>
        /// <param name="jobParameters"></param>
        /// <param name="replaceMode"></param>
        /// <param name="inputDates"></param>
        /// <param name="inputArgs"></param>
        public static bool SetParametersValuesPB(ref PropertyBag jobParameters, 
                                                                            ConfigUtils.MetatagMode replaceMode,
                                                                            MetaTagReplacerInputDates inputDates,
                                                                            object[] inputArgs
                                                                      )
        {
            bool retval = true;

            MetaTagReplacerInputDates inputDateParms = inputDates;
            if (inputDateParms == null)
                inputDateParms = new MetaTagReplacerInputDates(DateTime.Now);

            log.InfoFormat("Input Date used to initialize run-time properties: {0}", inputDateParms.InDate);

            PropertyBag tempPropBag = new PropertyBag();
            foreach (string metaTagKey in jobParameters.Names)
            {
                string metaTagValue = GetMetaTagValue(metaTagKey, inputDateParms, replaceMode, inputArgs);
                if (metaTagValue != null)
                {
                    tempPropBag[metaTagKey] = metaTagValue;
                }
                else
                {
                    if (IsValidMetatag(metaTagKey, replaceMode))
                    {
                        log.WarnFormat("Unable to assign property value for {0}", metaTagKey);
                    }
                    else
                        retval = false; //not a valid meta tag - should never happen at this point as illegal MTs should not make it to PB in a first place
                }
            }

            foreach (string metaTagKey in tempPropBag.Names)
            {
                jobParameters[metaTagKey] = tempPropBag[metaTagKey];
                log.InfoFormat("Assigned property value: {0} = {1}", metaTagKey, jobParameters[metaTagKey]);
            }

            return retval;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This should the main single point of getting the meta tag value
        /// This function fetches individual meta tag value as is, e.g. null if invalid metatag
        /// </summary>
        /// <param name="metaTagKey"></param>
        /// <param name="inDate"></param>
        /// <param name="inArgs"></param>
        /// <returns></returns>
        public static string GetMetaTagValue(string metaTagKey, 
                                                                        MetaTagReplacerInputDates inDateParms,
                                                                        ConfigUtils.MetatagMode? inMode,
                                                                        object[] inArgs
                                                              )
        {
            string metaTagValue = null;
            try
            {
                ConfigUtils.MetatagMode mode = ConfigUtils.MetatagMode.All;
                if (inMode != null)
                    mode = (ConfigUtils.MetatagMode) inMode;

                if (ConfigUtils.GlobalConfig.GlobalParameters.Contains(metaTagKey) &&
                    (mode == ConfigUtils.MetatagMode.Environment || mode == ConfigUtils.MetatagMode.All))
                {
                    metaTagValue = ConfigUtils.GlobalConfig.GlobalParameters[metaTagKey] as string;
                }

                if (MetaTagReplacerFunctions.ReplacerFunctions.ContainsKey(metaTagKey) && 
                    (mode != ConfigUtils.MetatagMode.Environment || mode == ConfigUtils.MetatagMode.All) )
                {
                    if(inDateParms == null)
                        throw new ArgumentNullException("Runtime metatag received null inDateParm.");

                    metaTagValue = MetaTagReplacerFunctions.EvaluateMetaTagFunction(metaTagKey,
                                                                                    inDateParms, 
                                                                                    inArgs) as string;
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            return metaTagValue;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// This should the main single point of getting the meta tag value
 /// This function fetches individual meta tag value as is, e.g. null if invalid metatag
 /// </summary>
 /// <param name="metaTagKey"></param>
 /// <param name="inDate"></param>
 /// <returns></returns>
 public static string GetMetaTagValue(string metaTagKey, MetaTagReplacerInputDates inDateParms, ConfigUtils.MetatagMode? inMode)
 {
     return GetMetaTagValue(metaTagKey, inDateParms, inMode, null);
 }