There was a conditional mapping change that I need to remove from the code repository, and unfortunately it’s not a .Net solution so Ctrl+Shft+F (Find in files) is not an option :|
Window search (built in) is not being helpful (as usual) and I’m too lazy to create a small script to search for the conditional mapping in the files.
Suddenly, I remembered about powershell, that should be able to do the job ;)
So in the end, after 15 minutes searching for the good stuffs at the web:
http://www.computerperformance.co.uk/ezine/ezine125.htm
http://technet.microsoft.com/en-us/library/dd347677.aspx
Tada, got the nice one line script below:
get-childitem C:\folders\ -recurse -include *.* | select-string 'some text in file' | group-object path | Format-Table -AutoSize -Wrap -Property Count, Group, Name
What it does:
- Search for all files under C:\folders\ + recursively
- look for ’some text in file’
- group the results by the path name
- format the result into table with autosize, wrap options.
- display the properties in order -> Count, Group, Name
Nice ;)
Simple multithreading exercise – Spawn different threads to collect data for different dates
Requirement: Need to fetch data by date. Ordering does not really matter and most likely this is for temporary purpose until the data service supports fetch by date range.
hhhmm… that sounds simple right, just spawn different threads for each date.
Okay, I admit that I spend more time than I expected just to come out with this simple task :p it’s been a while (lame excuse!) but hey, glad to come out with some code snippets below which does the job:
class Program
{
static void Main(string[] args)
{
List<Result> results = new List<Result>();
List<Thread> threads = new List<Thread>();
Random rnd = new Random();
Console.WriteLine("Collecting the results for different dates");
for (DateTime dt = DateTime.Now.Date; dt < DateTime.Now.Date.AddDays(10); dt = dt.AddDays(1))
{
Thread t = new Thread(new ParameterizedThreadStart(delegate (object obj)
{
int sleepTime = rnd.Next(1000, 5000);
Thread.Sleep(sleepTime);
int value = rnd.Next();
Result result = new Result { Date = (DateTime)obj, Amount = value };
results.Add(result);
Console.WriteLine("Result: {0}, Sleep: {1}, ThreadId: {2}", result, sleepTime, Thread.CurrentThread.ManagedThreadId);
}));
t.Start(dt);
threads.Add(t);
}
// wait until each thread completes
foreach (var item in threads)
item.Join();
// sort the result
results.Sort((x, y) => x.Date.CompareTo(y.Date));
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Showing results");
foreach (var item in results)
Console.WriteLine("Result: {0}", item);
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Created Threads state");
threads.ForEach(x => Console.WriteLine("Id: {0}, Status: {1}", x.ManagedThreadId, x.ThreadState));
Console.WriteLine(Environment.NewLine);
Console.WriteLine("Press any key to exit");
Console.Read();
}
}
class Result
{
public DateTime Date { get; set; }
public int Amount { get; set; }
public override string ToString()
{
return string.Format("Date: {0}, Amount:{1}", Date.ToString("dd-MMM-yy"), Amount);
}
}
Results are fetched with different sleep times to simulate that the data was returned in different sequences

Update 20 sep 2009:
Well things didn’t turn out as easy as it was expected to solve, after a week, bad things were getting started again, red dots/lines were showing from BIOS to windows, BSOD all the time when entering windows (could only logged in using safe mode). Finally gave up and I went back to the shop last weekend. and it’s confirmed by the tech support that the GPU was somehow corrupted and they said that it was pretty common for that particular brand :| since it was considered as 3rd grade (wish i knew about that really). Went to the distributor just across the building and out of luck again, they didn’t have ready stock for the replacement, so I need to wait for another 4 weeks, in the mean time I was given a temp VGA card (downgraded version of the current one). however the tech support guy told me not to have too high on hope eventhough i get the replacement, it might just as well happen again :| well, it’s time to save money to get a more decent card if/when it happens again *sigh*
It’s been quite some time that i haven’t encountered BSOD (blue screen) and need not to tell you all, it really sucks. Hey, it’s 2009 now and yeah it’s still around alrite.
It started a week back and last night was the worst, it hang then BSOD after just logged into windows. I thought it was the existing win7 O/S problem, then after trying other O/S even installing another new win7 O/S, the problem remained the same. I stayed up until almost 4AM looking for solutions and nothing seems to work, finally gave up (if i start opening the case, then it will be a sleepless night :p)
So after woke up this morning (actually afternoon), i started opening the case and tried quite a lot of things (reseat the vga, clean up the base plate, rearrange the cables, etc). finally after i switched the vga to another slot, it seems to be working fine (at least until this moment writing the blog post :p)
Well hopefully that resolved the problem for good, and i really hope it won’t show up if i ever use dual monitors.
One thing that quite surprised me was the amount of pages found in the net which are mentioning this problem with the vga (both ati and nvidia seem to have the same issue), a good one can be found here.



