/// <summary>联系信息</summary> /// <returns></returns> public ActionResult Avatar() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; IMemberInfo member = MembershipManagement.Instance.MemberService[this.Account.Id]; if (member == null) { ApplicationError.Write(404); } ViewBag.member = member; IAccountInfo account = MembershipManagement.Instance.AccountService[member.Account.Id]; string avatar_180x180 = string.Empty; if (string.IsNullOrEmpty(account.CertifiedAvatar)) { avatar_180x180 = MembershipConfigurationView.Instance.AvatarVirtualFolder + "default_180x180.png"; } else { avatar_180x180 = account.CertifiedAvatar.Replace("{avatar}", MembershipConfigurationView.Instance.AvatarVirtualFolder); } ViewBag.avatar_180x180 = avatar_180x180; return(View("/views/main/account/settings/avatar.cshtml")); }
/// <summary>表单内容界面</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[BugConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // ------------------------------------------------------- // 业务数据处理 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); // 文档编辑模式 DocEditMode docEditMode = DocEditMode.Unkown; // 实体数据信息 BugInfo param = null; if (string.IsNullOrEmpty(id)) { param = new BugInfo(); param.Id = DigitalNumberContext.Generate("Table_Bug_Key_Id"); // 设置编辑模式【新建】 docEditMode = DocEditMode.New; } else { param = BugContext.Instance.BugService.FindOne(id); if (param == null) { ApplicationError.Write(404); } // 设置编辑模式【编辑】 docEditMode = DocEditMode.Edit; } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", (string.IsNullOrEmpty(param.Title) ? "新问题" : param.Title), application.ApplicationDisplayName, this.SystemName); // 加载当前业务实体类名称 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; // 加载当前文档编辑模式 ViewBag.docEditMode = docEditMode; return(View("/views/main/bugs/bug-form.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult Setting() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/applications/application-feature-setting.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } ViewBag.searchApplication = AppsContext.Instance.ApplicationService.FindOne("00000000-0000-0000-0000-000000000001"); // 角色 return(View("/views/main/applications/application-feature-list.cshtml")); }
/// <summary>详细内容界面</summary> /// <param name="options"></param> /// <returns></returns> public ActionResult Detail(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[BugConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); // 实体数据编码 string code = !request.Keys.Contains("code") ? string.Empty : request["code"].ToString(); BugInfo param = null; if (!string.IsNullOrEmpty(id)) { param = BugContext.Instance.BugService.FindOne(id); } else if (!string.IsNullOrEmpty(code)) { param = BugContext.Instance.BugService.FindOneByCode(code); } if (param == null) { ApplicationError.Write(404); } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", param.Title, application.ApplicationDisplayName, this.SystemName); // 加载数据表前缀 ViewBag.dataTablePrefix = BugConfigurationView.Instance.DataTablePrefix; // 加载当前业务实体数据 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; // 加载当前用户详细信息 ViewBag.member = MembershipManagement.Instance.MemberService[this.Account.Id]; return(View("/views/main/bugs/bug-detail.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/membership/group-list.cshtml")); }
/// <summary>列表</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[WebConfiguration.APP_NAME_CUSTOMIZES]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/customizes/customize-content-list.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[ForumConfiguration.ApplicationName]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } return(View("/views/main/forum/forum-category-list.cshtml")); }
/// <summary>表单</summary> /// <returns></returns> public ActionResult Form(string options) { // 测试页面 customizes/customize-page/form?id=442049bb-9bb3-49cc-8a30-2454a56c770e // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[WebConfiguration.APP_NAME_CUSTOMIZES]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 业务数据处理 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); CustomizePageInfo param = null; if (string.IsNullOrEmpty(id)) { param = new CustomizePageInfo(); param.Id = param.Name = DigitalNumberContext.Generate("Key_Guid"); param.Html = CustomizeContext.Instance.CustomizeLayoutService.GetHtml("default"); param.CreateDate = param.UpdateDate = DateTime.Now; } else { param = CustomizeContext.Instance.CustomizePageService.FindOne(id); } ViewBag.param = param; return(View("/views/main/customizes/customize-page-form.cshtml")); }
/// <summary>表单</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options); string id = JsonHelper.GetDataValue(request, "id"); ApplicationMenuInfo param = new ApplicationMenuInfo(); if (string.IsNullOrEmpty(id)) { string applicationId = JsonHelper.GetDataValue(request, "applicationId", "00000000-0000-0000-0000-000000000001"); string menuId = JsonHelper.GetDataValue(request, "menuId", "00000000-0000-0000-0000-000000000000"); string menuType = JsonHelper.GetDataValue(request, "menuType", "00000000-0000-0000-0000-000000000000"); param.Id = DigitalNumberContext.Generate("Key_Guid"); param.ApplicationId = applicationId; param.ParentId = menuId; param.MenuType = menuType; param.Status = 1; } else { param = AppsContext.Instance.ApplicationMenuService.FindOne(id); } ViewBag.param = param; return(View("/views/main/applications/application-menu-form.cshtml")); }
/// <summary>环境变量</summary> /// <returns></returns> public ActionResult Variables() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } ViewBag.options = KernelConfigurationView.Instance.Configuration.Keys; return(View("/views/main/sys/variables.cshtml")); }
/// <summary>生成内容</summary> /// <returns></returns> public ActionResult GenerateContent(string options) { JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string name = JsonHelper.GetDataValue(request, "name"); CustomizeContentInfo content = CustomizeContext.Instance.CustomizeContentService.FindOneByName(name); if (content == null) { ApplicationError.Write(404); } ViewBag.output = content.Html; return(View("/views/main/customizes/customize-content-generate-template.cshtml")); }
/// <summary>会话设置</summary> /// <returns></returns> public ActionResult Sessions() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 刷新缓存数据 // ------------------------------------------------------- string reset = Request.QueryString["reset"]; if (reset == "1") { KernelContext.Current.AuthenticationManagement.ResetSessions(); } string removeKey = Request.QueryString["removeKey"]; if (!string.IsNullOrEmpty(removeKey)) { KernelContext.Current.AuthenticationManagement.RemoveSession(removeKey); Response.Redirect("/sys/sessions"); Response.End(); } // ------------------------------------------------------- // 加载数据 // ------------------------------------------------------- StringBuilder outString = new StringBuilder(); IDictionary <string, IAccountInfo> dictionary = ViewBag.dictionary = KernelContext.Current.AuthenticationManagement.GetSessions(); return(View("/views/main/sys/sessions.cshtml")); }
/// <summary>验证码发送日志</summary> /// <returns></returns> public ActionResult VerificationCodeHistory() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } // ------------------------------------------------------- // 加载数据 // ------------------------------------------------------- return(View("/views/main/sys/verification-code-history.cshtml")); }
/// <summary>下载</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public ActionResult Download(string options) { JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); IAttachmentFileInfo param = AttachmentStorageContext.Instance.AttachmentFileService[id]; if (param == null) { KernelContext.Log.Info("file not found id:" + id); ApplicationError.Write(404); } else { if (param != null && param.FileData == null) { KernelContext.Log.Info("file data is null id:" + id); // 下载分布式文件数据 param.FileData = DistributedFileStorage.Download(param); } // [容错] 由于人为原因将服务器上的文件删除。 if (param.FileData == null) { ApplicationError.Write(404); } Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment;filename=" + EncodeFileName(param.AttachmentName)); Response.BinaryWrite(param.FileData); } Response.End(); return(Content(string.Empty)); }
/// <summary>详细内容界面</summary> /// <param name="options"></param> /// <returns></returns> public ActionResult Overview(string options) { JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); string applicationName = JsonHelper.GetDataValue(request, "applicationName", ConnectConfiguration.ApplicationName); // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[applicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); ConnectInfo param = null; if (!string.IsNullOrEmpty(id)) { param = ConnectContext.Instance.ConnectService.FindOne(id); } if (param == null) { ApplicationError.Write(404); } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", param.Name, application.ApplicationDisplayName, this.SystemName); // 加载当前业务实体数据 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; return(View("/views/main/connect/connect-overview.cshtml")); }
/// <summary>提交界面</summary> /// <returns></returns> public ActionResult Form(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[ForumConfiguration.ApplicationName]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); ForumCategoryInfo param = null; if (string.IsNullOrEmpty(id)) { IAccountInfo account = KernelContext.Current.User; param = new ForumCategoryInfo(); param.Id = DigitalNumberContext.Generate("Key_Guid"); param.AccountId = account.Id; param.CreatedDate = param.ModifiedDate = DateTime.Now; } else { param = ForumContext.Instance.ForumCategoryService.FindOne(id); } ViewBag.param = param; return(View("/views/main/forum/forum-category-form.cshtml")); }
/// <summary>好友信息</summary> /// <returns></returns> public ActionResult Detail(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- JsonData request = JsonMapper.ToObject(options); string id = JsonHelper.GetDataValue(request, "id"); IMemberInfo member = MembershipManagement.Instance.MemberService[id]; if (member == null) { ApplicationError.Write(404); } ViewBag.member = member; IAccountInfo account = MembershipManagement.Instance.AccountService[id]; string avatar_120x120 = string.Empty; if (string.IsNullOrEmpty(account.CertifiedAvatar)) { avatar_120x120 = AttachmentStorageConfigurationView.Instance.VirtualUploadFolder + "avatar/default_120x120.png"; } else { avatar_120x120 = account.CertifiedAvatar.Replace("{uploads}", AttachmentStorageConfigurationView.Instance.VirtualUploadFolder); } ViewBag.avatar_120x120 = avatar_120x120; return(View("/views/main/account/friends/account-friend-detail.cshtml")); }
/// <summary>主页</summary> /// <returns></returns> public ActionResult List(string options) { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } JsonData request = JsonMapper.ToObject(options); string treeViewId = !request.Keys.Contains("treeViewId") ? string.Empty : request["treeViewId"].ToString(); ViewBag.tree = MembershipManagement.Instance.CatalogService.FindOne(treeViewId); // 角色 return(View("/views/main/membership/catalog-item-list.cshtml")); }
/// <summary>获取分页内容</summary> /// <param name="doc">Xml 文档对象</param> /// <returns>返回操作结果</returns> public string Download(XmlDocument doc) { this.ProcessRequest(HttpContext.Current); string id = HttpContext.Current.Request.QueryString["id"]; IAttachmentFileInfo param = AttachmentStorageContext.Instance.AttachmentFileService[id]; if (param == null) { ApplicationError.Write(404); } else { if (param != null && param.FileData == null) { // 下载分布式文件数据 param.FileData = DistributedFileStorage.Download(param); } // [容错] 由于人为原因将服务器上的文件删除。 if (param.FileData == null) { ApplicationError.Write(404); } HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + EncodeFileName(param.AttachmentName)); HttpContext.Current.Response.BinaryWrite(param.FileData); } HttpContext.Current.Response.End(); return(string.Empty); }
/// <summary>表单内容界面</summary> /// <returns></returns> public ActionResult Form(string options) { JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); string applicationName = JsonHelper.GetDataValue(request, "applicationName", ConnectConfiguration.ApplicationName); // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[applicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); // ------------------------------------------------------- // 业务数据处理 // ------------------------------------------------------- // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); // 文档编辑模式 DocEditMode docEditMode = DocEditMode.Unkown; // 实体数据信息 ConnectInfo param = null; if (string.IsNullOrEmpty(id)) { param = new ConnectInfo(); param.Id = param.AppKey = DigitalNumberContext.Generate("Key_Guid"); param.AppSecret = Guid.NewGuid().ToString().Substring(0, 8); param.IsInternal = false; // 设置编辑模式【新建】 docEditMode = DocEditMode.New; } else { param = ConnectContext.Instance.ConnectService.FindOne(id); if (param == null) { ApplicationError.Write(404); } // 设置编辑模式【编辑】 docEditMode = DocEditMode.Edit; } // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- ViewBag.Title = string.Format("{0}-{1}-{2}", (string.IsNullOrEmpty(param.Name) ? "新应用" : param.Name), application.ApplicationDisplayName, this.SystemName); // 加载当前业务实体数据 ViewBag.entityClassName = KernelContext.ParseObjectType(param.GetType()); // 加载当前业务实体数据 ViewBag.param = param; // 加载当前文档编辑模式 ViewBag.docEditMode = docEditMode; // 视图 return(View("/views/main/connect/connect-form.cshtml")); }
/// <summary>系统环境</summary> /// <returns></returns> public ActionResult Environment() { // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[APPLICATION_NAME]; // ------------------------------------------------------- // 身份验证 // ------------------------------------------------------- if (!AppsSecurity.IsAdministrator(KernelContext.Current.User, application.ApplicationName)) { ApplicationError.Write(401); } //服务器名称和地址 IPHostEntry server = Dns.GetHostEntry(Dns.GetHostName()); ViewBag.HostName = server.HostName.ToString(); ViewBag.Address = server.AddressList.GetValue(0).ToString(); //操作系统版本信息 ViewBag.OSVersion = System.Environment.OSVersion.ToString(); // .NET Framework 版本号 ViewBag.FrameworkVersion = System.Environment.Version.ToString(); // 系统文件夹目录 ViewBag.SystemDirectory = System.Environment.SystemDirectory; // 系统文件夹目录 ViewBag.ProcessorCount = System.Environment.ProcessorCount; ViewBag.Is64BitOperatingSystem = System.Environment.Is64BitOperatingSystem; //系统已运行时间 int timeCounter = System.Environment.TickCount; timeCounter = timeCounter / 1000; ViewBag.TickTime = ((timeCounter / 3600) % 60).ToString() + "小时" + ((timeCounter / 60) % 60).ToString() + "分钟" + (timeCounter % 60).ToString() + "秒"; // 当前登录的帐号 ViewBag.UserName = System.Environment.UserName; //检测已安装字体 /* * StringBuilder outString = new StringBuilder(); * * InstalledFontCollection fontCollection = new InstalledFontCollection(); * * FontFamily[] fontFamily = fontCollection.Families; * * for (int i = 0; i < fontFamily.Length; i++) * { * switch (fontFamily[i].Name) * { * // Arial | Courier New | Georgia | 宋体 | 黑体 * case "Arial": * outString.Append(" [Arial] "); * break; * case "Courier New": * outString.Append(" [Courier New] "); * break; * case "Georgia": * outString.Append(" [Georgia] "); * break; * case "Trebuchet MS": * outString.Append(" [Trebuchet MS] "); * break; * case "宋体": * outString.Append(" [宋体] "); * break; * case "黑体": * outString.Append(" [黑体] "); * break; * default: * break; * } * } * * ViewBag.FontStyle = outString.ToString(); */ //主机域名 ViewBag.HostName = Request.ServerVariables["HTTP_HOST"]; //端口 ViewBag.ServerPort = Request.ServerVariables["SERVER_PORT"]; //站点文件夹 ViewBag.PhysicalPath = Request.ServerVariables["APPL_PHYSICAL_PATH"]; ViewBag.configuration = KernelConfigurationView.Instance; return(View("~/views/main/sys/environment.cshtml")); }
/// <summary>系统接口文档</summary> /// <returns></returns> public ActionResult Doc() { string applicationName = Request.QueryString["applicationName"]; string methodName = ViewBag.methodName = Request.QueryString["methodName"]; string entityClassName = ViewBag.methodName = Request.QueryString["entityClassName"]; if (!string.IsNullOrEmpty(applicationName)) { ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService.FindOneByApplicationName(applicationName); if (application == null) { ApplicationError.Write(404); } if (string.IsNullOrEmpty(methodName)) { // 查看某个应用下的方法列表 ViewBag.methods = AppsContext.Instance.ApplicationMethodService.FindAllByApplicationName(applicationName).OrderBy(x => x.Id); } else { // 查看某个应用下的某个方法信息 ViewBag.method = AppsContext.Instance.ApplicationMethodService.FindOneByName(methodName); // Create new markdown instance Markdown mark = new Markdown(); // Run parser ViewBag.detail = mark.Transform(ViewBag.method.Detail); } } else if (!string.IsNullOrEmpty(methodName)) { // 查看方法详细信息 ViewBag.method = AppsContext.Instance.ApplicationMethodService.FindOneByName(methodName); ViewBag.application = AppsContext.Instance.ApplicationService.FindOne(ViewBag.method.ApplicationId); // Create new markdown instance Markdown mark = new Markdown(); // Run parser ViewBag.detail = mark.Transform(ViewBag.method.Detail); } else if (!string.IsNullOrEmpty(entityClassName)) { // 查看实体类详细信息 ViewBag.entitySchema = EntitiesManagement.Instance.EntitySchemaService.FindOneByEntityClassName(entityClassName); if (ViewBag.entitySchema != null) { ViewBag.metaDatas = EntitiesManagement.Instance.EntityMetaDataService.FindAllByEntityClassName(entityClassName); } } else { IList <ApplicationInfo> applications = ViewBag.applications = AppsContext.Instance.ApplicationService.FindAll(); VelocityContext context = new VelocityContext(); context.Put("applications", applications); ViewBag.detail = VelocityManager.Instance.Merge(context, "themes/" + WebConfigurationView.Instance.ThemeName + "/layouts/sdk-doc-default-content.vm"); } return(View("/views/main/sdk/doc.cshtml")); }
/// <summary></summary> public override void ProcessRequest(HttpContext context) { string responseText = string.Empty; // 示例: /api/application.method.hi.aspx // 获取客户端签名 clientId 和 clientSecret 或 clientId, clientSignature, timestamp, nonce string clientId = this.TryFetchRequstValue(context, "clientId", "client_id"); string clientSecret = this.TryFetchRequstValue(context, "clientSecret", "client_secret"); string clientSignature = this.TryFetchRequstValue(context, "clientSignature", "client_signature"); string timestamp = context.Request["timestamp"] == null ? string.Empty : context.Request["timestamp"]; string nonce = context.Request["nonce"] == null ? string.Empty : context.Request["nonce"]; string accessToken = this.TryFetchRequstValue(context, "accessToken", "access_token"); string name = context.Request.QueryString["name"]; // 验证权限 bool allowAccess = false; if (!string.IsNullOrEmpty(accessToken) && ConnectContext.Instance.ConnectAccessTokenService.IsExist(accessToken)) { // 验证会话 allowAccess = true; } else if (!string.IsNullOrEmpty(clientId)) { // 2.第三方应用连接 ConnectInfo connect = ConnectContext.Instance.ConnectService[clientId]; if (connect == null) { allowAccess = false; } else { if (!string.IsNullOrEmpty(clientSignature) && !string.IsNullOrEmpty(timestamp) && !string.IsNullOrEmpty(nonce)) { // 加密方式签名 var signature = Encrypter.EncryptSHA1(Encrypter.SortAndConcat(connect.AppSecret, timestamp, nonce)); if (clientSignature == signature) { allowAccess = true; } } else if (!string.IsNullOrEmpty(clientSecret) && connect.AppSecret == clientSecret) { // 明文客户端密钥 allowAccess = true; } else if (name == "connect.auth.authorize" || name == "connect.auth.token" || name == "connect.auth.callback" || name == "connect.oauth2.authorize" || name == "connect.oauth2.token" || name == "connect.oauth2.callback" || name == "session.me") { // 3.如果以上场景都不是,确认是否是用户登录验证的方法 allowAccess = true; } else { allowAccess = false; } } } else if (name == "membership.member.login" || name == "session.me") { // 3.如果以上场景都不是,确认是否是用户登录验证的方法 allowAccess = true; } if (!allowAccess) { ApplicationError.Write(401); } string xml = (context.Request.Form["xhr-xml"] == null) ? string.Empty : context.Request.Form["xhr-xml"]; if (!string.IsNullOrEmpty(name) && (!string.IsNullOrEmpty(xml) || context.Request.QueryString.Count > 1)) { XmlDocument doc = new XmlDocument(); if (string.IsNullOrEmpty(xml)) { doc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<root></root>"); } else { doc.LoadXml(xml); } // 将 QueryString 中,除 xhr-name 外的所有参数转为统一的Xml文档的数据 if (context.Request.QueryString.Count > 1) { for (int i = 0; i < context.Request.QueryString.Count; i++) { if (context.Request.QueryString.Keys[i] == null) { continue; } if (context.Request.QueryString.Keys[i] != "xhr-name") { XmlElement element = CreateXmlElement(doc, context.Request.QueryString.Keys[i]); element.InnerText = context.Request.QueryString[i]; doc.DocumentElement.AppendChild(element); } } } // 将表单中,除 xhr-name 和 xhr-xml 外的所有参数转为统一的Xml文档的数据 if (context.Request.HttpMethod == "POST" && context.Request.Form.Count > 1) { for (int i = 0; i < context.Request.Form.Count; i++) { if (context.Request.Form.Keys[i] == null) { continue; } if (context.Request.Form.Keys[i] != "xhr-name" && context.Request.Form.Keys[i] != "xhr-xml") { XmlElement element = CreateXmlElement(doc, context.Request.Form.Keys[i]); element.InnerText = context.Request.Form[i]; doc.DocumentElement.AppendChild(element); } } } string clientTargetObject = XmlHelper.Fetch("clientTargetObject", doc); string resultType = (context.Request.Form["resultType"] == null) ? "json" : context.Request.Form["resultType"]; // 设置输出的内容类型,默认为 json 格式。 HttpContentTypeHelper.SetValue(resultType); try { // 记录 if (ConnectConfigurationView.Instance.EnableCallLog == "ON") { ConnectCallInfo call = new ConnectCallInfo(clientId, context.Request.RawUrl, doc.InnerXml); try { call.Start(); responseText = X3Platform.Web.APIs.Methods.MethodInvoker.Invoke(name, doc, logger); call.ReturnCode = 0; } catch { call.ReturnCode = 1; throw; } finally { call.Finish(); call.IP = IPQueryContext.GetClientIP(); ConnectContext.Instance.ConnectCallService.Save(call); } } else { responseText = X3Platform.Web.APIs.Methods.MethodInvoker.Invoke(name, doc, logger); } if (resultType == "json" && responseText.IndexOf("\"message\":") > -1 && !string.IsNullOrEmpty(clientTargetObject)) { responseText = responseText.Insert(responseText.IndexOf("\"message\":"), "\"clientTargetObject\":\"" + clientTargetObject + "\","); } } catch (ThreadAbortException threadAbortException) { responseText = "{\"message\":{" + "\"returnCode\":\"2\"," + "\"category\":\"exception\"," + "\"value\":\"" + StringHelper.ToSafeJson(threadAbortException.Message) + "\"," + "\"description\":\"" + StringHelper.ToSafeJson(threadAbortException.ToString()) + "\"" + "}}"; } catch (Exception generalException) { responseText = "{\"message\":{" + "\"returnCode\":\"1\"," + "\"category\":\"exception\"," + "\"value\":\"" + StringHelper.ToSafeJson(generalException.Message) + "\"," + "\"description\":\"" + StringHelper.ToSafeJson(generalException.ToString()) + "\"" + "}}"; } HttpContext.Current.Response.ContentType = HttpContentTypeHelper.GetValue(true); HttpContext.Current.Response.Write(responseText); HttpContext.Current.Response.End(); } }
/// <summary>详细内容界面</summary> /// <param name="options"></param> /// <returns></returns> public ActionResult Detail(string options) { Response.Cache.SetCacheability(HttpCacheability.NoCache); // 所属应用信息 ApplicationInfo application = ViewBag.application = AppsContext.Instance.ApplicationService[ForumConfiguration.ApplicationName]; // 管理员身份标记 bool isAdminToken = ViewBag.isAdminToken = AppsSecurity.IsAdministrator(this.Account, application.ApplicationName); JsonData request = JsonMapper.ToObject(options == null ? "{}" : options); // 实体数据标识 string id = !request.Keys.Contains("id") ? string.Empty : request["id"].ToString(); ForumThreadInfo param = null; if (!string.IsNullOrEmpty(id)) { param = ForumContext.Instance.ForumThreadService.FindOne(id); } // 判断帖子信息是否存在,不存在就提示错误信息 if (param == null) { // 提示信息不存在 ApplicationError.Write(404); } // 是否是发布状态 if (param.Status != 1) { return(Redirect("forum/form?id=" + param.Id)); } // 是否拥有查看帖子的权限 if (!ForumContext.Instance.ForumCategoryService.IsCategoryAuthority(param.CategoryId) && !isAdminToken) { // 提示未经授权 ApplicationError.Write(401); } // 修改浏览量 param.Click++; ForumContext.Instance.ForumThreadService.SetClick(id); // ------------------------------------------------------- // 数据加载 // ------------------------------------------------------- // 设置标题 ViewBag.Title = string.Format("{0} - {1} - {2}", param.Title, application.ApplicationDisplayName, this.SystemName); // 个人信息 ForumMemberInfo member = ForumContext.Instance.ForumMemberService.FindOneByAccountId(this.Account.Id); ViewBag.member = member; string categoryAdminName = param.CategoryAdminName; if (string.IsNullOrEmpty(categoryAdminName)) { categoryAdminName = "网站管理员"; } else { categoryAdminName = categoryAdminName.Substring(0, categoryAdminName.Length - 1); } // 版主名称 ViewBag.categoryAdminName = categoryAdminName; // 是否是版主 bool categoryAdministrator = false; if (isAdminToken == false) { categoryAdministrator = ForumContext.Instance.ForumCategoryService.IsCategoryAdministrator(param.CategoryId); } ViewBag.isAdminToken = isAdminToken; ViewBag.categoryAdministrator = categoryAdministrator; ViewBag.param = param; ViewBag.nowDate = DateTime.Now; // ViewBag.uploadFileWizard= KernelConfigurationView.Instance.UploadFileWizard; // 推荐给某人需要url地址 // string requestUrl = Request.Url.ToString(); // ViewBag.url = requestUrl.Substring(requestUrl.IndexOf("/forum/")); ViewBag.url = Request.Url.PathAndQuery; // 回帖编号 ViewBag.CommentId = DigitalNumberContext.Generate("Key_Guid"); ViewBag.CreatedDate = param.CreatedDate.ToString("yyyy-MM-dd HH:mm"); string dayCountStr = AppsContext.Instance.ApplicationSettingService.GetValue(application.Id, string.Empty, "编辑有效天数").Trim().ToLower(); ViewBag.dayCountStr = dayCountStr; /* * * // 开启企业模式 * string openEnterprise = AppsContext.Instance.ApplicationSettingService.GetValue(application.Id, string.Empty, "开启企业模式").Trim().ToLower(); * // 论坛电梯所需参数 * string showFloor = Request.Params["showFloor"]; * * if (!string.IsNullOrEmpty(showFloor)) * { * int rowIndex = 0; * if (openEnterprise == "on" && info.Id != showFloor) * { * rowIndex = ForumContext.Instance.ForumCommentService.GetEnterpriseRowIndex(info.Id, showFloor, applicationTag); * } * else * { * rowIndex = ForumContext.Instance.ForumCommentService.GetRowIndex(info.Id, showFloor, applicationTag); * } * rowIndex = rowIndex == 0 ? 1 : rowIndex; * int currentPage = (rowIndex / pageSize) + (rowIndex % pageSize > 0 ? 1 : 0); * * context.Put("currentPage", currentPage); * context.Put("showFloor", showFloor); * } */ // 查看页面拷贝 string appsStr1 = AppsContext.Instance.ApplicationSettingService.GetValue(application.Id, string.Empty, "帖子信息禁止拷贝"); string appsStr2 = AppsContext.Instance.ApplicationSettingService.GetValue(application.Id, string.Empty, "管理员拷贝帖子信息"); ViewBag.forbidCopy = appsStr1.Trim().ToLower() == "on" && appsStr2.Trim().ToLower() == "off" ? 1 : 0; return(View("/views/main/forum/forum-thread-detail.cshtml")); }