Solved

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

Posted on 2007-03-26
2
284 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 17

Accepted Solution

by:
lem2802 earned 500 total points
Comment Utility
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
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now