コード例 #1
0
ファイル: BaseController.cs プロジェクト: firespeed79/WMS-5
        /// <summary>
        /// 初始化Controller
        /// </summary>
        /// <param name="requestContext"></param>
        private void Init(RequestContext requestContext)
        {
            //1.初始化变量
            WmsDc   = new WMSDcDataContext();
            options = new TransactionOptions();
            options.IsolationLevel = IsolationLevel.ReadCommitted; //默认为Serializable,这里根据参数来进行调整


            Rm            = new ResultMessage();
            Rm.ResultCode = ResultMessage.RESULTMESSAGE_SUCCESS;
            Rm.ResultDesc = "成功!";

            //2.初始化分页信息
            Pagination pgnt = new Pagination();

            pgnt.PageCount   = 0;
            pgnt.Pageid      = 1;
            pgnt.PageSize    = 20;
            pgnt.RecordCount = 0;
            Rm.PaginationObj = pgnt;

            set996 = (from e in WmsDc.wms_set
                      where e.setid == "996" &&
                      e.isvld == 'y'
                      select e).ToArray();
        }
コード例 #2
0
        protected void CancelUpdate(WMSDcDataContext dc)
        {
            ChangeSet ch = dc.GetChangeSet();

            foreach (Object up in ch.Updates)
            {
                dc.Refresh(RefreshMode.OverwriteCurrentValues, up);
            }
        }
コード例 #3
0
        protected void CancelDeleteAndInsert(WMSDcDataContext dc)
        {
            ChangeSet ch = dc.GetChangeSet();

            foreach (Object ins in ch.Inserts)
            {
                dc.GetTable(ins.GetType()).DeleteOnSubmit(ins);
            }

            foreach (Object del in ch.Deletes)
            {
                dc.GetTable(del.GetType()).InsertOnSubmit(del);
            }
        }
コード例 #4
0
        /// <summary>
        /// 初始化Controller
        /// </summary>
        /// <param name="requestContext"></param>
        private void Init(RequestContext requestContext)
        {
            //0.初始化请求时间
            iElapse    = 0;
            dtReqStart = DateTime.Now;


            //1.初始化变量
            WmsDc = new WMSDcDataContext();
            sLogReqAndRespFile = sLogReqAndResDir + "/" + DateTime.Now.ToString("yyyyMMdd") + ".log";

            //如果随机数不为空,就写入sql日志
            if (!string.IsNullOrEmpty(requestContext.HttpContext.Request["rnd"]))
            {
                sLogSqlFile = sLogSqlDir + "/" + requestContext.HttpContext.Request["rnd"] + ".log";
                WmsDc.Log   = new StreamWriter(msLogSql, Encoding.UTF8);
            }
            options = new TransactionOptions();
            options.IsolationLevel = IsolationLevel.ReadCommitted; //默认为Serializable,这里根据参数来进行调整


            Rm            = new ResultMessage();
            Rm.ResultCode = ResultMessage.RESULTMESSAGE_SUCCESS;
            Rm.ResultDesc = "成功!";

            //2.初始化分页信息
            Pagination pgnt = new Pagination();

            pgnt.PageCount   = 0;
            pgnt.Pageid      = 1;
            pgnt.PageSize    = 20;
            pgnt.RecordCount = 0;
            Rm.PaginationObj = pgnt;

            set996 = (from e in WmsDc.wms_set
                      where e.setid == "996" &&
                      e.isvld == 'y'
                      select e).ToArray();
        }
コード例 #5
0
ファイル: BaseController.cs プロジェクト: firespeed79/WMS-5
        /// <summary>
        /// 初始化Controller
        /// </summary>
        /// <param name="requestContext"></param>
        private void Init(RequestContext requestContext)
        {
            //1.初始化变量
            WmsDc = new WMSDcDataContext();

            Rm            = new ResultMessage();
            Rm.ResultCode = ResultMessage.RESULTMESSAGE_SUCCESS;
            Rm.ResultDesc = "成功!";

            //2.初始化分页信息
            Pagination pgnt = new Pagination();

            pgnt.PageCount   = 0;
            pgnt.Pageid      = 1;
            pgnt.PageSize    = 20;
            pgnt.RecordCount = 0;
            Rm.PaginationObj = pgnt;

            set996 = (from e in WmsDc.wms_set
                      where e.setid == "996" &&
                      e.isvld == 'y'
                      select e).ToArray();
        }
