public DOCollection DO <T>(string propertyname, params KeyValuePair <string, object>[] param) where T : DODBaseUnit
            {
                DODParameter pp = new DODParameter();

                pp.PropertyName = propertyname;
                foreach (var val in _driver._p.Domain(DomainKey.INPUT_PARAMETER))
                {
                    pp.SetValue(val.Key, val.Value);
                }
                foreach (var val in _driver._p.Domain(DomainKey.CONFIG))
                {
                    pp.SetValue(DomainKey.CONFIG, val.Key, val.Value);
                }
                if (param != null)
                {
                    foreach (var val in param)
                    {
                        pp.SetValue(val.Key, val.Value);
                    }
                }
                pp.FlowInstanceID = _driver._p.FlowInstanceID;
                pp.SetValue(ParameterKey.RESOURCE_MANAGER, _driver._p.Resources);
                pp.SetValue(ParameterKey.TOKEN, _driver._p.CurrentTransToken);
                var result = (DOCollection)UnitProxy <DODParameter> .Call <T>(pp);

                return(result);
            }
Beispiel #2
0
            private DODParameter GetP()
            {
                DODParameter pp = new DODParameter();

                foreach (var val in _logic.CallContext_Parameter.Domain(DomainKey.INPUT_PARAMETER))
                {
                    pp.SetValue(val.Key, val.Value);
                }
                foreach (var val in _logic.CallContext_Parameter.Domain(DomainKey.CONFIG))
                {
                    pp.SetValue(DomainKey.CONFIG, val.Key, val.Value);
                }

                pp.SetValue(ParameterKey.RESOURCE_MANAGER, _logic.CallContext_ResourceManage);
                pp.SetValue(ParameterKey.TOKEN, _logic.CallContext_CurrentToken);
                return(pp);
            }
Beispiel #3
0
        public static DODBaseUnit GetDOD(string unitname, DODParameter p)
        {
            Dictionary<string, Type> d = null;
            lock (lockobj)
            {
                if (GlobalCommon.ApplicationCache.Get("__dod_unit_dic__") != null)
                {
                    d = (Dictionary<string, Type>)GlobalCommon.ApplicationCache.Get("__dod_unit_dic__");
                }
                else
                {
                    d = new Dictionary<string, Type>();
                    GlobalCommon.ApplicationCache.Set("__dod_unit_dic__", d, TimeSpan.FromHours(1));
                }
                var key = unitname.ToLower().Replace("dod", "").Replace("dodunit", "").Replace("dounit", "").Replace("unit", "");
                DODBaseUnit rtn = null;
                if (d.ContainsKey(key))
                {
                    var ctor = d[key].GetConstructor(new Type[] { p.GetType() });
                    if (ctor != null)
                    {
                        rtn = (DODBaseUnit)Activator.CreateInstance(d[key], p);
                    }
                    else
                    {
                        rtn = (DODBaseUnit)Activator.CreateInstance(d[key]);
                        var prop = d[key].BaseType.GetField("_p", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.IgnoreCase | BindingFlags.NonPublic);
                        prop.SetValue(rtn, p);
                    }
                }
                else
                {
                    var ass = Assembly.Load(GlobalCommon.UnitCommon.UnitAssemblyPath);

                    foreach (var t in ass.GetTypes())
                    {
                        if (t.IsSubclassOf(typeof(DODBaseUnit)) && !t.IsAbstract && !t.IsInterface)
                        {
                            var tkey = t.Name.ToLower().Replace("dod", "").Replace("dodunit", "").Replace("dounit", "").Replace("unit", "");
                            d.Add(tkey, t);
                            if (tkey == key)
                            {
                                var ctor = d[key].GetConstructor(new Type[] { p.GetType() });
                                if (ctor != null)
                                {
                                    rtn = (DODBaseUnit)Activator.CreateInstance(d[key], p);
                                }
                                else
                                {
                                    rtn = (DODBaseUnit)Activator.CreateInstance(d[key]);
                                    var prop = d[key].BaseType.GetField("_p", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.IgnoreCase | BindingFlags.NonPublic);
                                    prop.SetValue(rtn, p);
                                }
                            }
                        }
                    }


                }

                if (rtn != null)
                {
                    return rtn;
                }
                else
                {
                    throw new NotFoundException(string.Format("Can't find DODUnit named {0}", unitname));
                }
            }
        }