Exemple #1
0
        protected override void AuthCheck(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    method  = request.GetString("Method", null);

            if (method != "GetSimulateInfo")
            {
                YZAuthHelper.AshxAuthCheck();
            }
        }
Exemple #2
0
        protected override void AuthCheck(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    method  = request.GetString("method");

            if (NameCompare.EquName(method, "GetString"))
            {
                return;
            }

            YZAuthHelper.AshxAuthCheck();
        }
Exemple #3
0
        protected override void AuthCheck(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            string    method  = request.GetString("method");

            if (NameCompare.EquName(method, "Login") ||
                NameCompare.EquName(method, "LoginTrial") ||
                NameCompare.EquName(method, "SendLoginValidationCode") ||
                NameCompare.EquName(method, "GetPublicKey") ||
                NameCompare.EquName(method, "DingTalkLogin"))
            {
                return;
            }

            YZAuthHelper.AshxAuthCheck();
        }
Exemple #4
0
 protected virtual void AuthCheck(HttpContext context)
 {
     YZAuthHelper.AshxAuthCheck();
 }
Exemple #5
0
    public virtual void ProcessRequest(HttpContext context)
    {
        YZAuthHelper.AshxAuthCheck();
        YZRequest request = new YZRequest(context);

        context.Response.AppendHeader("Access-Control-Allow-Origin", "*");
        try
        {
            string method = request.GetString("Method");
            if (!YZNameChecker.IsValidMethodName(method))
            {
                throw new Exception("Invalid method name");
            }
            Type type = this.GetType();
            System.Reflection.MethodInfo methodcall = type.GetMethod(method, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public, null, new Type[] { typeof(HttpContext) }, null);
            if (methodcall == null)
            {
                throw new Exception(String.Format(Resources.YZStrings.Aspx_UnknowCommand, method));
            }
            object rv;
            try
            {
                rv = methodcall.Invoke(this, new object[] { context });
            }
            catch (Exception exp)
            {
                throw exp.InnerException;
            }
            if (rv is JsonItem || rv is JsonItemCollection)
            {
                throw new Exception("JsonItem/JsonItemCollection is Obsoleted, please replace with JObject/JArray");
            }
            JToken jToken;
            if (rv == null)
            {
                jToken = new JObject();
            }
            else if (rv is JToken)
            {
                jToken = rv as JToken;
            }
            else
            {
                if (rv is string)
                {
                    jToken = JValue.FromObject(rv);
                }
                else if (rv is IEnumerable)
                {
                    jToken = JArray.FromObject(rv);
                }
                else
                {
                    jToken = JValue.FromObject(rv);
                }
            }
            jToken["code"] = 0;



            if (context.Request.Params["DateFormat"] == "text")
            {
                context.Response.Write(jToken.ToString(Formatting.Indented));
            }
            else
            {
                context.Response.Write(jToken.ToString(Formatting.Indented, request.Converters));
            }
        }
        catch (Exception e)
        {
            JObject rv = new JObject();
            rv["code"] = -1;
            rv["msg"]  = HttpUtility.HtmlEncode(e.Message);
            context.Response.Write(rv.ToString(Formatting.Indented, request.Converters));
        }
    }
Exemple #6
0
        public virtual void ProcessRequest(HttpContext context)
        {
            YZAuthHelper.AshxAccessCheck(context);
            YZAuthHelper.AshxAuthCheck();

            //如果是自己管理语言,需要放出以下2行
            //System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(1033);
            //System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(1033);

            //if (String.Compare(YZAuthHelper.LoginUserAccount, "usera06", true) == 0)
            //{
            //using (FileStream fs = new FileStream("e:\\abc.xml", FileMode.Create, FileAccess.Write))
            //{
            //    byte[] bytes = new byte[context.Request.InputStream.Length];
            //    context.Request.InputStream.Read(bytes, 0, (int)context.Request.InputStream.Length);
            //    fs.Write(bytes, 0, bytes.Length);
            //}
            //context.Request.InputStream.Seek(0, SeekOrigin.Begin);
            //}

            try
            {
                JArray         tables     = new JArray();
                JsonSerializer serializer = new JsonSerializer();
                StreamReader   reader     = new StreamReader(context.Request.InputStream);
                using (JsonTextReader streamReader = new JsonTextReader(reader))
                {
                    JArray requests = serializer.Deserialize(streamReader) as JArray;
                    using (BPMConnection cn = new BPMConnection())
                    {
                        cn.WebOpen();

                        for (int requestIndex = 0; requestIndex < requests.Count; requestIndex++)
                        {
                            JObject request = (JObject)requests[requestIndex];

                            string method = (string)request["Method"];

                            if (!YZNameChecker.IsValidMethodName(method))
                            {
                                throw new Exception("Invalid method name");
                            }

                            Type type = this.GetType();
                            System.Reflection.MethodInfo methodcall = type.GetMethod(method, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public);
                            if (methodcall == null)
                            {
                                throw new Exception(String.Format(Resources.YZStrings.Aspx_UnknowCommand, method));
                            }

                            try
                            {
                                object mrv = methodcall.Invoke(this, new object[] { cn, request });
                                if (mrv is JObject)
                                {
                                    (mrv as JObject)["Index"] = requestIndex;
                                    tables.Add(mrv);
                                }
                                else
                                {
                                    JArray rvs = mrv as JArray;
                                    foreach (JObject jTable in rvs)
                                    {
                                        jTable["Index"] = requestIndex;
                                        tables.Add(jTable);
                                    }
                                }
                            }
                            catch (Exception exp)
                            {
                                throw exp.InnerException;
                            }
                        }
                    }
                }

                JObject rv = new JObject();
                rv[YZJsonProperty.success] = true;
                rv["Tables"] = tables;
                context.Response.Write(rv.ToString());
            }
            catch (Exception e)
            {
                JObject rv = new JObject();
                rv[YZJsonProperty.success]      = false;
                rv[YZJsonProperty.errorMessage] = HttpUtility.HtmlEncode(e.Message);
                context.Response.Write(rv.ToString(Newtonsoft.Json.Formatting.Indented, YZJsonHelper.Converters));
            }
        }