コード例 #6
0
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        //protected virtual void OnResultExecuted(ResultExecutedContext filterContext)
        {
            //得到url
            //得到post params
            //得到返回值
            try
            {
                WMSDcDataContext            wmsdc1     = new WMSDcDataContext();
                string                      sUrl       = filterContext.HttpContext.Request.Url.PathAndQuery;
                string                      sParamters = "?";
                Dictionary <string, object> dicForm    = new Dictionary <string, object>();
                filterContext.HttpContext.Request.Form.CopyTo(dicForm);
                string[] arr = (from e in dicForm
                                select e.Key + "=" + e.Value).ToArray();
                sUrl += "&" + string.Join("&", arr);

                if (!string.IsNullOrEmpty(sLogReqAndRespFile))
                {
                    /*foreach (string s in filterContext.HttpContext.Request.Form.Keys)
                     * {
                     *  sParamters += s + "=" + dicForm[s] + "&";
                     * }*/
                    if (!string.IsNullOrEmpty(sParamters))
                    {
                        JavaScriptSerializer jss   = new JavaScriptSerializer();
                        ResultMessage        rmnew = new ResultMessage();
                        ResultMessage        rmold = (ResultMessage)((JsonResult)filterContext.Result).Data;
                        rmnew.ResultCode = rmold.ResultCode;
                        rmnew.ResultDesc = rmold.ResultDesc;
                        String sResult        = jss.Serialize(rmnew);
                        String sReqTime       = DateTime.Now.ToString("yyyyMMddHHmmss.fff");
                        String sReqResp       = "===============================================\r\n";
                        string sColSplitChars = "||||";
                        sReqResp += sReqTime + sColSplitChars + sUrl + sColSplitChars + sParamters + sColSplitChars + sResult + "\r\n";
                        sReqResp += "===============================================\r\n";
                        //System.IO.File.AppendAllText(sLogReqAndRespFile, sReqResp, Encoding.UTF8);

                        dtReqEnd = DateTime.Now;
                        iElapse  = ((TimeSpan)(dtReqEnd - dtReqStart)).Milliseconds;

                        wms_file_log flog = new wms_file_log();
                        flog.actdat  = sReqTime;
                        flog.fname   = sLogReqAndRespFile;
                        flog.logUsr  = UsrId;
                        flog.elapse  = iElapse;
                        flog.result  = sReqResp;
                        flog.url     = sUrl;
                        flog.@params = sParamters;
                        flog.uptdtm  = DateTime.Now;
                        wmsdc1.wms_file_log.InsertOnSubmit(flog);
                        wmsdc1.SubmitChanges();
                    }
                }


                //得到执行的sql语句,写入随机数文件中
                if (WmsDc.Log != null)
                {
                    WmsDc.Log.Flush();
                    msLogSql.Position = 0;
                    StreamReader sr      = new StreamReader(msLogSql);
                    String       slogSql = sr.ReadToEnd();
                    //System.IO.File.AppendAllText(sLogSqlFile, slogSql, Encoding.UTF8);
                    //WmsDc.Log.Close();

                    wms_file_log flog = new wms_file_log();
                    flog.actdat  = DateTime.Now.ToString("yyyyMMddHHmmss.fff");
                    flog.fname   = sLogSqlFile;
                    flog.logUsr  = UsrId;
                    flog.result  = slogSql;
                    flog.url     = sUrl;
                    flog.@params = sParamters;
                    flog.uptdtm  = DateTime.Now;
                    wmsdc1.wms_file_log.InsertOnSubmit(flog);
                    wmsdc1.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }