public bool Connect(bool createDefaultSession = false) { try { var appList = GetApps(); var appIdentifier = appList.Where(c => c.AppId == AppId.ToString()).SingleOrDefault() ?? null; if (appIdentifier == null) { appIdentifier = appList.Where(c => c.AppName == AppName).SingleOrDefault(); } Identifier = appIdentifier ?? throw new Exception($"No App with the id {AppId.ToString()} oder name {AppName} found."); if (createDefaultSession) { GetDefaultSession(); } else { GetFreeSession(); } return(true); } catch (Exception ex) { if (IsServerConnection) { logger.Error(ex, $"The connection to Qlik Sense Server with app \"{AppId}\" could not be established."); } else { logger.Error(ex, $"The connection to Qlik Sense Desktop with app \"{AppName}\" could not be established."); } return(false); } }
//我要提问 public ActionResult RaiseQuestion() { string strAppId = AppId.ToString(); string QUserId = ViewBag.WeChatUserID; if (string.IsNullOrEmpty(QUserId)) { return(Redirect("/notauthed.html")); } if (string.IsNullOrEmpty(strAppId) || !int.TryParse(strAppId, out AppId)) { return(Redirect("/notauthed.html")); } int appId = int.Parse(strAppId); //记录用户行为 ExecuteBehavior(appId, 7, "SERVICE_ONLINE"); QuestionManageView ResultViewModel = new QuestionManageView(); var lst = _objService.GetListByQUserId <QuestionManageView>(appId, QUserId, null); if (lst != null) { ResultViewModel.List = lst; } else { ResultViewModel.List = new List <QuestionManageView>(); } ViewBag.appid = AppId; return(View("../QuestionManage/RaiseQuestion", ResultViewModel)); }
public string GetStreamName(string streamName) { Guard.NotNullOrEmpty(streamName, nameof(streamName)); if (streamName.StartsWith("app-", StringComparison.OrdinalIgnoreCase)) { return(appStream ??= $"app-{AppId}"); } return(streamName.Replace(PreviousAppId.ToString(), AppId.ToString())); }
public async Task <IActionResult> GetMonthlyCalls(string app) { var count = await usageTracker.GetMonthlyCallsAsync(AppId.ToString(), DateTime.Today); var plan = appPlanProvider.GetPlanForApp(App); var response = new CurrentCallsDto { Count = count, MaxAllowed = plan.MaxApiCalls }; return(Ok(response)); }
public void New_AppId_Should_Be_An_Int() { // Arrange int id = 1234; // Act AppId appId = new AppId(id); // Assert Assert.Equal(1234, appId); Assert.Equal("1234", appId.ToString()); }
public Process Idle() { if (InIdle) { return(idleProcess); } idleProcess = Process.Start(new ProcessStartInfo("steam-idle.exe", AppId.ToString()) { WindowStyle = ProcessWindowStyle.Hidden }); return(idleProcess); }
public async Task <IActionResult> GetUsages(string app, DateTime fromDate, DateTime toDate) { if (fromDate > toDate && (toDate - fromDate).TotalDays > 100) { return(BadRequest()); } var entities = await usageTracker.QueryAsync(AppId.ToString(), fromDate.Date, toDate.Date); var response = entities.ToDictionary(x => x.Key, x => x.Value.Select(CallsUsageDto.FromUsage).ToArray()); return(Ok(response)); }
private ActionResult ExportToCsv(List <ArticleInfoView> wechatFollowReportList) { string[] headLine = { "Id", "ArticleTitle", "APPName", "ArticleCateName", "ReadCount", "ThumbsUpCount", "PublishDate" }; var csv = new CsvSerializer <ArticleInfoView> { UseLineNumbers = false }; var sRet = csv.SerializeStream(wechatFollowReportList, headLine); var channelConfig = CommonService.GetAppList().FirstOrDefault(x => x.WeixinAppId.Equals(AppId.ToString(CultureInfo.InvariantCulture))); string fileHeadName = channelConfig == null?AppId.ToString(CultureInfo.InvariantCulture) : channelConfig.AppName; string fileName = fileHeadName + "_Article_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".csv"; return(File(sRet, "text/comma-separated-values", fileName)); }
public async Task <IActionResult> GetUsages(string app, DateTime fromDate, DateTime toDate) { if (fromDate > toDate && (toDate - fromDate).TotalDays > 100) { return(BadRequest()); } var(summary, details) = await usageTracker.QueryAsync(AppId.ToString(), fromDate.Date, toDate.Date); var(plan, _) = appPlansProvider.GetPlanForApp(App); var response = CallsUsageDtoDto.FromStats(plan, summary, details); return(Ok(response)); }
private void LoadFromKey(RegistryKey key) { LocalService = key.GetValue("LocalService") as string; RunAs = key.GetValue("RunAs") as string; string name = key.GetValue(null) as string; if (!String.IsNullOrWhiteSpace(name)) { Name = name.ToString(); } else { Name = AppId.ToString("B"); } m_access = key.GetValue("AccessPermission") as byte[]; m_launch = key.GetValue("LaunchPermission") as byte[]; DllSurrogate = key.GetValue("DllSurrogate") as string; if (DllSurrogate != null) { if (String.IsNullOrWhiteSpace(DllSurrogate)) { DllSurrogate = "dllhost.exe"; } else { string dllexe = key.GetValue("DllSurrogateExecutable") as string; if (!String.IsNullOrWhiteSpace(dllexe)) { DllSurrogate = dllexe; } } } if (String.IsNullOrWhiteSpace(RunAs) && !String.IsNullOrWhiteSpace(LocalService)) { using (RegistryKey serviceKey = Registry.LocalMachine.OpenSubKey("System\\CurrentControlSet\\" + LocalService)) { if (serviceKey != null) { RunAs = serviceKey.GetValue("ObjectName") as string; } } } }
public async Task InstallAsync() { try { if (AppId <= 0) { return; } var installationsRegistry = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32) .OpenSubKey(Global.Uplay.InstallationsRegistryPath) ?? RegistryKey .OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64) .OpenSubKey(Global.Uplay.InstallationsRegistryPath); using (var registry = installationsRegistry) { using (var appRegistry = registry?.OpenSubKey(AppId.ToString(), RegistryKeyPermissionCheck.ReadWriteSubTree)) { if (appRegistry?.GetValue("InstallDir") != null) { appRegistry.SetValue("InstallDir", !InstallationDirectory.FullName.EndsWith(Path.DirectorySeparatorChar.ToString()) ? string.Join("", InstallationDirectory.FullName, Path.DirectorySeparatorChar).Replace(Path.DirectorySeparatorChar, '/') : InstallationDirectory.FullName.Replace(Path.DirectorySeparatorChar, '/')); } } } } catch (UnauthorizedAccessException ex) { await Main.FormAccessor.AppView.AppPanel.Dispatcher.Invoke(async delegate { await Main.FormAccessor.ShowMessageAsync( Functions.SLM.Translate(nameof(Properties.Resources.Uplay_UnauthorizedAccessExceptionTitle)), Framework.StringFormat.Format( Functions.SLM.Translate(nameof(Properties.Resources.Uplay_UnauthorizedAccessExceptionMessage)), new { AppName, ExceptionMessage = ex.Message })).ConfigureAwait(true); }, System.Windows.Threading.DispatcherPriority.Normal).ConfigureAwait(true); Logger.Fatal(ex); } catch (Exception ex) { Logger.Fatal(ex); } }
private static SendResult SendCCP(string url, string[] message, string receivers, AppId appId, string templateId, string signature) { NameValueCollection collection = new NameValueCollection(); int index = 0; message.ForEach(p => { collection.Add("ArrMessage[" + index + "]", p); index++; }); collection.Add("Receivers", receivers); collection.Add("Signature", signature); collection.Add("TemplateId", templateId); collection.Add("AppId", appId.ToString()); string json = HttpUtility.PostHtml(url, collection, Encoding.UTF8); var serializer = new JavaScriptSerializer(); return(serializer.Deserialize <SendResult>(json)); }
/// <summary> /// 导出报表 /// </summary> /// <param name="appid"></param> /// <param name="BeginDate"></param> /// <param name="EndDate"></param> /// <returns></returns> public ActionResult MpExportCSV(string appid, DateTime?BeginDate, DateTime?EndDate) { DateTime thisEnd = DateTime.Now; DateTime thisStart = DateTime.Now.AddDays(-30); List <MemberInCountWithSubscribe> list = new List <MemberInCountWithSubscribe>(); try { if (BeginDate != null && EndDate != null) { thisStart = (DateTime)BeginDate; thisEnd = (DateTime)EndDate; } list = GetAllMemberCountVisible(AppId.ToString()); List <DateData> listDateData = new List <DateData>(); if (list != null) { while (thisStart <= thisEnd) { DateData dateData = new DateData(); dateData.dateTime = thisStart.ToString("yyyy-MM-dd"); dateData.SubNum = list.Where(x => System.Convert.ToDateTime(x.SubscribeTime).ToString("yyyy-MM-dd") == thisStart.ToString("yyyy-MM-dd")).Count(); listDateData.Add(dateData); thisStart = thisStart.AddDays(1); } } return(mpExportToCSV(listDateData)); } catch (Exception e) { _Logger.Error(e, "An error occurred while sending news."); //throw; return(Json(new { results = new { Data = 500 } })); } }
/// <summary> /// Sets property values /// </summary> /// <param name="context"></param> /// <param name="collection"></param> public override void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection collection) { string username = (string)context["UserName"]; bool userIsAuthenticated = (bool)context["IsAuthenticated"]; if (username == null || username.Length < 1 || collection.Count < 1) { return; } NpgsqlConnection conn = null; NpgsqlDataReader reader = null; NpgsqlCommand cmd = null; try { bool anyItemsToSave = false; // First make sure we have at least one item to save foreach (SettingsPropertyValue pp in collection) { if (pp.IsDirty) { if (!userIsAuthenticated) { bool allowAnonymous = (bool)pp.Property.Attributes["AllowAnonymous"]; if (!allowAnonymous) { continue; } } anyItemsToSave = true; break; } } if (!anyItemsToSave) { return; } conn = new NpgsqlConnection(_NpgsqlConnectionString); conn.Open(); List <ProfileColumnData> columnData = new List <ProfileColumnData>(collection.Count); foreach (SettingsPropertyValue pp in collection) { if (!userIsAuthenticated) { bool allowAnonymous = (bool)pp.Property.Attributes["AllowAnonymous"]; if (!allowAnonymous) { continue; } } //Normal logic for original SQL provider //if (!pp.IsDirty && pp.UsingDefaultValue) // Not fetched from DB and not written to //Can eliminate unnecessary updates since we are using a table though if (!pp.IsDirty) { continue; } string persistenceData = pp.Property.Attributes["CustomProviderData"] as string; // If we can't find the table/column info we will ignore this data if (String.IsNullOrEmpty(persistenceData)) { continue; } string[] chunk = persistenceData.Split(new char[] { ';' }); if (chunk.Length != 2) { continue; } string columnName = chunk[0]; NpgsqlDbType datatype = (NpgsqlDbType)Enum.Parse(typeof(NpgsqlDbType), chunk[1], true); object value = null; if (pp.Deserialized && pp.PropertyValue == null) { // is value null? value = DBNull.Value; } else { value = pp.PropertyValue; } columnData.Add(new ProfileColumnData(columnName, pp, value, datatype)); } // Figure out userid, if we don't find a userid, go ahead and create a user in the aspnetUsers table Guid userId = Guid.Empty; string tmpUserId = null; cmd = new NpgsqlCommand( string.Format( "SELECT u.UserId FROM vw_aspnet_Users u WHERE u.ApplicationId = '{0}' AND u.LoweredUserName = LOWER(@Username)", AppId), conn); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@Username", NpgsqlDbType.Text, 255).Value = username; try { reader = cmd.ExecuteReader(); if (reader.Read()) { tmpUserId = reader.GetString(0); if (!string.IsNullOrEmpty(tmpUserId)) // != null && tmpUserId != "") { userId = new Guid(tmpUserId); } else { userId = Guid.NewGuid(); } } else { reader.Close(); cmd.Dispose(); reader = null; cmd = new NpgsqlCommand( " INSERT INTO aspnet_Users (ApplicationId, UserId, UserName, LoweredUserName, IsAnonymous, LastActivityDate) " + " VALUES (@ApplicationId, @UserId, @UserName, LOWER(@UserName), @IsUserAnonymous, @LastActivityDate) ", conn); userId = Guid.NewGuid(); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@UserId", NpgsqlDbType.Text, 36).Value = userId.ToString(); cmd.Parameters.Add("@ApplicationId", NpgsqlDbType.Text, 36).Value = AppId.ToString(); cmd.Parameters.Add("@UserName", NpgsqlDbType.Text, 255).Value = username; cmd.Parameters.Add("@IsUserAnonymous", NpgsqlDbType.Boolean).Value = !userIsAuthenticated; cmd.Parameters.Add("@LastActivityDate", NpgsqlDbType.Timestamp).Value = DateTime.UtcNow; cmd.ExecuteBlind(); } } finally { if (reader != null) { reader.Close(); reader = null; } cmd.Dispose(); } // Figure out if the row already exists in the table and use appropriate SELECT/UPDATE cmd = new NpgsqlCommand("SELECT * FROM " + _table + " WHERE UserId = @UserId", conn); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@UserId", NpgsqlDbType.Text, 36).Value = userId.ToString(); NpgsqlDataReader readerSelect = null; bool IfExists = false; try { using (readerSelect = cmd.ExecuteReader(CommandBehavior.SingleRow)) { if (readerSelect.HasRows) { // IF EXISTS (SELECT * FROM aspnet_users WHERE UserId = '') IfExists = true; } else { IfExists = false; } readerSelect.Close(); } } catch (NpgsqlException) { } finally { if (readerSelect != null) { readerSelect.Close(); } } cmd = new NpgsqlCommand(String.Empty, conn); StringBuilder NpgsqlCommand = new StringBuilder(); // Build up strings used in the query StringBuilder columnStr = new StringBuilder(); StringBuilder valueStr = new StringBuilder(); StringBuilder setStr = new StringBuilder(); int count = 0; foreach (ProfileColumnData data in columnData) { columnStr.Append(", "); valueStr.Append(", "); columnStr.Append(data.ColumnName); string valueParam = "@Value" + count; valueStr.Append(valueParam); cmd.Parameters.Add(valueParam, data.Value); if (data.DataType != NpgsqlDbType.Timestamp) { if (count > 0) { setStr.Append(","); } setStr.Append(data.ColumnName); setStr.Append("="); setStr.Append(valueParam); } ++count; } columnStr.Append(",LastUpdatedDate "); valueStr.Append(",@LastUpdatedDate"); setStr.Append(",LastUpdatedDate=@LastUpdatedDate"); cmd.Parameters.Add("@LastUpdatedDate", NpgsqlDbType.Timestamp).Value = DateTime.UtcNow; if (setStr.ToString().StartsWith(",")) { setStr.Remove(0, 1); } if (IfExists) { NpgsqlCommand.Append("UPDATE ").Append(_table).Append(" SET ").Append(setStr.ToString()); NpgsqlCommand.Append(" WHERE UserId = '").Append(userId).Append("'"); } else { NpgsqlCommand.Append("INSERT INTO ").Append(_table).Append(" (UserId").Append(columnStr.ToString()); NpgsqlCommand.Append(") VALUES ('").Append(userId).Append("'").Append(valueStr.ToString()).Append(")"); } cmd.CommandText = NpgsqlCommand.ToString(); cmd.CommandType = CommandType.Text; cmd.ExecuteBlind(); // Need to close reader before we try to update if (reader != null) { reader.Close(); reader = null; } UpdateLastActivityDate(conn, userId); } finally { if (reader != null) { reader.Close(); } if (cmd != null) { cmd.Dispose(); } if (conn != null) { conn.Close(); } } }
protected void ProcessView() { EditItemControl = (ItemForm)LoadControl(System.IO.Path.Combine(TemplateSourceDirectory, "SexyContent/EAV/Controls/ItemForm.ascx")); EditItemControl.DefaultCultureDimension = DefaultLanguageID != 0 ? DefaultLanguageID : new int?(); EditItemControl.IsDialog = false; EditItemControl.HideNavigationButtons = true; EditItemControl.PreventRedirect = true; EditItemControl.AttributeSetId = AttributeSetID; EditItemControl.AssignmentObjectTypeId = AssignmentObjectTypeId; EditItemControl.KeyNumber = KeyNumber; EditItemControl.KeyGuid = KeyGuid; EditItemControl.ZoneId = ZoneId; EditItemControl.ReturnUrl = ""; EditItemControl.AppId = AppId; EditItemControl.AddClientScriptAndCss = false; EditItemControl.ItemHistoryUrl = ""; EditItemControl.PreventRedirect = Request.QueryString["PreventRedirect"] == "true"; var newItemUrl = EditUrl(this.TabID, SexyContent.ControlKeys.EditContentGroup, true, new string[] { }); EditItemControl.NewItemUrl = newItemUrl + (newItemUrl.Contains("?") ? "&" : "?") + "AppID=" + AppId.ToString() + "&mid=" + ModuleID.ToString() + "&AttributeSetId=[AttributeSetId]&EditMode=New&CultureDimension=" + this.LanguageID; // If ContentGroupItem has Entity, edit that; else create new Entity if (EntityId.HasValue) { EditItemControl.Updated += EditItem_OnEdited; EditItemControl.EntityId = EntityId.Value; EditItemControl.InitForm(FormViewMode.Edit); hlkHistory.Visible = true; hlkHistory.NavigateUrl = EditUrl("", "", SexyContent.ControlKeys.EavManagement, new string[] { "AppID", AppId.ToString(), "ManagementMode", "ItemHistory", "EntityId", EntityId.Value.ToString(), "mid", ModuleID.ToString() }); } // Create a new Entity else { EditItemControl.Inserted += NewItem_OnInserted; EditItemControl.Visible = true; EditItemControl.InitForm(FormViewMode.Insert); } phNewOrEditItem.Controls.Add(EditItemControl); }
/// <summary> /// CSV文件出力 /// </summary> /// <param name="title">新闻标题</param> /// <param name="pulishDate">发布时间</param> /// <param name="categoryId">标签ID</param> /// <returns></returns> public ActionResult ExportCSV(string title, string pulishDate, string categoryId) { Expression <Func <ArticleInfo, bool> > predicate; if ((CategoryType)AppId == CategoryType.Undefined) { predicate = x => x.IsDeleted == false; } else { predicate = x => x.AppId == AppId && x.IsDeleted == false; } if (!string.IsNullOrEmpty(title)) { title = title.Trim().ToLower(); predicate = predicate.AndAlso(a => a.ArticleTitle.ToLower().Contains(title)); } if (!string.IsNullOrEmpty(pulishDate)) { DateTime condDate = Convert.ToDateTime(pulishDate); DateTime condDateEnd = condDate.AddDays(1); predicate = predicate.AndAlso(x => x.PublishDate >= condDate && x.PublishDate <= condDateEnd); } if (!string.IsNullOrEmpty(categoryId)) { // ID变更为CategoryCode var cateInfo = CommonService.lstCategory.FirstOrDefault(a => a.Id == Convert.ToInt32(categoryId) && a.IsDeleted == false); string categoryCode = cateInfo == null ? string.Empty : cateInfo.CategoryCode; predicate = predicate.AndAlso(a => a.ArticleCateSub == categoryCode); } //过滤掉isadmin的数据 var codes = (from item in CommonService.GetCategory(false).Where(a => !a.IsAdmin.Value).ToList() select item.CategoryCode).ToList(); predicate = predicate.AndAlso(a => codes.Contains(a.ArticleCateSub) && !string.IsNullOrEmpty(a.ArticleCateSub)); // APP列表 var appInfo = CommonService.lstSysWeChatConfig.FirstOrDefault(a => a.WeixinAppId == AppId.ToString()); List <ArticleInfoView> reportList = _articleInfoService.GetList <ArticleInfoView>(predicate).OrderByDescending(x => x.Id).ToList(); var ids = reportList.Select(x => x.Id).ToList(); var lst = _articleThumbsUpService.Repository.Entities.Where(x => ids.Contains(x.ArticleID) && x.IsDeleted != true && x.Type == ThumbupType.Article.ToString()).Select(x => x.ArticleID).ToList(); reportList.ForEach(x => { x.ThumbsUpCount = lst.Count(z => z == x.Id); }); if (appInfo != null) { reportList.ForEach(item => { item.APPName = appInfo.AppName; }); } return(ExportToCsv(reportList)); }
/// <summary> /// CSV文件出力 /// </summary> /// <param name="title">新闻标题</param> /// <param name="pulishDate">发布时间</param> /// <param name="predicate"></param> /// <returns></returns> public ActionResult ExportCSV(string title, string pulishDate, Expression <Func <MessageText, bool> > predicate) { if (!string.IsNullOrEmpty(title)) { predicate = predicate.AndAlso(x => x.Content.Contains(title)); } if (!string.IsNullOrEmpty(pulishDate)) { DateTime condDate = Convert.ToDateTime(pulishDate); DateTime condDateEnd = condDate.AddDays(1); predicate = predicate.AndAlso(x => x.PublishDate >= condDate && x.PublishDate <= condDateEnd); } // APP列表 var appInfo = CommonService.lstSysWeChatConfig.FirstOrDefault(a => a.WeixinAppId == AppId.ToString(CultureInfo.InvariantCulture)); List <MessageTextView> reportList = _messageTextService.GetList <MessageTextView>(predicate).OrderByDescending(x => x.Id).ToList(); var ids = reportList.Select(x => x.Id).ToList(); if (appInfo != null) { foreach (MessageTextView item in reportList) { item.AppName = appInfo.AppName; } } return(ExportToCsv(reportList)); }
public void Initialize() { LoadFunctions(); if (Engine.Configuration.DebugMode) { // If in debug mode, create app id file if missing. if (!File.Exists("steam_appid.txt")) { File.WriteAllText("steam_appid.txt", AppId.ToString()); } } else { // If not in debug mode, delete app id file. if (File.Exists("steam_appid.txt")) { File.Delete("steam_appid.txt"); } } Engine.Log.Info($"Initializing Steam plugin - app id is {AppId}", LOG_SOURCE); // Check if we should restart. bool necessary = SteamNative.RestartAppIfNecessary(AppId); if (necessary) { Engine.Log.Warning("Steam API said we should restart.", LOG_SOURCE); Engine.Quit(); } bool steamOpen = SteamNative.IsSteamRunning(); if (!steamOpen) { Engine.Log.Warning("Steam is not running.", LOG_SOURCE); Engine.Quit(); } try { bool initialized = SteamNative.Init(); if (!initialized) { Engine.Log.Warning("Steam didn't initialize.", LOG_SOURCE); Engine.Quit(); } } catch (Exception ex) { Engine.Log.Error($"Error while initializing Steam - {ex}.", LOG_SOURCE); Engine.Quit(); } // Initialize Steam modules. _steamClient = SteamNative.GetSteamClient(); _steamPipe = SteamNative.GetSteamPipe(); _steamUser = SteamNative.GetSteamUser(); _steamUtils = SteamNative.GetSteamUtils(_steamClient, _steamPipe, Constants.STEAMUTILS_INTERFACE_VERSION); _steamUserStats = SteamNative.GetSteamUserStats(_steamClient, _steamUser, _steamPipe, Constants.STEAMUSERSTATS_INTERFACE_VERSION); // Attach warning callback. SteamNative.SetWarningMessageHook(_steamUtils, _warningHook); bool statsReceived = SteamNative.RequestStats(_steamUserStats); if (!statsReceived) { Engine.Log.Warning("User is not logged in to Steam.", LOG_SOURCE); } SteamNative.RunCallbacks(); Engine.CoroutineManager.StartCoroutine(UpdateRoutine()); }
/// <summary> /// After the Update button is clicked, updates the template or creates a new one, /// depending if in edit mode or not. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnUpdate_Click(object sender, EventArgs e) { var attributeSetId = ctrContentType.ContentTypeID.HasValue && ctrContentType.ContentTypeID > 0 ? ctrContentType.ContentTypeID.Value : new int?(); // Get a new template if the temlpate does not exist yet, else take existing Template = ModeIsEdit ? Template : Sexy.TemplateContext.GetNewTemplate(AppId.Value); Template.PortalID = this.PortalId; Template.AttributeSetID = attributeSetId; Template.DemoEntityID = ctrContentType.DemoEntityID; Template.Location = ddlTemplateLocations.SelectedValue; Template.Type = ddlTemplateTypes.SelectedValue; Template.PipelineEntityID = ddlDataPipeline.SelectedValue == "0" ? (int?)null : int.Parse(ddlDataPipeline.SelectedValue); Template.ViewNameInUrl = txtViewNameInUrl.Text; Template.SysModifiedBy = UserId; Template.SysModified = DateTime.Now; Template.Name = txtTemplateName.Text; Template.Script = ""; Template.IsHidden = chkHidden.Checked; Template.UseForList = chkEnableList.Checked; Template.AppID = AppId.Value; Template.PublishData = chkPublishSource.Checked; Template.StreamsToPublish = txtPublishStreams.Text; if (pnlSelectTemplateFile.Visible) { Template.Path = ddlTemplateFiles.SelectedValue; } else { SexyUncached.CreateTemplateFileIfNotExists(txtTemplateFileName.Text, Template, Server, LocalizeString("NewTemplateFile.DefaultText")); } if (ModeIsEdit) { SexyUncached.TemplateContext.UpdateTemplate(Template); } else { Template.SysCreatedBy = UserId; SexyUncached.TemplateContext.AddTemplate(Template); } if (!chkSeparateContentPresentation.Checked) { ctrPresentationType.ContentTypeID = new int?(); } // Add template configuration entities for presentation, list header content type, list content, etc. SexyUncached.CreateOrUpdateTemplateDefault(Template.TemplateID, ContentGroupItemType.Presentation.ToString("F"), ctrPresentationType.ContentTypeID, ctrPresentationType.DemoEntityID); SexyUncached.CreateOrUpdateTemplateDefault(Template.TemplateID, ContentGroupItemType.ListContent.ToString("F"), ctrListContentType.ContentTypeID, ctrListContentType.DemoEntityID); SexyUncached.CreateOrUpdateTemplateDefault(Template.TemplateID, ContentGroupItemType.ListPresentation.ToString("F"), ctrListPresentationType.ContentTypeID, ctrListPresentationType.DemoEntityID); // Redirect to the manage templates control string RedirectUrl = UrlUtils.PopUpUrl(DotNetNuke.Common.Globals.NavigateURL(SexyContent.ControlKeys.ManageTemplates, "mid", ModuleId.ToString(), SexyContent.AppIDString, AppId.ToString()), this, PortalSettings, false, true); Response.Redirect(RedirectUrl); }
/// <summary> /// CSV文件出力 /// </summary> /// <param name="title">新闻标题</param> /// <param name="pulishDate">发布时间</param> /// <returns></returns> public ActionResult ExportCSV(string title, string pulishDate, Expression <Func <Message, bool> > predicate) { //Expression<Func<Message, bool>> predicate = x => x.AppId == AppId && x.IsDeleted == false; if (!string.IsNullOrEmpty(title)) { title = title.Trim().ToLower(); predicate = predicate.AndAlso(a => a.Title.ToLower().Contains(title)); } if (!string.IsNullOrEmpty(pulishDate)) { DateTime condDate = Convert.ToDateTime(pulishDate); DateTime condDateEnd = condDate.AddDays(1); predicate = predicate.AndAlso(x => x.PublishDate >= condDate && x.PublishDate <= condDateEnd); } // APP列表 var appInfo = CommonService.lstSysWeChatConfig.FirstOrDefault(a => a.WeixinAppId == AppId.ToString()); List <MessageView> reportList = _messageService.GetList <MessageView>(predicate).OrderByDescending(x => x.Id).ToList(); var ids = reportList.Select(x => x.Id).ToList(); var lst = _articleThumbsUpService.Repository.Entities.Where(x => ids.Contains(x.ArticleID) && x.IsDeleted != true && x.Type == ThumbupType.Message.ToString()).Select(x => x.ArticleID).ToList(); reportList.ForEach(x => { x.ThumbsUpCount = lst.Count(z => z == x.Id); }); if (appInfo != null) { foreach (MessageView item in reportList) { item.APPName = appInfo.AppName; } } return(ExportToCsv(reportList)); }
/// <summary> /// Redirect to the edit template window /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdTemplates_EditCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { int TemplateID = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][SexyContent.TemplateID]); string EditUrl = ModuleContext.NavigateUrl(TabId, SexyContent.ControlKeys.EditTemplate.ToString(), true, "mid" + "=" + ModuleId.ToString() + "&" + SexyContent.TemplateID + "=" + TemplateID.ToString() + "&" + SexyContent.AppIDString + "=" + AppId.ToString()); Response.Redirect(EditUrl); }
/// <summary> /// Initialize EAVManagement Control and add it to the page /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["ManagementMode"] == "NewItem" || Request.QueryString["ManagementMode"] == "EditItem") { ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/SexyContent/EAV/Controls/ItemForm.js", 100); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/SexyContent/EAV/AngularServices/EavGlobalConfigurationProvider.js", 101); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/SexyContent/EAV/AngularServices/EavApiService.js", 102); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/SexyContent/EAV/AngularServices/EavDialogService.js", 103); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/SexyContent/EAV/Controls/ItemFormEntityModelCreator.js", 200); ClientResourceManager.RegisterScript(this.Page, "~/DesktopModules/ToSIC_SexyContent/Js/ItemForm.js", 300); ClientResourceManager.RegisterStyleSheet(this.Page, "~/DesktopModules/ToSIC_SexyContent/SexyContent/EAV/Controls/ItemForm.css", 150); } // Register Stylesheet & Script ClientResourceManager.RegisterStyleSheet(this.Page, "~/DesktopModules/ToSIC_SexyContent/Styles/Edit.css", 200); // Add DNN Version to body class SexyContent.AddDNNVersionToBodyClass(this); var eavManagement = (ToSic.Eav.ManagementUI.EavManagement)Page.LoadControl(TemplateControl.TemplateSourceDirectory + "/../SexyContent/EAV/Controls/EAVManagement.ascx"); eavManagement.BaseUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, SexyContent.ControlKeys.EavManagement, "mid=" + ModuleId.ToString() + "&popUp=true&" + "AppID=" + AppId.ToString()); eavManagement.Scope = SexyContent.AttributeSetScope; eavManagement.AssignmentObjectTypeId = SexyContent.AssignmentObjectTypeIDDefault; eavManagement.DefaultCultureDimension = SexyContent.GetLanguageId(ZoneId.Value, PortalSettings.DefaultLanguage); eavManagement.ZoneId = ZoneId; eavManagement.AppId = AppId; eavManagement.AddFormClientScriptAndCss = false; eavManagement.EntityDeleting += EavManagementEntityDeleting; pnlEAV.Controls.Add(eavManagement); }