Posts
12
Comments
19
Trackbacks
1
Monday, May 05, 2008
BizTalk Database Maintenance

Out of the box, BizTalk Server 2006 doesn't provide any tool for auto clearing and cleaning up database used by BizTalk, this cause problems like performance and data storage issues. While browsing BizTalk installation directory (\BizTalk Installation Folder\Schema) I've found out few sql scripts that can used to cleanup the MessageBox  = BizTalkMsgBoxDb and Tracking = BizTalkDTADb database.

To clean MessageBox:

1) Stop all BizTalk related services.

2) Open Analyzer and open sql script:  msgbox_cleanup_logic.sql, press F5 (this will create the sp) - be sure to use BizTalkMsgBoxDb.

3) run bts_CleanupMsgbox

4) Start services.

For Tracking:

1) Execute dtasp_CleanHMData sp from BizTalkDTADb 

There are many sql script located in that Schema Directory and by reading and analyzing this scripts it will give us better understanding on how BizTalk stores the data.

 

posted @ Monday, May 05, 2008 3:23 PM | Feedback (1)
Wednesday, July 25, 2007
Changing Users Email address in MOSS 2007

It's been a week since I've installed MOSS on our development server and found out that it's quite easy to install and configure except for changing the email of users associated in MOSS. I've done some research and here is it:

1) Go to Sharepoint Server (physical server), Click Start -> Microsoft Office Server -> Sharepoint 3.0 Central Administration.

2) Login as administrator, on the left pane click Shared Services Administration.

3) Click the default Shared Services by default it's SharedServices1. Login as administrator.

4) Click user profiles and properties.

5) Click view user profiles.

6) User list is displayed. To edit the email address click the dropdown menu and select edit.

Note:

When adding user to group or site just click the address book popup to browse to the list of users (email address can be seen in this list) . 

 

 

posted @ Wednesday, July 25, 2007 3:27 PM | Feedback (1)
Tuesday, May 15, 2007
BizTalk Server 2006 Prerequisite

Link  can be found below:

http://msdn2.microsoft.com/en-us/library/aa578652.aspx

 


posted @ Tuesday, May 15, 2007 4:40 PM | Feedback (3)
Monday, March 19, 2007
C# Using ThreadPool for Multi-Threaded Application

I'm currently designing an application specifically to handle multiple processing at a certain time. I've read all articles about threading, whether to use a background worker, custom thread management, or by using a thread pool. What facinates me is the thread pool, just by passing a workitem viola you have a working multi-threaded application. See simple example below:

using System;
using System.Threading;

public class MyProcess
{

    private ManualResetEvent _doneEvent;

    public MyProcess(ManualResetEvent doneEvent)
    {
        _doneEvent = doneEvent;
    }

    public void MyProcessThreadPoolCallback(Object threadContext)
    {
        int threadIndex = (int)threadContext;
        Console.WriteLine("thread {0} started...", threadIndex);
        StartProcess();
        Console.WriteLine("thread {0} end...", threadIndex);

    // Indicates that the process had been completed
        _doneEvent.Set();
    }


    public void StartProcess()
    {
        // TODO: Add code for processing here

    }

  
}

public class ThreadPoolExample
{
    static void Main()
    {
        const int totalCountToProcess = 10;
        
        ManualResetEvent[] doneEvents = new ManualResetEvent[totalCountToProcess];
        MyProcess[] MyProcessArray = new MyProcess[totalCountToProcess];
      
        // Configure and launch threads using ThreadPool:
        Console.WriteLine("launching tasks...");
        for (int i = 0; i < totalCountToProcess ; i++)
        {
            doneEvents[i] = new ManualResetEvent(false);
            MyProcess p = new MyProcess(doneEvents[i]);
            MyProcess[i] = p;
            ThreadPool.QueueUserWorkItem(p.MyProcessThreadPoolCallback, i);
        }

        // Wait for all threads in pool to finished processing

        WaitHandle.WaitAll(doneEvents);
        Console.WriteLine("All Process are complete.");

           }
}

posted @ Monday, March 19, 2007 1:01 PM | Feedback (2)
Monday, February 19, 2007
N-Tier Web Applications using ASP.NET 2.0 and SQL Server 2005

