Rob Chartier ~ Contemplation...

.NET, C#, Work, etc.

News






www.flickr.com
This is a Flickr badge showing public photos from Rob & Kat Chartier. Make your own badge here.


Even Quicker Links

July 2004 - Posts

Spam Box Responder...

Someone pointed this out to me the other day.  Its an auto-responder email he received....

If you so happen to be reading this automated e-mail message and you are one of those bulk e-mail bottomfeeders that I've somehow attracted to this account, I would at this time like to take a moment to implore you to kindly piss right the eff off please with your pointlessly, ill-conceived attempt at making a quick buck offa me.  Put simply, your efforts with me are nothing more than a waste of both of our time and effort for the following mentioned reasons, which are...first, that as long as I have any sense of self worth I will never register with any sort of a dating service you're running, since they are all nothing short of being quasi-humane societies, except instead of finding a loving home for an unwanted pet, you're dealing with unwanted people.  Not to mention there being this (unfortunate) lack of a euthanasia procedure for those miserable souls that no one wanted to bring home for keeps whom so happen to remain with the agency for just too long of a time.  In a nutshell, they're for desperate and ugly people as well as convicted felons looking for something more than a same sex relationship upon their anticipated parole.  Also, I'm quite certain that i'll never go bald, i have no interest in consolidating my interest, and the last thing i need is any kind of a damn diet.  Lastly, I am pleasantly relieved to be able to say that I am more than content with what i've been blessed to be packin due to something wonderfully selfless I must have done in a previous life, so please, point those measly extra three inches you're always boasting about elsewhere. 

With that said, if this so happens to not be the typical spam e-mail i've been so cursed with getting, then I must humbly offer you my sincerest apologies for the preceeding words and would hope that I at the very least kept you entertained whilst reading thru this somewhat revealing schpeel.  And I will (in time) respond to all of my personal e-mails from only those friends of mine who took the time to share something meaningful or even slightly interesting tales about their lives with me. Thank you my friend. 

Oh, and I almost forgot, there is yet one final bit of instruction for all those involved here, the very last (and infinitely most important) topic which absolutely must be addressed to even my dearest friends sending e-mails this way.  And it goes like this...if you ever so much as dare send me any form of chain-mail crap imploring me to take any kind of action that I normally would never do, such as having to forward what I've just read to ten people that I'd otherwise prefer to maintain a level of respect with, yet to not do as this carbon copy superstitious wankery tells me to, will result in me facing a certain wrath which is usually embedded in a threat that will bring forth great disaster with my love life, sex life, or anything at all having to do with my personal life (including the afterlife)...on my word, all of those e-mailing offenders will promptly be put over my knee and whooped like a rotten little bastard stepchild the next time I get you in my crosshairs.  Though to digress for a moment, as I would like to think the friends I choose are instinctively far wiser than anyone else that would spend more than a half a second on such drivel, let alone forward it on to me as well. 

Thus in conclusion, after finally having said all that, thank you ever-so-graciously for taking your valuable time to read this...and may good fortune be with you, always...forever and ever...amen...bitches.

Email Queue made simple...

 

Just a quick task that I completed recent, and wanted to share.  I needed to create a Sql Server based email queue.  Here is what I did...

1. Create a table that will hold the emails that need to be sent.  Watch for wrapping, if any.

CREATE TABLE [EmailQueue] (
 [EmailID] [int] IDENTITY (1, 1) NOT NULL ,
 [QueueDate] [datetime] NOT NULL CONSTRAINT [DF_EmailQueue_QueueDate] DEFAULT (getdate()),
 [SendDate] [datetime] NULL ,
 [EmailTo] [nvarchar] (150) NOT NULL CONSTRAINT [DF_EmailQueue_EmailTo] DEFAULT ('youremail@yourserver.com'),
 [EmailFrom] [nvarchar] (150) NOT NULL CONSTRAINT [DF_EmailQueue_EmailFrom] DEFAULT ('youremail@yourserver.com'),
 [EmailSubject] [nvarchar] (150) NOT NULL CONSTRAINT [DF_EmailQueue_EmailSubject] DEFAULT (N'[Default Subject]'),
 [EmailBody] [nvarchar] (3000) NOT NULL ,
 [EmailCC] [nvarchar] (150) NULL ,
 [EmailBCC] [nvarchar] (150) NULL ,
 [EmailPriority] [int] NOT NULL CONSTRAINT [DF_EmailQueue_EmailPriority] DEFAULT (0)
) ON [PRIMARY]
GO

 

