MapPoint 2011- DataMap(ShadedArea) - Visual Studio - c#

I've got a question about adding a datamap to my current map in mappoint while importing data to a dataset.
So, i have an excel file that has the following columns in order: ID,Name,Adress,City,Country,PostalCode,Service,MoneyImport.
I'm creating a dataset to be used for the datamap:
object missing = System.Reflection.Missing.Value;
MapPoint.DataSet dataset = map.DataSets.ImportData(filename, missing,
MapPoint.GeoCountry.geoCountryItaly,
MapPoint.GeoDelimiter.geoDelimiterDefault,
MapPoint.GeoImportFlags.geoImportExcelSheet);
I'm using the "missing" value cause the MapPoint Application when running through the normal interface*(importing from the same excel file i use here)* recognises perfectly the datafields, so i don't have the need to specify their types by myself.
Then i'm tryin' to use this dataset in order to create the datamap i need. This map is supposed to display as shaded areas the "MONEYIMPORT field" on the map based on zoomlevel.
When using the normal mappoint interface it does it smoothly with no problem and no errors at all.
Object Import = 8;
MapPoint.Field GainedMoney = dataset.Fields.get_Item(Import);
This two lines are ment to let me add to the GainedMoney field the values of the 8th column of excel by exctracting 'em from the dataset.
So further i add the datamap:
MapPoint.DataMap datamap =dataset.DisplayDataMap(MapPoint.GeoDataMapType.geoDataMapTypeShadedArea, GainedMoney,
ShowDataBy: MapPoint.GeoShowDataBy.geoShowByZoomLevel,
DataRangeType: MapPoint.GeoDataRangeType.geoRangeTypeDefault,
DataRangeOrder: MapPoint.GeoDataRangeOrder.geoRangeOrderDefault,
ColorScheme: 13,
CombineDataBy: MapPoint.GeoCombineDataBy.geoCombineByAdd);
So the MapPoint object model decides to throw me an error that says that the type of area i'm tryin' to add to the map cannot be recognized, so it has been impossible to add it to the map.
I've checked several times if the attributes i pass to the .DisplayDataMap are correct, and they are identical to the ones i choose when creating the datamap through the user interface of mappoint, and still no result gained. Really i don't know anymore how to fix this.
If any of you would be able to help me and provide me a hint, please do so!
Thanks in advance,
George.

There are some articles on MP2Kmag.com to help with DisplayDataMap. In particular, the arrays you pass in as parameters are tricky. Also, the book Programming MapPoint in .NET was a big help to me in dealing with the DisplayDataMap method.

Related

Is it possible to pass a report dataset as a method parameter to a custom assembly in SSRS 2008 or above?