Been looking for articles on how to implement a N-tier Web applications using ASP.NET 2.0 and SQL 2005 and I think this article clearly provide techniques and samples on how to.

http://www.15seconds.com/issue/050721.htm

posted @ Monday, February 19, 2007 6:02 PM | Feedback (4)
Thursday, February 15, 2007
ASP.NET AJAX "Atlas"

Microsoft recently released the v. 1.0 of ASP.NET AJAX "Atlas" and I've attended a demo about Atlas and find it really cool. Just simple drag and drop, cut and paste viola... you have an AJAX enabled website. It also include AJAX toolkit (extenders) which can be downloaded for free.

Microsoft offers new certification for ASP.NET Developers named MCDDP which stands for Microsoft Ceritified Drag-and-Drop Professional..

http://ajax.asp.net

posted @ Thursday, February 15, 2007 12:26 PM | Feedback (1)
Microsoft BizTalk 2004 SP2 Installation

I've tried to install the latest Service Pack of BizTalk 2004 and prompts me an installation error.

The Patch b3ce917f-b0f4-4b45-8fa7-97e44aec4a0e in the package Microsoft BizTalk Server 2004 Service Pack - (SP2) cannot be applied. It requires the installed version of Microsoft Enterprise Single Sign-On to be between 3.0.6070.0 and 3.0.7405.0. The installed version on this computer is 3.0.4902.0.  

I googled the error and found that solution is quite simple.. install the SP1 prior to the installation of SP2. (Huh!) weird, cause the normal Service packs from Microsoft doesn't require the installing the previous SPs.

posted @ Thursday, February 15, 2007 11:32 AM | Feedback (1)
Friday, July 21, 2006
BizTalk Database Customization

One of the problems we face during the development of BizTalk Application is that lack of space in the main drive C:\, Since we do default installation for MSSQL and BizTalk 2004, the Data File and Log Files is of course is installed in C:\Program Files\Microsoft SQL Server\MSSQL\Data.

To solve this is we have to move all BizTalk's DB from C:\ to another drive. Another thing is, we also do have the CovastDB which is used in X12 parsing which has to be moved also.

Note: Before performing this operation you should first stop the following services:

Enterprise Single Sign-On Services

BizTalk Service BizTalk Group : BizTalkServerApplication

Covast EDI Service

Script:

sp_detach_db 'BAMArchive'
sp_detach_db 'BAMPrimaryImport'
sp_detach_db 'BizTalkDTADB'
sp_detach_db 'BizTalkEDIDb'
sp_detach_db 'BizTalkHwsDb'
sp_detach_db 'BizTalkMgmtDb'
sp_detach_db 'BizTalkMsgBoxDb'
sp_detach_db 'BizTalkRuleEngineDb'
sp_detach_db 'SSODB'
sp_detach_db 'CovastDB'


sp_attach_db 'BAMArchive',
'E:\DBDat\BAMArchive.mdf',
'F:\DBLOG\BAMArchive_log.LDF'

sp_attach_db 'BAMPrimaryImport',
'E:\DBDat\BAMPrimaryImport.mdf',
'F:\DBLOG\BAMPrimaryImport_log.LDF'


sp_attach_db 'BizTalkDTADB',
'E:\DBDat\BizTalkDTADB.mdf',
'F:\DBLOG\BizTalkDTADB_log.LDF'

 

sp_attach_db 'BizTalkEDIDb',
'E:\DBDat\BizTalkEDIDb.mdf',
'F:\DBLOG\BizTalkEDIDb_log.LDF'

 

sp_attach_db 'BizTalkHwsDb',
'E:\DBDat\BizTalkHwsDb.mdf',
'F:\DBLOG\BizTalkHwsDb_log.LDF'


sp_attach_db 'BizTalkMgmtDb',
'E:\DBDat\BizTalkMgmtDb.mdf',
'F:\DBLOG\BizTalkMgmtDb_log.LDF'

sp_attach_db 'BizTalkMsgBoxDb',
'E:\DBDat\BizTalkMsgBoxDb.mdf',
'F:\DBLOG\BizTalkMsgBoxDb_log.LDF'

sp_attach_db 'BizTalkRuleEngineDb',
'E:\DBDat\BizTalkRuleEngineDb.mdf',
'F:\DBLOG\BizTalkRuleEngineDb_log.LDF'

