public void Overriding_filter_when_parent_data_member_is_blank() { var testField = new SummaryField { Name = "SummaryCalculation", Expression = $"[{nameof(TestDataSourceItem.Value)}]", DataMember = nameof(TestDataSource.Items), Mode = SummaryFieldMode.Immediate, Func = SummaryFunc.Sum, OverrideFilter = "True" }; var label = new XRLabel { DataBindings = { { nameof(XRLabel.Text), null, $"{nameof(TestDataSource.Items)}.{testField.Name}" } } }; using (var report = new XtraReport { DataSource = GetDefaultDataSource(), DataMember = nameof(TestDataSource.Items), CalculatedFields = { testField }, Bands = { new DetailBand { Controls = { label } } } }) { report.CreateDocument(); Assert.That(GetPrintedInstances(report, label), Has.All.EqualTo("111")); } }
private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e) { var designPanel = designMdiController.ActiveDesignPanel; var node = (DataMemberListNodeBase)e.Args[0]; var report = designPanel.Report; var designerHost = designPanel.GetService <IDesignerHost>(); var changeServ = designPanel.GetService <IComponentChangeService>(); var selectionServ = designPanel.GetService <ISelectionService>(); // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v16.1.Extensions.dll, Version=16.1.4.0 var c = new SummaryField { DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty }; var description = $"Add {nameof(SummaryField)} object"; var transaction = designerHost.CreateTransaction(description); try { var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields"); changeServ.OnComponentChanging(report, propertyDescriptor); DesignToolHelper.AddToContainer(designerHost, c); report.CalculatedFields.Add(c); changeServ.OnComponentChanged(report, propertyDescriptor, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new[] { c }); }
private void TestAddSheetSummaryFieldImage() { SummaryField summaryField = smartsheet.SheetResources.SummaryResources.AddSheetSummaryFieldImage(sheet.Id.Value, asf[0].Id.Value, "D:\\Smartsheet\\vHepGiJaeL6GPOX3wAx8yaxD75ym5eAbk0GB-MSz0gc.png", null, "alt text"); Assert.IsInstanceOfType(summaryField.Image, typeof(Image)); }
public void Filtering_by_summary_field() { var testField = new SummaryField { Name = "SummaryCalculation", Expression = $"[{nameof(TestDataSourceItem.Value)}]", DataMember = nameof(TestDataSource.Items), Mode = SummaryFieldMode.Immediate, Func = SummaryFunc.Avg, FieldType = FieldType.Int32 }; var label = new XRLabel { DataBindings = { { nameof(XRLabel.Text), null, $"{nameof(TestDataSource.Items)}.{nameof(TestDataSourceItem.Value)}" } } }; using (var report = new XtraReport { DataSource = GetDefaultDataSource(), DataMember = nameof(TestDataSource.Items), CalculatedFields = { testField }, Bands = { new DetailBand { Controls = { label } } }, FilterString = $"[{nameof(TestDataSourceItem.Value)}] < [{testField.Name}]" }) { report.CreateDocument(); Assert.That(GetPrintedInstances(report, label), Is.EqualTo(new[] { "1", "10" })); } }
public override List <SummaryField> GetSummaryColumnInfo(IRptParams filter) { List <SummaryField> fls = new List <SummaryField>(); SummaryField fs = new SummaryField("FSEQ", Kingdee.BOS.Core.Enums.BOSEnums.Enu_SummaryType.SUM); fls.Add(fs); return(fls); }
/// <summary> /// <para>Adds an image to the sheet summary field.</para> /// <para>Mirrors to the following Smartsheet REST API method: POST /sheets/{sheetId}/summary/fields/{fieldId}/images</para> /// </summary> /// <param name="sheetId"> the sheet id </param> /// <param name="fieldId"> the summary field id </param> /// <param name="file"> the file path </param> /// <param name="fileType"> the file type </param> /// <param name="altText"> image alternate text </param> /// <returns> Result </returns> /// <exception cref="System.InvalidOperationException"> if any argument is null or an empty string </exception> /// <exception cref="InvalidRequestException"> if there is any problem with the REST API request </exception> /// <exception cref="AuthorizationException"> if there is any problem with the REST API authorization (access token) </exception> /// <exception cref="ResourceNotFoundException"> if the resource cannot be found </exception> /// <exception cref="ServiceUnavailableException"> if the REST API service is not available (possibly due to rate limiting) </exception> /// <exception cref="SmartsheetException"> if there is any other error during the operation </exception> public virtual SummaryField AddSheetSummaryFieldImage(long sheetId, long fieldId, string file, string fileType, string altText) { string path = "sheets/" + sheetId + "/summary/fields/" + fieldId + "/images"; Utility.Utility.ThrowIfNull(file); if (fileType == null) { fileType = "application/octet-stream"; } IDictionary <string, string> parameters = new Dictionary <string, string>(); if (altText != null) { parameters.Add("altText", altText); } path = QueryUtil.GenerateUrl(path, parameters); FileInfo fi = new FileInfo(file); HttpRequest request = CreateHttpRequest(new Uri(this.Smartsheet.BaseURI, path), HttpMethod.POST); request.Headers["Content-Disposition"] = "attachment; filename=\"" + fi.Name + "\""; HttpEntity entity = new HttpEntity(); entity.ContentType = fileType; entity.Content = File.ReadAllBytes(file); entity.ContentLength = fi.Length; request.Entity = entity; HttpResponse response = this.Smartsheet.HttpClient.Request(request); SummaryField summaryField = null; switch (response.StatusCode) { case HttpStatusCode.OK: summaryField = this.smartsheet.JsonSerializer.deserializeResult <SummaryField>(response.Entity.GetContent()).Result; break; default: HandleError(response); break; } this.Smartsheet.HttpClient.ReleaseConnection(); return(summaryField); }
public void Immediate_empty_child_collection_grouping_by_parent() { var testField = new SummaryField { Name = "SummaryCalculation", Expression = $"[{nameof(TestDataSourceItem.Value)}]", DataMember = $"{nameof(TestDataSource.Items)}.{nameof(TestDataSourceItem.RecursiveItems)}", Mode = SummaryFieldMode.Immediate, Func = SummaryFunc.Sum }; var label = new XRLabel { DataBindings = { { nameof(XRLabel.Text), null, $"{testField.DataMember}.{testField.Name}" } } }; var dataSource = new TestDataSource(new[] { new TestDataSourceItem("Item 1", 1), new TestDataSourceItem("Item 2", 10, new[] { new TestDataSourceItem("Item 2.1", 2), new TestDataSourceItem("Item 2.2", 20) }) }); using (var report = new XtraReport { DataSource = dataSource, DataMember = nameof(TestDataSource.Items), CalculatedFields = { testField }, Bands = { new DetailBand(), new DetailReportBand { DataSource = dataSource, DataMember = $"{nameof(TestDataSource.Items)}.{nameof(TestDataSourceItem.RecursiveItems)}", Bands = { new DetailBand { Controls = { label } } }, ReportPrintOptions = { DetailCountOnEmptyDataSource = 0 } } } }) { report.CreateDocument(); Assert.That(GetPrintedInstances(report, label), Has.All.EqualTo("22")); } }
private void TestUpdateSheetSummaryFields() { SummaryField sf = new SummaryField(); sf.Id = asf[0].Id; sf.Title = "Hellooo World!"; SummaryField sf1 = new SummaryField(); sf1.Id = asf[1].Id; sf1.Title = "Eeek!"; IList <SummaryField> usf = smartsheet.SheetResources.SummaryResources.UpdateSheetSummaryFields(sheet.Id.Value, new List <SummaryField> { sf, sf1 }, null); }
private void TestUpdateSheetSummaryFieldsWithPartialSuccess() { SummaryField sf = new SummaryField(); sf.Id = asf[0].Id; sf.Title = "Hello World!"; SummaryField sf1 = new SummaryField(); sf1.Id = 123; sf1.Title = "Eeek!"; BulkItemResult <SummaryField> usf = smartsheet.SheetResources.SummaryResources.UpdateSheetSummaryFieldsAllowPartialSuccess(sheet.Id.Value, new List <SummaryField> { sf, sf1 }, true); Assert.AreEqual(usf.FailedItems.Count, 1); }
private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e) { var designPanel = designMdiController.ActiveDesignPanel; var fieldListControl = ((FieldListDockPanel)designDockManager[DesignDockPanelType.FieldList]).GetFieldList(); var node = fieldListControl.DataMemberNode; if (node == null) { return; } if (!node.IsList) { node = (DataMemberListNodeBase)node.ParentNode; } var report = designPanel.Report; var designerHost = designPanel.GetService <IDesignerHost>(); var changeServ = designPanel.GetService <IComponentChangeService>(); var selectionServ = designPanel.GetService <ISelectionService>(); // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v14.1.Extensions.dll, Version=14.1.5.0 var c = new SummaryField { DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty }; var description = string.Format("Add {0} object", typeof(SummaryField).Name); var transaction = designerHost.CreateTransaction(description); try { var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields"); changeServ.OnComponentChanging(report, propertyDescriptor); DesignToolHelper.AddToContainer(designerHost, c); report.CalculatedFields.Add(c); changeServ.OnComponentChanged(report, propertyDescriptor, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new[] { c }); }
private void TestAddSheetSummaryFieldsWithPartialSuccess() { SummaryField sf = new SummaryField(); sf.Title = "Hello World"; sf.Type = ColumnType.TEXT_NUMBER; sf.ObjectValue = new StringObjectValue("Sally Smart"); SummaryField sf1 = new SummaryField(); sf1.Title = "Eeck!"; sf1.Type = ColumnType.TEXT_NUMBER; sf1.ObjectValue = new StringObjectValue("Sammy Smart"); BulkItemResult <SummaryField> asf = smartsheet.SheetResources.SummaryResources.AddSheetSummaryFieldsAllowPartialSuccess( sheet.Id.Value, new List <SummaryField> { sf, sf1 }, null); Assert.AreEqual(asf.FailedItems.Count, 1); }
private void TestAddSheetSummaryFields() { SummaryField sf = new SummaryField(); sf.Title = "Hello World"; sf.Type = ColumnType.CHECKBOX; sf.ObjectValue = new BooleanObjectValue(true); SummaryField sf1 = new SummaryField(); sf1.Title = "Checkbox"; sf1.Type = ColumnType.CHECKBOX; sf1.ObjectValue = new BooleanObjectValue(false); asf = smartsheet.SheetResources.SummaryResources.AddSheetSummaryFields(sheet.Id.Value, new List <SummaryField> { sf, sf1 }, true); Assert.AreEqual(asf.Count, 2); }
private static void ProcessField(Field fld, XmlWriter xmlw, string type) { xmlw.WriteStartElement(type + "Field"); xmlw.WriteAttributeString("Description", fld.Description); xmlw.WriteAttributeString("FormulaForm", fld.FormulaForm); xmlw.WriteAttributeString("HeadingText", fld.HeadingText); xmlw.WriteAttributeString("IsRecurring", fld.IsRecurring.ToStringSafe()); xmlw.WriteAttributeString("Kind", fld.Kind.ToStringSafe()); xmlw.WriteAttributeString("Length", fld.Length.ToStringSafe()); xmlw.WriteAttributeString("LongName", fld.LongName); xmlw.WriteAttributeString("Name", fld.Name); xmlw.WriteAttributeString("ShortName", fld.ShortName); xmlw.WriteAttributeString("Type", fld.Type.ToStringSafe()); xmlw.WriteAttributeString("UseCount", fld.UseCount.ToStringSafe()); switch (fld.Kind) { case CrFieldKindEnum.crFieldKindDBField: { DBField dbf = (DBField)fld; xmlw.WriteAttributeString("TableAlias", dbf.TableAlias); break; } case CrFieldKindEnum.crFieldKindFormulaField: { FormulaField ff = (FormulaField)fld; xmlw.WriteAttributeString("FormulaNullTreatment", ff.FormulaNullTreatment.ToStringSafe()); xmlw.WriteAttributeString("Text", ff.Text.ToStringSafe()); xmlw.WriteAttributeString("Syntax", ff.Syntax.ToStringSafe()); break; } case CrFieldKindEnum.crFieldKindGroupNameField: { GroupNameField gnf = (GroupNameField)fld; xmlw.WriteAttributeString("Group", gnf.Group.ConditionField.FormulaForm); break; } case CrFieldKindEnum.crFieldKindParameterField: { ParameterField pf = (ParameterField)fld; xmlw.WriteAttributeString("AllowCustomCurrentValues", pf.AllowCustomCurrentValues.ToStringSafe()); xmlw.WriteAttributeString("AllowMultiValue", pf.AllowMultiValue.ToStringSafe()); xmlw.WriteAttributeString("AllowNullValue", pf.AllowNullValue.ToStringSafe()); if (pf.BrowseField != null) { xmlw.WriteAttributeString("BrowseField", pf.BrowseField.FormulaForm); } xmlw.WriteAttributeString("DefaultValueSortMethod", pf.DefaultValueSortMethod.ToStringSafe()); xmlw.WriteAttributeString("DefaultValueSortOrder", pf.DefaultValueSortOrder.ToStringSafe()); xmlw.WriteAttributeString("EditMask", pf.EditMask); xmlw.WriteAttributeString("IsEditableOnPanel", pf.IsEditableOnPanel.ToStringSafe()); xmlw.WriteAttributeString("IsOptionalPrompt", pf.IsOptionalPrompt.ToStringSafe()); xmlw.WriteAttributeString("IsShownOnPanel", pf.IsShownOnPanel.ToStringSafe()); xmlw.WriteAttributeString("ParameterType", pf.ParameterType.ToStringSafe()); xmlw.WriteAttributeString("ReportName", pf.ReportName); xmlw.WriteAttributeString("ValueRangeKind", pf.ValueRangeKind.ToStringSafe()); if (pf.CurrentValues != null) { ProcessValues(pf.CurrentValues, xmlw, "Current"); } if (pf.DefaultValues != null) { ProcessValues(pf.DefaultValues, xmlw, "Default"); } if (pf.InitialValues != null) { ProcessValues(pf.InitialValues, xmlw, "Initial"); } if (pf.Values != null) { ProcessValues(pf.Values, xmlw, ""); } ProcessValue(pf.MaximumValue as Value, xmlw, "Maximum"); ProcessValue(pf.MinimumValue as Value, xmlw, "Minimum"); break; } case CrFieldKindEnum.crFieldKindRunningTotalField: { RunningTotalField rtf = (RunningTotalField)fld; xmlw.WriteAttributeString("EvaluateCondition", ProcessCondition(rtf.EvaluateCondition)); xmlw.WriteAttributeString("EvaluateConditionType", rtf.EvaluateConditionType.ToStringSafe()); xmlw.WriteAttributeString("Operation", rtf.Operation.ToStringSafe()); xmlw.WriteAttributeString("ResetCondition", ProcessCondition(rtf.ResetCondition)); xmlw.WriteAttributeString("ResetConditionType", rtf.ResetConditionType.ToStringSafe()); xmlw.WriteAttributeString("SummarizedField", rtf.SummarizedField.FormulaForm); break; } case CrFieldKindEnum.crFieldKindSpecialField: { SpecialField sf = (SpecialField)fld; xmlw.WriteAttributeString("SpecialType", sf.SpecialType.ToStringSafe()); break; } case CrFieldKindEnum.crFieldKindSummaryField: { SummaryField smf = (SummaryField)fld; if (smf.Group != null) { xmlw.WriteAttributeString("Group", smf.Group.ConditionField.FormulaForm); } xmlw.WriteAttributeString("Operation", smf.Operation.ToStringSafe()); xmlw.WriteAttributeString("SummarizedField", smf.SummarizedField.FormulaForm); break; } case CrFieldKindEnum.crFieldKindUnknownField: { break; } } xmlw.WriteEndElement(); }
private void OnHandleAddSummaryField(object sender, CommandExecuteEventArgs e) { var designPanel = designMdiController.ActiveDesignPanel; var fieldListControl = ((FieldListDockPanel)designDockManager[DesignDockPanelType.FieldList]).GetFieldList(); var node = fieldListControl.DataMemberNode; if (node == null) return; if (!node.IsList) node = (DataMemberListNodeBase)node.ParentNode; var report = designPanel.Report; var designerHost = designPanel.GetService<IDesignerHost>(); var changeServ = designPanel.GetService<IComponentChangeService>(); var selectionServ = designPanel.GetService<ISelectionService>(); // Functionality patterned after AddCalculatedField() from DevExpress.XtraReports.Design.Commands.FieldListCommandExecutor, DevExpress.XtraReports.v14.1.Extensions.dll, Version=14.1.5.0 var c = new SummaryField { DataSource = node.DataSource != report.DataSource ? node.DataSource : null, DataMember = node.DataMember ?? string.Empty }; var description = string.Format("Add {0} object", typeof(SummaryField).Name); var transaction = designerHost.CreateTransaction(description); try { var propertyDescriptor = XRAccessor.GetPropertyDescriptor(report, "CalculatedFields"); changeServ.OnComponentChanging(report, propertyDescriptor); DesignToolHelper.AddToContainer(designerHost, c); report.CalculatedFields.Add(c); changeServ.OnComponentChanged(report, propertyDescriptor, null, null); } finally { transaction.Commit(); } selectionServ.SetSelectedComponents(new[] { c }); }
private static IList <string> GetPrintedValues(object dataSource, string dataMember, SummaryField testField) { var label = new XRLabel { DataBindings = { { nameof(XRLabel.Text), null, $"{testField.DataMember}.{testField.Name}" } } }; using (var report = new XtraReport { DataSource = dataSource, DataMember = dataMember, CalculatedFields = { testField }, Bands = { new DetailBand { Controls = { label } } } }) { report.CreateDocument(); return(GetPrintedInstances(report, label)); } }