public virtual void OnAtawAuthorization(AuthorizationContext filterContext) { //if (filterContext.Controller is AtawBaseController) //{ var b = filterContext.Controller; if (b != null) { if (!GlobalVariable.IsAuthenticated) { if (!GlobalVariable.IsAjax) { string url = SetReturnUrl(GlobalVariable.Context.Server.UrlEncode(GlobalVariable.Context.Request.RawUrl)); filterContext.Result = WebUtil.GetActionResultUrl(url); IsReturn = true; } else { JsResponseResult <string> obj = new JsResponseResult <string>(); obj.Content = "请登录..."; obj.ActionType = JsActionType.Alert; filterContext.Result = new ContentResult() { Content = AtawAppContext.Current.FastJson.ToJSON(obj) }; IsReturn = true; } } } //} }
public ActionResult Error303() { if (GlobalVariable.IsAjax) { JsResponseResult <string> jsRes = new JsResponseResult <string>() { ActionType = JsActionType.Alert }; jsRes.Content = Request.RawUrl + " 未找到"; ContentResult res = new ContentResult(); res.Content = AtawAppContext.Current.FastJson.ToJSON(jsRes); return(res); } string mvcName = "303MVC".AppKv <string>(""); if (!mvcName.IsEmpty()) { var mvc = AtawAppContext.Current.MvcConfigXml.DataRoutes.Where(a => a.Name == mvcName).FirstOrDefault(); if (mvc != null) { return(RedirectToAction(mvc.ActionName, mvc.ControlName, new { area = mvc.AreaName })); } else { return(new ContentResult() { Content = "配置的 303MVC 路由名称貌似没有找到" }); } } return(View("NotFound")); }
public override void ExecuteResult(ControllerContext context) { var response = context.HttpContext.Response; var request = context.HttpContext.Request; ViewData["RequestedUrl"] = GetRequestedUrl(request); ViewData["ReferrerUrl"] = GetReferrerUrl(request, request.Url.OriginalString); response.StatusCode = 404; // Prevent IIS7 from overwriting our error page! response.TrySkipIisCustomErrors = true; var req = context.HttpContext.Request; string mesg = "{1}IP地址:{0}{1}浏览器:{2}({3}){1}网址:{4}{1}".AkFormat(req.UserHostAddress, Environment.NewLine, req.Browser.Type, req.Browser.Browser, req.Url); if (AtawAppContext.Current.Logger != null) { AtawAppContext.Current.Logger.Info(mesg); } if (GlobalVariable.IsAjax) { JsResponseResult <string> jsRes = new JsResponseResult <string>() { ActionType = JsActionType.Alert }; jsRes.Content = req.Url.ToString() + " 未找到"; ContentResult res = new ContentResult(); res.Content = AtawAppContext.Current.FastJson.ToJSON(jsRes); response.Clear(); res.ExecuteResult(context); } else { ViewResult viewResult = null; viewResult = new ViewResult { ViewName = ViewName, ViewData = ViewData }; response.Clear(); viewResult.ExecuteResult(context); } }
public static ActionResult GetActionResultUrl(string url) { if (GlobalVariable.IsAjax) { var jsRes = new JsResponseResult <string>() { ActionType = JsActionType.Url, Content = url }; var result = new ContentResult() { Content = jsRes.ToJSON() }; return(result); } else { return(new RedirectResult(url)); } }
protected string ReturnJsonObject <T>(T res) { JsResponseResult <T> ree = new JsResponseResult <T>() { ActionType = JsActionType.JsonObject, Obj = res }; // ree.SaveString(System.Xml.Formatting.Indented); // string str = JsonConvert.SerializeObject(ree); string str = FastJson(ree); AtawTrace.WriteFile(LogType.JsonData, str); HttpContext.Response.HeaderEncoding = Encoding.UTF8; ree.EndTimer = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.ffff"); ree.BeginTime = AtawAppContext.Current.GetItem("__beginTime").Value <DateTime>().ToString("yyyy/MM/dd HH:mm:ss.ffff"); //HttpContext.Response. return(str); }
protected override void OnException(ExceptionContext filterContext) { var exception = filterContext.Exception; filterContext.ExceptionHandled = true; JsResponseResult <object> ree = null; if (exception is AtawLegalException) { ree = new JsResponseResult <object>() { ActionType = JsActionType.Object, Obj = new LegalPageView() { Error = exception.Message } // Content = }; } else { ree = new JsResponseResult <object>() { ActionType = JsActionType.Alert // Content = }; } StringBuilder sb = new StringBuilder(); SetException(exception, sb, AtawAppContext.Current.ApplicationXml.ExceptionStack); ree.Content = sb.ToString(); AtawTrace.WriteFile(LogType.Error, SetException(exception, new StringBuilder(), true).ToString()); // this.ControllerContext.Controller.Co filterContext.Result = new ContentResult() { Content = FastJson(ree) }; // AtawAppContext.Current.Logger.Debug(string.Format(ObjectUtil.SysCulture, "{0}/r/n{1}", exception.Message, exception.StackTrace)); base.OnException(filterContext); }
public AtawPageConfigView getPageView(string xml, string pageStyle) { string ds = ""; string keyValue = ""; xml = Xml(xml); AtawDebug.AssertNotNullOrEmpty(xml, "亲 ,modulexml 注册名不可以为空的", this); ModuleConfig mc = xml.PlugGet <ModuleConfig>(); if (mc.Mode == ModuleMode.None) { throw new AtawException("ModuleXml的Mode节点不能为空", this); } var tool = GetPageViewTool(mc); tool.BeginModuleInterceptor(ref ds, ref xml, ref pageStyle, ref keyValue, ref mc); mc = xml.SingletonByPage <ModuleConfig>(); if (!AtawBasePageViewCreator.IsSupportPage(mc.SupportPage, pageStyle.Value <PageStyle>())) { JsResponseResult <object> ree = new JsResponseResult <object>() { ActionType = JsActionType.Alert, Content = "无权访问该页面" }; // return null; } AtawBasePageViewCreator pageCreator = (pageStyle + "PageView").PlugGet <AtawBasePageViewCreator>(); // AtawAppContext.Current.FastJson.ToJSON(ds ?? ""); pageCreator.Initialize(mc, ds.SafeJsonObject <DataSet>(), keyValue, "", false); var apcv = pageCreator.Create(); apcv.RegName = xml; return(apcv); }
public string WorkflowProcess(string wid, DataSet PostDataSet) { Workflow.Core.Workflow wf = Workflow.Core.Workflow.CreateWorkflow(context, wid); WorkflowConfig.ConnString = PlugAreaRegistration.CONN; ManualStepConfig config = wf.CurrentStep.Config as ManualStepConfig; AtawDebug.AssertNotNull(config, "调用时机有误,当前的步骤必须是人工步骤,现在不是", this); WorkflowContent content = WorkflowInstUtil.CreateContent(wf.WorkflowRow); if (!string.IsNullOrEmpty(config.Process.UIOperation.RegName)) { UIProcessor processor = AtawIocContext.Current.FetchInstance <UIProcessor>( config.Process.UIOperation.PlugIn); processor.Config = config; processor.Source = context; processor.Content = content; processor.UIData = PostDataSet; processor.Execute(wf.WorkflowRow); WorkflowInstUtil.ManualSendWorkflow(wf.WorkflowRow, GlobalVariable.UserId, processor); } else { wf.WorkflowRow.WI_PROCESS_ID = GlobalVariable.UserId.ToString(); wf.WorkflowRow.WI_PROCESS_DATE = context.Now; wf.WorkflowRow.WI_STATUS = (int)StepState.ProcessNotSend; } //context.Submit(); wf.UpdateState(ManualPNSState.Instance); string url = wf.GetWorkflowUrl(); JsResponseResult <string> res = new JsResponseResult <string>() { ActionType = JsActionType.Url, Content = url }; return(res.ToJSON()); }
public ListPageExcelCreator() { NameValueCollection nvc = (NameValueCollection)AtawAppContext.Current.GetItem("querystring"); string ds = nvc["ds"] ?? ""; string keyValue = nvc["keyvalue"] ?? ""; ModuleXml = nvc["xml"] ?? ""; string xml = ModuleXml; // xml = Xml(xml); string pageStyle = nvc["pageStele"] ?? "List"; xml = Xml(xml); AtawDebug.AssertNotNullOrEmpty(xml, "亲 ,modulexml 注册名不可以为空的", this); ModuleConfig mc = xml.PlugGet <ModuleConfig>(); if (mc.Mode == ModuleMode.None) { throw new AtawException("ModuleXml的Mode节点不能为空", this); } var tool = GetPageViewTool(mc); tool.BeginModuleInterceptor(ref ds, ref xml, ref pageStyle, ref keyValue, ref mc); mc = xml.SingletonByPage <ModuleConfig>(); if (!AtawBasePageViewCreator.IsSupportPage(mc.SupportPage, pageStyle.Value <PageStyle>())) { JsResponseResult <object> ree = new JsResponseResult <object>() { ActionType = JsActionType.Alert, Content = "无权访问该页面" }; // return null; } AtawBasePageViewCreator pageCreator = (pageStyle + "PageView").PlugGet <AtawBasePageViewCreator>(); pageCreator.Initialize(mc, JsonConvert.DeserializeObject <DataSet>(ds ?? ""), keyValue, "", false); var apcv = pageCreator.Create(); apcv.RegName = xml; //清空数据..... mc.Forms.Cast <FormConfig>().ToList().ForEach(a => { string name = a.DataPlug; AtawAppContext.Current.PageFlyweight.Remove <IListDataTable>(a.DataPlug, a.Name); }); var __apcv = apcv as AtawListPageConfigView; string _formName = __apcv.ListFormName; string _tableName = __apcv.Forms[_formName].TableName; this.Table = apcv.Data.Tables[_tableName]; apcv.createFillDataSet(__apcv.ListFormName); this.ColumnList = new List <ColumnItem>(); apcv.Forms[_formName].Columns.ForEach((col) => { if (col.ControlType != ControlType.Hidden) { this.ColumnList.Add(new ColumnItem() { Name = col.Name, Title = col.DisplayName }); } }); this.FileName = __apcv.Title + "列表"; }
public string Module(string ds, string xml, string pageStyle, string keyValue) { try { xml = Xml(xml); AtawDebug.AssertNotNullOrEmpty(xml, "亲 ,modulexml 注册名不可以为空的", this); ModuleConfig mc = xml.SingletonByPage <ModuleConfig>(); if (mc.Mode == ModuleMode.None) { throw new AtawException("ModuleXml的Mode节点不能为空", this); } var tool = GetPageViewTool(mc); tool.BeginModuleInterceptor(ref ds, ref xml, ref pageStyle, ref keyValue, ref mc); //if (!AtawAppContext.Current.IsAuthenticated) //{ // JsResponseResult<object> ree = new JsResponseResult<object>() // { // ActionType = JsActionType.Alert, // Content = "请登录,匿名暂不开放...." // }; // return FastJson(ree); //} mc = xml.SingletonByPage <ModuleConfig>(); if (!AtawBasePageViewCreator.IsSupportPage(mc.SupportPage, pageStyle.Value <PageStyle>())) { JsResponseResult <object> ree = new JsResponseResult <object>() { ActionType = JsActionType.Alert, Content = "无权访问该页面" }; return(FastJson(ree)); } bool isXml2Db = AtawAppContext.Current.ApplicationXml.IsMigration && !mc.IsNoDb; if (isXml2Db && mc.DataBase == null) { mc.Forms.Cast <FormConfig>().ToList().ForEach(a => { var dataForm = a.File.XmlConfig <DataFormConfig>(); AtawAppContext.Current.Xml2Db.Migrations(dataForm); } ); } if (isXml2Db) { AtawTrace.WriteFile(LogType.DatabaseStructure, AtawAppContext.Current.Xml2Db.GetLogMessage()); var dbContext = AtawAppContext.Current.UnitOfData; if (dbContext != null) { AtawAppContext.Current.UnitOfData.Submit(); AtawAppContext.Current.UnitOfData = null; } } AtawBasePageViewCreator pageCreator = (pageStyle + "PageView").SingletonByPage <AtawBasePageViewCreator>(); pageCreator.Initialize(mc, JsonConvert.DeserializeObject <DataSet>(ds ?? ""), keyValue, "", false); var apcv = pageCreator.Create(); apcv.RegName = xml; return(tool.EndModuleInterceptor(apcv)); } catch (Exception ex) { RecoredException(ex); AtawPageConfigView apcv = new AtawPageConfigView(); apcv.Header = new PageHeader(); apcv.Header.IsValid = false; apcv.Header.Message = "<h2>系统出现异常,请跟管理员联系!</h2><p>异常信息是:{0}</p>".AkFormat(ex.Message); return(ReturnJson(apcv)); } //return ReturnJson(apcv); }