sp_attach_db 'SSODB',
'E:\DBDat\SSODB.mdf',
'F:\DBLOG\SSODB_log.LDF'


sp_attach_db 'CovastDB',
'E:\DBDat\CovastDB.mdf',
'F:\DBLOG\CovastDB_log.LDF'

Luckily, BizTalk 2004 and Covast still work.

 

posted @ Friday, July 21, 2006 9:28 PM
Thursday, February 09, 2006
Processing Excel Documents in Biztalk 2004 (Excel Disassembler)

We all know that excel format is not supported in Biztalk 2004 and in order to process excel you must first buy a third-party excel adapter which I think Itemfield offers and this comes way to expensive since we are going to use it just once. And for this I've develop a solution wherein I can still process excel in Biztalk 2004 without any use of  a third party software.

My solution involves creating a customize disassembler pipeline that:

1) converts the stream to excel file using the Binary Writer same as what the File Adapter is using (in this step I also perform backup since it was converted back to its original form), and 2) from excel I save it to Unicode TAB Delimited format using the Excel Interop and save it to a temporary folder 3) open the file using Stream Reader 4) Clean the stream using regular expression (this is where unwanted data are deleted, like the header the subtotals etc. 5) After cleaning pass it back (  inMsg.BodyPart.Data = sw.BaseStream; inMsg.BodyPart.Data.Position = 0; ) 6) Delete the Temporary File

And also the Schema I'll be using is the TAB Delimited format of the data since It was already a clean data.

This is how you can save the Stream back to Excel File or any other format:

public void SaveStreamToFile(Stream inMsgStream)

{

int bufferSize = 4096;

byte[] buffer = new byte[4096];

int numBytesRead = 0;

FileStream fs = new FileStream( tmpExcelFileName,FileMode.CreateNew );

// Setup the stream writter and reader

BinaryWriter w = new BinaryWriter(fs);

w.BaseStream.Seek(0, SeekOrigin.End);

if (inMsgStream!=null)

{

inMsgStream.Seek(0, SeekOrigin.Begin);

// Copy the data from the msg to the file

int n = 0;

do

{

n = inMsgStream.Read(buffer, 0, bufferSize );

if (n==0) // We're at EOF

break;

w.Write(buffer, 0, n);

numBytesRead += n;

} while (n > 0);

}

w.Flush();

w.Close();

}

 

 

posted @ Thursday, February 09, 2006 10:39 AM
Thursday, June 23, 2005
Pagination using Stored Procedure

There are different approach on how to do pagination, but the I personally uses the dynamic sql pagination using subquery, and this I think is very efficient when doing a pagination in which all the fields to be filtered and sorted are all in the same table:

EXEC  ( 'SELECT ' + @sqlQuery +
    ' WHERE [ID] IN ' +
   '  (SELECT TOP ' + @strPageSize + ' [ID] FROM ' + @strBaseTable + @strFilter +
             @Connector +  '  [ID] NOT IN ' + '
                (SELECT TOP ' + @strSkippedRoW + ' [ID] FROM ' + @strBaseTable + @strFilter + @SortBy + ') '
   + @SortBy + ') ' + @SortBy)


Example we have our SalesOrderTable which comprises of SalesID, Date, ItemID, WholeSalerID, CustomerID and   the other table we have are Item Table, Wholesaler Table, CustomerTable . In this example lets take in mind these are the number of records per table:

SalesOrderTable = 2,300,000  |  ItemTable = 670,000  |  WholeSaler Table = 310,000 |  Customer Table = 900,000

What if the user wanted the data sorted using ItemName, CustomerName, WholeSaler Name which is on different table, in order to achive this we are going to use JOINS right??.  using the dynamic subquery will take forever.  I came up with more optimized approach which runs less than 8 secs..

 

1. Checks the orderby statement. If the sorting is based on fields that is on the same table or fields that are located in different table.

