{"id":23050808,"url":"https://github.com/geta/geta.scheduledparameterjob","last_synced_at":"2025-04-03T03:42:31.038Z","repository":{"id":66329535,"uuid":"137875853","full_name":"Geta/Geta.ScheduledParameterJob","owner":"Geta","description":"EPiServer scheduled job with parameters that can be managed in the admin UI.","archived":false,"fork":false,"pushed_at":"2021-02-10T09:51:27.000Z","size":44819,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-02-08T17:44:36.741Z","etag":null,"topics":["cms","episerver","scheduled-jobs"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Geta.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-19T10:22:35.000Z","updated_at":"2021-02-02T22:35:46.000Z","dependencies_parsed_at":"2024-04-19T06:47:02.490Z","dependency_job_id":null,"html_url":"https://github.com/Geta/Geta.ScheduledParameterJob","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geta%2FGeta.ScheduledParameterJob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geta%2FGeta.ScheduledParameterJob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geta%2FGeta.ScheduledParameterJob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Geta%2FGeta.ScheduledParameterJob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Geta","download_url":"https://codeload.github.com/Geta/Geta.ScheduledParameterJob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246933355,"owners_count":20857052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cms","episerver","scheduled-jobs"],"created_at":"2024-12-15T23:38:05.566Z","updated_at":"2025-04-03T03:42:31.012Z","avatar_url":"https://github.com/Geta.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Scheduled job with parameters\n=============================\n\n* Master\u003cbr\u003e\n![](http://tc.geta.no/app/rest/builds/buildType:(id:GetaPackages_GetaScheduledParameterJob_00ci),branch:master/statusIcon)\n\n## Description\nEPiServer scheduled job with parameters that can be configured in the admin UI.\n\n## Features\n* Create a scheduled job with parameters to be used in the admin UI.\n* Create any parameter type that you wish and use it within your scheduled job.\n* Scheduled job will work and run like any other.\n\n## How to get started?\n* ``install-package Geta.ScheduledParameterJob``\n\n* Add an App_Browsers folder to your site root if there is none there already.\nInside the folder you should create an AdapterMappings.browser file with the content inside:\n```\n\u003cbrowsers\u003e\n  \u003cbrowser refID=\"Default\"\u003e\n    \u003ccontrolAdapters\u003e\n      \u003cadapter controlType=\"EPiServer.UI.Admin.DatabaseJob\"\n               adapterType=\"Geta.ScheduledParameterJob.DatabaseJobAdapter\" /\u003e\n    \u003c/controlAdapters\u003e\n  \u003c/browser\u003e\n\u003c/browsers\u003e\n```\n\n* Create you scheduled job extending **ScheduledJob** class.\n* Create your Definitions (parameters) class implementing **IParameterDefinitions** interface.\n\n## Code\nCredits: [Mathias Kunto](https://blog.mathiaskunto.com/)\n\n### Example scheduled job\n\nExample includes definition class with all available parameter types. Use the appropriate ones that you need for your solution.\n``\nMake sure that you reference the correct DefinitionsClass and DefinitionsAssembly in your scheduled job's attribute. It should match the definitions class that you create to add parameters. Also dont forget to load the correct plugin descriptor. \n``\n\n```csharp\npublic class DefinitionSample : IParameterDefinitions\n    {\n        public IEnumerable\u003cParameterControlDto\u003e GetParameterControls()\n        {\n            return new List\u003cParameterControlDto\u003e\n                        {\n                            AddACheckBoxSample(),\n                            AddATextBoxSample(),\n                            AddAnInputPageReferenceSample(),\n                            AddACalendarSample(),\n                            AddADropDownListSample()\n                        };\n        }\n\n        public void SetValue(Control control, object value)\n        {\n            if (control is CheckBox)\n            {\n                ((CheckBox)control).Checked = (bool)value;\n            }\n            else if (control is TextBox)\n            {\n                ((TextBox)control).Text = (string)value;\n            }\n            else if (control is DropDownList)\n            {\n                ((DropDownList)control).SelectedValue = (string)value;\n            }\n            else if (control is InputPageReference)\n            {\n                ((InputPageReference)control).PageLink = (PageReference)value;\n            }\n            else if (control is System.Web.UI.WebControls.Calendar)\n            {\n                ((System.Web.UI.WebControls.Calendar)control).SelectedDate = (DateTime)value;\n            }\n        }\n\n        public object GetValue(Control control)\n        {\n            if (control is CheckBox)\n            {\n                return ((CheckBox)control).Checked;\n            }\n            if (control is TextBox)\n            {\n                return ((TextBox)control).Text;\n            }\n            if (control is DropDownList)\n            {\n                return ((DropDownList)control).SelectedValue;\n            }\n            if (control is InputPageReference)\n            {\n                return ((InputPageReference)control).PageLink;\n            }\n            if (control is System.Web.UI.WebControls.Calendar)\n            {\n                return ((System.Web.UI.WebControls.Calendar)control).SelectedDate;\n            }\n            return null;\n        }\n\n        private static ParameterControlDto AddACheckBoxSample()\n        {\n            return new ParameterControlDto\n            {\n                // Omitting LabelText will render control without label\n                Description = \"Sample of a CheckBox control\",\n                Control = new CheckBox\n                {\n                    ID = \"CheckBoxSample\",\n                    Text = \"CheckBox Sample\"\n                }\n            };\n        }\n\n        private static ParameterControlDto AddATextBoxSample()\n        {\n            return new ParameterControlDto\n            {\n                LabelText = \"TextBox Sample\",\n                Description = \"Sample of a TextBox control\",\n                Control = new TextBox { ID = \"TextBoxSample\" }\n            };\n        }\n\n        private static ParameterControlDto AddAnInputPageReferenceSample()\n        {\n            return new ParameterControlDto\n            {\n                LabelText = \"InputPageReference Sample\",\n                Description = \"Sample of an EPiServer Page Selector control; InputPageReference.\",\n                Control = new InputPageReference { ID = \"InputPageReferenceSample\" }\n            };\n        }\n\n        private static ParameterControlDto AddACalendarSample()\n        {\n            return new ParameterControlDto\n            {\n                LabelText = \"Calendar Sample\",\n                Description = \"Sample of a Calendar control\",\n                Control = new System.Web.UI.WebControls.Calendar { ID = \"CalendarSample\" }\n            };\n        }\n\n        private static ParameterControlDto AddADropDownListSample()\n        {\n            return new ParameterControlDto\n            {\n                LabelText = \"DropDownList Sample\",\n                Description = \"Sample of a DropDownList control\",\n                Control = new DropDownList\n                {\n                    ID = \"DropDownListSample\",\n                    DataTextField = \"Text\",\n                    DataValueField = \"Value\",\n                    DataSource = new List\u003cListItem\u003e\n                                {\n                                    new ListItem\n                                        {\n                                            Text = \"The first sample item\",\n                                            Value = \"1\"\n                                        },\n                                    new ListItem\n                                        {\n                                            Text = \"The second sample item\",\n                                            Value = \"2\"\n                                        },\n                                    new ListItem\n                                        {\n                                            Text = \"The third sample item\",\n                                            Value = \"3\"\n                                        },\n                                    new ListItem\n                                        {\n                                            Text = \"The fourth sample item\",\n                                            Value = \"4\"\n                                        }\n                                }\n                }\n            };\n        }\n    }\n\n\n[ScheduledPlugInWithParameters(\n        DisplayName = \"Sample parameter job\",\n        Description = \"Sample job with parameters\",\n        DefinitionsClass = \"AlloyDemo.Business.ScheduledJobs.ScheduledJobWithParameters.DefinitionSample\",\n        DefinitionsAssembly = \"AlloyDemo\"\n    )]\n    public class SampleParameterJob : ScheduledJob\n    {\n        public static string Execute()\n        {\n            var descriptor = PlugInDescriptor.Load(\"AlloyDemo.Business.ScheduledJobs.ScheduledJobWithParameters.SampleParameterJob\", \"AlloyDemo\");\n            var store = typeof(ScheduledJobParameters).GetStore();\n            var parameters = store.LoadPersistedValuesFor(descriptor.ID.ToString(CultureInfo.InvariantCulture));\n\n            var cbChecked = parameters.ContainsKey(\"CheckBoxSample\") \u0026\u0026 (bool)parameters[\"CheckBoxSample\"] ? \"Aye!\" : \"Nay..\";\n            var tbText = parameters.ContainsKey(\"TextBoxSample\") ? parameters[\"TextBoxSample\"] as string : string.Empty;\n            var sampleReference = parameters.ContainsKey(\"InputPageReferenceSample\") ? (PageReference)parameters[\"InputPageReferenceSample\"] : PageReference.EmptyReference;\n            var samplePageName = sampleReference != null \u0026\u0026 sampleReference != PageReference.EmptyReference ? DataFactory.Instance.GetPage(sampleReference).PageName : string.Empty;\n            var cDateTime = parameters.ContainsKey(\"CalendarSample\") ? (DateTime?)parameters[\"CalendarSample\"] : null;\n            var ddlSelectedValue = parameters.ContainsKey(\"DropDownListSample\") ? parameters[\"DropDownListSample\"] as string : string.Empty;\n\n            var result = string.Empty;\n            result += string.Format(\"CheckBoxSample checked: \u003cb\u003e{0}\u003c/b\u003e\u003cbr /\u003e\", cbChecked);\n            result += string.Format(\"TextBoxSample text: \u003cb\u003e{0}\u003c/b\u003e\u003cbr /\u003e\", tbText);\n            result += string.Format(\"InputPageReferenceSample page name: \u003cb\u003e{0}\u003c/b\u003e (PageId: \u003cb\u003e{1}\u003c/b\u003e)\u003cbr /\u003e\", samplePageName, sampleReference);\n            result += string.Format(\"CalendarSample date: \u003cb\u003e{0}\u003c/b\u003e\u003cbr /\u003e\", cDateTime.ToString());\n            result += string.Format(\"DropDownListSample selected value: \u003cb\u003e{0}\u003c/b\u003e\u003cbr /\u003e\", ddlSelectedValue);\n            return result;\n        }\n    }\n```\n\n## More info\n\n* [Blog for 7.5 upgrade](https://blog.mathiaskunto.com/2014/03/21/scheduled-jobs-with-input-parameters-in-episerver-7-5/)\n* [Blog for WebForms](https://blog.mathiaskunto.com/2012/02/13/supplying-episerver-scheduled-jobs-with-parameters-through-admin-mode/)\n\n## Package maintainer\nhttps://github.com/digintsys\n\n## Changelog\n[Changelog](CHANGELOG.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeta%2Fgeta.scheduledparameterjob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeta%2Fgeta.scheduledparameterjob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeta%2Fgeta.scheduledparameterjob/lists"}