Exemple #1
0
        private void WriteError()
        {
            var rlt = new Model.SP_RESULT()
            {
                status = _errCode, description = _errMsg
            };
            var sp = new Model.APIResponseModel(rlt, _aqm);

            if (_aqm != null)
            {
                _aqm.status = ResultStatusMap(rlt);
            }

            Response.Write(sp.ToJson());
        }
Exemple #2
0
        public sealed override void BeginProcess()
        {
            Response.ContentType = "text/plain";
            //var ticks = new System.Diagnostics.Stopwatch();
            //ticks.Start();
            if (!OnInit())
            {
                WriteError();
                return;
            }

            Model.SP_RESULT        result = null;
            String                 step   = Request["step"];
            Func <Model.SP_RESULT> func   = null;

            if (step == null || step != "2")
            {
                Step = 1;
                func = GetSpCmd;
            }
            else
            {
                Step = 2;
                func = GetSpCmdStep2;
            }

            try
            {
                result = func();
            }
            catch (WebException webex)
            {
                SetError(API_ERROR.INNER_ERROR, webex.Message);
                WriteLog(webex.ToString());
            }
#if !DEBUG
            catch (Exception ex)
            {
                WriteLog(ex.ToString());
                SetError(API_ERROR.INNER_ERROR, "内部错误");
            }
#endif
            finally { }

            if (result == null)
            {
                WriteError();
            }
            else
            {
                if (_aqm == null)
                {
                    Response.Write("{}");
                    return;
                }
                ResultStatusMap(result);
                var json = new Model.APIResponseModel(result, _aqm);
                _aqm.status = ResultStatusMap(result);

                Response.Write(json.ToJson());
            }
            FlushLog();
        }