Just got blue screen when trying to start up VS2008 SP1 Profiler.
And as usual, google saved the day.
This applies to any PC which is using Intel Nehalem Processor (i7).
Hotfix can be downloaded at http://code.msdn.microsoft.com/KB958842
Just found out that the Visibility property of WPF controls is not having true / false value.
So just by returning bool (IsControlVisible) like the code below won’t work:
<ContentControl Visibility="{Binding Path=IsControlVisible}"></ContentControl>
Include this into the resources.
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
And use it in the control binding
<ContentControl Visibility="{Binding Path=IsControlVisible, Converter={StaticResource BooleanToVisibilityConverter}}"></ContentControl>
I’m currently using a modelling tool for the application design, and below is an example of how we have 2 entities, which in the end will produce 2 xsd files, Transaction.xsd and Person.xsd.

Notice in the Transaction.xsd below, there is a madeBy element with the type of Person which is declared in another Person.xsd (xs:import)

Now, if we want to generate the Transaction.xsd, it will give us
C:\Schema>xsd.exe Transaction.xsd /c
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.1432]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Type 'http://bembengarifin.wordpress.com/Person:Person' is not declared. Line 8, position 5.
Warning: Schema could not be validated. Class generation may fail or may produce incorrect results.
Error: Error generating classes for schema 'Transaction'.
- The datatype 'http://bembengarifin.wordpress.com/Person:Person' is missing.
If you would like more help, please type "xsd /?".
So how to resolve that is to use
C:\Schema>xsd.exe Person.xsd Transaction.xsd /c
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 2.0.50727.1432]
Copyright (C) Microsoft Corporation. All rights reserved.
Writing file 'C:\Schema\Person_Transaction.cs'.
Note: You will need to put the referenced xsd prior to the xsd which is having the references, or else it will throw the same error.
Hope this helps ;)
I just got my hands on TIBCO Business Events for the first time today and trying the Fraud Detection getting started project :P
When trying to start up the engine, I got the following error:
Error occurred during initialization of VM
Could not reserve enough space for object heap
Failed to create the Java VM

