Archive for 2004
Amazon-Web-Service And C# (ASP.NET)

I have signed up for the Amazon-Web-Service. It is a nice interface to handle the search queries. The results are displayed in XML. In C# I was using HttpWebRequest and HttpWebResponse. The code sample below is working well and fast. I have Integrated the HandleURL with a search-function-class that find the best prices for certain Artists and CD’s in some less minutes; 500 prices in about 2 minutes with CPU usage of 1-2%. Thus, the code below is worth to work with :-)

private HttpWebResponse reply;
private HttpWebRequest www;
private Stream s;
private StreamWriter sW;
private StreamReader reader;
private int rowcount;
private string webdata;
private bool halt=false;
private Match M; // using System.Text.RegularExpressions;

void HandleURL()
{
// Service=AWSECommerceService&SubscriptionID=#yourid#Operation=ItemLookup&
// IdType=ASIN&Item=#ASIN#&MerchantId=All&ResponseGroup=OfferSummary
// #yourID# replace this with your SubscriptionID
// #ASINCode#

www = (HttpWebRequest)WebRequest.Create(/*GET Request with Query for Amazon-Web-Service*/);
www.Timeout=10000;
if(www==null) return;
reply = (HttpWebResponse)www.GetResponse();
s = reply.GetResponseStream();
reader =
new StreamReader(s, Encoding.ASCII);
while((webdata = reader.ReadLine())!=null&&halt==false)
{
RegEx a_NewPrice = new Regex(@”\$([^<]*)<“,RegexOptions.IgnoreCase | RegexOptions.Compiled);
if((M=a_NewPrice.Match(webdata)).Success)
if(M.Result(”$1″)!=null)
{
Response.Write(M.Result(”$1″));
halt=true;

}
}
// close everything here… dispose etc.
}
Related Links:
http://www.amazon.com/gp/aws/landing.html

 

Amazon-Web-Service And C# (ASP.NET)

I have signed up for the Amazon-Web-Service. It is a nice interface to handle the search queries. The results are displayed in XML. In C# I was using HttpWebRequest and HttpWebResponse. The code sample is working well and fast.

Click here to read the article:
http://blog.manueladam.com/Manuel/articles/165.aspx

VS.net debugging fixed
I am using Visual Studio for developing web appliactions. I was installing dotnet 1.1. I was programming windows based applications for some while. Later I found debugging web applications had not worked anymore. I was getting the error that it can’t find Internet Explorer. Today I started the File-Monitor-Tool from Sysinternals. I noticed that VS was opening a browser-file while debugging the web-project.
C:\Documents and Settings\Administrator\Local Settings\Application Data\Microsoft\VisualStudio\7.1\browsers.xml
I was editing the file through VS integrated XML-Editor and changed the Browser Table, IsDefault-value for Internet Explorer; the issue was solved in changing the value from False to True.

State Boundary

I was watching the state border for about six weeks. I made some pics, enjoy! By the way seven images are large, so it is worth to checkout the orginal size.

005045033322334 335001006013003Urkunde

Working on a new website

I was starting yesterday to work on a new site. The idea was, to create a site with suggestions, including top and useful sites with a description. I was sorting out some previous made web templates; I picked out one and created the new layout.

The content will soon be ready.
 You can check it out here - click here.

Wallpaper #1

I was working on a new website and had the upcoming idea for a wallpaper.
It is simple but it looks not too bad, comments welcome.

The text below the fish is from Jeremiah 16:16. 

Behold I will send for many fishers, saith the LORD, and they shall fish them; and after will I send for many hunters, and they shall hunt them from every mountain, and from every hill, and out of the holes of the rocks.

File Content Replacer, C#/VS.NET

Last month my ISP contacted me about replacing my current modem with a new model. The replacement was free but required to change the IP.

I thought, “great, again going through all DNS settings for my domains”. For example: Microsoft DNS Server is storing IP entires in plain text files (ending with the extension “dns”).

I had an idea, to write an application for this purpose. I went ahead and programmed a simple tool. Its job was to allow folder selection and to replace a search query; its purpose was to do the same as notepad; using the replace option but processing multiply files. Later I was enhancing the program by using multi threading.


Operating System programmed on:
Windows 2000
Visual Studio C# Standard 2003
Everything is starting by selecting a Folder. Code snipped:FileInfo [] fI;

private void button1_Click(object sender, System.EventArgs e)
{

DialogResult A=this.folderBrowserDialog1.ShowDialog();
if(DialogResult.OK==A){

System.IO.DirectoryInfo D = new DirectoryInfo(this.folderBrowserDialog1.SelectedPath);
fI = D.GetFiles(this.TB_extension.Text);
this.tempFolder = this.folderBrowserDialog1.SelectedPath;
MessageBox.Show(fI.GetLength(0).ToString()+” File(s) found.”);
if(fI.GetLength(0)>0) this.B_Process.Enabled=true;

}

}

Then it is starting to handle the threads (void).

System.Threading.Thread a;
a =
new Thread(new ThreadStart(handlingThreads));
a.Start();

I was using a Hashtable, to store the file location and to let the processing thread know what it should work on.

Hashtable CurrentThreads = new Hashtable();

It is important to limit the number of threads executed the same time. Thus, the application can run safe; it is not over loading the CPU.

