public IronConsoleTask(IronRuntime runtime, string expression, string extension) { _runtime = runtime; _expression = expression; _extension = extension; _waitHandle = new AutoResetEvent(false); }
protected override void Render(HtmlTextWriter writer) { if (Exception != null) { if (SPContext.Current.Web.UserIsSiteAdmin && ironRuntime.IronHive.Web.CurrentUser.IsSiteAdmin) { IronRuntime.LogError(String.Format("Error: {0}", ScriptName, Exception.Message), Exception); writer.Write(Exception.Message); } else { writer.Write("Error occured."); } } else { try { base.Render(writer); } catch (Exception ex) { writer.Write(ex.Message); IronRuntime.LogError("Error", ex); } } }
public override void ItemDeleted(SPItemEventProperties properties) { var ironRuntime = IronRuntime.GetDefaultIronRuntime(properties.List.ParentWeb.Site); //ironRuntime.IronHive.ReloadFiles(); base.ItemDeleted(properties); }
public static IronConsole GetConsoleForRuntime(IronRuntime runtime) { var hiveId = runtime.IronHive.Id; IronConsole console; if (!_hiveConsoles.TryGetValue(hiveId, out console) || console.IsDisposed) { console = new IronConsole(runtime); _hiveConsoles[hiveId] = console; } return console; }
protected IronConsole(IronRuntime runtime, params string[] supportedExtensions) { _runtime = runtime; _queue = new BlockingQueue<IronConsoleTask>(); _queueWorker = new Thread(ProcessTaskQueue) { Name = string.Format("IronConsole Worker for {0}", string.Join(", ", supportedExtensions)), IsBackground = true }; _queueWorker.Start(); }
protected IronConsole(IronRuntime runtime, params string[] supportedExtensions) { _runtime = runtime; _queue = new BlockingQueue <IronConsoleTask>(); _queueWorker = new Thread(ProcessTaskQueue) { Name = string.Format("IronConsole Worker for {0}", string.Join(", ", supportedExtensions)), IsBackground = true }; _queueWorker.Start(); }
public static IronConsole GetConsoleForRuntime(IronRuntime runtime) { var hiveId = runtime.IronHive.Id; IronConsole console; if (!_hiveConsoles.TryGetValue(hiveId, out console) || console.IsDisposed) { console = new IronConsole(runtime); _hiveConsoles[hiveId] = console; } return(console); }
protected override void OnInit(EventArgs e) { Guid hiveId = String.IsNullOrEmpty(ScriptHiveId) ? Guid.Empty : new Guid(ScriptHiveId); //ironRuntime = IronRuntime.GetIronRuntime(SPContext.Current.Site, hiveId); ironRuntime = IronRuntime.GetDefaultIronRuntime(SPContext.Current.Site); if (String.IsNullOrEmpty(ScriptClass)) { Exception = new InvalidEnumArgumentException("Property ScriptClass is empty!"); } if (Exception != null) { return; } try { Control ctrl = null; if (!String.IsNullOrEmpty(ScriptName)) { var engine = ironRuntime.GetEngineByExtension(Path.GetExtension(ScriptName)); ctrl = engine.CreateDynamicInstance(ScriptClass, ScriptName) as Control; } else { ctrl = ironRuntime.CreateDynamicInstance(ScriptClass) as Control; } DynamicControl = ctrl as IIronControl; if (DynamicControl != null) { DynamicControl.WebPart = this; DynamicControl.Data = this; } this.Controls.Add(ctrl); base.OnInit(e); } catch (Exception ex) { Exception = ex; IronRuntime.LogError("IronWebPart Error", Exception); } }
private void CallDynamicEventreceiver(SPItemEventProperties properties) { var dynEventReceiver = IronRuntime.GetDefaultIronRuntime(properties.Web.Site).CreateDynamicInstance(properties.ReceiverData) as SPItemEventReceiver; switch (properties.EventType) { case SPEventReceiverType.ItemAdded: dynEventReceiver.ItemAdded(properties); break; case SPEventReceiverType.ItemUpdated: dynEventReceiver.ItemUpdated(properties); break; case SPEventReceiverType.ItemDeleted: dynEventReceiver.ItemDeleted(properties); break; case SPEventReceiverType.ItemFileMoved: dynEventReceiver.ItemFileMoved(properties); break; case SPEventReceiverType.ItemCheckedIn: dynEventReceiver.ItemCheckedIn(properties); break; case SPEventReceiverType.ItemCheckedOut: dynEventReceiver.ItemCheckedOut(properties); break; case SPEventReceiverType.ItemAdding: dynEventReceiver.ItemAdding(properties); break; case SPEventReceiverType.ItemUpdating: dynEventReceiver.ItemUpdating(properties); break; case SPEventReceiverType.ItemDeleting: dynEventReceiver.ItemDeleting(properties); break; case SPEventReceiverType.ItemFileMoving: dynEventReceiver.ItemFileMoving(properties); break; case SPEventReceiverType.ItemCheckingIn: dynEventReceiver.ItemCheckingIn(properties); break; case SPEventReceiverType.ItemCheckingOut: dynEventReceiver.ItemCheckingOut(properties); break; case SPEventReceiverType.ItemUncheckedOut: dynEventReceiver.ItemUncheckedOut(properties); break; case SPEventReceiverType.ItemUncheckingOut: dynEventReceiver.ItemUncheckingOut(properties); break; case SPEventReceiverType.ItemAttachmentAdded: dynEventReceiver.ItemAttachmentAdded(properties); break; case SPEventReceiverType.ItemAttachmentAdding: dynEventReceiver.ItemAttachmentAdding(properties); break; case SPEventReceiverType.ItemAttachmentDeleted: dynEventReceiver.ItemAttachmentDeleted(properties); break; case SPEventReceiverType.ItemAttachmentDeleting: dynEventReceiver.ItemAttachmentDeleting(properties); break; case SPEventReceiverType.ItemFileConverted: dynEventReceiver.ItemFileConverted(properties); break; } }
private void CompileScript(SPItemEventProperties properties) { if (!properties.ListItem.ContentTypeId.IsChildOf(new SPContentTypeId(IronContentTypeId.IronScript))) { return; } IronRuntime runtime = null; try { runtime = IronRuntime.GetDefaultIronRuntime(properties.Web.Site); engine = runtime.GetEngineByExtension(Path.GetExtension(properties.ListItem.File.Name)); EventFiringEnabled = false; properties.ListItem[IronField.IronOutput] = engine.ExcecuteScriptFile(properties.ListItem.File); properties.ListItem[IronField.IronErrorFlag] = false; properties.ListItem.SystemUpdate(false); //cause compile bug?? // runtime.IronHive.ReloadFiles(); } catch (Exception ex) { var eo = engine.ScriptEngine.GetService <ExceptionOperations>(); string error = eo.FormatException(ex); properties.ListItem[IronField.IronOutput] = error; properties.ListItem[IronField.IronErrorFlag] = true; properties.ListItem.SystemUpdate(false); } finally { EventFiringEnabled = true; if (runtime != null) { runtime.IronHive.Dispose(); } } }
public override void ItemUncheckingOut(SPItemEventProperties properties) { IronRuntime.GetDefaultIronRuntime(properties.Web.Site).IronHive.FireHiveEvent(this, "ItemUncheckingOut", properties); }
public override void ItemFileMoving(SPItemEventProperties properties) { IronRuntime.GetDefaultIronRuntime(properties.Web.Site).IronHive.FireHiveEvent(this, "ItemFileMoving", properties); }
public IronLogger(IronRuntime runtime) { _runtime = runtime; }