public async Task <GetResult> Get([FromBody] GetRequest request) { var user = await _authManager.GetUserAsync(); var dynamicInfo = DynamicInfo.GetDynamicInfo(_settingsManager, request.Value, request.Page, user, Request.Path + Request.QueryString); var ifInfo = TranslateUtils.JsonDeserialize <DynamicInfo.IfInfo>(dynamicInfo.ElementValues); var isSuccess = false; var html = string.Empty; if (ifInfo != null) { if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserLoggin)) { isSuccess = _authManager.IsUser; } var template = isSuccess ? dynamicInfo.SuccessTemplate : dynamicInfo.FailureTemplate; html = await StlDynamic.ParseDynamicContentAsync(_parseManager, dynamicInfo, template); } return(new GetResult { Value = isSuccess, Html = html }); }
public async Task <ActionResult <Options> > Get([FromQuery] SiteRequest request) { var siteIds = await _authManager.GetSiteIdsAsync(); if (!ListUtils.Contains(siteIds, request.SiteId)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(this.Error("无法确定内容对应的站点")); } var options = TranslateUtils.JsonDeserialize(site.Get <string>($"Home.{nameof(LayerImageUploadController)}"), new Options { IsEditor = true, IsThumb = false, ThumbWidth = 1024, ThumbHeight = 1024, IsLinkToOriginal = true }); return(options); }
public static void LoadSites(TreeInfo oldTreeInfo, List <int> siteIdList, List <string> tableNameListForContent, List <string> tableNameListForGovPublic, List <string> tableNameListForGovInteract, List <string> tableNameListForJob) { foreach (string oldSiteTableName in TableSite.OldTableNames) { var siteMetadataFilePath = oldTreeInfo.GetTableMetadataFilePath(oldSiteTableName); if (FileUtils.IsFileExists(siteMetadataFilePath)) { var siteTableInfo = TranslateUtils.JsonDeserialize <TableInfo>(FileUtils.ReadText(siteMetadataFilePath, Encoding.UTF8)); foreach (var fileName in siteTableInfo.RowFiles) { var filePath = oldTreeInfo.GetTableContentFilePath(oldSiteTableName, fileName); var rows = TranslateUtils.JsonDeserialize <List <JObject> >(FileUtils.ReadText(filePath, Encoding.UTF8)); foreach (var row in rows) { var dict = TranslateUtils.ToDictionaryIgnoreCase(row); if (dict.ContainsKey(nameof(TableSite.PublishmentSystemId))) { var value = Convert.ToInt32(dict[nameof(TableSite.PublishmentSystemId)]); if (value > 0 && !siteIdList.Contains(value)) { siteIdList.Add(value); } } if (dict.ContainsKey(nameof(TableSite.AuxiliaryTableForContent))) { var value = Convert.ToString(dict[nameof(TableSite.AuxiliaryTableForContent)]); if (!string.IsNullOrEmpty(value) && !tableNameListForContent.Contains(value)) { tableNameListForContent.Add(value); } } if (dict.ContainsKey(nameof(TableSite.AuxiliaryTableForGovInteract))) { var value = Convert.ToString(dict[nameof(TableSite.AuxiliaryTableForGovInteract)]); if (!string.IsNullOrEmpty(value) && !tableNameListForGovInteract.Contains(value)) { tableNameListForGovInteract.Add(value); } } if (dict.ContainsKey(nameof(TableSite.AuxiliaryTableForGovPublic))) { var value = Convert.ToString(dict[nameof(TableSite.AuxiliaryTableForGovPublic)]); if (!string.IsNullOrEmpty(value) && !tableNameListForGovPublic.Contains(value)) { tableNameListForGovPublic.Add(value); } } if (dict.ContainsKey(nameof(TableSite.AuxiliaryTableForJob))) { var value = Convert.ToString(dict[nameof(TableSite.AuxiliaryTableForJob)]); if (!string.IsNullOrEmpty(value) && !tableNameListForJob.Contains(value)) { tableNameListForJob.Add(value); } } } } } } }
public async Task <ActionResult <DeleteResult> > Delete([FromBody] DeleteRequest request) { if (!await _authManager.HasAppPermissionsAsync(Types.AppPermissions.SettingsUsersStyle)) { return(Unauthorized()); } await _tableStyleRepository.DeleteAsync(_userRepository.TableName, 0, request.AttributeName); var allAttributes = _userRepository.TableColumns.Select(x => x.AttributeName).ToList(); var styles = new List <InputStyle>(); foreach (var style in await _tableStyleRepository.GetUserStylesAsync()) { styles.Add(new InputStyle { Id = style.Id, AttributeName = style.AttributeName, DisplayName = style.DisplayName, InputType = style.InputType, Rules = TranslateUtils.JsonDeserialize <List <InputStyleRule> >(style.RuleValues), Taxis = style.Taxis, IsSystem = ListUtils.ContainsIgnoreCase(allAttributes, style.AttributeName) }); } return(new DeleteResult { Styles = styles }); }
public async Task <ActionResult <Options> > Get([FromQuery] SiteRequest request) { var options = new Options(); if (request.SiteId > 0) { var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(this.Error("无法确定内容对应的站点")); } options = TranslateUtils.JsonDeserialize(site.Get <string>(nameof(LayerImageUploadController)), new Options { IsEditor = true, IsMaterial = true, IsThumb = false, ThumbWidth = 1024, ThumbHeight = 1024, IsLinkToOriginal = true }); } return(options); }
public async Task ImportAsync(int siteId, string filePath, bool overwrite) { var json = await FileUtils.ReadTextAsync(filePath); var rule = TranslateUtils.JsonDeserialize <Rule>(json); if (rule != null) { rule.SiteId = siteId; rule.CreatedDate = DateTime.Now; rule.LastModifiedDate = DateTime.Now; rule.LastGatherDate = null; var srcRule = await _ruleRepository.GetByRuleNameAsync(siteId, rule.RuleName); if (srcRule != null) { if (overwrite) { await _ruleRepository.DeleteAsync(srcRule.Id); } else { rule.RuleName = await _ruleRepository.GetImportRuleNameAsync(siteId, rule.RuleName); } } await _ruleRepository.InsertAsync(rule); } }
public static void LoadContentTableNameList(TreeInfo oldTreeInfo, string oldSiteTableName, List <string> contentTableNameList) { var siteMetadataFilePath = oldTreeInfo.GetTableMetadataFilePath(oldSiteTableName); if (FileUtils.IsFileExists(siteMetadataFilePath)) { var siteTableInfo = TranslateUtils.JsonDeserialize <TableInfo>(FileUtils.ReadText(siteMetadataFilePath, Encoding.UTF8)); foreach (var fileName in siteTableInfo.RowFiles) { var filePath = oldTreeInfo.GetTableContentFilePath(oldSiteTableName, fileName); var rows = TranslateUtils.JsonDeserialize <List <JObject> >(FileUtils.ReadText(filePath, Encoding.UTF8)); foreach (var row in rows) { var dict = TranslateUtils.JsonGetDictionaryIgnorecase(row); object obj; if (dict.TryGetValue("AuxiliaryTableForContent", out obj)) { if (obj != null && !contentTableNameList.Contains(obj.ToString())) { contentTableNameList.Add(obj.ToString()); } } if (dict.TryGetValue("AuxiliaryTableForGovInteract", out obj)) { if (obj != null && !contentTableNameList.Contains(obj.ToString())) { contentTableNameList.Add(obj.ToString()); } } if (dict.TryGetValue("AuxiliaryTableForGovPublic", out obj)) { if (obj != null && !contentTableNameList.Contains(obj.ToString())) { contentTableNameList.Add(obj.ToString()); } } if (dict.TryGetValue("AuxiliaryTableForJob", out obj)) { if (obj != null && !contentTableNameList.Contains(obj.ToString())) { contentTableNameList.Add(obj.ToString()); } } if (dict.TryGetValue("AuxiliaryTableForVote", out obj)) { if (obj != null && !contentTableNameList.Contains(obj.ToString())) { contentTableNameList.Add(obj.ToString()); } } } } } }
public FileResult CaptchaGet([FromQuery] string token) { var captcha = TranslateUtils.JsonDeserialize <CaptchaUtils.Captcha>(_settingsManager.Decrypt(token)); var bytes = CaptchaUtils.GetCaptcha(captcha.Value); return(File(bytes, "image/png")); }
public FileResult Get([FromRoute] string value) { var info = TranslateUtils.JsonDeserialize <CaptchaUtils.Captcha>(_settingsManager.Decrypt(value)); var bytes = CaptchaUtils.GetCaptcha(info.Value); return(File(bytes, "image/png")); }
public IHttpActionResult Main() { try { var request = new AuthenticatedRequest(); var dynamicInfo = DynamicInfo.GetDynamicInfo(request, request.UserInfo); var ifInfo = TranslateUtils.JsonDeserialize <DynamicInfo.IfInfo>(dynamicInfo.ElementValues); var isSuccess = false; var html = string.Empty; if (ifInfo != null) { if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserLoggin)) { isSuccess = request.IsUserLoggin; } else if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsAdministratorLoggin)) { isSuccess = request.IsAdminLoggin; } else if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserOrAdministratorLoggin)) { isSuccess = request.IsUserLoggin || request.IsAdminLoggin; } else if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserGroup)) { if (request.IsUserLoggin) { var group = UserGroupManager.GetUserGroupInfo(request.UserInfo.GroupId); if (StringUtils.EqualsIgnoreCase(ifInfo.Op, StlIf.OperateNotEquals)) { isSuccess = !StringUtils.EqualsIgnoreCase(group.GroupName, ifInfo.Value); } else { isSuccess = StringUtils.EqualsIgnoreCase(group.GroupName, ifInfo.Value); } } } var template = isSuccess ? dynamicInfo.SuccessTemplate : dynamicInfo.FailureTemplate; html = StlDynamic.ParseDynamicContent(dynamicInfo, template); } return(Ok(new { Value = isSuccess, Html = html })); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task PullMenuAsync(string accessTokenOrAppId, int siteId) { var result = CommonApi.GetMenu(accessTokenOrAppId); if (result == null) { return; } await _wxMenuRepository.DeleteAllAsync(siteId); var json = result.menu.button.ToJson(); var buttons = TranslateUtils.JsonDeserialize <List <MenuFull_RootButton> >(json); var firstTaxis = 1; foreach (var button in buttons) { var first = new WxMenu { SiteId = siteId, ParentId = 0, Taxis = firstTaxis++, Text = button.name, MenuType = TranslateUtils.ToEnum(button.type, WxMenuType.View), Key = button.key, Url = button.url, AppId = button.appid, PagePath = button.pagepath, MediaId = button.media_id }; var menuId = await _wxMenuRepository.InsertAsync(first); if (button.sub_button != null && button.sub_button.Count > 0) { var childTaxis = 1; foreach (var sub in button.sub_button) { var child = new WxMenu { SiteId = siteId, ParentId = menuId, Taxis = childTaxis++, Text = sub.name, MenuType = TranslateUtils.ToEnum(sub.type, WxMenuType.View), Key = sub.key, Url = sub.url, AppId = sub.appid, PagePath = sub.pagepath, MediaId = sub.media_id }; await _wxMenuRepository.InsertAsync(child); } } } }
public InputStyle(TableStyle style) { Id = style.Id; AttributeName = style.AttributeName; DisplayName = style.DisplayName; HelpText = style.HelpText; InputType = style.InputType; Rules = TranslateUtils.JsonDeserialize <List <InputStyleRule> >(style.RuleValues); Items = style.Items; Taxis = style.Taxis; DefaultValue = style.DefaultValue; }
public async Task <ActionResult <List <SubmitResult> > > Submit([FromBody] SubmitRequest request) { var siteIds = await _authManager.GetSiteIdsAsync(); if (!ListUtils.Contains(siteIds, request.SiteId)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(this.Error("无法确定内容对应的站点")); } var result = new List <SubmitResult>(); foreach (var filePath in request.FilePaths) { if (string.IsNullOrEmpty(filePath)) { continue; } var fileName = PathUtils.GetFileName(filePath); var virtualUrl = await _pathManager.GetVirtualUrlByPhysicalPathAsync(site, filePath); var fileUrl = await _pathManager.ParseSiteUrlAsync(site, virtualUrl, true); result.Add(new SubmitResult { FileUrl = fileUrl, FileVirtualUrl = virtualUrl }); } var options = TranslateUtils.JsonDeserialize(site.Get <string>($"Home.{nameof(LayerFileUploadController)}"), new Options { IsChangeFileName = true }); options.IsChangeFileName = request.IsChangeFileName; site.Set($"Home.{nameof(LayerFileUploadController)}", TranslateUtils.JsonSerialize(options)); await _siteRepository.UpdateAsync(site); return(result); }
public async Task <ActionResult <GetResult> > Get([FromQuery] GetRequest request) { var relatedIdentities = ListUtils.GetIntList(request.RelatedIdentities); var style = await _tableStyleRepository.GetTableStyleAsync(request.TableName, request.AttributeName, relatedIdentities); var options = ListUtils.GetEnums <ValidateType>().Select(validateType => new Select <string>(validateType.GetValue(), validateType.GetDisplayName())); return(new GetResult { Options = options, Rules = TranslateUtils.JsonDeserialize <IEnumerable <InputStyleRule> >(style.RuleValues) }); }
private TemplateInfo GetTemplateInfo(string templatesDirectoryPath, string name) { TemplateInfo templateInfo = null; var configPath = PathUtils.Combine(templatesDirectoryPath, name, "config.json"); if (FileUtils.IsFileExists(configPath)) { templateInfo = TranslateUtils.JsonDeserialize <TemplateInfo>(FileUtils.ReadText(configPath)); templateInfo.Name = name; } return(templateInfo); }
public void Load(string json) { if (string.IsNullOrEmpty(json)) { return; } if (json.StartsWith("{") && json.EndsWith("}")) { var dict = TranslateUtils.JsonDeserialize <Dictionary <string, object> >(json); foreach (var key in dict.Keys) { _dataDict[key] = dict[key]; } } else { json = json.Replace("/u0026", "&"); var attributes = new NameValueCollection(); var pairs = json.Split('&'); foreach (var pair in pairs) { if (pair.IndexOf("=", StringComparison.Ordinal) == -1) { continue; } var name = pair.Split('=')[0]; if (string.IsNullOrEmpty(name)) { continue; } name = name.Replace("_equals_", "=").Replace("_and_", "&").Replace("_question_", "?").Replace("_quote_", "'").Replace("_add_", "+").Replace("_return_", "\r").Replace("_newline_", "\n"); var value = pair.Split('=')[1]; if (!string.IsNullOrEmpty(value)) { value = value.Replace("_equals_", "=").Replace("_and_", "&").Replace("_question_", "?").Replace("_quote_", "'").Replace("_add_", "+").Replace("_return_", "\r").Replace("_newline_", "\n"); } attributes.Add(name.ToLower(), value); } foreach (string key in attributes.Keys) { Set(key, attributes[key]); } } }
protected KeyValuePair <string, TableInfo> GetNewTableInfo(string oldTableName, TableInfo oldTableInfo, string newTableName, List <TableColumn> newColumns, Dictionary <string, string> convertKeyDict, Dictionary <string, string> convertValueDict) { if (string.IsNullOrEmpty(newTableName)) { newTableName = oldTableName; } if (newColumns == null || newColumns.Count == 0) { newColumns = oldTableInfo.Columns; } var newTableInfo = new TableInfo { Columns = newColumns, TotalCount = oldTableInfo.TotalCount, RowFiles = oldTableInfo.RowFiles }; CliUtils.PrintRow(oldTableName, newTableName, oldTableInfo.TotalCount.ToString("#,0")); var i = 0; using (var progress = new ProgressBar()) { foreach (var fileName in oldTableInfo.RowFiles) { progress.Report((double)i++ / oldTableInfo.RowFiles.Count); var oldFilePath = OldTreeInfo.GetTableContentFilePath(oldTableName, fileName); var newFilePath = NewTreeInfo.GetTableContentFilePath(newTableName, fileName); if (convertKeyDict != null) { var oldRows = TranslateUtils.JsonDeserialize <List <JObject> >(FileUtils.ReadText(oldFilePath, Encoding.UTF8)); var newRows = UpdateUtils.UpdateRows(oldRows, convertKeyDict, convertValueDict); FileUtils.WriteText(newFilePath, Encoding.UTF8, TranslateUtils.JsonSerialize(newRows)); } else { FileUtils.CopyFile(oldFilePath, newFilePath); } } } return(new KeyValuePair <string, TableInfo>(newTableName, newTableInfo)); }
public void Page_Load(object sender, EventArgs e) { var json = @"{ ""columns"": [ { ""attributeName"": ""IsAbolition"", ""dataType"": ""VarChar"", ""dataLength"": 10, ""isPrimaryKey"": false, ""isIdentity"": false, ""inputStyle"": { ""inputType"": ""Radio"", ""displayName"": ""是否废止"", ""helpText"": null, ""listItems"": [ { ""text"": ""是"", ""value"": ""True"", ""selected"": false }, { ""text"": ""否"", ""value"": ""False"", ""selected"": true } ], ""defaultValue"": null, ""isRequired"": true, ""validateType"": null, ""minNum"": 0, ""maxNum"": 0, ""regExp"": null, ""width"": null, ""height"": null } } ], ""totalCount"": 796, ""rowFiles"": [ ""1.json"", ""2.json"" ] }"; var tableInfo = TranslateUtils.JsonDeserialize <MyTableInfo>(json); LtlContent.Text = ""; }
public static async Task UpdateSitesSplitTableNameAsync(IDatabaseManager databaseManager, TreeInfo newTreeInfo, Dictionary <int, TableInfo> splitSiteTableDict) { var siteMetadataFilePath = newTreeInfo.GetTableMetadataFilePath(databaseManager.SiteRepository.TableName); if (FileUtils.IsFileExists(siteMetadataFilePath)) { var siteTableInfo = TranslateUtils.JsonDeserialize <TableInfo>(FileUtils.ReadText(siteMetadataFilePath, Encoding.UTF8)); foreach (var fileName in siteTableInfo.RowFiles) { var filePath = newTreeInfo.GetTableContentFilePath(databaseManager.SiteRepository.TableName, fileName); var oldRows = TranslateUtils.JsonDeserialize <List <JObject> >(FileUtils.ReadText(filePath, Encoding.UTF8)); var newRows = new List <Dictionary <string, object> >(); foreach (var row in oldRows) { var dict = TranslateUtils.ToDictionaryIgnoreCase(row); if (dict.ContainsKey(nameof(Site.Id))) { //var siteId = Convert.ToInt32(dict[nameof(Site.Id)]); dict[nameof(Site.TableName)] = await databaseManager.ContentRepository.GetNewContentTableNameAsync(); } newRows.Add(dict); } await FileUtils.WriteTextAsync(filePath, TranslateUtils.JsonSerialize(newRows)); } } //foreach (var siteId in splitSiteTableDict.Keys) //{ // var siteTableInfo = splitSiteTableDict[siteId]; // var siteTableName = UpdateUtils.GetSplitContentTableName(siteId); // siteTableInfo.Columns //} //var tableFilePath = newTreeInfo.GetTableMetadataFilePath(DataProvider.TableDao.TableName); //if (FileUtils.IsFileExists(tableFilePath)) //{ // var siteTableInfo = TranslateUtils.JsonDeserialize<TableInfo>(FileUtils.ReadText(tableFilePath, Encoding.UTF8)); // var filePath = newTreeInfo.GetTableContentFilePath(DataProvider.SiteRepository.TableName, siteTableInfo.RowFiles[siteTableInfo.RowFiles.Count]); // var tableInfoList = TranslateUtils.JsonDeserialize<List<CMS.Model.TableInfo>>(FileUtils.ReadText(filePath, Encoding.UTF8)); // await FileUtils.WriteTextAsync(filePath, Encoding.UTF8, TranslateUtils.JsonSerialize(tableInfoList)); //} }
private async Task <List <TableStyle> > GetAllAsync(string tableName) { var styles = await _repository.GetAllAsync(Q .Where(nameof(TableStyle.TableName), tableName) .OrderByDesc(nameof(TableStyle.Taxis), nameof(TableStyle.Id)) .CachingGet(GetCacheKey(tableName)) ); foreach (var style in styles) { style.Items = TranslateUtils.JsonDeserialize <List <InputStyleItem> >(style.ItemValues); style.Rules = TranslateUtils.JsonDeserialize <List <InputStyleRule> >(style.RuleValues); } return(styles); }
public static Dynamic GetDynamicInfo(ISettingsManager settingsManager, string value, int page, User user, string pathAndQuery) { var dynamicInfo = TranslateUtils.JsonDeserialize <Dynamic>(settingsManager.Decrypt(value)); if (dynamicInfo.ChannelId == 0) { dynamicInfo.ChannelId = dynamicInfo.SiteId; } dynamicInfo.User = user; dynamicInfo.QueryString = PageUtils.GetQueryStringFilterSqlAndXss(pathAndQuery); dynamicInfo.QueryString.Remove("siteId"); dynamicInfo.Page = page; return(dynamicInfo); }
public T GetPostObject <T>(string name = "") { string json; if (string.IsNullOrEmpty(name)) { var bodyStream = new StreamReader(HttpRequest.InputStream); bodyStream.BaseStream.Seek(0, SeekOrigin.Begin); json = bodyStream.ReadToEnd(); } else { json = GetPostString(name); } return(TranslateUtils.JsonDeserialize <T>(json)); }
public static DynamicInfo GetDynamicInfo(IAuthenticatedRequest request, UserInfo userInfo) { var dynamicInfo = TranslateUtils.JsonDeserialize <DynamicInfo>(TranslateUtils.DecryptStringBySecretKey(request.GetPostString("value"))); if (dynamicInfo.ChannelId == 0) { dynamicInfo.ChannelId = dynamicInfo.SiteId; } dynamicInfo.UserInfo = userInfo; dynamicInfo.QueryString = PageUtils.GetQueryStringFilterXss(PageUtils.UrlDecode(HttpContext.Current.Request.RawUrl)); dynamicInfo.QueryString.Remove("siteId"); dynamicInfo.Page = request.GetPostInt("page"); return(dynamicInfo); }
public async Task <ActionResult <Options> > Get([FromQuery] SiteRequest request) { var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(this.Error("无法确定内容对应的站点")); } var options = TranslateUtils.JsonDeserialize(site.Get <string>(nameof(LayerFileUploadController)), new Options { IsChangeFileName = true, IsLibrary = true, }); return(options); }
public string GetValue(TableStyle style, Comment comment) { var value = string.Empty; if (comment.ContainsKey(style.AttributeName)) { var fieldValue = comment.Get <string>(style.AttributeName); if (style.InputType == InputType.CheckBox || style.InputType == InputType.SelectMultiple) { var list = TranslateUtils.JsonDeserialize <List <string> >(fieldValue); if (list != null) { value = string.Join(",", list); } } else if (style.InputType == InputType.Date) { if (!string.IsNullOrEmpty(fieldValue)) { var date = CommentUtils.ToDateTime(fieldValue, DateTime.MinValue); if (date != DateTime.MinValue) { value = date.ToString("yyyy-MM-dd"); } } } else if (style.InputType == InputType.DateTime) { if (!string.IsNullOrEmpty(fieldValue)) { var date = CommentUtils.ToDateTime(fieldValue, DateTime.MinValue); if (date != DateTime.MinValue) { value = date.ToString("yyyy-MM-dd HH:mm"); } } } else { value = fieldValue; } } return(value); }
public ActionResult <BoolResult> CaptchaCheck([FromBody] CheckRequest request) { var captcha = TranslateUtils.JsonDeserialize <CaptchaUtils.Captcha>(_settingsManager.Decrypt(request.Token)); if (captcha == null || string.IsNullOrEmpty(captcha.Value) || captcha.ExpireAt < DateTime.Now) { return(this.Error("验证码已超时,请点击刷新验证码!")); } if (!StringUtils.EqualsIgnoreCase(captcha.Value, request.Value)) { return(this.Error("验证码不正确,请重新输入!")); } return(new BoolResult { Value = true }); }
public static ConfigInfo LoadConfigByFile(string configFileName) { ConfigInfo configInfo = null; if (string.IsNullOrEmpty(configFileName)) { configFileName = "cli.json"; } if (FileUtils.IsFileExists(PathUtils.Combine(PhysicalApplicationPath, configFileName))) { configInfo = TranslateUtils.JsonDeserialize <ConfigInfo>( FileUtils.ReadText(PathUtils.Combine(PhysicalApplicationPath, configFileName), Encoding.UTF8)); if (configInfo != null) { WebConfigUtils.Load(PhysicalApplicationPath, configInfo.DatabaseType, configInfo.ConnectionString); if (configInfo.BackupConfig == null) { configInfo.BackupConfig = new BackupConfigInfo(); } if (configInfo.RestoreConfig == null) { configInfo.RestoreConfig = new RestoreConfigInfo(); } } } else if (FileUtils.IsFileExists(PathUtils.Combine(PhysicalApplicationPath, "web.config"))) { WebConfigUtils.Load(PhysicalApplicationPath, "web.config"); configInfo = new ConfigInfo { DatabaseType = WebConfigUtils.DatabaseType.Value, ConnectionString = WebConfigUtils.ConnectionString, BackupConfig = new BackupConfigInfo(), RestoreConfig = new RestoreConfigInfo(), }; } return(configInfo); }
public async Task <ActionResult <Options> > Get([FromQuery] SiteRequest request) { var siteIds = await _authManager.GetSiteIdsAsync(); if (!ListUtils.Contains(siteIds, request.SiteId)) { return(Unauthorized()); } var site = await _siteRepository.GetAsync(request.SiteId); if (site == null) { return(this.Error("无法确定内容对应的站点")); } var options = TranslateUtils.JsonDeserialize(site.Get <string>($"Home.{nameof(LayerVideoUploadController)}"), new Options { IsChangeFileName = true }); return(options); }
public static void Execute(string[] args) { if (!CliUtils.ParseArgs(Options, args)) { return; } if (_isHelp) { return; } var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Console.WriteLine($"SiteServer CLI Version: {version.Substring(0, version.Length - 2)}"); Console.WriteLine($"Work Directory: {CliUtils.PhysicalApplicationPath}"); Console.WriteLine(); var content = FileUtils.ReadText(PathUtils.Combine(CliUtils.PhysicalApplicationPath, "_metadata.json"), Encoding.UTF8); var table = TranslateUtils.JsonDeserialize <TableInfo>(content); Console.WriteLine($"_metadata: {TranslateUtils.JsonSerialize(table.Columns)}"); }
public void Load(string json) { if (string.IsNullOrEmpty(json)) { return; } if (json.StartsWith("{") && json.EndsWith("}")) { var dict = TranslateUtils.JsonDeserialize <Dictionary <string, object> >(json); foreach (var key in dict.Keys) { _dataDict[key] = dict[key]; } } else { var nameValues = Utils.ToNameValueCollection(json); foreach (string key in nameValues.Keys) { Set(key, nameValues[key]); } } }