Solved

More info on exception

Posted on 2004-08-18
21
283 Views
Last Modified: 2010-04-15
How can I find out what the error is?

System.IO.__Error.WinIOError(Int32 errorCode, String str)



referred to in the following exception:


There was a problem copying the original SMDR file from cosmo to tank.  Path to SMDR on COSMO:  \\cosmo\SMDR_Output\SMDR.csv

Path to SMDR on TANK:  C:\smdr\smdr.csv

Details:     at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.CopySMDRFromCosmoToTank()
Returned from method CopySMDRFromCosmoToTank()
Returned from method RemoveExistingFiles()
There was a problem during the ImportPhoneLog execution.  Details:     at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
   at System.IO.StreamReader..ctor(String path)
   at System.IO.File.OpenText(String path)
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.ReadInFile(String strFilePath)
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.timerImportPhoneLogWS_Elapsed(Object sender, ElapsedEventArgs e)
ortPhoneLog.ImportPhoneLogWS.timerImportPhoneLogWS_Elapsed(Object sender, ElapsedEventArgs e)
0
Comment
Question by:knowlton
  • 14
  • 7
21 Comments
 
LVL 5

Author Comment

by:knowlton
ID: 11835111
Here is the Windows Service source code:


using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.Diagnostics;
using System.ServiceProcess;
using System.Web.Mail;
using System.IO;
using BuyersFund.GatherMessages;
using BuyersFund.GeneralFunctions;
using BuyersFund.NEOMail;

namespace nsWindowsServiceImportPhoneLog
{
      public class ImportPhoneLogWS : System.ServiceProcess.ServiceBase
      {

            private FileStream fsFileStream;
                  
            private StreamWriter swStreamWriter;
                  
            private StreamReader srStreamReader;

            private SqlConnection SMDRConnection;
            private SqlDataAdapter SMDRDataAdapter;
            private DataSet SMDRDataSet;
            private DataTable SMDRDataTable;      
            private SqlCommandBuilder cmdSMDRBuilder;
            private DataRow SMDRDataRow;

                  
            public int intCompletedOkay;
            private string strTankConnection;
            private const string PATH_TO_SMDR_ON_TANK = "C:\\smdr\\smdr.csv";
            private const string PATH_TO_SMDR_ON_COSMO = "\\\\cosmo\\SMDR_Output\\SMDR.csv";
            private string USE_TABLE;


            private System.Timers.Timer timerImportPhoneLogWS;
            private static ArrayList arLines = new ArrayList();
            public static BuyersFund.GatherMessages.GatherMessages gmMessage = new BuyersFund.GatherMessages.GatherMessages();
            public static BuyersFund.GeneralFunctions.GeneralFunctions genFuncs = new BuyersFund.GeneralFunctions.GeneralFunctions();
                        
            public static string strDBConnection = "";
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.Container components = null;

            public ImportPhoneLogWS()
            {
                  try
                  {
                        // This call is required by the Windows.Forms Component Designer.
                        InitializeComponent();

                        strTankConnection = "server=TANK\\ECAS;Trusted_Connection=yes;database=smdr";                                                      

                        #if(DEBUG)                        
                        USE_TABLE = "CurrentCalls_Test";
                        #else
                              USE_TABLE = "CurrentCalls";
                        #endif
                  }
                  catch(Exception e)
                  {
                        gmMessage.AddMessage("IT","Using table:  " + USE_TABLE);                        
                        gmMessage.AddMessage("IT","connection to tank failed.  Details:  " + e.StackTrace);                                                
                  }
            }




