public bool Resolve(object sender, IBindingContextElement element) { ExcelInterop.Range concernedRange = sender as ExcelInterop.Range; if (concernedRange == null) { return(false); } try { ExcelInterop.Range concernedRangeFirstCell = concernedRange.Cells[1, 1]; // We delete the previous concernedRange comment ExcelInterop.Comment comment = concernedRangeFirstCell.Comment; comment?.Delete(); // Invoke decorator resolver object result = EventCallbacksManager.DecoratorInvoke(Callback, concernedRange, element.DataSource, null); if (result != null) { string commentStr = result as string; if (!string.IsNullOrEmpty(commentStr)) { concernedRange.AddComment(commentStr); ExcelInterop.Comment addedComment = concernedRange.Comment; ExcelInterop.Shape shape = addedComment.Shape; ExcelInterop.TextFrame textFrame = shape.TextFrame; textFrame.AutoSize = true; } return(commentStr != null); } return(false); } catch (Exception ex) { log.LogExceptionFormat(LogType.Error, ex, $"Cannot resolve decorator2 '{Ident}':{ex.Message}"); return(false); } }
public object GDA(ExcelInterop.Range caller, string dataType, object[] parameters) { if (caller == null) { return(null); } if (ETKExcel.ExcelApplication.IsInEditMode()) { return("#Edit Mode"); } if (test == null) { IExcelTemplateView view = ETKExcel.TemplateManager.AddView("Templates Customer", "AllCustomers", caller.Worksheet.Name, caller.Address); test = new ExcelRequestDefinition("Test", "Ceci est un test", view as ExcelTemplateView); ExcelInterop.Comment comment = caller.Comment; if (comment != null) { comment.Delete(); } caller.Application.Application.Caller.AddComment(test.Description); } ExcelInterop.Range firstOutputCell = (caller as ExcelInterop.Range).Offset[++yOffset, ++xOffset]; (test.View as ExcelTemplateView).FirstOutputCell = firstOutputCell; try { //if (parameters.Length < 2) // return "#N/A"; ETKExcel.TemplateManager.ClearView(test.View); ExcelApplication application = (ETKExcel.TemplateManager as ExcelTemplateManager).ExcelApplication; application.PostAsynchronousAction(() => { try { application.PostAsynchronousAction(() => (test.View as ExcelTemplateView).FirstOutputCell.Value2 = "#Retrieving Data"); Task task = new Task(() => { //Thread.Sleep(5000); test.View.SetDataSource(parameters[0]); application.PostAsynchronousAction(() => test.View.FirstOutputCell.Value2 = string.Empty); application.PostAsynchronousAction(() => ETKExcel.TemplateManager.Render(test.View)); }); task.Start(); } catch (Exception ex) { string errorMessage = $"#ERR:{ex.Message}.{(ex.InnerException == null ? string.Empty : ex.InnerException.Message)}"; application.PostAsynchronousAction(() => (test.View as ExcelTemplateView).FirstOutputCell.Value2 = errorMessage); } }); return(test.Name); } catch (Exception ex) { return($"#ERR: {ex.Message}"); } }