示例#1
0
        private SqlParameter[] ParseParameters(Hashtable inputData)
        {
            if (String.IsNullOrEmpty(parameterString))
                return null;

            //get parm string from job spec and build array of parms
            string[] ps = parameterString.Split(';');
            SqlParameter[] parameters = new SqlParameter[ps.Length];

            //enumerate each parn specification and add new parm to parm array
            int i = 0;
            foreach (string pp in ps)
            {
                string parmValue;
                string parmName;
                SqlDbType parmType;

                // see if parm spec is fully defined
                string[] parms = pp.Split('=');
                if (parms.Length <= 0)
                {
                    log.WarnFormat("No parms found [{0}] ", pp);
                    return parameters;
                }

                // break down parm spec into name and type
                if (parms[0].IndexOf(",") > -1)
                {
                    string[] parmDef = parms[0].Split(',');
                    parmName = parmDef[0].Replace("\"", "");
                    parmType = Bits.Common.Utilities.DataUtils.ConvertToDbType(parmDef[1].Replace("\"", ""));
                }
                else
                {
                    //default case
                    parmName = parms[0].Replace("\"", "");
                    parmType = SqlDbType.VarChar;
                }


                //special metatag cases
                if (parms[1].Equals("*FOLDERWATCHERFILENAME*") && inputData.ContainsKey("FOLDERWATCHERFILENAME"))
                    parmValue = inputData["FOLDERWATCHERFILENAME"].ToString();
				else if (parms[1].Equals( "*NEXT_BUSINESS_DATE*" ))
                    //Replaced legacy ConfigUtils meta tag replacement logic with new MetaTagReplacer
					//parmValue = ConfigUtils.MetaTagReplacer( "*NEXT_BUSINESS_DATE*", DateTime.Today );
                    parmValue = MetaTagReplacer.GetMetaTagValue("*NEXT_BUSINESS_DATE*", 
                                                                                                    ((State)this.ExecutionEngine.GetJobState(this.job.JobName)).CurrentParameters.ProcessInputDates,
                                                                                                    null);
				else
				{
                    //New meta tag replacement logic 
                    //+ (UNUSED ?) substitution of "BUS_" keys with values  - added for backward compatibility
					//parmValue = ConfigUtils.MetaTagReplacer( parms[1].Replace( "\"", "" ), inputData );
					//parmValue = ConfigUtils.MetaTagReplacer( parmValue );
                    parmValue = parms[1].Replace("\"", "");
                    foreach (string key in inputData.Keys)
                    {
                        string metaTag = String.Format("*BUS_{0}*", key);
                        parmValue = parmValue.Replace(metaTag, inputData[key].ToString());
                    }
                    parmValue = MetaTagReplacer.InlineMetatagSubstitution(parmValue,
                                            ((State)this.ExecutionEngine.GetJobState(this.job.JobName)).CurrentParameters.CurrentParameters);
				}

                //special case to put data on bus
                if (parameters.Equals("RunDate"))
                    AddToOutputs("RunDate", parmValue);

                // add parm to collection
                parameters[i] = new SqlParameter(parmName, parmType);
				if (parmType.Equals( SqlDbType.DateTime ) || parmType.Equals( SqlDbType.SmallDateTime ))
				{
					//deal with Geneva formatting before attempting Sql Server call
                    if (parmValue.Length > 10 && parmValue.Substring(10, 1) == ":")
						parmValue = String.Format( "{0} {1}", parmValue.Substring( 0, 10 ), parmValue.Substring( 11, parmValue.Length - 11 ) );

					DateTime pvD = DateTime.MinValue;
					if (DateTime.TryParse( parmValue.ToString(), out pvD ))
						parameters[i].Value = pvD;
				}
				else
					parameters[i].Value = parmValue;
                i++;
            }

            return parameters;
        }