Solved

Need to write this in asp.net vb..net

Posted on 2007-03-26
2
287 Views
Last Modified: 2011-10-03
Function Main
      Dim strTemp, strSQL, strFilterList, varTemp, rstTemp, lngTemp,varParameters
      Dim strURLReport            
      Dim strFileName, strTimeFlag      
      Dim FS, i,  strUniqueID
      dim blnNoResult      
      dim strTemplate, strReportName, strParameters, strReportFormat      
            
      Dim rstMain
      
      strReportFormat = ".PDF"
                        
      'Log file name
      mstrReportFilePath = GetCDPath                        
      strLogFIle = mstrReportFilePath & "\" & TEMP_FOLDER & LOG_FILE & ".log"
      '-----------
            
      if mblnAutoRun then
            strStringtoAppend = "----------------------------------------------------------------------------------------" & vbCrLf
            lngErr = AppendStringToFile(strStringToAppend, strLogFile)
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | " & strActiveDivisionName & " | PROCESS STARTED"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
                                    
      strParamConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, APP_SERVER_NAME)
      strParamConnection = Replace(strParamConnection, REPLACE_DATABASE_NAME, DIVISION_DB_NAME)
      strParamConnection = Replace(strParamConnection, REPLACE_USERNAME, IIS_USERNAME)
      strParamConnection = Replace(strParamConnection, REPLACE_PASSWORD, IIS_PASSWORD)
      
      strActiveDBConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, APP_SERVER_NAME)
      strActiveDBConnection = Replace(strActiveDBConnection, REPLACE_DATABASE_NAME, APP_DB_NAME)
      strActiveDBConnection = Replace(strActiveDBConnection, REPLACE_USERNAME, IIS_USERNAME)
      strActiveDBConnection = Replace(strActiveDBConnection, REPLACE_PASSWORD, IIS_PASSWORD)
      
      strActiveIHConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, strActiveIHServerName)
      strActiveIHConnection = Replace(strActiveIHConnection, REPLACE_DATABASE_NAME, strActiveIHDBName)
      strActiveIHConnection = Replace(strActiveIHConnection, REPLACE_USERNAME, IIS_USERNAME)
      strActiveIHConnection = Replace(strActiveIHConnection, REPLACE_PASSWORD, IIS_PASSWORD)
            
      strActiveMWConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, strActiveMWServerName)
      strActiveMWConnection = Replace(strActiveMWConnection, REPLACE_DATABASE_NAME, strActiveMWDBName)
      strActiveMWConnection = Replace(strActiveMWConnection, REPLACE_USERNAME, IIS_USERNAME)
      strActiveMWConnection = Replace(strActiveMWConnection, REPLACE_PASSWORD, IIS_PASSWORD)
                        
      strActiveMAConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, strActiveMAServerName)
      strActiveMAConnection = Replace(strActiveMAConnection, REPLACE_DATABASE_NAME, strActiveMADBName)
      strActiveMAConnection = Replace(strActiveMAConnection, REPLACE_USERNAME, IIS_USERNAME)
      strActiveMAConnection = Replace(strActiveMAConnection, REPLACE_PASSWORD, IIS_PASSWORD)
      
      strActiveAWConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, strActiveAWServerName)
      strActiveAWConnection = Replace(strActiveAWConnection, REPLACE_DATABASE_NAME, strActiveAWDBName)
      strActiveAWConnection = Replace(strActiveAWConnection, REPLACE_USERNAME, IIS_USERNAME)
      strActiveAWConnection = Replace(strActiveAWConnection, REPLACE_PASSWORD, IIS_PASSWORD)
                              
      '-----------------------------------------------------------------      
      'Get last completed week ending date
      if mblnAutoRun then      
            'strWeekDate = FormatDateTime(DateAdd("ww", -1, DateAdd("d", 7 - DatePart("w", Now), Now)), vbShortDate)
            strWeekDate = FormatDateTime(DateAdd("ww", 0, DateAdd("d", 7 - DatePart("w", Now-1), Now-1)), vbShortDate)
      
            strSQL = SQL_GET_SELECTED_WEEK
                  
            strSQL = replace(strSQL,REPLACE_WEEK_DATE,strWeekDate)
                                                      
            Set rstTemp = ExecSQL(strActiveMWConnection, strSQL, 900, true)
            
            strCurrYear = rstTemp("merch_year").value
            strCurrPeriod = rstTemp("merch_period").value
            
            mstrYearPeriod = strCurrYear & RIGHT("00" & strCurrPeriod,2)
      else
            strSQL = SQL_GET_CURRENT_YEAR_PERIOD
                  
            strSQL = replace(strSQL,REPLACE_YEAR_PERIOD,mstrYearPeriod)
                                                      
            Set rstTemp = ExecSQL(strActiveMWConnection, strSQL, 900, true)
            
            strWeekDate = rstTemp("WEEK_DATE").value
            
            strCurrYear = rstTemp("merch_year").value
            strCurrPeriod = rstTemp("merch_period").value
      end if
      
      if mblnAutoRun then
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | RUN WEEK: " & strWeekDate
            AppendStringToLog strStringToAppend, strLogFile
      end if
                                                                        
      '-----------------------------------------------------------------
      
      strTemp = GetCDPath() & "\" & SQL_FILE_SELECT_PERIOD
                                    
      strSQL = ReadTextFile(strTemp)            
            
      strSQL = replace(strSQL,REPLACE_WEEK_DATE,strWeekDate)
                                                
      Set rstTemp = ExecSQL(strActiveMWConnection, strSQL, 900, true)
      
      rstTemp.filter = "calendar_year_code = " & strCurrYear & " and period_code = " & strCurrPeriod
      
      if not rstTemp.eof then
            mstrFromDate = rstTemp("period_start_date").value
            mstrToDate = rstTemp("period_end_date").value
      end if
      '----------GLOBAL_APPS-----      
      Set cnnGlobalApps = CreateObject("ADODB.Connection")
      cnnGlobalApps.Open strActiveDBConnection            
                
      if mblnAutoRun then
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | DROP TEMP TABLES - GLOBAL_APPS"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                                                            
      end if
            
      'Drop temporary tables
      call DropTmpTable(cnnGlobalApps,1)            
                              
      if mblnAutoRun then
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | CREATE TEMP TABLES - GLOBAL_APPS"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                                                            
      end if
                  
      '-----CREATE TEMPORARY TABLE-----
      strTemp = GetCDPath() & "\" & SQL_FILE_CREATE_TEMP_TABLE
      strSQL = ReadTextFile(strTemp)
                              
      cnnGlobalApps.Execute strSQL
                                                            
      
      '----------MW-----      
      Set cnnMW = CreateObject("ADODB.Connection")
      cnnMW.Open strActiveMWConnection            
                
      if mblnAutoRun then
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | DROP TEMP TABLES - MW"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                                                            
      end if
            
      'Drop temporary tables
      call DropTmpTable(cnnMW,2)            
                              
      if mblnAutoRun then
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | CREATE TEMP TABLES - MW"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                                                            
      end if
                  
      '-----CREATE TEMPORARY TABLE-----
      strTemp = GetCDPath() & "\" & SQL_FILE_CREATE_TEMP_TABLE_MW
      strSQL = ReadTextFile(strTemp)
                              
      cnnMW.Execute strSQL                                    
      
      '-------Main SQL
      if mblnAutoRun then            
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | EXTRACT DATA"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
      
      '-----Extract SL Components from IH to MW
      strTemp = GetCDPath() & "\" & SQL_FILE_MW_SL_COMPONENT
      strSQL = ReadTextFile(strTemp)
                  
      Set rstTemp = ExecSQL(strActiveIHConnection, strSQL, 900, true)
                                                                                                                               
      if not rstTemp.eof then
            'Insert into GlobalApps DB
            lngTemp = TransferDataBetweenServer("", cnnMW, "", TMP_TBL_MW_SL_COMPONENT, "", rstTemp, , False, 120)
            'lngTemp = TransferDataBetweenServer("", cnnMW, "", "TMP_MW_SL_COMPONENT" , "", rstTemp, , False, 120)                  
      end if                  
      '----------------------------------------------------
      strTemp = GetCDPath() & "\" & SQL_FILE_LOCATION_AW
      strSQL = ReadTextFile(strTemp)
            
      strSQL = replace(strSQL,REPLACE_BEGIN_DATE,mstrFromDate)
      strSQL = replace(strSQL,REPLACE_END_DATE,mstrToDate)
            
      if mblnAutoRun then      'Add by Ivan Guentchev #0001610      
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | SQL_FILE_LOCATION_AW"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
      
      Set rstTemp = ExecSQL(strActiveAWConnection, strSQL, 1800, true)      
                                                                                                                               
      if not rstTemp.eof then
            'Insert into GlobalApps DB
            lngTemp = TransferDataBetweenServer("", cnnGlobalApps, "", TMP_TBL_AW_DATA, "", rstTemp, , False, 120)
            'lngTemp = TransferDataBetweenServer("", cnnGlobalApps, "", "TMP_AW_DATA" , "", rstTemp, , False, 120)                  
      end if                  
                  
      '-------Main SQL
      strTemp = GetCDPath() & "\" & SQL_FILE_LOCATION_MA
      strSQL = ReadTextFile(strTemp)
            
      strSQL = replace(strSQL,REPLACE_BEGIN_DATE,mstrFromDate)
      strSQL = replace(strSQL,REPLACE_END_DATE,mstrToDate)
      strSQL = replace(strSQL,REPLACE_YEAR_PERIOD,mstrYearPeriod)
      
            
      if mblnAutoRun then      'Add by Ivan Guentchev #0001610      
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | SQL_FILE_LOCATION_MA"
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
      
      Set rstTemp = ExecSQL(strActiveMAConnection, strSQL, 1800, true)      

      if not rstTemp.eof then
            'Insert into GlobalApps DB
            lngTemp = TransferDataBetweenServer("", cnnGlobalApps, "", TMP_TBL_MA_DATA, "", rstTemp, , False, 120)
            'lngTemp = TransferDataBetweenServer("", cnnGlobalApps, "", "TMP_MA_DATA" , "", rstTemp, , False, 120)                  
      end if                  
      '------------------------------------------
      '-------Main SQL
      strTemp = GetCDPath() & "\" & SQL_FILE_LOCATION_MW
      strSQL = ReadTextFile(strTemp)
            
      strSQL = replace(strSQL,REPLACE_DIVISION_LEVEL_ID,DivisionLevel)      
      strSQL = replace(strSQL,REPLACE_BEGIN_DATE,mstrFromDate)
      strSQL = replace(strSQL,REPLACE_END_DATE,mstrToDate)
      strSQL = replace(strSQL,REPLACE_YEAR_PERIOD,mstrYearPeriod)
      
      if mblnAutoRun then      'Add by Ivan Guentchev #0001610
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | SQL_FILE_LOCATION_MW"
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
            
      Set rstTemp = ExecSQL(cnnMW, strSQL, 1800, true)
      
      
      if not rstTemp.eof then
            'Insert into GlobalApps DB
            lngTemp = TransferDataBetweenServer("", cnnGlobalApps, "", TMP_TBL_MW_DATA, "", rstTemp, , False, 120)
            'lngTemp = TransferDataBetweenServer("", cnnGlobalApps, "", "TMP_MW_DATA" , "", rstTemp, , False, 120)                  
      end if                  
      
      '-------------------------------------
      '-------Main SQL
      strTemp = GetCDPath() & "\" & SQL_FILE_MAIN
      strSQL = ReadTextFile(strTemp)
      
      if mblnAutoRun then      'Add by Ivan Guentchev #0001610            
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | FINAL QUERY"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
                        
      Set rstMain = ExecSQL(cnnGlobalApps, strSQL, 1800, true)
            
            
      If Not (rstMain Is Nothing)  Then
            if rstMain.recordcount = 0 then
                  if strLanguage = "F" then
                        strMessage = "Aucun résultat trouvé pour les critères sélectionné."
                  else
                        strMessage = "No data found for the selected criteria."
                  end if                                          
                  if mblnAutoRun then
                        strStringtoAppend = PAGENAME & "-" & METHODNAME & " | "      & strMessage
                        lngErr = AppendStringToLog(strStringToAppend, strLogFile)                              
                        strStringtoAppend = PAGENAME & "-" & METHODNAME & " | PROCESS ENDED"
                        AppendStringToLog strStringToAppend, strLogFile
                        strStringtoAppend = "----------------------------------------------------------------------------------------" & vbCrLf
                        AppendStringToFile strStringToAppend, strLogFile
                  end if
            else                  
                                                                                                                                    
                  Call GenerateReport(rstMain, strReportFormat)
                  Server.ScriptTimeout = iScriptTimeout
                                    
            end if
      end if
      
      'Drop temporary tables
      call DropTmpTable(cnnGlobalApps,1)            
                                                      
      'Close connection
      if isobject(cnnGlobalApps) then
            if not cnnGlobalApps is nothing then
                  if cnnGlobalApps.State <> adStateClosed  then
                        cnnGlobalApps.Close
                  end if
                  Set cnnGlobalApps = Nothing
            end if
      end if
                  
      'Drop temporary tables
      call DropTmpTable(cnnMW,2)            
                                                      
      'Close connection
      if isobject(cnnMW) then
            if not cnnMW is nothing then
                  if cnnMW.State <> adStateClosed  then
                        cnnMW.Close
                  end if
                  Set cnnMW = Nothing
            end if
      end if
                  
      Server.ScriptTimeout = iScriptTimeout      'reset to default timeout

      if mblnAutoRun then                                          
            Response.Write "<script LANGUAGE='javascript'>"
            Response.Write "window.history.go(-2);" 'must put this because if not the report is processed another time!!
            Response.Write "window.opener = '';"
            Response.Write "window.close();"
            Response.Write "</script>"
      else
            Response.Write "<script LANGUAGE='javascript'>"            
            Response.Write "alert('" & strMessage & "');"            
            Response.Write "history.back();"
            Response.Write "</script>"
      end if