2. Create a job that will send the emails, every 5 minutes.

BEGIN TRANSACTION           
  DECLARE @JobID BINARY(16) 
  DECLARE @ReturnCode INT   
  SELECT @ReturnCode = 0    
IF (SELECT COUNT(*) FROM msdb.dbo.syscategories WHERE name = N'[Uncategorized (Local)]') < 1
  EXECUTE msdb.dbo.sp_add_category @name = N'[Uncategorized (Local)]'

  -- Delete the job with the same name (if it exists)
  SELECT @JobID = job_id    
  FROM   msdb.dbo.sysjobs   
  WHERE (name = N'Send Email Queue')      
  IF (@JobID IS NOT NULL)   
  BEGIN 
  -- Check if the job is a multi-server job 
  IF (EXISTS (SELECT  *
              FROM    msdb.dbo.sysjobservers
              WHERE   (job_id = @JobID) AND (server_id <> 0)))
  BEGIN
    -- There is, so abort the script
    RAISERROR (N'Unable to import job ''Send Email Queue'' since there is already a multi-server job with this name.', 16, 1)
    GOTO QuitWithRollback 
  END
  ELSE
    -- Delete the [local] job
    EXECUTE msdb.dbo.sp_delete_job @job_name = N'Send Email Queue'
    SELECT @JobID = NULL
  END

BEGIN

  -- Add the job
  EXECUTE @ReturnCode = msdb.dbo.sp_add_job @job_id = @JobID OUTPUT , @job_name = N'Send Email Queue', @owner_login_name = N'sa', @description = N'No description available.', @category_name = N'[Uncategorized (Local)]', @enabled = 1, @notify_level_email = 0, @notify_level_page = 0, @notify_level_netsend = 0, @notify_level_eventlog = 2, @delete_level= 0
  IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

  -- Add the job steps
  EXECUTE @ReturnCode = msdb.dbo.sp_add_jobstep @job_id = @JobID, @step_id = 1, @step_name = N'Run Stored Proc', @command = N'exec [dbo].[SendEmailQueue] ', @database_name = N'master', @server = N'', @database_user_name = N'', @subsystem = N'TSQL', @cmdexec_success_code = 0, @flags = 0, @retry_attempts = 0, @retry_interval = 1, @output_file_name = N'', @on_success_step_id = 0, @on_success_action = 1, @on_fail_step_id = 0, @on_fail_action = 2
  IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
  EXECUTE @ReturnCode = msdb.dbo.sp_update_job @job_id = @JobID, @start_step_id = 1

  IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

  -- Add the job schedules
  EXECUTE @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id = @JobID, @name = N'Run the sucker', @enabled = 1, @freq_type = 4, @active_start_date = 20040726, @active_start_time = 0, @freq_interval = 1, @freq_subday_type = 4, @freq_subday_interval = 5, @freq_relative_interval = 0, @freq_recurrence_factor = 0, @active_end_date = 99991231, @active_end_time = 235959
  IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

  -- Add the Target Servers
  EXECUTE @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @JobID, @server_name = N'(local)'
  IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback

END
COMMIT TRANSACTION         
GOTO   EndSave             
QuitWithRollback:
  IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
EndSave:

 

3. Create the Stored Procedure to actually send the emails, which the job above runs every 5 minutes

CREATE procedure [dbo].[SendEmailQueue]

as


Set NoCount on

--make sure we have items to send, if not we dont need to do any of the--
--initial overhead temp table and select--
if exists( select * from EmailQueue where SendDate is null )
begin
 
 --global settings--
 Declare @EmailServer nvarchar(10)