            // The main entry point for the process
            static void Main()
            {
                  try
                  {
                        System.ServiceProcess.ServiceBase[] ServicesToRun;
      
                        // More than one user Service may run within the same process. To add
                        // another service to this process, change the following line to
                        // create a second service object. For example,
                        //
                        //   ServicesToRun = New System.ServiceProcess.ServiceBase[] {new Service1(), new MySecondUserService()};
                        //
                        ServicesToRun = new System.ServiceProcess.ServiceBase[] { new ImportPhoneLogWS() };

                        System.ServiceProcess.ServiceBase.Run(ServicesToRun);
                        //                        throw new Exception("ERROR HANDLING TESTING");
                        genFuncs.SendMessage("tom@buyersfund.com","Windows Service ImportPhoneLogWS","Main seems to be okay");
                  }
                  catch(Exception eee)
                  {
                        genFuncs.SendMessage("tom@buyersfund.com","PROBLEM FOUND IN ImportPhoneLogWS","PROBLEM:  Error Message:  " + eee.ToString());
                  }

            }


            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                  try
                  {
                        this.timerImportPhoneLogWS = new System.Timers.Timer();
                        ((System.ComponentModel.ISupportInitialize)(this.timerImportPhoneLogWS)).BeginInit();
                        //
                        // timerTrackRequest
                        //
                        this.timerImportPhoneLogWS.Interval = 30000;
                        this.timerImportPhoneLogWS.Elapsed += new System.Timers.ElapsedEventHandler(this.timerImportPhoneLogWS_Elapsed);
                        //
                        // ServiceTrackRequestStatus
                        //
                        this.ServiceName = "ImportPhoneLogWS";
                        ((System.ComponentModel.ISupportInitialize)(this.timerImportPhoneLogWS)).EndInit();
                        //                        throw new Exception("ERROR HANDLING TESTING");
                        genFuncs.SendMessage("tom@buyersfund.com","Windows Service ImportPhoneLogWS","InitializeComponent seems to be okay");
                  }
                  catch(Exception eee)
                  {
                        genFuncs.SendMessage("tom@buyersfund.com","PROBLEM FOUND IN ImportPhoneLogWS","PROBLEM:  Error Message:  " + eee.ToString());
                  }

            }

            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            protected override void Dispose( bool disposing )
            {
                  try
                  {
                        if( disposing )
                        {
                              if (components != null)
                              {
                                    components.Dispose();
                              }
                        }
                        base.Dispose( disposing );
                        //                        throw new Exception("ERROR HANDLING TESTING");
                        genFuncs.SendMessage("tom@buyersfund.com","Windows Service ImportPhoneLogWS","Dispose seems to be okay");
                  }
                  catch(Exception eee)
                  {
                        genFuncs.SendMessage("tom@buyersfund.com","PROBLEM FOUND IN ImportPhoneLogWS","PROBLEM:  Error Message:  " + eee.ToString());
                  }
            }


            /// <summary>
            /// Set things in motion so your service can do its work.
            /// </summary>
            protected override void OnStart(string[] args)
            {
                  try
                  {
                        this.timerImportPhoneLogWS.Enabled = true;            
                        //                        throw new Exception("ERROR HANDLING TESTING");
                        genFuncs.SendMessage("tom@buyersfund.com","Windows Service ImportPhoneLogWS","OnStart seems to be okay");
                  }
                  catch(Exception eee)
                  {
                        genFuncs.SendMessage("tom@buyersfund.com","PROBLEM FOUND IN ImportPhoneLogWS","PROBLEM:  Error Message:  " + eee.ToString());
                  }

            }
 
            /// <summary>
            /// Stop this service.
            /// </summary>
            protected override void OnStop()
            {
                  try
                  {
                        this.timerImportPhoneLogWS.Enabled = false;
                        //                        throw new Exception("ERROR HANDLING TESTING");

                  }
                  catch(Exception eee)
                  {
                        genFuncs.SendMessage("tom@buyersfund.com","PROBLEM FOUND IN ImportPhoneLogWS","PROBLEM:  Error Message:  " + eee.ToString());
                  }
            }