After googling for a while, it seems that during the startup, the engine will try to reserve/allocate memory space for the process. and if you have 1 Gb of RAM like I do, most likely you will get the same exception.
C:\Program Files\TIBCO\be\3.0\bin\be-engine.tra
#
# 32 bit JVM parameters for production. Increase heap size and tune other
# parameters as needed.
#
java.extended.properties=-server -Xms1024m -Xmx1024m ............................
So back up your be-engine.tra file and configure the value to a size that will work, for example below:
java.extended.properties=-server -Xms128m -Xmx256m ...........................
Hope this helps ;)
Business Objects – Get Webi (Web Intelligence) Prompts Information using InfoStore from CMS Repository
Finally found a better way to get the prompts for webi, previously I was using IDocumentInstance to get the prompt list, but to get the document instance iself can take around 30+ seconds :|
The code snippet below will show how to get the prompt list by using InfoStore to query the CMS repository, this will only take around 4 seconds :D
public List<string> GetWebIntelligencePrompts(int docId, EnterpriseSession session)
{
List<string> reportParameterList = new List<string>();
string query = string.Format("SELECT SI_ID, SI_NAME, SI_KIND, SI_PROCESSINFO.SI_HAS_PROMPTS, SI_WEBI_DOC_PROPERTIES FROM CI_INFOOBJECTS WHERE SI_ID = {0}", docId);
using (InfoStore iStore = (InfoStore)session.GetService("InfoStore"))
{
using (InfoObjects objList = iStore.Query(query))
{
if (objList != null && objList.Count > 0)
{
InfoObject infoObj = objList[1];// InfoObjects collection is 1-based, not 0-based index
Webi webi = infoObj as Webi;
if (webi != null && webi.HasPrompts)
{
// Not sure what's in the GetEnumerator() implementation, but using foreach below will cause an exception
//foreach (WebiDocPrompt prompt in webi.WebiDocPrompts)
//{
// reportParameterList.Add(new ReportParameter(prompt.PromptQuestion, ParameterType.Single));
//}
WebiDocPrompts prompts = webi.WebiDocPrompts;
for (int iPrompt = 0; iPrompt < prompts.Count; iPrompt++)
{
reportParameterList.Add(prompts[iPrompt].PromptQuestion);
}
}
}
}
}
return reportParameterList;
}
I’m not sure what’s in the GetEnumerator() implementation of the WebiDocPrompts, but using foreach for the collection will cause an exception below, so just use regular for statement instead ;)
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at BusinessObjects.Enterprise.Desktop.ISWebiDocPrompts.GetEnumerator()
at BusinessObjects.Enterprise.Desktop.WebiDocPrompts.GetEnumerator()
Really glad that finally found out a faster way now, hope this helps you as well ;)
Business Objects – Get Crystal Report 2008 Prompts using InfoStore from CMS Repository
I’m working on a POC where I created a crystal report 2008 report with some prompts then deployed the report into BO server.
I need to get the list of prompts (parameters) before generating the report and fortunately turns out that the prompt information is available in the CMS Repository, so by using the code snippet below, we can get the list of parameter names for a particular crystal report deployed in the BO server (CMS).
public static List<string> GetCrystalReportPrompts(int reportId, EnterpriseSession session)
{
List<string> reportParameterList = new List<string>();
string query = string.Format("SELECT SI_ID, SI_NAME, SI_PROCESSINFO.SI_PROMPTS FROM CI_INFOOBJECTS WHERE SI_ID = {0}", reportId);
using (InfoStore iStore = (InfoStore)session.GetService("InfoStore"))
{
using (InfoObjects objList = iStore.Query(query))
{
if (objList != null)
{
InfoObject infoObj = objList[1];// InfoObjects collection is 1-based, not 0-based index
#region Use Processing Info to get the prompts
//ProcessingInfo procInfo = infoObj.ProcessingInfo;
//Property promptsProperty = procInfo.Properties["SI_PROMPTS"];
//noParameters = (int)promptsProperty.Properties["SI_NUM_PROMPTS"].Value;
//foreach (Property prop in promptsProperty.Properties)
//{
// if (prop.Name == "SI_NUM_PROMPTS") // Ignore the number of prompt property
// continue;
// string promptName = prop.Properties["SI_NAME"].Value.ToString();
// reportParameterList.Add(promptName);
//}
#endregion
#region Cast to Report object to get the prompts (cleaner so we don't have to know the logic inside)
Report rpt = infoObj as Report;
if (rpt != null)
{
foreach (CrystalDecisions.Enterprise.Desktop.ReportParameter parameter in rpt.ReportParameters)
{
reportParameterList.Add(new ReportParameter(parameter.ParameterName, ParameterType.Single));
}
}
#endregion
}
}
}
return reportParameterList;
}
**Updates: The code snippet above provides getting the parameters by casting the InfoObject into CrystalDecisions.Enterprise.Desktop.Report, which is cleaner IMHO ;)
Unfortunately that we are not able to access the prompts / parameters using the same way for webi (web intelligence) report, the same properties are not available for webi :|
An interesting exception I got when try to access the first index of the InfoObjects collection
System.Runtime.InteropServices.COMException: Item 0 was not found in the collection.
at CrystalDecisions.Enterprise.ISInfoObjects.get_Item(Object Index)
at CrystalDecisions.Enterprise.InfoObjects.get_Item(Object index)
[Test]
public void adhoc_get_report_parameters()
{
string query = "SELECT SI_ID, SI_NAME, SI_PROCESSINFO.SI_PROMPTS FROM CI_INFOOBJECTS WHERE SI_KIND = 'CrystalReport' and SI_NAME = 'TestCRUniverse'";
using (InfoStore iStore = (InfoStore)_session.GetService("InfoStore"))
{
using (InfoObjects objList = iStore.Query(query))
{
if (objList != null)
{
Assert.That(objList.Count, Is.EqualTo(1));
InfoObject infoObj = objList[0];// This will cause the exception
InfoObject infoObj = objList[1];// This will work
}
}
}
}
Found the reason at : BusinessObjects Enterprise .Net SDK Developer Guide
Topic: To load a report from BusinessObjects Enterprise into RAS using the OpenDocument method of ReportAppFactory
Step#10: Note – The InfoObjects indexed class is 1-based, not 0-based.