--*****CHANGE YOUR MAIL SERVER HERE****--
 set @EmailServer = 'MYMAIL SERVER' 

 --message level variables--
 declare @EmailID bigint
 declare @QueueDate as datetime
 declare @SendDate as datetime
 declare @EmailTo as nvarchar(150)
 declare @EmailFrom as nvarchar(150)
 declare @EmailSubject as nvarchar(150)
 declare @EmailBody as nvarchar(3000)
 declare @EmailCC as nvarchar(150)
 declare @EmailBCC as nvarchar(150)
 declare @EmailPriority as int
 declare @OriginalEmailID as int
 
 --looping variables--
 declare @RowCounter bigint
 declare @Max bigint


 --create the temp table, mirror the existing queue table--
 Declare @EmQ Table (
  [EmailID] [int] IDENTITY (1, 1) NOT NULL ,
  [OriginalEmailID] [int] NOT NULL ,
  [QueueDate] [datetime] NOT NULL ,
  [SendDate] [datetime] NULL ,
  [EmailTo] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  [EmailFrom] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  [EmailSubject] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  [EmailBody] [nvarchar] (3000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
  [EmailCC] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
  [EmailBCC] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
  [EmailPriority] [int] NOT NULL
 )
 
 --insert the data that we need to send into our temp table--
 insert into @Emq
  select  EmailID as OriginalEmailID, [QueueDate], [SendDate], [EmailTo], [EmailFrom], [EmailSubject],
   [EmailBody], [EmailCC], [EmailBCC], [EmailPriority]
  from EmailQueue where SendDate is null
 
 --get the max num of records for our loop--
 select  @Max=count(*) from @Emq

 --set our row counter to the first id--
 set @RowCounter=1

 --loop for each record--
 while @RowCounter <= @Max
 begin
  --grab the individual record based on our record counter--
  select  @OriginalEmailID=[OriginalEmailID],
   @EmailID=[EmailID],
   @QueueDate=[QueueDate],
   @SendDate=[SendDate],
   @EmailTo=[EmailTo],
   @EmailFrom=[EmailFrom],
   @EmailSubject=[EmailSubject],
   @EmailBody=[EmailBody],
   @EmailCC=[EmailCC],
   @EmailBCC=[EmailBCC],
   @EmailPriority=[EmailPriority]
  from @Emq where [EmailID]=@RowCounter
 
 --set @EmailBody='[EmailID='+Cast(@OriginalEmailID as nvarchar)+']' + char(10) + char(13) + @EmailBody

  --send the email--
  Exec master.dbo.xp_smtp_sendmail
   @From_Name = @EmailFrom,
   @From = @EmailFrom, 
   @ReplyTo = @EmailFrom, 
   @To = @EmailTo,
   @Subject = @EmailSubject, 
   @Message =@EmailBody
   @Type = N'text/plain', 
   @Server = @EmailServer, 
   @Timeout = 20000
   
  --update the original table based on the original id--
  update EmailQueue set SendDate=GetDate() where [EmailID]=@OriginalEmailID

  --incrememnt our rowcounter--
  set @RowCounter=@RowCounter+1
 end
end

GO

Thats it. 

In your ASP or .NET code simply create a method that will insert items into the EmailQueue table above.  How simple is that?  One handy side effect is that you get a log of all emails and the exact time they were queued to be sent, and when they actually did get sent.

Oh btw, the xp_smtp_sendmail component is from http://sqldev.net/xp/xpsmtp.htm

 

Posted: Jul 29 2004, 01:37 PM by Rob Chartier | with 2 comment(s)
Filed under:
Nightlife in Europe...

We (my girlfriend and I) are heading over to Europe for a few weeks in September and she started to look into stuff to do while we are there.  She found this link:

http://www.euroteam.info/subeventdetail.asp?event=Concerts&subevent=France

Ok, WTF!?  Is this standard pricing for tickets for most events?  Even that crap Blink 182 is over $100 Euros.

We plan on flying into Amsterdam, then to Paris, down to Monaco/Rome, over to Venice, up to Zurich and back to Amsterdam all in about 14 days.  Quick trip so we need some ideas.  If you live there, or have travelled let me know your top 5 things to do, other than the obvious.

 

AMD pops out two notebook chips

 

Read about them here

 

Posted: Jul 19 2004, 12:58 PM by Rob Chartier | with no comments
Filed under:
ELM Enterprise Manager 3.1...

A MOM direct competitor is ELM Enterprise Manager.  I wonder if anyone has did any comparison between the two?

We have allot of very specific and disparate needs for a operations management software package such as this.  Something as simple as a robust API is a must have; I dont see any specific documentation on this with this product.  Anyone?

 

 

Posted: Jul 19 2004, 11:25 AM by Rob Chartier | with no comments
Filed under:
Moral Dilemma...

 

You are driving down the road on a wild, stormy night, when you pass a bus stop and see
three people waiting for the bus:

1. An old lady who looks as if she is about to die.
2. An old friend who once saved your life.
3. The perfect partner you have been dreaming about.

Which one would you choose to offer a ride to, knowing that there could only be one
passenger in your car?

This is a moral/ethical dilemma that was once actually used as part of a job application.

You could pick up the old lady, because she is going to die, and thus you should save her first.
Or you could take the old friend because he once saved your life, and this would be the perfect chance to pay him back.
However, you may never be able to find your perfect mate again.

What would you do?

 

Microsoft Operations Manager

Today is day one with my investigation of Microsoft Operations Manager (MOM)

What is MOM?

From the docs:

“Microsoft Operations Manager (MOM) 2005 provides event-driven operations monitoring, performance tracking, security policy enforcement, and auditing capability.”

Has anyone did a full technical analysis and wants to share their findings?  Any good links?  I'm on the beta so I have access to all of those docs. 

Posted: Jul 19 2004, 10:11 AM by Rob Chartier | with 1 comment(s)
Filed under:
ASP.NET Web Service Strange Behaviour...

So we have this Web Service in production, its not all that special; just handles thousands upon thousands of transactions per day.  Well I uploaded an assembly (after some extensive testing on a staging environment, of course) which was specific to a provider and is actually loaded in at runtime by .NET.  Think of it as a plug-in for the Web Service to make a call out to the 3rd party in real-time to handle a specific duty for the transaction.

Well for some reason, once I uploaded the assembly it broke the service.  We managed to pull some logs from the VB6 client and it states:

WSDLReader:XML Parser failed at linenumber 0, lineposition 0, reason is: The download of the specified resource has failed.  HRESULT=0x1: Incorrect function.  - WSDLReader:Loading of the WSDL file failed HRESULT=0x80070057: The parameter is incorrect.  - Client:One of the parameters supplied is invalid. HRESULT=0x80070057: The parameter is incorrect.

The reason for this error, it would appear, is that it could not download the WSDL from the ASMX; which means my ASP.NET 1.1 app could not generate it for some reason or another.

So, I immediately attempted to load up the ASMX in the local browser on the transaction server to reproduce the issue and get a more detailed description of the error.  It loaded up perfectly, and guess what?  That caused web service to behave normally from now on on the clients.

Nothing of use in any log (event, iis, etc..).  The only thing I have to go on is the error above, and the fact that by loading the ASMX up in IE fixed it.

Anyone have any ideas?  Have you seen this?  How on earth would I even begin to find out the cause?

 

Bubb Rubb

For a good laugh...

http://www.pr0n.com/images/misc/carwhistle.wmv

http://lisupras.com/wooo.html

It is work safe

Making Links Short...

Many times in any given day I find myself forced to send links to others some of which are excessively long and usually will break in email clients, news readers and other tools.  There have been many solutions available which I have used over the years to make the urls shorter, the most recent launch http://url123.com has to be one of the nicest implementations I have seen yet, and is done fully in .NET. 

Very clean interface with allot of features including the ability to track all of your URLs and it even allows for you to create your own sub domains.  For example, hit http://robc.url123.com/myblog which of course I have pointing to my current blog.  Since I can manage these links it’s a nice way to alias URL’s which change often and keep my top list of URL’s super handy (like those pesky MSDN url’s).

 

More Posts Next page »