            private void timerImportPhoneLogWS_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                  try
                  {
                        //1.      copy the file to a temporary location
                        CopySMDRFromCosmoToTank();
                        gmMessage.AddMessage("IT","Returned from method CopySMDRFromCosmoToTank()");

                        //2.      Call stored procedure to remove the existing files for that day
                        RemoveExistingFiles();
                        gmMessage.AddMessage("IT","Returned from method RemoveExistingFiles()");
                        
                        //3.      Read in File
                        ReadInFile(PATH_TO_SMDR_ON_TANK);
                        gmMessage.AddMessage("IT","Returned from method ReadInFile(PATH_TO_SMDR_ON_TANK)");

                        //4.  Write out the file minus the header row
                        //This is so the CSV will import into the DataTable properly
                        WriteOutFileMinusHeaderRow(PATH_TO_SMDR_ON_TANK);
                        gmMessage.AddMessage("IT","Returned from method WriteOutFileMinusHeaderRow(PATH_TO_SMDR_ON_TANK)");

                        //5.  Now import the CSV file into the DataTable in memory
                        ImportDataIntoTankDB();
                        gmMessage.AddMessage("IT","Returned from method ImportDataIntoTankDB()");
                  
                        //6.      Delete the smdr file from temporary location
                        File.Delete(PATH_TO_SMDR_ON_TANK);
                        gmMessage.AddMessage("IT","Delete(PATH_TO_SMDR_ON_TANK)");

                        //7.  Run MOVE archive files to ArchiveCalls table

                        gmMessage.AddMessage("IT","Completed all steps for SMDR import");
                        gmMessage.WriteMessagesOutToFile("IT","C:\\Success_IPL.txt");
                  }
                  catch(Exception eee)
                  {
                        gmMessage.AddMessage("IT","There was a problem during the ImportPhoneLog execution.  Details:  " + eee.StackTrace);
                        gmMessage.WriteMessagesOutToFile("IT","C:\\error_IPL.txt");
                  }
            }      
      
            private void CopySMDRFromCosmoToTank()
            {      
                  try
                  {
                        File.Copy(PATH_TO_SMDR_ON_COSMO, PATH_TO_SMDR_ON_TANK, true);      
                        gmMessage.AddMessage("IT","SMDR CSV file copied over from cosmo to tank just fine");
                  }
                  catch(Exception e)
                  {
                        gmMessage.AddMessage("IT","There was a problem copying the original SMDR file from cosmo to tank.  Path to SMDR on COSMO:  " + PATH_TO_SMDR_ON_COSMO + "\n\nPath to SMDR on TANK:  " + PATH_TO_SMDR_ON_TANK + "\n\nDetails:  " + e.StackTrace);
                  }
            }

            private void RemoveExistingFiles()
            {
                  try
                  {
                        SqlConnection myConn = new SqlConnection(strTankConnection);
                        myConn.Open();
                        SqlCommand dataCommand = new SqlCommand("Delete " + USE_TABLE + " Where datediff(dd, callStart, GetDate() ) = 0", myConn);
                        dataCommand.Connection = myConn;
                        dataCommand.ExecuteNonQuery();
                        myConn.Close();                        
                  }
                  catch(Exception e)
                  {
                        gmMessage.AddMessage("IT","There was a problem running the Delete command for TANK" + e.StackTrace);
                  }
            }

            
            private void ImportDataIntoTankDB()
            {
                  DataSet ds;
                  long lngCounter;
                              
                  string  sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\smdr;Extended Properties='text;HDR=No;FMT=Delimited'";
                  string strSMDRSQL;

                  int intHours;
                  int intMinutes;
                  int intSeconds;

                  DateTime dt = new DateTime(2004,1,30);


                  gmMessage.AddMessage("IT","Connection String set to:  " + sConnectionString);

                  gmMessage.AddMessage("IT","ImportDataIntoTankDB");

                  strSMDRSQL = "select * from " + USE_TABLE;
                  SMDRConnection = new SqlConnection(strTankConnection);
                  SMDRDataAdapter = new SqlDataAdapter(strSMDRSQL,SMDRConnection);
                  SMDRDataSet = new DataSet();
                  SMDRDataAdapter.Fill(SMDRDataSet, "SMDR");                                          
                  SMDRDataTable = SMDRDataSet.Tables["SMDR"];                  
                  cmdSMDRBuilder = new SqlCommandBuilder(SMDRDataAdapter);                  
                  
                  OleDbConnection conn = new OleDbConnection(sConnectionString);
                  OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [smdr.csv]", conn);

                  gmMessage.AddMessage("IT","Just before TRY block inside method ImportDataIntoTankDB");
                  try
                  {

                        try
                        {
                              conn.Open();

                              gmMessage.AddMessage("IT","Just opened OleDBConnection, status:  " + conn.State.ToString());
                        }
                        catch(InvalidOperationException IOex)
                        {
                              gmMessage.AddMessage("IT","There was an InvalidOperationException thrown opening the connection.  Details:  " + IOex.Message + "\n--------\n" + IOex.StackTrace);
                        }
                        catch(OleDbException OLEDBex)
                        {
                              gmMessage.AddMessage("IT","There was an OleDbException thrown opening the connection.  Details:  " + OLEDBex.Message + "\n--------\n" + OLEDBex.StackTrace);
                        }

                        gmMessage.AddMessage("IT","Just opened OleDBConnection");
                        ds = new DataSet("SMDR");
                        gmMessage.AddMessage("IT","Just declared new DataSet ds");
                        da.FillSchema(ds, SchemaType.Source, "c:\\smdr\\smdr.csv");
                        gmMessage.AddMessage("IT","Just filled schema for ds");
                        da.Fill(ds, "c:\\smdr\\smdr.csv");                                                       
                        gmMessage.AddMessage("IT","FILL command successful inside method ImportDataIntoTankDB");

                        lngCounter = 0;                              

                        gmMessage.AddMessage("IT","init counter to 0");

                        foreach(DataRow dr in ds.Tables[0].Rows)  
                        {                                    
                                    
                              //While importing...change CallDuration to seconds only (like ring duration field)
                              
                              SMDRDataRow = SMDRDataTable.NewRow();

                              gmMessage.AddMessage("IT","Just added new row to data table inside method ImportDataIntoTankDB");

                              gmMessage.AddMessage("IT","Field value is:  --" + dr[0].ToString() + "--");
                              if((dr[0].ToString() != "")||(dr[0].ToString() != null)&&("--" + dr[0].ToString() + "--" != "----"))
                              {
                                    SMDRDataRow["callStart"] = dr[0].ToString();
                                    gmMessage.AddMessage("IT","Just appended to field callStart:  " + dr[0].ToString());
                              
                              
                                    dt = DateTime.Parse(dr[1].ToString());                        

                                    intHours = dt.Hour;
                                    intMinutes = dt.Minute;
                                    intSeconds = dt.Second;

                                    intSeconds += (intHours * 3600) + (intMinutes * 60);

                                    //2004/01/30 04:14:57
                                    //00:00:37
                                    //10
                                    //917709940787
                                    //I
                                    //5238983
                                    //5238983
                                    //????
                                    //0
                                    //1001995830,
                                    //0,
                                    //E502,
                                    //BF Fax 02,
                                    //T9168,
                                    //LINE 5.8,
                                    //0,
                                    //0

                                    gmMessage.AddMessage("IT","Seconds to be appended:  " + intSeconds.ToString());
                                    SMDRDataRow["callDuration"] = intSeconds;
                              
                                    SMDRDataRow["ringDuration"] = dr[2].ToString();
                                    gmMessage.AddMessage("IT","dr2 okay");
                                    SMDRDataRow["caller"] = dr[3].ToString();
                                    gmMessage.AddMessage("IT","dr3 okay");
                                    SMDRDataRow["direction"] = dr[4].ToString();
                                    gmMessage.AddMessage("IT","dr4 okay");
                                    SMDRDataRow["calledNumber"] = dr[5].ToString();
                                    gmMessage.AddMessage("IT","dr5 okay");
                                    SMDRDataRow["dialedNumber"] = dr[6].ToString();
                                    gmMessage.AddMessage("IT","dr6 okay");
                                    SMDRDataRow["account"] = dr[7].ToString();
                                    gmMessage.AddMessage("IT","dr7 okay");
                                    if(dr[8].ToString() == "0")
                                    {
                                          SMDRDataRow["isInternal"] = false;
                                          gmMessage.AddMessage("IT","dr8 okay FALSE value");
                                    }
                                    else
                                    {
                                          SMDRDataRow["isInternal"] = true;
                                          gmMessage.AddMessage("IT","dr8 okay TRUE value");
                                    }
                                    gmMessage.AddMessage("IT","dr8 okay");
                                    SMDRDataRow["callID"] = dr[9].ToString();
                                    gmMessage.AddMessage("IT","dr9 okay");
                                    if(dr[10].ToString() == "0")
                                    {
                                          SMDRDataRow["continuation"] = false;
                                          gmMessage.AddMessage("IT","dr10 okay FALSE value");
                                    }
                                    else
                                    {
                                          SMDRDataRow["continuation"] = true;
                                          gmMessage.AddMessage("IT","dr10 okay TRUE value");
                                    }                              
                                    gmMessage.AddMessage("IT","dr10 okay");
                                    SMDRDataRow["party1Device"] = dr[11].ToString();
                                    gmMessage.AddMessage("IT","dr11 okay");
                                    SMDRDataRow["party1Name"] = dr[12].ToString();
                                    gmMessage.AddMessage("IT","dr12 okay");
                                    SMDRDataRow["party2Device"] = dr[13].ToString();
                                    gmMessage.AddMessage("IT","dr13 okay");
                                    //SMDRDataRow["party2Name"] = dr[14].ToString();
                                    SMDRDataRow["party2Name"] = lngCounter.ToString();
                                    gmMessage.AddMessage("IT","dr14 okay");
                                    SMDRDataRow["holdTime"] = dr[15].ToString();
                                    gmMessage.AddMessage("IT","dr15 okay");
                                    SMDRDataRow["parkTime"] = dr[16].ToString();
                                    gmMessage.AddMessage("IT","dr16 okay");                              
                                    SMDRDataTable.Rows.Add(SMDRDataRow);      

                                    SMDRDataAdapter.InsertCommand = cmdSMDRBuilder.GetInsertCommand();
                                    SMDRDataAdapter.Update(SMDRDataSet,"SMDR");
                        

                                    if(lngCounter > 90115)
                                    {
                                          gmMessage.AddMessage("IT","Data DUMP:  " +  "|=BEGIN=|" + dr[0].ToString() + "|==|" + dr[1].ToString() + "|==|" + dr[2].ToString() + "|==|" + dr[3].ToString() + "|==|" + dr[4].ToString() + "|==|" + dr[5].ToString() + "|==|" + dr[6].ToString() + "|==|" + dr[7].ToString() + "|==|" + dr[8].ToString() + "|==|" + dr[9].ToString() + "|==|" + dr[10].ToString() + "|==|" + dr[11].ToString() + "|==|" + dr[12].ToString() + "|==|" + dr[13].ToString() + "|==|" + dr[14].ToString() + "|==|" + dr[15].ToString() + "|==|" + dr[16].ToString() + "|=END=|");
                                    }

                                    lngCounter++;

                                    gmMessage.AddMessage("IT","Just appended row:  " + lngCounter.ToString());                              

                              }
                                    
                        }
            
                        SMDRConnection.Close();

                        conn.Close();                                                      
                  }
                  catch(Exception e)
                  {                              
                        gmMessage.AddMessage("IT","Exception was raised while bringing CSV file into DataTable.  Details:  " + e.StackTrace + " -- " + e.ToString());
                        conn.Close();                              
                        gmMessage.AddMessage("IT","Closed conn connection");
                        gmMessage.AddMessage("IT","conn state is:" + conn.State.ToString());
                  }
            }
      
            private void ReadInFile(string strFilePath)
            {
                  srStreamReader=File.OpenText(strFilePath);
                  string sLine = "";
                  while (sLine != null)
                  {
                        sLine = srStreamReader.ReadLine();
                              
                        if ((sLine != null) && (sLine != ""))
                        {
                              arLines.Add(sLine);
                              //                              Console.WriteLine(sLine);
                        }
                  }                        
                  srStreamReader.Close();                  
                  //Console.WriteLine("Done reading in file");                              
            }


            private void WriteOutFileMinusHeaderRow(string strFilePath)
            {            
                                    
                  if(File.Exists(strFilePath))
                  {
                        File.Delete(strFilePath);                        
                  }

                        
                  fsFileStream = new FileStream(strFilePath, FileMode.OpenOrCreate, FileAccess.Write);
                  
                        
                  swStreamWriter = new StreamWriter(fsFileStream); // create a stream writer
                  
                        
                  //Start at 1 to remove header row                        
                  for (int a = 1; a < arLines.Count; a++)
                  {                              
                        if(arLines[a].ToString().Trim() != "")
                        {
                              if(arLines[a].ToString().Trim() != "REMOVE")
                              {
                                    swStreamWriter.WriteLine(arLines[a].ToString().Trim());
                              }
                        }
                  }                                          
                  swStreamWriter.Flush();                        
                  swStreamWriter.Close();                        
                  fsFileStream.Close();                  
            }            
            
      }//END of class
}//END of namespace
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11835117
looks to me like that is a custom exception someone threw ... what is the inner exception (if its set).
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11835134
                  gmMessage.AddMessage("IT","There was a problem copying the original SMDR file from cosmo to tank.  Path to SMDR on COSMO:  " + PATH_TO_SMDR_ON_COSMO + "\n\nPath to SMDR on TANK:  " + PATH_TO_SMDR_ON_TANK + "\n\nDetails:  " + e.StackTrace);

