/// <summary> /// Handles the UniGrid's OnAction event. /// </summary> /// <param name="actionName">Name of item (button) that threw event</param> /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param> protected void gridElem_OnAction(string actionName, object actionArgument) { switch (actionName.ToLowerCSafe()) { case "edit": if (!String.IsNullOrEmpty(EditURL)) { URLHelper.Redirect(UrlResolver.ResolveUrl(String.Format(EditURL, actionArgument))); } break; case "delete": { // Check "modify" permission if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.ScheduledTasks", "Modify")) { RedirectToAccessDenied("CMS.ScheduledTasks", "Modify"); } // Delete the task try { int taskId = Convert.ToInt32(actionArgument); TaskInfo ti = TaskInfoProvider.GetTaskInfo(taskId); if (ti != null) { ti.Generalized.LogSynchronization = SynchronizationTypeEnum.LogSynchronization; ti.Generalized.LogIntegration = true; ti.Generalized.LogEvents = true; TaskInfoProvider.DeleteTaskInfo(ti); } } catch (Exception ex) { ShowError(GetString("Task_List.DeleteError"), ex.Message); } } break; case "execute": { // Check "modify" permission if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.ScheduledTasks", "Modify")) { RedirectToAccessDenied("CMS.ScheduledTasks", "Modify"); } TaskInfo taskInfo = TaskInfoProvider.GetTaskInfo(Convert.ToInt32(actionArgument)); if (taskInfo != null) { SiteInfo siteInfo = SiteInfoProvider.GetSiteInfo(SiteID); if (!taskInfo.TaskEnabled) { // Task is not enabled (won't be executed at the end of request), run it now SchedulingExecutor.ExecuteTask(taskInfo, (siteInfo != null) ? siteInfo.SiteName : SiteContext.CurrentSiteName); } else { if (!taskInfo.TaskIsRunning) { taskInfo.TaskNextRunTime = DateTime.Now; // Update the task TaskInfoProvider.SetTaskInfo(taskInfo); // Run the task SchedulingTimer.RunSchedulerImmediately = true; if (siteInfo != null) { SchedulingTimer.SchedulerRunImmediatelySiteName = siteInfo.SiteName; } } else { ShowWarning(GetString("ScheduledTask.TaskAlreadyrunning")); return; } } ShowConfirmation(GetString("ScheduledTask.WasExecuted")); } } break; } }
protected void ButtonGetColumn_Click(object sender, EventArgs e) { LiteralWaitting.Text = " Loading ... "; get_column_table(); if (bl) { ButtonExport.Visible = true; RadioButtonKeep.Visible = true; RadioButtonAll.Visible = true; } DataClassInfo clsi = null; clsi = (Session["DataClassInfo"] != null ? (DataClassInfo)Session["DataClassInfo"] : null); DeleteCustomTableItem(clsi); int i = 1; if (ds_excel == null) { ds_excel = (Session["ds_excel"] != null ? (DataSet)Session["ds_excel"] : null); } if (!DataHelper.DataSourceIsEmpty(ds_excel)) { Literal1.Text = ""; foreach (DataRow row in ds_excel.Tables[0].Rows) { if (i != 1) { if (CreateCustomTableItem(clsi, row)) { Literal1.Text += "<br> insert row " + i.ToString() + " sucess"; } else { Literal1.Text += "<br> <span style='color:red;'>insert row " + i.ToString() + " error</span>"; } } i++; } Literal1.Text += "<br> Import sucess"; EventLogProvider.LogInformation("CustomTable", "Import sucess", ""); string taskName = "SportingCarzTask"; string siteName = CMSContext.CurrentSiteName; // Get task object TaskInfo ti = TaskInfoProvider.GetTaskInfo(taskName, siteName); // If task exists if (ti != null) { // Run task SchedulingExecutor.ExecuteTask(ti); Literal1.Text += "<br> Run task sucess"; } } }