Example #1
0
        public static WebContext ProcessRequest(System.Collections.IDictionary header, WebClient client)
        {
            WebRuntime runtime = new WebRuntime(client, header);

            var value = System.Threading.Thread.CurrentPrincipal;

            runtime.DoFactory(value);
            return(runtime.Context);
        }
Example #2
0
 public static void Registers(IEnumerable <System.Reflection.Assembly> assembly)
 {
     WebRuntime.Register(typeof(UMC.Data.Reflection).Assembly);
     foreach (var a in assembly)//mscorlib,
     {
         var mpps = a.GetCustomAttributes(typeof(MappingAttribute), false);
         if (mpps.Length > 0)
         {
             WebRuntime.Register(a);
         }
     }
 }
Example #3
0
        public static WebContext Start(WebClient client)
        {
            WebRuntime runtime = new WebRuntime(client, new Hashtable());

            Current         = runtime;
            runtime.Context = client.Session.Context();
            try
            {
                runtime.Context.Init(runtime);
                runtime.Context.OnInit(client);
            }
            catch (UMC.Web.WebAbortException)
            {
            }

            return(runtime.Context);
        }
Example #4
0
        void Send(System.Collections.IDictionary doc2)
        {
            this.IsEmptyReq = false;
            var context = this.Context = doc2 == null?WebRuntime.Start(this) : WebRuntime.ProcessRequest(doc2, this);

            var response = context.Response;

            if (IsEmptyReq)
            {
                _lastRedirect = null;
            }

            this.Session.Check(context);
            this.RedirectTimes++;
            var clientEvent = response.ClientEvent;

            this.InnerHeaders.Clear();
            this.ModelCommand(context.Request.Model, context.Request.Command, this.InnerHeaders);


            if ((Convert.ToInt32(clientEvent) & OuterDataEvent) == OuterDataEvent)
            {
                this.ClientEvent = clientEvent;
                this.OutputHeader(response.Headers);
                return;
            }

            var clientRedirect = response.ClientRedirect;

            if ((clientEvent & WebEvent.AsyncDialog) == WebEvent.AsyncDialog)
            {
                this.InnerHeaders[WebRequest.KEY_HEADER_ARGUMENTS] = response.Headers.GetMeta(WebRequest.KEY_HEADER_ARGUMENTS);
                if (clientRedirect != null)
                {
                    if ((clientEvent & WebClient.Prompt) != WebClient.Prompt)
                    {
                        this.ModelCommand(clientRedirect.Model, clientRedirect.Command, this.InnerHeaders);
                        clientRedirect = response.ClientRedirect = null;
                    }
                }
                if ((clientEvent & WebEvent.Dialog) == WebEvent.Dialog)
                {
                    clientEvent ^= WebEvent.Dialog;

                    this.InnerHeaders["POS-DIALOG"] = "YES";
                }
            }
            if (clientRedirect != null)
            {
                if (this.RedirectTimes > 10)
                {
                    throw new Exception(String.Format("{0}.{1},请求重定向超过最大次数", clientRedirect.Model, clientRedirect.Command));
                }
                var args = response.Headers.GetMeta(WebRequest.KEY_HEADER_ARGUMENTS);
                _lastRedirect = clientRedirect;

                if (clientEvent != WebEvent.None)
                {
                    this.ClientEvent |= clientEvent;
                    response.Headers.Remove(WebRequest.KEY_HEADER_ARGUMENTS);
                    OutputHeader(response.Headers);
                }

                if (String.IsNullOrEmpty(response.ClientRedirect.Value))
                {
                    this.Redirect(clientRedirect.Model, clientRedirect.Command, args);
                }
                else
                {
                    if (clientRedirect.Value.IndexOf("&") > -1)
                    {
                        var nquery = System.Web.HttpUtility.ParseQueryString(clientRedirect.Value);
                        this.Redirect(clientRedirect.Model, clientRedirect.Command, nquery);
                    }
                    else if (clientRedirect.Value.StartsWith("{"))
                    {
                        var p   = UMC.Data.JSON.Deserialize(clientRedirect.Value) as Hashtable;
                        var pos = new NameValueCollection();
                        var em  = p.GetEnumerator();
                        while (em.MoveNext())
                        {
                            pos[em.Key.ToString()] = em.Value.ToString();
                        }
                        this.Redirect(clientRedirect.Model, clientRedirect.Command, pos);
                    }
                    else
                    {
                        this.Redirect(clientRedirect.Model, clientRedirect.Command, clientRedirect.Value);
                    }
                }
                return;
            }
            response.Headers.Remove(WebRequest.KEY_HEADER_ARGUMENTS);
            OutputHeader(response.Headers);
            this.ClientEvent = this.ClientEvent | clientEvent;
            if (IsEmptyReq == false)
            {
                if (_lastRedirect != null && XHRTime > 1)
                {
                    this.ClientEvent = this.ClientEvent | WebEvent.Reset;
                    response.Headers.Put("Reset", _lastRedirect);
                }
            }
        }