try using e.Tostring() so you get the message too :)
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835144
I'll get that info for you....

What I am doing is mixing the actual StackTrace from the exception......along with some custom messaging I have added before and after the StackTrace.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11835151
yes but you didnt write the message from the original exception (probably something like "File in use")
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835154
e.ToString(  )

Got it.....just a few minutes......thanks.....
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835166
>>>> yes but you didnt write the message from the original exception (probably something like "File in use")


Correct.

Sounds like replacing e.StackTrace   with e.ToString()   will help solve this.....


back in a few minutes....
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835368
I changed the souce a little bit so the errors are cleaner:


Here is the exception I get now:

There was a problem during the ImportPhoneLog execution.  Details:  System.NullReferenceException: Object reference not set to an instance of an object.
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.CopySMDRFromCosmoToTank()
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.timerImportPhoneLogWS_Elapsed(Object sender, ElapsedEventArgs e)



I also expected the method  CopySMDRFromCosmoToTank   to generate an error log file....but it did not!!!!!


I need to debug for a few more minutes......I'll be back with questions if I have any......
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835447
Okay.  It is failing on the copy attempt, that much is obvious.

Both of the methods  (timerImportPhoneLogWS_Elapsed  and  CopySMDRFromCosmoToTank)   write out the exceptions to a text file in the root of the C: drive on the server running the Windows Service.