TL;DR In a SSRS 2008 report which uses a custom assembly to do some extra calculations can I pass an entire report dataset as a method parameter?
Full story
I have an SSRS report with 3 datasets, each returned from an SQL query.
(In case it makes a difference to my question they're currently shared datasets although I'm sure local would work too)
The largest and primary dataset is a list of tasks which may or may not have been completed. I have information in here such as the ID, status, create date/time, target resolution hours etc of each task.
This dataset is displayed in a tablix and is the focus of the report.
The remaining two datasets are not displayed and are for reference. One is a simple one column query which returns a list of holiday dates for the UK. The other is a small table which contains our exact business hours.
At the moment I'm able to loop through the rows in the tablix of tasks and pass multiple values from the current row to a method. This is useful if I want to do some calculations based on data found only in the current row. For example I could take the create date/time and the response target hours and the assembly would return a target date/time for the current task. Cool so far.
I want to do a more complicated version of this where I not only pass in the row data but the 2 other datasets to get my return value. This is because in reality the due date calculation is much more complex and must take into account changing business hours and holidays from the other 2 datasets.
Can I pass a dataset as a method parameter to an assembly? Something like:
=Code.MyClass.MyMethod(val1, val2, dataset1, dataset2);.
I've been unable to find much definitive information on this. Nearly all tutorials demonstrate what I'm already doing by processing single rows. I'm sure I had an MSDN article that hinted this was not possible but I've lost it (helpful I know). There's a post on the Microsoft forums where a moderator says it's not possible. The general lack of information and tutorials suggests it's not possible or I'm doing this in the wrong way.
Any suggestions?
(I have alternate solutions such as having the assembly fetch the other datasets or just writing something outside SSRS but I'm not pursuing those until I knnow whether it can be done this way).
An older topic on the MSDN forums Iterate through rows of dataset in report's custom code offers a more definitive answer as well as a potential solution to this problem.
Passing the DataSet as an object or collection is not a possibility because:
A dataset in Reporting Services is not the same type of object as an ADO.Net dataset. A report dataset is an internal object managed by the SSRS runtime (it's actually derived from a DataReader object) and not an XML structure containing datatables, etc. and cannot be passed into the report's custom code.
The only way to effectively loop through the rows of a report dataset is to call a custom function or referenced method in a report data region expression. Using this technique, it may be possible to pass all of the the row and field information into a code structure, array or collection.
The hint given in the above statement suggests passing row and field information into a code structure. A contributor to the linked MSDN topic, Migeul Catalao developed a workaround using such an approach.
A real-world scenario of it's usage with example code demonstrating Migeul Catalao's solution can be found here.
Granted, it is still more of a row-by-row approach, so I would strongly suggest moving outside of SSRS and pursue alternative solutions.
Although I've accepted the other answer due to it being clear and helpful I didn't use that solution in the end (I was too stupid to understand it) and went for something else that works.
Disclaimer: This is a horrible hack. It works absolutely great in my scenario so I though I'd share in case it was useful to somebody else. There are many pitfalls here which could most likely be worked around given time.
I ended up following the advice in the comment given by Steven White and looking into LookupSet. This function allows you to query a dataset to return matching rows and a single column of data.
It looks like this:
LookupSet(Fields!ComparisonField.Value, // The value to search for, e.g '001'.
Fields!MatchField.Value, // The column to match on in the target dataset.
Fields!MyColumn.Value, // The column that will be returned.
"MyDataSet") // The dataset to search.
This returns a string array representing the returned values.
So far so good, but I needed ALL columns and rows. This is where the dirty hack appears in the form of string concatenation:
LookupSet(0, // Dummy ID 0.
0, // Matches the dummy ID 0 so all rows are returned.
Fields!Column1.Value + "[^]" // I concatenate all of the values into
+ Fields!Column2.Value + "[^]" // one string with the separator [^]
+ Fields!.Column3.Value, // so I can split them later.
"MyDataSet") // The dataset to query
I can now pass this to my custom assembly:
=MyAssemblyNamespace.Class.Method(LookupSet(0,0,Fields!Column1.Value..., "MyDataSet"), other, parameters, here)
Now in my C# method I have a generic object which after some reflection is actually an array of strings.
Cast to something useful:
var stringList = ((IEnumerable)MyDataSetObject).Cast<string>().ToList();
Split it:
foreach (var item in stringList)
{
var columns = item.Split(new[] { "[^]" }, StringSplitOptions.None);
// columns is a string[] which holds each column value for the current row
// So columns[0] is the value for column 1 in this row
// In my case I pushed the values to a DataTable row each time and built a datatable
// which when finished represented my dataset in full with all rows and columns.
}
I hope this makes sense to anyone trying to achieve a similar result.

How to generate and understand a list of field names in a UniData table

I'm new to both UniData and Uniobjects so if I ask something that obvious I apologize.
I'm trying to write a tool that will let me export contacts from our ERP (Manage2000) that runs on UniData (v. 6.1) and can then import them into AD/Exchange.
The primary issue I'm having is that I don't know which fields (columns?) in the table (file?) are for what. I know that that there is a dictionary that has this information in it but I'm not sure how to get what I want out of it.
I found that there is a command LIST.METADATA in the current UniData documentation from Rocket but it seems that either the version of UniData that we are using is so old that it doesn't have this command in it or it was removed from the VOC file for some unknown reason.
Does anyone know how or have any tips to pull out the structure of a table so that I can know which fields are for what data?
Thanks in advance!
At TCL:
LIST DICT contact.master
Please note that the database file name (EX: contact.master) is case sensitive. I don't have a UniData instance at the moment to provide an example output. However, it should be similar to Universe's output:
Field......... Type & Field........ Conversion.. Column......... Output Depth &
Name.......... Field. Definition... Code........ Heading........ Format Assoc..
Number
AMOUNT.WEBB A 1 MR22 Amt WEBB 10R M
PANDAS.COST A 3 MD2Z Pandass Cost 10R M
CREDIT.EXP.DT A 6 D4/ Cred Exp Date 10R M
For the example above, you can generally tell the "data type" of the field by looking at the conversion code. "D4/" is the conversion code for a date. "MD2Z" is a numeric conversion code, which we can guess is for monetary amounts. I'm glossing over the power of conversion codes, so please make sure to reference Rocket's documentation for these codes to truly understand what these fields would output. If you don't have the documentation in front of you, you can also reference this site:
http://www.koretech.com/kr_help/KU2/30/en/KMK_Prog_Conversions.htm
If you wanted to use UniObjects and C# to retrieve the field names in a file, you could use the following code:
UniCommand fieldSelectCommand = activeSession.CreateUniCommand();
fieldSelectCommand.Command = "SELECT DICT contact.master";
fieldSelectCommand.Execute();
UniSelectList resultList = activeSession.CreateUniSelectList(0);
String[] allFieldNames = resultList.ReadListAsStringArray();
Having answered your question, I would also like to make a recommendation that you check out Rocket's U2 Toolkit for .NET if you're mostly going to be selecting data from the database instead of reading and manipulating individual records:
http://www.rocketsoftware.com/products/rocket-u2-toolkit-net
Not only does it present an ADO.NET way of accessing the database, it also has a better performance version of the UniObjects library under the U2.Data.Client.UO namespace.
The Dictionary, in my opinion, is a recommendation of how the schema should behave. However, there are cases when it's not 100% accurate. You could run "LIST CONTACT.MASTER TOXML TO MYFILE.XML" which would create an xml file what you could parse.
See https://u2devzone.rocketsoftware.com/accelerate/articles/u2-xml/u2-xml#section-0 for more information.

Converting logic of DateTime.FromBinary method in TSQL query

I have a table that contain column with VARBINARY(MAX) data type. That column represents different values for different types in my c# DB layer class. It can be: int, string and datetime. Now I need to convert that one column into three by it's type. So values with int type go to new column ObjectIntValue and so on for every new column.
But I have a problems with transmitting data to datetime column, because the old column contains datetime value as a long received from C# DateTime.ToBinary method while data saving.
I should make that in TSQL and can't using .NET for convert that value in new column. Have you any ideas?
Thanks for any advice!
Using CLR in T_SQl
Basically you use Create Assembly to register the dll with your function(s) in it,
Then create a user defined function to call it, then you can use it.
There's several rules depending on what you want to do, but as basically you only want DateTime.FromBinary(), shouldn't be too hard to figure out.
Never done it myself, but these guys seem to know what they are talking about
CLR in TSQL tutorial
This is a one off convert right? Your response to #schglurps is a bit of a concern.
If I get you there would have to be break in your update script, ie the one you have woukld work up to when you implement this chnage, then you's have a one off procedure for this manouevre, then you would be updating from a new version.
If you want to validate it, just check for the existnec or non-existance of the new columns.
Other option would be to write a wee application that filled in the new columns from the old one and invoke it. Ugh...
If this isn't one off and you want to keep and maintain the old column, then you have problems.

How to get collection data into a chart object?

I have a C# app I'm building in Visual Studio 2010. The app contains code that crunches some input data to make some output data which I want to put on a chart. I can put the output data into any of the desired .NET collection objects. But I can't get the chart to look to an object defined on my form to get the chart's data. It seems the chart will only go to a service, database, or object that is external to my project.
I've reviewed all the posts I could find and it seems the chart object has evolved recently and the relevant posts aren't relevant any more because the Chart class has changed.
I've been working with the chart's DataSource property to specify the data source. I've also looked through all the options that come up with the automatic code completion facility of Visual Studio and can't find anything that looks or works like what I want.
This must be easy if one knows the trick. Anybody know the trick to this?
Thanks,
Bill
Eventually found the answer in MSDN under the heading "Adding Series Data at Run Time". Here is some example code I developed from the MSDN example code which shows the solution to my problem:
chart1.Series.Add("example");
chart1.Series["example"].ChartType = System.Windows.Forms.DataVisualization.
Charting.SeriesChartType.Line;
for (int i = 0; i < 20; ++i)
{
chart1.Series["example"].Points.Add(2 * i);
}
Cheers,
Bill

how do i get a count of columns that contain data from excel

I'm wondering if there is a simple property in the Excel interop that returns the count of used columns--ones containing data--from a given worksheet.
In example:
If myWorksheet.Columns.Count returns the total number of columns in a given worksheet, is there no equivalent along the lines of: myWorksheet.Columns.UsedCount?
I'm not sure if this question is too basic to even ask, but in searching google I can only seem to find rather arcane solutions to something that seems like a rather basic type of thing a person would want to do, when interacting with Excel.
I've tried to keep this brief by not posing up a bunch of unrelated code; but please let me know if I haven't been explicit enough.
Using the interop you can get the range of used elements using
oXLSheet.UsedRange.Address
where oXLSheet is your Worksheet object

Categories

Resources