/// <summary> /// 构造函数 /// </summary> /// <param name="SiteInfo"></param> /// <param name="ObsInfo"></param> public SiteObsInfo(ISiteInfo SiteInfo, IObsInfo ObsInfo) { this.ObsInfo = ObsInfo; this.SiteInfo = SiteInfo; this.Comments = new List <string>(); this.Comments.Add("This file is created by Gdp. www.gnsser.com"); }
private static void EnsureTask(ISiteInfo site) { var currentServerName = WebFarmHelper.ServerName; var taskServerName = Service.Resolve <IWebFarmService>().GetEnabledServerNames().First(serverName => !currentServerName.Equals(serverName, StringComparison.Ordinal)); TaskInterval interval = new TaskInterval { StartTime = DateTime.Now, Period = SchedulingHelper.PERIOD_ONCE }; var task = new TaskInfo { TaskAssemblyName = "CMS.UIControls", TaskClass = "Samples.DancingGoat.EnableDataProtectionSampleTask", TaskEnabled = true, TaskLastResult = string.Empty, TaskData = string.Empty, TaskDisplayName = "Data protection sample", TaskName = "EnableDataProtectionSampleTask", TaskType = ScheduledTaskTypeEnum.System, TaskInterval = SchedulingHelper.EncodeInterval(interval), TaskNextRunTime = SchedulingHelper.GetFirstRunTime(interval), TaskDeleteAfterLastRun = true, TaskRunInSeparateThread = true, TaskSiteID = site.SiteID, TaskServerName = taskServerName, TaskAvailability = TaskAvailabilityEnum.Administration }; TaskInfo.Provider.Set(task); }
public Runner(ICourses coursesApi, IUsers usersApi, IGroups groupsApi, ISiteInfo siteInfo, IOutput output) { _coursesApi = coursesApi; _usersApi = usersApi; _groupsApi = groupsApi; _siteInfo = siteInfo; _output = output; }
protected BaseAuthenticator(ISiteInfo siteInfo, ICredentials credentials) : this() { Ensure.ArgumentNotNull(nameof(siteInfo), siteInfo); Ensure.ArgumentNotNull(nameof(credentials), credentials); SiteInfo = siteInfo; Credentials = credentials; }
public static bool IsFileSizeAllowed(ISiteInfo siteInfo, int contentLength) { if (!siteInfo.Attributes.ContainsKey("FileUploadTypeMaxSize")) { return(true); } return(contentLength <= Convert.ToInt32(siteInfo.Attributes.GetString("FileUploadTypeMaxSize")) * 1024); }
public static void LoadFromReader(this ISiteInfo site, DbDataReader reader) { site.Id = new Guid(reader["SiteGuid"].ToString()); site.SiteName = reader["SiteName"].ToString(); site.SiteFolderName = reader["SiteFolderName"].ToString(); site.PreferredHostName = reader["PreferredHostName"].ToString(); site.IsServerAdminSite = Convert.ToBoolean(reader["IsServerAdminSite"]); }
/// <summary> /// 追加测站信息 /// </summary> /// <param name="sb"></param> /// <param name="SiteInfo"></param> private void BuildSiteInfo(StringBuilder sb, ISiteInfo SiteInfo) { AppendLine(sb, "接收机编号", SiteInfo.ReceiverNumber); AppendLine(sb, "接收机类型", SiteInfo.ReceiverType); AppendLine(sb, "接收机版本", SiteInfo.ReceiverVersion); AppendLine(sb, "测站标识名称", SiteInfo.SiteName); AppendLine(sb, "测站标识编号", SiteInfo.MarkerNumber); AppendLine(sb, "天线距离测站点偏差HEN", SiteInfo.Hen); AppendLine(sb, "近似坐标", SiteInfo.ApproxXyz); }
/// <summary> /// 构造函数 /// </summary> /// <param name="siteInfo"></param> /// <param name="obsInfo"></param> public StationInfo(ISiteInfo siteInfo, IObsInfo obsInfo) { Init(); this.AntHEN = siteInfo.Hen; this.AntennaType = siteInfo.AntennaType; this.AntennaNumber = siteInfo.AntennaNumber; this.ReceiverNumber = siteInfo.ReceiverNumber; this.ReceiverType = siteInfo.ReceiverType; this.TimePeriod = obsInfo.TimePeriod; this.SiteName = siteInfo.SiteName; this.StationName = siteInfo.SiteName; }
/// <summary> /// 以基本信息初始化 /// </summary> /// <param name="ObsInfo"></param> /// <param name="SiteInfo"></param> public RinexObsFileHeader(IObsInfo ObsInfo, ISiteInfo SiteInfo) : base(SiteInfo, ObsInfo) { this.FileInfo = new FileInfomation { CreationAgence = "Gnsser", CreationDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), CreationProgram = "Gnsser" }; CountryCode = "000"; GlonassSlotFreqNums = new Dictionary <SatelliteNumber, int>(); SystemPhaseShift = new Dictionary <SatelliteNumber, Dictionary <ObservationCode, double> >(); GlonassCodePhaseBias = new Dictionary <ObservationCode, double>(); }
private ConfigurationData() { try { var data = JsonConvert.DeserializeObject <ConfigurationValues>(File.ReadAllText(ConfigurationFilePath)); Credentials = data.Credentials ?? DefaultCredentials; SiteInfo = data.SiteInfo ?? DefaultSiteInfo; } catch (Exception) { Credentials = DefaultCredentials; SiteInfo = DefaultSiteInfo; } }
/// <summary> /// 构造函数 /// </summary> /// <param name="epoch"></param> /// <param name="RefName"></param> /// <param name="RovName"></param> /// <param name="CovaMatrix"></param> /// <param name="stdDev"></param> /// <param name="RovEstmatedXYZCorrection"></param> public EstimatedBaseline(ISiteInfo RefName, ISiteInfo RovName, Time epoch, RmsedXYZ RovEstmatedXYZCorrection, Matrix CovaMatrix, double stdDev) { this.CovaMatrix = CovaMatrix; this.SiteInfoOfRef = RefName; this.SiteInfoOfRov = RovName; this.Epoch = epoch; this.BaseLineName = new GnssBaseLineName(this.SiteInfoOfRov.SiteName, this.SiteInfoOfRef.SiteName); this.ApproxXyzOfRef = RefName.ApproxXyz; this.ApproxXyzOfRov = RovName.ApproxXyz; this.CorrectionOfRov = RovEstmatedXYZCorrection; this.EstimatedVectorRmsedXYZ = new RmsedXYZ(ApproxVector + CorrectionOfRov.Value, CorrectionOfRov.Rms); StdDev = stdDev; ClosureError = 1; }
/// <summary> /// 数据源读取 /// </summary> private static void ReadFiles(GnsserConfig config) { //加载文件数据 observationDataSource = new RinexFileObsDataSource(config.ObsPath); SiteInfo = observationDataSource.SiteInfo; //是否读取星历文件,如果设置了,且存在则读取只 if (File.Exists(config.NavPath)) { ephemerisDataSource = EphemerisDataSourceFactory.Create(config.NavPath); } //是否有精密星历 if (File.Exists(config.ClkPath)) { clockFile = new ClockService(config.ClkPath); } }
private void ExecuteRevokeTrackingConsentTask(ISiteInfo site, ContactInfo contact) { const string TASK_NAME_PREFIX = "DataProtectionSampleRevokeTrackingConsentTask"; string taskName = $"{TASK_NAME_PREFIX}_{contact.ContactID}"; // Do not create same task if already scheduled var scheduledTask = taskInfoProvider.Get(taskName, site.SiteID); if (scheduledTask != null) { return; } var currentServerName = WebFarmHelper.ServerName; var taskServerName = webFarmService.GetEnabledServerNames().First(serverName => !currentServerName.Equals(serverName, StringComparison.Ordinal)); TaskInterval interval = new TaskInterval { StartTime = DateTime.Now, Period = SchedulingHelper.PERIOD_ONCE }; var task = new TaskInfo { TaskAssemblyName = "CMS.UIControls", TaskClass = "Samples.DancingGoat.RevokeTrackingConsentTask", TaskEnabled = true, TaskLastResult = string.Empty, TaskData = contact.ContactID.ToString(), TaskDisplayName = "Data protection sample - Revoke tracking consent", TaskName = taskName, TaskType = ScheduledTaskTypeEnum.System, TaskInterval = SchedulingHelper.EncodeInterval(interval), TaskNextRunTime = SchedulingHelper.GetFirstRunTime(interval), TaskDeleteAfterLastRun = true, TaskRunInSeparateThread = true, TaskSiteID = site.SiteID, TaskServerName = taskServerName, TaskAvailability = TaskAvailabilityEnum.Administration }; taskInfoProvider.Set(task); }
public async Task UpdateSiteInfoAsync(ISiteInfo site) { var dbContext = GetDbContext(); var siteSettingsSet = dbContext.Set <SiteSettings>(); var existing = await Task.FromResult(siteSettingsSet.FirstOrDefault()); existing.BaseUrl = site.BaseUrl; existing.SiteName = site.SiteName; existing.SuperUser = site.SuperUser; existing.HomeRoute = site.HomeRoute; existing.Properties = site.Properties; siteSettingsSet.Update(existing); dbContext.SaveChanges(); _memoryCache.Set(SiteCacheKey, site); _signal.SignalToken(SiteCacheKey); return; }
/// <summary> /// 从 Rinex Header 中创建。 /// </summary> /// <param name="name"></param> /// <param name="h"></param> /// <param name="path"></param> public StaInfoItem(string name, ISiteInfo h, string path) { int recNum = 0; int.TryParse(h.ReceiverNumber, out recNum); int antNum = 0; int.TryParse(h.AntennaNumber, out antNum); MakerName = name; MakerNumber = (h.MarkerNumber == null || h.MarkerNumber == "") ? "" : h.MarkerNumber.ToUpper(); Flag = 1; From = fromDate; To = toDate; OldStaName = name + "*"; Remark = "From " + Path.GetFileName(path); ReceiverType = h.ReceiverType == null ? " " : h.ReceiverType.ToUpper(); AntennaType = h.AntennaType == null ? " " : h.AntennaType.ToUpper().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)[0]; RecNum = recNum > 999999 ? 0 : recNum; AntNum = antNum > 999999 ? 0 : antNum; NEU = CoordTransformer.HenToNeu(h.Hen); Discription = " "; }
private void EnableDataProtectionSamples(ISiteInfo site) { var dataProtectionSamplesEnabledSettingsKey = SettingsKeyInfoProvider.GetSettingsKeyInfo(DATA_PROTECTION_SETTINGS_KEY); if (dataProtectionSamplesEnabledSettingsKey?.KeyValue.ToBoolean(false) ?? false) { return; } var keyInfo = new SettingsKeyInfo { KeyName = DATA_PROTECTION_SETTINGS_KEY, KeyDisplayName = DATA_PROTECTION_SETTINGS_KEY, KeyType = "boolean", KeyValue = "True", KeyDefaultValue = "False", KeyIsGlobal = true, KeyIsHidden = true }; SettingsKeyInfoProvider.SetSettingsKeyInfo(keyInfo); EnsureTask(site); }
/// <summary> /// Gets a list of `SubNav` items under the `Node` passed in. /// </summary> /// <param name="node"></param> /// <returns></returns> public IEnumerable <SubNav> GetSubNavFromAliasPath(string nodeAliasPath, CultureInfo cultureInfo = null, ISiteInfo siteInfo = null) { if (siteInfo == null) { // If site is not provided, get the current site siteInfo = _siteService.CurrentSite; _eventLogService.LogEvent("GetSubNavFromAliasPath", "ExampleService", "GET", "Using current site"); } else { _eventLogService.LogEvent("GetSubNavFromAliasPath", "ExampleService", "GET", "Using passed in site"); } if (cultureInfo == null) { cultureInfo = LocalizationContext.GetCurrentCulture(); _eventLogService.LogEvent("GetSubNavFromAliasPath", "ExampleService", "GET", "Using current culture"); } else { _eventLogService.LogEvent("GetSubNavFromAliasPath", "ExampleService", "GET", "Using passed in culture"); } var subnavList = new List <SubNav>(); try { foreach (ITreeNode Node in DocumentQueryHelper.RepeaterQuery( Path: nodeAliasPath + "/%", CultureCode: cultureInfo.CultureCode, SiteName: siteInfo.SiteName, ClassNames: "CMS.MenuItem", OrderBy: "NodeLevel, NodeOrder", Columns: "MenuItemName,NodeAliasPath" )) { subnavList.Add(new SubNav() { LinkText = Node.GetValue("MenuItemName").ToString(), // You have to decide what your URL will be, for us our URLs = NodeAliasPath LinkUrl = Node.NodeAliasPath }); } } catch (Exception ex) { _eventLogService.LogException("ExampleService", "GET", ex); } return(subnavList); }
public static bool IsFileExtenstionAllowed(ISiteInfo siteInfo, string fileExtention) { var typeCollection = siteInfo.Attributes.GetString("FileUploadTypeCollection", "zip,rar,7z,js,css,txt,doc,docx,ppt,pptx,xls,xlsx,pdf") + "," + siteInfo.Attributes.GetString("ImageUploadTypeCollection", "gif|jpg|jpeg|bmp|png|pneg|swf") + "," + siteInfo.Attributes.GetString("VideoUploadTypeCollection", "asf|asx|avi|flv|mid|midi|mov|mp3|mp4|mpg|mpeg|ogg|ra|rm|rmb|rmvb|rp|rt|smi|swf|wav|webm|wma|wmv|viv"); return(IsFileExtenstionAllowed(typeCollection, fileExtention)); }
/// <summary> /// Constructor. /// </summary> /// <param name="site">Site the form consent will be generated for</param> public FormConsentGenerator(ISiteInfo site) { mSite = site; }
///<summary> ///Authenticate a request using cookies. This should work as long as ///you are already logged into a TargetProcess account. ///</summary> ///<param name="siteInfo">The request to authenticate (Optional/null)</param> ///<param name="credentials">The credentials to attach to the request(Optional/null)</param> ///<remarks> ///See the <a href="https://dev.targetprocess.com/docs/authentication#section-cookie-authentication">Cookie Authentication documentation</a> for more information. ///</remarks> public CookieAuthenticator(ISiteInfo siteInfo, ICredentials credentials) : base(siteInfo, credentials) { }
/// <summary> /// Constructor. /// </summary> /// <param name="site">Site the newsletters data will be generated for</param> public NewslettersDataGenerator(ISiteInfo site) { this.site = site; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, ILogger <Startup> logger, IFormatterService formatter, ISiteInfo siteInfo, IRepository <Post> postRepository, IRepository <Author> authorRepository) { if (_env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } logger.LogInformation($"Settings directory: {siteInfo.BasePath}"); if (!String.IsNullOrWhiteSpace(siteInfo.BasePath)) { app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(Path.Combine(siteInfo.BasePath, "Images")), RequestPath = "/images" }); } logger.LogInformation($"Posts directory: {postRepository.BasePath}"); if (!String.IsNullOrWhiteSpace(postRepository.BasePath)) { app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(postRepository.BasePath), RequestPath = "/posts" }); } logger.LogInformation($"Authors directory: {authorRepository.BasePath}"); if (!String.IsNullOrWhiteSpace(authorRepository.BasePath)) { app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(authorRepository.BasePath), RequestPath = "/authors" }); } app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(_env.WebRootPath), RequestPath = "" }); app.UseCookiePolicy(); app.UseMvc(routes => { routes.MapRoute( name: "tags", template: "Posts/Tag/{tag}/Page/{pageNumber?}/", defaults: new { Controller = "Posts", Action = "Index", tag = "", pageNumber = 1 }); routes.MapRoute( name: "posts", template: "Posts/Page/{pageNumber?}", defaults: new { Controller = "Posts", Action = "Index", pageNumber = 1 }); routes.MapRoute( name: "post", template: "Posts/{id}", defaults: new { Controller = "Posts", Action = "Post" }); routes.MapRoute( name: "default", template: "{controller=Posts}/{action=Index}"); }); }
public HomeController(ILogger <HomeController> logger, IRepositoryContainer repositories, ISiteInfo siteInfo) { _logger = logger; _repositories = repositories; _settings = siteInfo.Settings; }
public AccessTokenAuthenticator(ISiteInfo siteInfo, ICredentials credentials) : base(siteInfo, credentials) { }
/// <summary> /// Constructor. /// </summary> /// <param name="site">Site the form consent will be generated for</param> public FormConsentGenerator(ISiteInfo site, IFormBuilderConfigurationSerializer formBuilderConfigurationSerializer) { mSite = site; mFormBuilderConfigurationSerializer = formBuilderConfigurationSerializer; }
private static bool GatherOneByUrl(ISiteInfo siteInfo, IChannelInfo channelInfo, bool isSaveImage, bool isSetFirstImageAsImageUrl, bool isEmptyContentAllowed, bool isSameTitleAllowed, bool isChecked, string charset, string url, string cookieString, string regexTitleInclude, string regexContentExclude, string contentHtmlClearCollection, string contentHtmlClearTagCollection, string contentReplaceFrom, string contentReplaceTo, string regexTitle, string regexContent, string regexContent2, string regexContent3, string regexNextPage, string regexChannel, IEnumerable <string> contentAttributes, NameValueCollection contentAttributesXml, IDictionary <int, IList <string> > contentTitleDict, ICollection <KeyValuePair <int, int> > channelIdAndContentIdList, IAdministratorInfo adminInfo, out string title, out string errorMessage) { title = string.Empty; errorMessage = string.Empty; try { //TODO:采集文件、链接标题为内容标题、链接提示为内容标题 //string extension = PathUtils.GetExtension(url); //if (!EFileSystemTypeUtils.IsTextEditable(extension)) //{ // if (EFileSystemTypeUtils.IsImageOrFlashOrPlayer(extension)) // { // } //} var tableName = Context.ContentApi.GetTableName(siteInfo.Id, channelInfo.Id); var contentHtml = WebClientUtils.GetRemoteFileSource(url, ECharsetUtils.GetEnumType(charset), cookieString); title = GetContent("title", regexTitle, contentHtml); var content = GetContent("content", regexContent, contentHtml); if (string.IsNullOrEmpty(content) && !string.IsNullOrEmpty(regexContent2)) { content = GetContent("content", regexContent2, contentHtml); } if (string.IsNullOrEmpty(content) && !string.IsNullOrEmpty(regexContent3)) { content = GetContent("content", regexContent3, contentHtml); } //如果标题或内容为空,返回false并退出 if (string.IsNullOrEmpty(title)) { errorMessage = $"无法获取标题:{url}"; return(false); } if (isEmptyContentAllowed == false && string.IsNullOrEmpty(content)) { errorMessage = $"无法获取内容正文:{url}"; return(false); } title = StringUtils.StripTags(title); if (!string.IsNullOrEmpty(regexTitleInclude)) { if (IsMatch(regexTitleInclude, title) == false) { errorMessage = $"标题不符合要求:{url}"; return(false); } } if (!string.IsNullOrEmpty(regexContentExclude)) { content = Replace(regexContentExclude, content, string.Empty); } if (!string.IsNullOrEmpty(contentHtmlClearCollection)) { var htmlClearList = StringCollectionToList(contentHtmlClearCollection); foreach (var htmlClear in htmlClearList) { var clearRegex = $@"<{htmlClear}[^>]*>.*?<\/{htmlClear}>"; content = Replace(clearRegex, content, string.Empty); } } if (!string.IsNullOrEmpty(contentHtmlClearTagCollection)) { var htmlClearTagList = StringCollectionToList(contentHtmlClearTagCollection); foreach (var htmlClearTag in htmlClearTagList) { var clearRegex = $@"<{htmlClearTag}[^>]*>"; content = Replace(clearRegex, content, string.Empty); clearRegex = $@"<\/{htmlClearTag}>"; content = Replace(clearRegex, content, string.Empty); } } if (!string.IsNullOrEmpty(contentReplaceFrom)) { var fromList = TranslateUtils.StringCollectionToStringCollection(contentReplaceFrom); var isMulti = false; if (!string.IsNullOrEmpty(contentReplaceTo) && contentReplaceTo.IndexOf(value: ',') != -1) { if (StringUtils.GetCount(",", contentReplaceTo) + 1 == fromList.Count) { isMulti = true; } } if (isMulti == false) { foreach (var from in fromList) { title = Replace($"({from.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", title, contentReplaceTo); content = Replace($"({from.Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", content, contentReplaceTo); } } else { var tos = TranslateUtils.StringCollectionToStringCollection(contentReplaceTo); for (var i = 0; i < fromList.Count; i++) { title = Replace($"({fromList[i].Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", title, tos[i]); content = Replace($"({fromList[i].Replace(" ", "\\s")})(?!</a>)(?![^><]*>)", content, tos[i]); } } } var contentNextPageUrl = GetUrl(regexNextPage, contentHtml, url); if (!string.IsNullOrEmpty(contentNextPageUrl)) { try { content = GetPageContent(content, charset, contentNextPageUrl, cookieString, regexContentExclude, contentHtmlClearCollection, contentHtmlClearTagCollection, regexContent, regexContent2, regexContent3, regexNextPage); } catch (Exception ex) { errorMessage = ex.Message; return(false); } } var channel = GetContent("channel", regexChannel, contentHtml); var channelId = channelInfo.Id; if (!string.IsNullOrEmpty(channel)) { var channelIdByNodeName = 0; var childChannelIdList = Context.ChannelApi.GetChannelIdList(siteInfo.Id, channelInfo.Id); foreach (var childChannelId in childChannelIdList) { if (channel == Context.ChannelApi.GetChannelName(siteInfo.Id, childChannelId)) { channelIdByNodeName = childChannelId; } } //var channelIdByNodeName = ChannelManager.GetChannelIdByParentIdAndChannelName(siteInfo.Id, channelInfo.Id, channel, recursive: false); if (channelIdByNodeName == 0) { var newChannelInfo = Context.ChannelApi.NewInstance(siteInfo.Id); newChannelInfo.ParentId = channelInfo.Id; newChannelInfo.ChannelName = channel; newChannelInfo.ContentModelPluginId = channelInfo.ContentModelPluginId; channelId = Context.ChannelApi.Insert(siteInfo.Id, newChannelInfo); } else { channelId = channelIdByNodeName; } } if (!isSameTitleAllowed) { if (!contentTitleDict.TryGetValue(channelId, out var contentTitleList)) { var repository = new Repository(Context.Environment.DatabaseType, Context.Environment.ConnectionString, tableName); contentTitleList = repository.GetAll <string>(Q.Select(ContentAttribute.Title) .Where(ContentAttribute.ChannelId, channelId)); } if (contentTitleList.Contains(title)) { errorMessage = $"已包含相同标题:{title}"; return(false); } contentTitleList.Add(title); contentTitleDict[channelId] = contentTitleList; } var contentInfo = Context.ContentApi.NewInstance(siteInfo.Id, channelId); contentInfo.AdminId = adminInfo.Id; contentInfo.AddUserName = adminInfo.UserName; contentInfo.AddDate = DateTime.Now; contentInfo.LastEditUserName = contentInfo.AddUserName; contentInfo.LastEditDate = contentInfo.AddDate; contentInfo.Checked = isChecked; contentInfo.CheckedLevel = 0; contentInfo.Title = title; foreach (var attributeName in contentAttributes) { if (!StringUtils.EqualsIgnoreCase(attributeName, ContentAttribute.Title) && !StringUtils.EqualsIgnoreCase(attributeName, ContentAttribute.Content)) { var normalStart = StringUtils.ValueFromUrl(contentAttributesXml[attributeName + "_ContentStart"]); var normalEnd = StringUtils.ValueFromUrl(contentAttributesXml[attributeName + "_ContentEnd"]); //采集为空时的默认值 var normalDefault = StringUtils.ValueFromUrl(contentAttributesXml[attributeName + "_ContentDefault"]); var regex = GetRegexAttributeName(attributeName, normalStart, normalEnd); var value = GetContent(attributeName, regex, contentHtml); //采集为空时的默认值 if (string.IsNullOrEmpty(value)) { value = normalDefault; } if (ContentAttribute.AllAttributes.Value.Contains(attributeName)) { if (StringUtils.EqualsIgnoreCase(ContentAttribute.AddDate, attributeName)) { contentInfo.AddDate = TranslateUtils.ToDateTime(value, DateTime.Now); } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.IsColor, attributeName)) { contentInfo.Color = TranslateUtils.ToBool(value, defaultValue: false); } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.IsHot, attributeName)) { contentInfo.Hot = TranslateUtils.ToBool(value, defaultValue: false); } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.IsRecommend, attributeName)) { contentInfo.Recommend = TranslateUtils.ToBool(value, defaultValue: false); } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.IsTop, attributeName)) { contentInfo.Top = TranslateUtils.ToBool(value, defaultValue: false); } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.ImageUrl, attributeName)) { if (!string.IsNullOrEmpty(value)) { var attachmentUrl = PageUtils.GetUrlByBaseUrl(value, url); var fileExtension = PageUtils.GetExtensionFromUrl(attachmentUrl); var fileName = $"{StringUtils.GetShortGuid(false)}{fileExtension}"; var filePath = Context.SiteApi.GetUploadFilePath(siteInfo.Id, fileName); Utils.CreateDirectoryIfNotExists(filePath); try { WebClientUtils.SaveRemoteFileToLocal(attachmentUrl, filePath); contentInfo.ImageUrl = Context.SiteApi.GetSiteUrlByFilePath(filePath); } catch { // ignored } } } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.VideoUrl, attributeName)) { if (!string.IsNullOrEmpty(value)) { var attachmentUrl = PageUtils.GetUrlByBaseUrl(value, url); var fileExtension = PageUtils.GetExtensionFromUrl(attachmentUrl); var fileName = $"{StringUtils.GetShortGuid(false)}{fileExtension}"; var filePath = Context.SiteApi.GetUploadFilePath(siteInfo.Id, fileName); Utils.CreateDirectoryIfNotExists(filePath); try { WebClientUtils.SaveRemoteFileToLocal(attachmentUrl, filePath); contentInfo.VideoUrl = Context.SiteApi.GetSiteUrlByFilePath(filePath); } catch { // ignored } } } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.FileUrl, attributeName)) { if (!string.IsNullOrEmpty(value)) { var attachmentUrl = PageUtils.GetUrlByBaseUrl(value, url); var fileExtension = PageUtils.GetExtensionFromUrl(attachmentUrl); var fileName = $"{StringUtils.GetShortGuid(false)}{fileExtension}"; var filePath = Context.SiteApi.GetUploadFilePath(siteInfo.Id, fileName); Utils.CreateDirectoryIfNotExists(filePath); try { WebClientUtils.SaveRemoteFileToLocal(attachmentUrl, filePath); contentInfo.FileUrl = Context.SiteApi.GetSiteUrlByFilePath(filePath); } catch { // ignored } } } else if (StringUtils.EqualsIgnoreCase(ContentAttribute.Hits, attributeName)) { contentInfo.Hits = TranslateUtils.ToInt(value); } else { contentInfo.Set(attributeName, value); } } else { //var styleInfo = TableStyleManager.GetTableStyleInfo(tableName, attributeName, relatedIdentities: null); //value = InputParserUtility.GetContentByTableStyle(value, siteInfo, styleInfo); //if (styleInfo.InputType == InputType.Image || styleInfo.InputType == InputType.Video || styleInfo.InputType == InputType.File) //{ // if (!string.IsNullOrEmpty(value)) // { // var attachmentUrl = PageUtils.GetUrlByBaseUrl(value, url); // var fileExtension = PathUtils.GetExtension(attachmentUrl); // var fileName = $"{StringUtils.GetShortGuid(false)}{fileExtension}"; // var filePath = Context.SiteApi.GetUploadFilePath(siteInfo.Id, fileName); // Utils.CreateDirectoryIfNotExists(filePath); // try // { // WebClientUtils.SaveRemoteFileToLocal(attachmentUrl, filePath); // value = Context.SiteApi.GetSiteUrlByFilePath(filePath); // } // catch // { // // ignored // } // } //} contentInfo.Set(attributeName, value); } } } if (string.IsNullOrEmpty(contentInfo.ImageUrl)) { var firstImageUrl = string.Empty; if (isSaveImage) { var originalImageSrcList = GetOriginalImageSrcList(content); var imageSrcList = GetImageSrcList(url, content); if (originalImageSrcList.Count == imageSrcList.Count) { for (var i = 0; i < originalImageSrcList.Count; i++) { var originalImageSrc = originalImageSrcList[i]; var imageSrc = imageSrcList[i]; var fileExtension = PathUtils.GetExtension(originalImageSrc); var fileName = $"{StringUtils.GetShortGuid(false)}{fileExtension}"; var filePath = Context.SiteApi.GetUploadFilePath(siteInfo.Id, fileName); Utils.CreateDirectoryIfNotExists(filePath); try { WebClientUtils.SaveRemoteFileToLocal(imageSrc, filePath); var fileUrl = Context.SiteApi.GetSiteUrlByFilePath(filePath); content = content.Replace(originalImageSrc, fileUrl); if (firstImageUrl == string.Empty) { firstImageUrl = fileUrl; } } catch { // ignored } } } } else if (isSetFirstImageAsImageUrl) { var imageSrcList = GetImageSrcList(url, content); if (imageSrcList.Count > 0) { firstImageUrl = imageSrcList[index : 0]; } } if (isSetFirstImageAsImageUrl) { contentInfo.ImageUrl = firstImageUrl; } } //contentInfo.Content = StringUtility.TextEditorContentEncode(content, siteInfo, false); contentInfo.Content = content; //contentInfo.SourceId = SourceManager.CaiJi; var theContentId = Context.ContentApi.Insert(siteInfo.Id, channelInfo.Id, contentInfo); channelIdAndContentIdList.Add(new KeyValuePair <int, int>(contentInfo.ChannelId, theContentId)); errorMessage = string.Empty; return(true); } catch (Exception ex) { errorMessage = ex.Message; return(false); } }
private string GetGMTTooltipString(IUserInfo userInfo, ISiteInfo siteInfo) { if (String.IsNullOrEmpty(mGMTTooltip)) { mGMTTooltip = TimeZoneHelper.GetUTCLongStringOffset(userInfo, siteInfo); } return mGMTTooltip; }
/// <summary> /// Checks if Online marketing is enabled, including license check and crawler check. /// </summary> /// <returns>True if online marketing is enabled, license is available and check pro crawlers passed.</returns> private bool CheckEnabled(ISiteInfo site, RequestDependencies requestDependencies) { return(mSettingsService[site.SiteName + ".CMSEnableOnlineMarketing"].ToBoolean(false) && mLicenseService.CheckLicense(FeatureEnum.FullContactManagement, requestDependencies.RequestDomain, false) && !mCrawlerChecker.IsCrawler()); }
/// <summary> /// Constructor. /// </summary> /// <param name="site">Site the data protection sample data will be generated for.</param> public TrackingConsentGenerator(ISiteInfo site) { mSite = site; }
public BasicAuthenticator(ISiteInfo siteInfo, ICredentials credentials) : base(siteInfo, credentials) { }
/// <summary> /// Constructor. /// </summary> /// <param name="site">Site the campaign data will be generated for</param> /// <param name="contactFirstNamePrefix">First name prefix of contacts generated for sample campaigns.</param> public CampaignDataGenerator(ISiteInfo site, string contactFirstNamePrefix) { mSite = site; mContactFirstNamePrefix = contactFirstNamePrefix; }