I don't understand why only the "error_IPL<unique num>.txt" is getting written out to the C: drive and not the "IPL_COPY_PROBLEM<unique num>.txt"


Both files should be getting written out, correct?


=======================================
            


            private void timerImportPhoneLogWS_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
            {
                  try
                  {
                        //1.      copy the file to a temporary location
                        CopySMDRFromCosmoToTank();
                        gmMessage.AddMessage("IT","Returned from method CopySMDRFromCosmoToTank()");

                        //2.      Call stored procedure to remove the existing files for that day
                        RemoveExistingFiles();
                        gmMessage.AddMessage("IT","Returned from method RemoveExistingFiles()");
                        
                        //3.      Read in File
                        ReadInFile(PATH_TO_SMDR_ON_TANK);
                        gmMessage.AddMessage("IT","Returned from method ReadInFile(PATH_TO_SMDR_ON_TANK)");

                        //4.  Write out the file minus the header row
                        //This is so the CSV will import into the DataTable properly
                        WriteOutFileMinusHeaderRow(PATH_TO_SMDR_ON_TANK);
                        gmMessage.AddMessage("IT","Returned from method WriteOutFileMinusHeaderRow(PATH_TO_SMDR_ON_TANK)");

                        //5.  Now import the CSV file into the DataTable in memory
                        ImportDataIntoTankDB();
                        gmMessage.AddMessage("IT","Returned from method ImportDataIntoTankDB()");
                  
                        //6.      Delete the smdr file from temporary location
                        File.Delete(PATH_TO_SMDR_ON_TANK);
                        gmMessage.AddMessage("IT","Delete(PATH_TO_SMDR_ON_TANK)");

                        //7.  Run MOVE archive files to ArchiveCalls table

                        gmMessage.AddMessage("IT","Completed all steps for SMDR import");
                        gmMessage.WriteMessagesOutToFile("IT","C:\\Success_IPL.txt");
                  }
                  catch(Exception eee)
                  {
                        gmMessage.ClearALLMessages();
                        gmMessage.AddMessage("IT","There was a problem during the ImportPhoneLog execution.  Details:  " + eee.ToString());
                        gmMessage.WriteMessagesOutToFile("IT","C:\\error_IPL" + genFuncs.GenUniqueCode() + ".txt");
                  }
            }      







      
            private void CopySMDRFromCosmoToTank()
            {      
                  try
                  {
                        File.Copy(PATH_TO_SMDR_ON_COSMO, PATH_TO_SMDR_ON_TANK, true);      
                        gmMessage.AddMessage("IT","SMDR CSV file copied over from cosmo to tank just fine");
                  }
                  catch(Exception e)
                  {
                        gmMessage.ClearALLMessages();
                        gmMessage.AddMessage("IT","There was a problem copying the original SMDR file from cosmo to tank.  Path to SMDR on COSMO:  " + PATH_TO_SMDR_ON_COSMO + "\n\nPath to SMDR on TANK:  " + PATH_TO_SMDR_ON_TANK + "\n\nDetails:  " + e.ToString() + "\n\n\n\nINNER EXCEPTION:  " + e.InnerException.ToString());
                        gmMessage.WriteMessagesOutToFile("IT","C:\\IPL_COPY_PROBLEM" + genFuncs.GenUniqueCode() + ".txt");
                  }
            }

