123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using Comal.Classes;
- using FastReport.Messaging.Xmpp;
- using InABox.Core;
- using InABox.DynamicGrid;
- using InABox.WPF;
- using PRS.Shared;
- using Syncfusion.DocIO.DLS;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Media.Imaging;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.TrackBar;
- using ScriptEditor = InABox.DynamicGrid.ScriptEditorWindow;
- namespace PRSServer
- {
- public class ScheduledScriptsGrid : DynamicDataGrid<ScheduledScript>
- {
- private const string DefaultScript = @"using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime;
- using System.Windows;
- using InABox.Core;
- using InABox.Clients;
- using InABox.Logging;
- using Comal.Classes;
- public class Module
- {
-
- public Object Data { get; set; }
-
- public bool Execute()
- {
- return true;
- }
-
- }";
- public ScheduledScriptsGrid()
- {
- HiddenColumns.Add(x => x.Script);
- ActionColumns.Add(new DynamicImageColumn(ScriptImage, ScriptAction));
- ActionColumns.Add(new DynamicImageColumn(ScheduleImage, ScheduleAction));
- }
- protected override void DoReconfigure(DynamicGridOptions options)
- {
- base.DoReconfigure(options);
- options.Clear();
- options.AddRows = true;
- options.EditRows = true;
- options.DeleteRows = true;
- }
- public override ScheduledScript CreateItem()
- {
- var item = base.CreateItem();
- item.Script = DefaultScript;
- return item;
- }
- private bool ScriptAction(CoreRow? arg)
- {
- if (arg is null) return false;
- var script = LoadItem(arg);
- var editor = new ScriptEditor(script.Script);
- editor.OnSave += (e, args) =>
- {
- if (script.Script != editor.Script)
- {
- script.Script = editor.Script;
- SaveItem(script);
- }
- };
- if (editor.ShowDialog() == true)
- {
- if (script.Script != editor.Script)
- {
- script.Script = editor.Script;
- SaveItem(script);
- }
- }
- return false;
- }
- private bool ScheduleAction(CoreRow? arg)
- {
- if (arg is null) return false;
- var script = LoadItem(arg);
- var form = new ScheduleForm(script);
- form.ShowDialog();
- return false;
- }
- private BitmapImage ScriptImage(CoreRow? arg)
- {
- return Properties.Resources.script.AsBitmapImage();
- }
- private BitmapImage ScheduleImage(CoreRow? arg)
- {
- return Properties.Resources.schedule.AsBitmapImage();
- }
- }
- }
|