void IComponent.Append(ref Dictionary <string, object> variables, IOutputWriter writer) { ClassQuery cq = new ClassQuery(_namespace, _query); List <IDbDataParameter> pars = new List <IDbDataParameter>(); StringOutputWriter swo = new StringOutputWriter(); foreach (string str in _parameters.Keys) { string par = ""; foreach (IComponent ic in _parameters[str]) { swo.Clear(); ic.Append(ref variables, swo); par += swo.ToString(); } pars.Add(cq.CreateParameter(str, par)); } cq.Execute(pars.ToArray()); object var = new ArrayList(); while (cq.Read()) { Hashtable ht = new Hashtable(); for (int x = 0; x < cq.FieldCount; x++) { if (!cq.IsDBNull(x)) { ht.Add(cq.GetName(x), cq[x]); } } ((ArrayList)var).Add(ht); } cq.Close(); if (((ArrayList)var).Count == 1 && ((Hashtable)((ArrayList)var)[0]).Count == 1) { Hashtable tmp = (Hashtable)((ArrayList)var)[0]; var = tmp; object[] objAr = new object[1]; ((Hashtable)var).Values.CopyTo(objAr, 0); var = objAr[0]; } if (variables.ContainsKey(_variableName)) { variables.Remove(_variableName); } variables.Add(_variableName, var); }
void IComponent.Append(ref Dictionary <string, object> variables, IOutputWriter writer) { object var = null; try { Type t = Type.GetType(_type, true); ConstructorInfo ci = null; foreach (ConstructorInfo c in t.GetConstructors()) { if ((_pars.Count == 0) && (c.GetParameters().Length == 0)) { ci = c; break; } else { bool isOkay = c.GetParameters().Length == _pars.Count; foreach (ParameterInfo pi in c.GetParameters()) { if (!_pars.ContainsKey("@" + pi.Name)) { isOkay = false; break; } } if (isOkay) { ci = c; break; } } } if (ci != null) { object[] pars = new object[_pars.Count]; StringOutputWriter swo = new StringOutputWriter(); for (int x = 0; x < pars.Length; x++) { ParameterInfo pi = ci.GetParameters()[x]; string tmp = ""; foreach (IComponent ic in _pars["@" + pi.Name]) { swo.Clear(); ic.Append(ref variables, swo); tmp += swo.ToString(); } pars[x] = Convert.ChangeType(tmp, pi.ParameterType); } var = ci.Invoke(pars); } } catch (Exception e) { EventController.TriggerEvent(new ErrorOccuredEvent(e)); Log.Error(e); } if (variables.ContainsKey(_varName)) { variables.Remove(_varName); } variables.Add(_varName, var); }