0
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 500 total points
ID: 11835469
because you aren't rethrowing the exception ...

               catch(Exception eee)
               {
                    gmMessage.ClearALLMessages();
                    gmMessage.AddMessage("IT","There was a problem during the ImportPhoneLog execution.  Details:  " + eee.ToString());
                    gmMessage.WriteMessagesOutToFile("IT","C:\\error_IPL" + genFuncs.GenUniqueCode() + ".txt");
                    throw eee;
               }
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11835531
sorry I was backwards.
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835631
I am still ONLY getting the error_IPL file.
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835685
I am supposed to throw the exception again inside the method  CopySMDRFromCosmoToTan  ????
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11835689
its probably failing right here :

                   gmMessage.AddMessage("IT","There was a problem copying the original SMDR file from cosmo to tank.  Path to SMDR on COSMO:  " + PATH_TO_SMDR_ON_COSMO + "\n\nPath to SMDR on TANK:  " + PATH_TO_SMDR_ON_TANK + "\n\nDetails:  " + e.ToString() + "\n\n\n\nINNER EXCEPTION:  " + e.InnerException.ToString());

in specific on the innerexception ... you arent checking that its there first.
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835697
>>>n specific on the innerexception ... you arent checking that its there first.

Okay.
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835790
Greg:

UPDATE:

