More info on exception

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)
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
gregoryyoungConnect With a Mentor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
gregoryyoungCommented:
looks to me like that is a custom exception someone threw ... what is the inner exception (if its set).
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
gregoryyoungCommented:
                  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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
gregoryyoungCommented:
yes but you didnt write the message from the original exception (probably something like "File in use")
0
 
Tom KnowltonWeb developerAuthor Commented:
e.ToString(  )

Got it.....just a few minutes......thanks.....
0
 
Tom KnowltonWeb developerAuthor Commented:
>>>> 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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
gregoryyoungCommented:
sorry I was backwards.
0
 
Tom KnowltonWeb developerAuthor Commented:
I am still ONLY getting the error_IPL file.
0
 
Tom KnowltonWeb developerAuthor Commented:
I am supposed to throw the exception again inside the method  CopySMDRFromCosmoToTan  ????
0
 
gregoryyoungCommented:
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
 
Tom KnowltonWeb developerAuthor Commented:
>>>n specific on the innerexception ... you arent checking that its there first.

Okay.
0
 
Tom KnowltonWeb developerAuthor Commented:
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
 
gregoryyoungCommented:
is the service running as a domain user ?
0
 
Tom KnowltonWeb developerAuthor Commented:
It logs on as Administrator.
0
 
Tom KnowltonWeb developerAuthor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
 
Tom KnowltonWeb developerAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.