Esempio n. 1
0
        /// <summary>
        /// This function is responsible for building a PropertyBag from the metatags that are used in a given job spec.  It
        /// parses the job spec to identify and build a list of metatags as the properties in the PropertyBag.
        /// The PropertyBag properties are then initialized and assigned from the Environment Metatags that were set earlier and made
        /// available in the GlobalConfig.GlobalParameters (also a PropertyBag).  Any runtime parameters will not be found in the
        /// GlobalConfig.GlobalParameters object and those properties in the new PropertyBag will be set to null.        
        /// </summary>
        /// <param name="jobName"></param>
        /// <param name="jobSpec"></param>
        /// <param name="jobParameters"></param>
        public static PropertyBag GetJobParametersPB(string jobName, string jobSpec)
        {
            PropertyBag jobParameters = new PropertyBag();

            List<string> metaTagNameCandidates = jobSpec.Split('*').ToList<string>();

            if (metaTagNameCandidates.Count > 1)
            {

                for (int index = 1; index < metaTagNameCandidates.Count - 1; index++)
                {
                    string metaTagKey = "*" + metaTagNameCandidates[index] + "*";
                    string metaTagValue = metaTagKey;

                    if (!jobParameters.Contains(metaTagKey) && IsValidMetatag(metaTagKey, null))
                    {
                            jobParameters[metaTagKey] = null;
                            log.DebugFormat("[Job = {0}] Initialized property from metatag: {1}", jobName, metaTagKey);
                    }
                    else
                    {
                        log.DebugFormat("[Job = {0}] Unrecognized string is not a known metatag: {1}", jobName, metaTagKey);
                    }
                }
            }
            log.DebugFormat("[Job = {0}] Found {1} metatags from {2} candidates (i.e. split no '*')", jobName, jobParameters.Count(), metaTagNameCandidates.Count);

            return jobParameters;
        }
Esempio n. 2
0
		public Object GetMetaTagReplacement(object arg)
		{
            //VJ New MetaTag substitution logic
			//return ConfigUtils.MetaTagReplacer(arg.ToString(),ConfigUtils.MetatagMode.Environment);
            //
            string result = string.Empty;

            string[] arguments = arg.ToString().Split(Convert.ToChar(252));
            string replace_in = (string) arguments.GetValue(0);
            DateTime in_date = DateTime.MinValue;
            bool useInDate = false;
            if (arguments.Length > 1)
            {
                string in_date_str = (string) arguments.GetValue(1);
                if (!string.IsNullOrEmpty(in_date_str))
                {
                    if (DateTime.TryParse(in_date_str, out in_date))
                        useInDate = true;
                }
            }

            // Check if explicit "bag of parameters" is passed then if true use it for 1st pass of meta tag replacement
            //Should be list of "Name;Vlaue" delimited pairs
            if (arguments.Length > 2)
            {
                PropertyBag in_parameters = new PropertyBag();
                for (int incr = 2; incr < arguments.Length; incr++)
                {
                    string[] in_parms = ((string)arguments.GetValue(incr)).Split(Convert.ToChar(253));
                    if (in_parms.Length == 2)
                    {
                        string in_parm_name = (string) in_parms.GetValue(0);
                        string in_parm_value = (string)in_parms.GetValue(1);
                        if (!string.IsNullOrEmpty(in_parm_name) && !string.IsNullOrEmpty(in_parm_value))
                            in_parameters.Add(in_parm_name, in_parm_value);
                    }
                }
                if (in_parameters.Count() > 0)
                    result = MetaTagReplacer.InlineMetatagSubstitution(replace_in, in_parameters);
            }

            //Second, replace the rest of the tags
            if (useInDate)
                //use "Full" replacement driven by InDate parameter when it is passed
                result = MetaTagReplacer.InlineMetatagSubstitution(replace_in, in_date);
            else
                //Dafault: replace Environment parameters only (as before)
                result = MetaTagReplacer.InlineMetatagSubstitution(replace_in, ConfigUtils.GlobalConfig.GlobalParameters);

            return result;
		}