I have one theory on what is happening.

I am getting a challenge / response on the server I am trying to get to.

When I go   Start -> Run   "\\cosmo"    it asks for a username and password.

That must be it.

==================================


error_IPL file:

There was a problem during the ImportPhoneLog execution.  Details:  System.IO.FileNotFoundException: Could not find file "\\cosmo\SMDR_Output\SMDR.csv".
File name: "\\cosmo\SMDR_Output\SMDR.csv"
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.CopySMDRFromCosmoToTank()
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.timerImportPhoneLogWS_Elapsed(Object sender, ElapsedEventArgs e)

==================================

IPL_COPY_PROBLEM file now reads:


There was a problem copying the original SMDR file from cosmo to tank.  Path to SMDR on COSMO:  \\cosmo\SMDR_Output\SMDR.csv

Path to SMDR on TANK:  C:\smdr\smdr.csv

Details:  System.IO.FileNotFoundException: Could not find file "\\cosmo\SMDR_Output\SMDR.csv".
File name: "\\cosmo\SMDR_Output\SMDR.csv"
   at System.IO.__Error.WinIOError(Int32 errorCode, String str)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
   at nsWindowsServiceImportPhoneLog.ImportPhoneLogWS.CopySMDRFromCosmoToTank()
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 11835844
is the service running as a domain user ?
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835865
It logs on as Administrator.
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835875
I am working with the Network Admin....I believe this to be a Net Admin related issue versus source code now....

I'll let you know!!!!!

You did answer my question, though....so the points are yours.

Tom
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835907
Greg:

I should have given you more background on this.

We are smack dab in the middle of changing a bunch of our servers around and re-tasking them to handle other duties.

So what I'm running into is related to these changes.

Tom
0
 
LVL 5

Author Comment

by:knowlton
ID: 11835929
Once I started re-throwing the Exception.......this confirmed that the issue is due to lack of me authenticating properly to the server I am trying to copy files from.  I showed this to the Network Admin and he grumbled something about "gotta change that" and walked off.  :)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

13 Experts available now in Live!

Get 1:1 Help Now