Preview: Sushila Patel's Weblog
Sushila Patel's Weblog
When the going gets tough, upgrade
How to: Call Julia from C#
Fri, 05 Feb 2016 11:01:00 GMT
This is basic sample that shows how to call Julia code from C#
Set up the 64 bit solution
Build / Configuration Manager
Active solution platform /New X64/ Copy settings from Win32
Code as below
public static extern bool SetDllDirectory(string pathName);
public static extern void jl_init(string julia_home_dir);
public static extern void jl_eval_string(string str);
static void Main(string args)
libjulia.dll: All the necessary symbols to embed Julia are located in libjulia (location: \julia\bin)
More details can be found @ Embedding Julia
How to: Generate semitransparent Stacked Range bar chart
Wed, 07 Oct 2015 19:03:40 GMT
This sample demonstrates one of the ways to generate semitransparent Stacked Range bar chart.
The table consists of following columns and data
This table data has to be represented in the graphical manner as below
Gross and net as stacked bar charts,
ExpectedPerformance to be shown as green/ red block depending on the scores last semester has
If ExpectedPerformance > ScoreLastSemester display green block
If ExpectedPerformance < ScoreLastSemester display red block
Since the ScoreLastSemester and ScoreCurrentSemester are stacked in chart, the ExpectedPerformance on top should be displayed as semitransparent
The solution for the above requirements is as below.
The sample is developed using Microsoft SQL Server 2012->Sql server data tools
Step 1. Create Report server Project
Step 2. Right click Shared Datasource
Create new datasource pointing to correct database or used shared datasource.
Test the connection
Step 3. Right click dataset
Create shared DataSet that uses newly created data source or use existing one
Write the applicable Select query for the table
Step 4. Right click Reports
Add->New Item -> Report-> give appropriate name to report and click ok
Step 5. Once the report is open,
Right click on the design area
Insert Chart, select the Stacked Bar chart
Choose the proper dataset
Drag and drop the chart wherever applicable, resize if needed
Step 6. To achieve the stacked bar chart for the score last and current semester
Drag and drop the two fields ScoreLastSemester, ScoreCurrentSemester in the values of Chart Data(you get this option when you click on chart)
Drag and drop the Subject in the Category groups
c. Preview the report. By default we get the preview as follows
Step 7. To customize the graph for the values and colors for the scores last and current year
a. Select item from values, right click -> Select series Properties b. For ScoreLastSemester -> Change value field [Sum(ScoreLastSemester)] to [ScoreLastSemester] Go to Axes and Chart Area, change the horizontal axis from Primary to secondaryc. For ScoreCurrentSemester -> Change value field [Sum(ScoreCurrentSemester)] to [ScoreCurrentSemester]d. Click on ScoreLastSemester in the Properties, change the color from Automatic to CornflowerBlue(or any preferred)e. Click on ScoreCurrentSemester in the properties, change the color from Automatic to LightGrey(or any preferred)
Step 8. To get the Expected performance to display green/red based on the value of score last and current year
a. Select the Chart->Chart Data -> Values Click on + sign to add the ExpectedPerformance columnThis is alternative to drag and drop it from the report Data-> dataset section to Chart Data->Values section
Step 9. Go to Series Properties of ExpectedPerformance column
a. For ExpectedPerformance -> Change value field [Sum(ExpectedPerformance)] to [ExpectedPerformance]b. Go to Axes and Chart Area, change the vertical axis from Primary to secondary
Step 10. While on Series properties of ExpectedPerformance
a. Change the Chart type to Range typeb. Click on the low that got added to the ExpectedPerformance
c. Click Expression and type
d. Set the Color as Expression below
=switch (Fields!ExpectedPerformance.Value - Fields!ScoreLastSemester.Value >0,"Green" , Fields!ExpectedPerformance.Value-Fields!ScoreLastSemester.Value<0,"Red")
e. Go to preview, the green and red bars overlap the Score values. So there is need to set it semi transparent
Step 11. To get the Semitransparent effect
a. Go to Chart Properties-> Set the Palette property to SemiTransparentb. Change the ExpectedPerformance color to No ColorThe Preview will show default color for ExpectedPerformance with semitransparent effectc. To set the color back to Green/Red depending on the ScoreLastSemester value,Set the ExpectedPerformance
How To: Consume ASP.NET Webmethod in AngularJS
Wed, 29 Apr 2015 01:49:00 GMT
There are many queries related to how ASP.NET webmethod can be consumed in AngularJS.
The post demonstrate how to do it.
The solution is attached with has samples that show how this can be done
In Sample 1: Webmethod returns a string
In Sample 2: Webmethod returns a list of the ids that are retrieved from the database using very basic code to serialize object to JSON( uses: DataContractJsonSerializer)
In Sample 3: Webmethod takes id as the input and retrives the string(name) from the database
The data returned from webmethod is then consumed by AngularJS
Demo code location: Sample Code
Sample code is developed using Visual Studio 2013, Sql Server 2008R2.
Use applicable best practises in the real world applications for AngularJS/WebMethods
Remote Desktop Connection has stopped working
Mon, 11 Jul 2011 21:00:00 GMT
Ever come across the error "Remote Desktop Connection has stopped working"
Solution: Go to Remote Desktop Connection-> Local Resources Tab-> In the Local Devices and Resources uncheck the checkbox for Printers
That should do the trick!
Sun, 13 Mar 2011 01:36:00 GMT
I had attended couple of sessions on Silverlight few years ago, bumped into couple of blogs until recently that I actually got to work on it. Well I must say I am xapped so far.
Still learning to float in the Silverlight ocean, here is what I would like to share based on my mindset as C#/ASP.NET Developer.
I created my first Silverlight Application using VS.NET 2010. Everything was same old same old till I began coding. Normally for the ASP.NET application I would start with
tag to drag and drop control. May be I was missing that in the editor, or may be not. This control was in the toolbox.
Well with Silverlight we can use control. The main.xaml page that is created by default already has a tag.
In the Grid we have to define columns and rows as below
We can drag and drop controls in this Grid and below is how that would look
It may initially be bit unusual for few like me who have used % for width and height or
| and |
In case of Silverlight we can set height and width by giving attributes like "Auto", pixel size or "*" i.e "3*"
How does it consider the width and height for the page?
That's defined in the .html /.aspx file that resides in the Web application. The width and height is 100%. So no worries here.
Well not really, for this width and height to work wonders remove the designheight and designwidth of the in .xaml as given below
This may sound simple, non technical too. But if we are used to ASP.NET controls, Silverlight basic controls(alignment) or getting used to it can be little bit different.
I use VS.NET 2010, but Microsoft Expression Blend is preferred for designing...
Why I haven't swtiched to Expression Blend yet, hmmm ummm...working with VS.NET 2010 editor seems like being at home with just the interior changed from ASP.NET to Silverlight. Blend would mean like changing homes, will design using it soon...
Weekend, Vista Ultimate and my laptop
Mon, 16 Apr 2007 19:23:00 GMT
Probably everyone having a love/hate relationship with Microsoft is talking about Windows Vista these days.
Not to say some of my Anti-Microsoft friends are taking pride saying they have Vista installed on laptops/desktops. Reason could be the eye candy UI, features, watching TV or just about anything that the old Windows OS did not provide according to them.
I have Microsoft Vista Ultimate on my desktop for quite some time. The upgrade from Beta version to the final version was quite a journey. As of now I am impressed by the end product.
My oldie laptop Toshiba A35-S159 (with memory upgraded from 512MB to 1GB) is running on Windows XP Pro which absolutely isn't problem. Until recently that I started suffering from the Upgrade to Vista syndrome.
I am a bit reluctant to use the Upgrade feature for installing the new OS. A clean installation is always my preference. Taking backup of all important files -> installing new OS -> install all required software to the new OS are the steps I normally take assuming that I have lots of patience!
This time though I tried upgrading Windows XP pro to Windows Vista Ultimate after making sure that the Windows Vista Upgrade advisor gave me a green signal. There was a straight face on the Graphics card and couple of things that may/may not work after the Vista installation. Not serious enough to change decision of upgrade.
I started my installation and got the unhappy Windows Vista compatibility Report on my desktop with message about uninstalling the Toshiba Configfree and DVD-RAM Driver Software/BD Driver Software.
As far as Toshiba ConfigFree Error:
I rectified this error by uninstalling Toshiba Configfree (Toshiba Configfree wasn't installed at all on my System. As the error persisted every time I tried installing Vista, so all I did was download Toshiba ConfigFree from the Toshiba site, install it and uninstall. Well this worked!)
Regarding DVD-RAM Driver Software/BD Driver Software Error:
This was something I thought was related to Nero/Roxio software that was installed on my system. I sincerely uninstalled it.
Error persisted. I gave search for keywords like DVD/CD/BD. I managed to uninstall anything and everything that showed me the traces of these culprit words. This wasn't really of any help.
The whole upgrade experience wasn’t smooth so I thought of doing a clean install.
The clean installation gave me a good looking blue screen saying that the ACPI BIOS isn’t compatible.
Well Toshiba's site did have some BIOS upgrade which wasn't of any help. The error still persists and I think only some update on the BIOS compatibility from Toshiba will help.
Digging and searching more about this I found John’s Blog about Problems upgrading to Windows Vista which also talks about same issue.
Below is relevant extract from Toshiba Windows Vista Express Upgrade Promotion site
Toshiba offers Windows Vista drivers and Windows Vista-compatible BIOS upgrades for computer models that have a valid Windows Vista Capable sticker. It may be possible to upgrade to Windows Vista on some Toshiba computer models that do not have a Windows Vista Capable sticker, but Toshiba cannot guarantee that all features of the computer will function correctly after the upgrade. Microsoft’s Windows Vista Upgrade Advisor may be able to indicate whether or not your computer has the minimum hardware requirements for Windows Vista, but a positive report from the Upgrade Advisor is not a clear indication that the specific features of the computer will function correctly after an upgrade to Windows Vista.
My laptop does not have any Vista capable sticker. So will wait and watch if Toshiba can figure out a way to satisfy disappointed old customers!
On brighter note spendin[...]
Somasegar: Listening to your feedback - Expression and MSDN
Wed, 04 Apr 2007 13:29:00 GMT
Microsoft has its own ways to amuse people with there new products. Almost every year Microsoft invites MVP's (Microsoft Valuable Professional) for Microsoft Global Summit in Seattle. This year was no different and I was glad to be a part of it!
With keynote address from Bill Gates and Microsoft Product Managers sharing their vision of what's next, Product feedback all was informative, most of it under NDA.
Meeting Somasegar, Scott Guthrie whose blogs are survival kit for me was a pleasure. Nonetheless the exciting stuff that they mentioned about Microsoft coming up with was amazing.
I had been hearing about Microsoft Expression, Global Summit was no different. I did not work on it extensively, but a little bit of reading was done over the time. Though I got a chance to visit the Microsoft eCompanyStore at Seattle I am not sure what held me back from grabbing Microsoft Expression.
Well I always wished and still wish, such goodies should be a part of MSDN and to my surprise, below mail from my lead Steve Dybing about Announcement from Somasegar was a succor:
"...Based on this feedback, I am pleased to say that we will be making Expression Blend and Expression Web available to all MSDN Premium subscribers shortly after the release of Expression Studio (Q2 2007). Expression Blend and Expression Web are intended to help creative professionals collaborate with developers to create rich user experiences for the Web, Windows Vista applications and beyond, which means we need to make sure both tools are readily available to our developer community."
More about this announcement on Somasegar's blog: Listening to your feedback - Expression and MSDN
Very glad and can't wait to try it out!
How To: Hide close button for Windows Form
Tue, 05 Sep 2006 03:53:00 GMT
Several times there is a requirement to hide/disable the close button and to close the Form with a button on the Form to exit the application.
To hide the Close Button on the form we can set ControlBox propertyof the Form to False (by default its set to True)
How To: Get Selected Date from MonthCalendar control
Wed, 16 Aug 2006 02:03:00 GMT
Private Sub MonthCalendar1_DateChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DateRangeEventArgs) Handles MonthCalendar1.DateChanged
'Display the dates for selected range
Label1.Text = "Dates Selected from :" & (MonthCalendar1.SelectionRange.Start() & " to " & MonthCalendar1.SelectionRange.End)
'To display single selected of date
'MonthCalendar1.MaxSelectionCount = 1
'To display single date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
Label2.Text = "Date Selected :" & MonthCalendar1.SelectionRange.Start
private void MonthCalendar1_DateChanged(object sender, System.Windows.Forms.DateRangeEventArgs e)
//Display the dates for selected range
Label1.Text = "Dates Selected from :" + (MonthCalendar1.SelectionRange.Start() + " to " + MonthCalendar1.SelectionRange.End);
//To display single selected of date
//MonthCalendar1.MaxSelectionCount = 1;
//To display single selected of date use MonthCalendar1.SelectionRange.Start/ MonthCalendarSelectionRange.End
Label2.Text = "Date Selected :" + MonthCalendar1.SelectionRange.Start;
How To: Get the foldername in which the file resides
Fri, 04 Aug 2006 15:49:00 GMT
We come across situation many a times where we need the name of the folder in which the file resides. Let's say the folder is as "C:\Project1\CSProj1\somename\file1.cs"
We need to get the folder "somename"
We can do this by using the namespace System.IO. Code goes as below
Dim file As FileInfo = New FileInfo("C:\Project1\VBProj1\somename\file1.vb")
Response.Write(file.Directory & "
") 'O/P -> C:\Project1\VBProj1\somename
Response.Write(file.Directory.Name) 'O/P -> somename
FileInfo file = new FileInfo(@"C:\Project1\CSProj1\somename\file1.cs");
Response.Write(file.Directory + "
"); //O/P -> C:\Project1\CSProj1\somename
Response.Write(file.Directory.Name); //O/P -> somename
More about FileInfo members
How To: Extract numbers from string
Fri, 04 Aug 2006 02:56:00 GMT
Shared Function ExtractNumbers( ByVal expr As String ) As String
Return String.Join( Nothing, System.Text.RegularExpressions.Regex.Split( expr, "[^\d]" ) )
static string ExtractNumbers( string expr )
return string.Join( null,System.Text.RegularExpressions.Regex.Split( expr, "[^\\d]" ) );
Call the function as follows
Response.Write ( ExtractNumbers( "12EFR77" ) )
Response.Write ( ExtractNumbers( "12EFR77" ) );