Example #5
0
        static WebRuntime()
        {
            Console.WriteLine("                                                                     ");
            Console.WriteLine("                                                                     ");
            Console.WriteLine("    $$         $$          $$$$$$$$   $$$$$$$            $$$$$$$$    ");
            Console.WriteLine("    $$         $$         $$      $$$$      $$         $$            ");
            Console.WriteLine("    $$         $$        $$        $$        $$       $$             ");
            Console.WriteLine("    $$         $$        $$        $$        $$       $$             ");
            Console.WriteLine("    $$         $$        $$        $$        $$       $$             ");
            Console.WriteLine("    $$         $$        $$        $$        $$       $$             ");
            Console.WriteLine("    $$         $$        $$        $$        $$       $$             ");
            Console.WriteLine("     $$       $$         $$        $$        $$        $$            ");
            Console.WriteLine("       $$$$$$$           $$        $$        $$          $$$$$$$$    ");
            Console.WriteLine("                                                                     ");
            Console.WriteLine("                                                                     ");

            var dics = new System.IO.DirectoryInfo(System.AppDomain.CurrentDomain.BaseDirectory).GetFiles("*.dll", SearchOption.TopDirectoryOnly);

            var last = DateTime.Now;// Utility.TimeSpan();// dic.LastWriteTime);

            foreach (var f in dics)
            {
                if (last > f.LastWriteTime)
                {
                    last = f.LastWriteTime;
                }
            }

            String mapFile  = Utility.MapPath("App_Data/register.net");
            var    lastTime = Utility.TimeSpan(last);
            String m        = Utility.Reader(mapFile);

            if (String.IsNullOrEmpty(m) == false)
            {
                Hashtable map = JSON.Deserialize(m) as Hashtable;
                if (map.ContainsKey("time"))
                {
                    if (Utility.IntParse(map["time"].ToString(), 0) == lastTime)
                    {
                        Array mapings = map["data"] as Array;
                        if (mapings != null)
                        {
                            int l = mapings.Length;
                            for (int i = 0; i < l; i++)
                            {
                                String v = mapings.GetValue(i) as string;
                                WebRuntime.Register(Type.GetType(v));
                            }
                        }
                    }
                }
            }
            if (isScanning() == false)
            {
                Reflection.instance.ScanningClass();
                ;
                Utility.Writer(mapFile, JSON.Serialize(new WebMeta().Put("time", lastTime).Put("data", WebRuntime.RegisterCls())), false);
            }
            WebRuntime.webFactorys.Sort((x, y) => y.Weight.CompareTo(x.Weight));
            var em = WebRuntime.flows.GetEnumerator();

            while (em.MoveNext())
            {
                em.Current.Value.Sort((x, y) => y.Weight.CompareTo(x.Weight));
            }
        }
Example #6
0
 internal void Init(WebRuntime runtime)
 {
     this.runtime = runtime;
 }