SET @strBaseTable =  ( CASE
   WHEN (@SortBy IS NOT NULL AND @SortBy!='') THEN
    (CASE
    WHEN    (     @SortByFilter='ID' 
              OR @SortByFilter='SalesOrderTable.WholeSalerTableCode' 
              OR @SortByFilter= 'SalesOrderTable.HPCode' 
              OR @SortByFilter='SalesOrderTable.ITEM'
              OR @SortByFilter='QTY'
              OR @SortByFilter='OEDate' )
     THEN ' SalesOrderTable'  
    WHEN @SortByFilter=  'a.CNAME' THEN ' SalesOrderTable INNER JOIN  dbo.CustomerTable a ON dbo.SalesOrderTable.WholeSalerTableCode = a.CustomerTable  '
    WHEN @SortByFilter=  'a.CustomerTablePRV' THEN ' SalesOrderTable INNER JOIN  dbo.CustomerTable a ON dbo.SalesOrderTable.WholeSalerTableCode = a.CustomerTable '
    WHEN @SortByFilter= 'a.CustomerTableCITY' THEN ' SalesOrderTable INNER JOIN  dbo.CustomerTable a ON dbo.SalesOrderTable.WholeSalerTableCode = a.CustomerTable '
    WHEN @SortByFilter= 'b.CNAME' THEN ' SalesOrderTable INNER JOIN dbo.CustomerTable b ON dbo.SalesOrderTable.HPCode = b.CustomerTable  '  
    WHEN @SortByFilter= 'b.CustomerTablePRV' THEN ' SalesOrderTable INNER JOIN dbo.CustomerTable b ON dbo.SalesOrderTable.HPCode = b.CustomerTable  '  
    WHEN @SortByFilter=  'b.CustomerTableCITY' THEN ' SalesOrderTable INNER JOIN dbo.CustomerTable b ON dbo.SalesOrderTable.HPCode = b.CustomerTable  '  
    WHEN @SortByFilter=  'ITEMDES' THEN ' SalesOrderTable     INNER JOIN     dbo.ItemTable ON dbo.SalesOrderTable.ITEM = dbo.ItemTable.ITEM '
    ELSE ' SalesOrderTable '
    END)  
   ELSE  ' SalesOrderTable '
             END )

2. Inserts only the ID with proper sorting to the temp table. I use #temp table because the filtering is dynamic.

 --- Inserts all ID to #TempTable with sorting
 SET @sql1 =   'INSERT INTO #TempTable ([ID])' +
             ' SELECT SalesOrderTable.[ID] FROM ' + @strBaseTable  + @strFilter + @SortBy

  EXEC @sql1

SET @rowCount = @@rowcount

3. Finally Get the proper data by linking all tables + temp table's ID and ROW

 --- Retrieves All Information Needed
           SELECT
    @rowCount AS RecordCount,
    dbo.SalesOrderTable.[ID],
                                         a.CustomerTablePRV AS WholeSalerTablePrv,
                                         a.CustomerTableCITY AS WholeSalerTableCity,
                                         dbo.SalesOrderTable.WholeSalerTableCode,
                                         a.CNAME AS WholeSalerTableName,
                                         b.CustomerTablePRV AS HPPrv,
                                         b.CustomerTableCITY AS HPCity,
                                         dbo.SalesOrderTable.HPCode,
                                         b.CNAME AS HPName,
                                        dbo.SalesOrderTable.ITEM,
                                        dbo.ItemTable.ITEMDES,
                                        dbo.SalesOrderTable.QTY,
                                        dbo.SalesOrderTable.OEDate,
                                        dbo.SalesOrderTable.CFM,
                                        dbo.SalesOrderTable.SalesID,
               dbo.SalesOrderTable.InpDate
              FROM      dbo.SalesOrderTable
   INNER JOIN     dbo.CustomerTable a ON dbo.SalesOrderTable.WholeSalerTableCode = a.CustomerTable
               INNER JOIN     dbo.CustomerTable b ON dbo.SalesOrderTable.HPCode = b.CustomerTable
               INNER JOIN     dbo.ItemTable ON dbo.SalesOrderTable.ITEM = dbo.ItemTable.ITEM
  INNER JOIN    #TempTable t ON dbo.SalesOrderTable.[ID] = t.[ID]
 WHERE (t.ROW >= @Start) AND (t.ROW <= @END)

Conclusion:

I do many test with the given scenario and I think this is the fastest approach I've ever had.

 

 

 

posted @ Thursday, June 23, 2005 1:18 PM
Thursday, June 09, 2005
Multi-Language Support in Classic ASP