End function      
0
Comment
Question by:mathieu_cupryk
2 Comments
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 500 total points
ID: 18795717
mathieu_cupryk... i don't think one expert want to work for you... this is a forum!!! please post an question about an specific case not an entrie code to translate
0
 

Author Comment

by:mathieu_cupryk
ID: 18796475
Just this part

Function Main
      Dim strTemp, strSQL, strFilterList, varTemp, rstTemp, lngTemp,varParameters
      Dim strURLReport            
      Dim strFileName, strTimeFlag      
      Dim FS, i,  strUniqueID
      dim blnNoResult      
      dim strTemplate, strReportName, strParameters, strReportFormat      
           
      Dim rstMain
     
      strReportFormat = ".PDF"
                       
      'Log file name
      mstrReportFilePath = GetCDPath                        
      strLogFIle = mstrReportFilePath & "\" & TEMP_FOLDER & LOG_FILE & ".log"
      '-----------
           
      if mblnAutoRun then
            strStringtoAppend = "----------------------------------------------------------------------------------------" & vbCrLf
            lngErr = AppendStringToFile(strStringToAppend, strLogFile)
            strStringtoAppend = PAGENAME & "-" & METHODNAME & " | " & strActiveDivisionName & " | PROCESS STARTED"            
            lngErr = AppendStringToLog(strStringToAppend, strLogFile)                  
      end if
                                   
      strParamConnection = Replace(CONN_STRING, REPLACE_SERVER_NAME, APP_SERVER_NAME)
      strParamConnection = Replace(strParamConnection, REPLACE_DATABASE_NAME, DIVISION_DB_NAME)
      strParamConnection = Replace(strParamConnection, REPLACE_USERNAME, IIS_USERNAME)
      strParamConnection = Replace(strParamConnection, REPLACE_PASSWORD, IIS_PASSWORD)
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question