void handlingThreads(){

System.Collections.IEnumerator Enumerator = fI.GetEnumerator();

lock(pB){

this.pB.Maximum = fI.GetLength(0)+2;
this.pB.Visible=true;

}

this.T_Query=this.TB_Query.Text;
this.T_Replace=this
.TB_Replace.Text;

bool ok;
while
(ok = Enumerator.MoveNext()){

Thread currentP = new Thread(new ThreadStart(CurrentFile));
this
.CurrentThreads.Add(currentP,Enumerator.Current); // Store file location in Hastable
currentP.Start(); // Start Thread
Thread.Sleep(1); // Pause the thread. If you leave this out your CPU would get a usage of 100% when handling many files

while(this.CurrentThreads.Count>5){

Thread.Sleep(10); // Queue the processing when more than 5 threads are running the same time

}

}

int count=0;
while(CurrentThreads.Count>0&&!this.cancle)
// Wait till all threads are closed. (sure is sure)
{
if(count>30) Thread.Sleep(10); else
Thread.Sleep(10000); count++; // Don’t wait forever.
}

this.pB.Step=this.pB.Maximum;
MessageBox.Show(
this
,”Done!”,”",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.pB.Visible=false
;
this.pB.Value = 0;

}

The final step to search, find and replace:

public void CurrentFile(){

string cF;

try{

cF = this.CurrentThreads[Thread.CurrentThread].ToString();

}
catch(System.Exception ex){

lock(errors)
{
errors+=ex.ToString()+”\n”;
}

return;
}

try{
string oFile = this.tempFolder + @”\” + cF;
//Enumerator.Current;
StreamReader q = File.OpenText(oFile);
string
tempContent = q.ReadToEnd();
q.Close();
q=
null;

tempContent = Regex.Replace(tempContent, T_Query,Regex.Unescape(T_Replace));
StreamWriter q2 = File.CreateText(oFile);

q2.Write(tempContent);
q2.Close();
q2=
null;
System.Threading.Thread.Sleep(10);
}

catch(System.Exception ex){

lock(errors)
{
errors+=ex.ToString()+”\n”;
}

}

finally
{
RemoveThread(Thread.CurrentThread);
}

}

You can download the entire project ZIP file here: http://blog.manueladam.com/download/FCR.zip
License: Free, Link to us.
Author: Manuel ADAM

 

 

 

 

 

Background Music #1 on Flashkit.com

I have signed up to be a constributer for background music on www.flashkit.com. They was reviewing and accepted it. You can check it out here: http://www.flashkit.com/search.php?term=Manuel+Adam&cat=loops…

The time is passing by quickly and the military life has been enjoyable. I have 64 days left. I thank God for his blessing and protection. I am meeting a lot of people. Even after six months, I still see new faces. Next monday the new Troop will arrive. They will have a hard basic training for six weeks and then they will be soldiers. I can remember when I first started in January. It was truly a hard time. Thanks for all prayers, I value it.

Newage Background Music #1

I was working on a song last night. I asked some friends and they told me that they like it. It can be used as background music for a spot or flash animation.

Check it out here: http://blog.manueladam.com/bgmusic.mp3
When you decide to use this file in your own project/site please refer to this site.
Last year I bought the Audigy Platinum eX.
The package included the Music Studio Storm.
That is what I used to make the music.

Reserved Words

When you use file systems like “FAT” or “NTFS”, there are restrictions by naming a folder or file. You cannot use specific words to name your data. The restricted words called “reserved words”. One example is: your PC is communicating with your printer on LPT1, the reserved word is: LPT1. To name a folder “LPT1″,”LPT2″,”LPT3″, etc. wouldn’t work, unless you are one PC-freak, knowing how to hack.

There is also some interesting fact about using the space character: folders cannot end with empty spaces, when you try it, it will be ignored and left out.

Using Internet Explorer there is a special bug creating folders or files that usually cannot be deleted. Indeed the file system is messed up by ignoring the rules of naming a folder or file. Such problems are found in the folder next to “C:\Documents and Settings\[your login name]\Local Settings\Temporary Internet Files\Content.IE5\..”. The error: files like something[1]. cannot be deleted.

To solve this issue you are required to have a short Command-Line or DOS knowledge, knowing how to change a folder name or using the commands like CD, DIR and DELETE.

dir /x /a:s browsing the folder where the problem is found.
Note the short names with 8 characters like DOCUME~1 and the long name Documents and Settings

Example:
Long name: C:\Documents and Settings\Manuel\Local Settings\Temporary Internet Files\Content.IE5\FOLDER
Short name: C:\DOCUME~1\MANUEL\LOCAL~1\TEMPOR~1\CONTENT.IE5\FOLDER

You need finally a tool called RM.exe. It is included in the Windows 2000 Resource kit under the apps\posix\ folder but you can find it browsing www.google.com, search for “download RM posix” (without the quote mark).

Copy the RM.exe to the root of your C: drive.
Open the Command Line (CMD.exe) and browse to C:\> by switching with CD\
Following should delete the file:
rm  //C/DOKUME~1/MANUEL~1/LOCAL~1/TEMPOR~1/Content.IE5/FOLDER/something[1].

More Reserved Words:
COM1-COM9, LPT1-LPT9, CON, PRN, AUX, CLOCK$, NUL

Related Links:
http://www.windowsnetworking.com
http://www.whatis.com