FRAMES | NO FRAMES |
Generates a report to rank data based on a selected variable.
Availability: Business Analyst Server.
TaskResultOutput MarketRanking ( MarketRankingParameters Parameters, esriReportFormat ReportFormat, RenderingParameters RenderingParameters, TaskOutputType[] OutputTypes, esriFolderItem OutputAnalysisItem, esriFolderItem OutputReportItem );
Parameter | Description |
---|---|
Parameters | Configuration options for analysis. Type MarketRankingParameters. |
ReportFormat | This parameter should be null. This parameter is deprecated. |
RenderingParameters | Configuration options for rendering output when GetMapImage option is specified in the OutputTypes parameter. Type RenderingParameters. |
OutputTypes | Array of task output options. Options for this method include rendering output image (GetMapImage), creating a feature layer for subsequent analysis (GetFeatureClass), and creating a report (GetReport). Type TaskOutputType[]. |
OutputAnalysisItem | (Optional
parameter — can be null). Configuration options for storing the output feature layer in the repository. This will enable viewing and working with the output result in subsequent tasks. Type esriFolderItem. |
OutputReportItem | (Optional
parameter — can be null). Configuration options for storing the output report in the repository. This will enable viewing and working with the output result in subsequent tasks. Type esriFolderItem. |
Variable of type TaskResultOutput
The example below generates a Market Ranking report from a table of customers and the sales associated with them.
C# |
// Instantiate the BAServerHelper class to access analysis methods BAServerHelper baServerHelper = new BAServerHelper(); baServerHelper.ActiveDatasetID = "USA_ESRI"; // Optional parameter baServerHelper.IsFullErrorMessage = true; // Default is false // You can specify below a domain of your local Business Analyst Server. //baServerHelper.BAServerDomain = "esri.com"; // If a domain name is specified, a local server name in output URLs is replaced with the // fully-addressable server name so people and machines outside the domain of your local // Business Analyst Server instance can access these URLs. RenderingParameters imageOptions; TaskOutputType[] outputOptions; esriFolderItem outputLayer; esriFolderItem outputReport; // ========= STEP 1: Geocode the table of customers RecordSet table = new RecordSet(); // Create table fields string[] fieldNames = new string[] { "CUST_ID", "NAME", "ADDRESS", "CITY", "STATE", "ZIP", "STORE_ID", "SALES" }; table.Fields = new Fields(); table.Fields.FieldArray = new Field[fieldNames.Length]; for (int i = 0; i < fieldNames.Length; i++) { Field field = new Field(); field.Name = fieldNames[i]; field.Type = esriFieldType.esriFieldTypeString; table.Fields.FieldArray[i] = field; } // The last field is numeric table.Fields.FieldArray[fieldNames.Length - 1].Type = esriFieldType.esriFieldTypeInteger; // Create table records table.Records = new Record[5]; table.Records[0] = new Record(); table.Records[0].Values = new object[] { "101", "CUST1", "2355 Pine St.", "San Francisco", "CA", "94115", "1", 12343 }; table.Records[1] = new Record(); table.Records[1].Values = new object[] { "102", "CUST2", "2501 California St.", "San Francisco", "CA", "94115", "1", 10008 }; table.Records[2] = new Record(); table.Records[2].Values = new object[] { "103", "CUST3", "563 Ruger St.", "San Francisco", "CA", "94129", "2", 3200 }; table.Records[3] = new Record(); table.Records[3].Values = new object[] { "104", "CUST4", "301 Finley Rd.", "San Francisco", "CA", "94129", "2", 15802 }; table.Records[4] = new Record(); table.Records[4].Values = new object[] { "105", "CUST5", "614 Balboa St.", "San Francisco", "CA", "94129", "2", 4750 }; TableData tableData = new TableData(); tableData.RecordSet = table; // Specify geocode data GeocodeData geocodeData = new GeocodeData(); geocodeData.Table = tableData; CustomerStoreSetupByGeocodeTableParameters geocodeParameters = new CustomerStoreSetupByGeocodeTableParameters(); // Set specific analysis parameters geocodeParameters.GeocodeCustomers = true; geocodeParameters.GeocodeData = geocodeData; geocodeParameters.LinkField = "STORE_ID"; geocodeParameters.NameField = "NAME"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; outputLayer = null; TaskResultOutput customerGeocodeResult = baServerHelper.CustomerStoreSetupByGeocodeTable(geocodeParameters, imageOptions, outputOptions, outputLayer); PointLayer customerLayer = new PointLayer(); customerLayer.RecordSet = customerGeocodeResult.RecordSet; // ========= STEP 2: Create an analysis extent for San Francisco County StandardLevelsOfGeographyParameters geographyParameters = new StandardLevelsOfGeographyParameters(); // Set specific analysis parameters geographyParameters.GeographyFeaturesBehavior = esriStdGeographyType.esriStdGeographyTypeFirst; geographyParameters.GeographyIDs = new string[] { "06075" }; // FIPS ID code for San Francisco County geographyParameters.GeographyLevelID = "US.Counties"; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass }; outputLayer = null; outputReport = null; TaskResultOutput geographyResult = baServerHelper.StandardLevelsOfGeography(geographyParameters, imageOptions, outputOptions, outputLayer, outputReport); PolygonN polygon = (PolygonN)geographyResult.RecordSet.Records[0].Values[1]; ExtentData extentData = new ExtentData(); extentData.Extent = polygon.Extent; // ========= STEP 3: Execute the analysis MarketRankingParameters parameters = new MarketRankingParameters(); // Set specific analysis parameters parameters.AnalysisExtent = extentData; parameters.FeaturesLimit = 50; parameters.IncludeSummaryField = true; parameters.NameField = "NAME"; parameters.PrimaryRankField = "SALES"; parameters.RankingData = customerLayer; parameters.UseAllFeatures = true; // Set report options ReportOptions reportOptions = new ReportOptions(); reportOptions.ReportFormat = "PDF"; reportOptions.ReportHeader = new KeyValue[1]; reportOptions.ReportHeader[0] = new KeyValue(); reportOptions.ReportHeader[0].Key = "subtitle"; reportOptions.ReportHeader[0].Value = "Market Ranking Report for the customers table"; parameters.StandardReportOptions = reportOptions; // Set other parameters imageOptions = null; outputOptions = new TaskOutputType[] { TaskOutputType.GetFeatureClass, TaskOutputType.GetReport }; outputLayer = null; outputReport = null; TaskResultOutput result = baServerHelper.MarketRanking(parameters, imageOptions, outputOptions, outputLayer, outputReport); string reportURL = result.Reports[0].ReportURL; |