I was ask to create COM+ that will return data from DB2 to Classic ASP that has multi-language support.

At first, it was really a headache on how I can accomplish this project. I've try to just passed the data comming from DB2 directly to ASP but it was totally garbage.I get data from DB2 using Dataset and I loop each rows in the dataset to construct a string, since string datatype is compatible with Classic ASP, My delimiter per row is  "___NLINE__" and per column is 
"N$XITM_". Also in order to connect to DB2, I used Ritmo Driver for iSeries, its a third-party driver that supports .NET.

Well the solution is seems simple, I connect to DB2 server passed the query and then convert the result to Ascii Codes, I set a delimiter for every row, every item, and every letters from COM+ and pass it to ASP then convert again to characters by using spit() , Chr & ChrW function to convert to character since  the charset and code page is already declared.

C# Code for converting to ASCII - delimited by & per character:

public static string Chr(string str)
  {
   if (str.Length > 0)
    {
    StringBuilder retStr = new StringBuilder();
    char[] arrychr = str.ToCharArray(); 
    foreach (char chr in arrychr)
    {
     int asciicode = (int)chr;
     retStr.Append("&" + asciicode.ToString());
    }
    return retStr.ToString();
   }
   return "";
  }

                    Function in ASP to convert from ASCII to Characters:

Function ConvertToChar(byval str)
'delimiters
dim delrows, delitems, delcols
delrows  = "___NLINE__"
delcols  = "N$XITM_"
delitems = "&"
'********************************
'return string
dim strConverted
'arrays
dim arryRows, arryCols, arryItems
'counters
dim ctrrows, ctrcol, ctritems
'Ubound Var
dim UarryRows,UarryCols,UarryItems
strConverted = ""
dim ichr
'Get the Rows
 arryRows = split(str,delrows)
 UarryRows = Cint(Ubound(arryRows))
 for ctrrows = 0  to UarryRows
 'Get Columns
 arryCols = split(arryRows(ctrrows),delcols)
 UarryCols = Cint(ubound(arryCols))
 for ctrCol = 0 to UarryCols
  'Get Items
  arryItems = split(arryCols(ctrCol),delitems)
  UarryItems = Cint(UBound(arryItems)) 
   for ctrItems = 0 to UarryItems
    'checks if Item is ASCII Code
    if len(arryItems(ctrItems)) > 1 then 
     ichr =  cLng(arryItems(ctrItems))
     select case ichr
     case 219,254,221: 'this characters are whitespace
     case else:
      if ichr > 254 then
       strConverted = strConverted & Chrw(ichr)
      else
       strConverted = strConverted & Chr(ichr)
      end if
     end select
    else
     strConverted = strConverted & arryItems(ctrItems)
    end if
   next
   'Adds NextItem Attrib
      if (ctrCol <> UarryCols) then strConverted = strConverted & delcols
  next
  'Adds NextLine Attrib
   if (ctrrows <> UarryRows) then strConverted = strConverted & delrows
next
ConvertToChar = strConverted
End Function

 

 

posted @ Thursday, June 09, 2005 11:35 AM | Feedback (1)
Tuesday, May 31, 2005
Naming Convention in Tables, Stored Procedures, Views, and UDF's

I would like to share my standard naming practice in MSSQL. This naming convention wouldn't be only good for the eyes but its purpose mainly is to know what the SP,View, or UDF does by just looking its name, also to easily access all related objects.

Tables: Use a noun, instead of using an underscore just use Pascal Case Naming just like in .NET.

1. CustomerProfile - table for Customer's Profile

2. Customer - table for Customer

3. Account - table for accounts

Stored Procedure. In SP names I use noun + the purpose of the SP.

1. CustomerProfileInsProc - sp for inserting operations in CustomerProfile Table

2. CustomerProfileUpdProc - sp for updating operations

3. CustomerProfileDelProc - sp for deleting operations

4. CustomerProfileSelProc - sp for selecting operations

Views:

1. CustomerProfileListView - list of customer profile

2. CustomerAccountListView - list of customer accounts

In UDF use verbs + camel casing

1. getTotalCredit

2. getLastLogin

3. computeTotalProduction

posted @ Tuesday, May 31, 2005 10:27 AM | Feedback (4)