Beispiel #1
0
 private void OpenAttachmentData()
 {
     if (SaveAttachmentData())
     {
         string fileName = TermsProvider.GetTempFolderPath() + "\\" + currentJobCard.AirlineCardNumber + ".pdf";
         if (File.Exists(fileName))
         {
             Process tempProcess = new Process();
             tempProcess.StartInfo.FileName = fileName;
             try
             {
                 tempProcess.Start();
                 tempProcess.WaitForExit();
             }
             catch (Exception ex)
             {
                 Program.Provider.Logger.Log("Error while loading data", ex);
             }
             try
             {
                 TryDeleteFile();
             }
             catch (Exception ex)
             {
                 Program.Provider.Logger.Log("Error while deleting data", ex);
             }
         }
     }
 }
 private void OpenAttachmentData()
 {
     if (SaveAttachmentData())
     {
         fileNameToRemove = TermsProvider.GetTempFolderPath() + "\\" + file.FileName;
         if (File.Exists(fileNameToRemove))
         {
             Process tempProcess = new Process();
             tempProcess.StartInfo.FileName = fileNameToRemove;
             try
             {
                 tempProcess.Start();
                 tempProcess.WaitForExit();
             }
             catch (Exception ex)
             {
                 Program.Provider.Logger.Log("Error while loading data", ex);
             }
             try
             {
                 TryDeleteFile();
             }
             catch (Exception ex)
             {
                 Program.Provider.Logger.Log("Error while deleting data", ex);
             }
         }
     }
 }
        private void OpenReport(object parameter)
        {
            JobCard jobCard = (JobCard)parameter;
            string  path    = TermsProvider.GetTempFolderPath() + "\\" + jobCard.AirlineCardNumber + ".pdf";

            if (!File.Exists(path))
            {
                UsefulMethods.SaveFileFromByteArray(jobCard.AttachedFile.FileData, path);
            }
            Process tempProcess = new Process();

            tempProcess.StartInfo = new ProcessStartInfo(path);
            try
            {
                tempProcess.Start();
                tempProcess.WaitForExit();
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading data", ex);
            }
            try
            {
                TryDeleteFile(path);
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while deleting data", ex);
            }
        }
Beispiel #4
0
        public virtual void Log(String message, Exception ex)
        {
            StringBuilder content = new StringBuilder();

            content.AppendLine("-----------------------");
            content.AppendLine(DateTime.Now.ToString());

            if (ex != null)
            {
                content.AppendLine("" + ex.GetType());
                content.AppendLine("Message: " + ex.Message);
                content.AppendLine("Inner: " + ex.InnerException != null ? "" : ex.InnerException.ToString());
                content.AppendLine("Source: " + ex.Source);
                content.AppendLine(ex.StackTrace);
            }

            lock (syncObject)
            {
                String localApplicationData = TermsProvider.GetTempFolderPath();
                String logFile = Path.Combine(localApplicationData, "error.log");
                try
                {
                    File.AppendAllText(logFile, content.ToString());
                }
                catch (Exception e)
                {
                    // Ошибка возникает при сохранении ошибки....
                }
            }
        }
Beispiel #5
0
        public override void Log(Exception ex)
        {
            base.Log("Uncaught exception", ex);

            String localApplicationData = TermsProvider.GetTempFolderPath();
            String logFile = Path.Combine(localApplicationData, "error.log");

            ErrorReportSender.SendReport(logFile);
        }
Beispiel #6
0
 private bool SaveAttachmentData()
 {
     try
     {
         string     fileName       = TermsProvider.GetTempFolderPath() + "\\" + currentJobCard.AirlineCardNumber + ".pdf";
         FileStream fileStreamBack = new FileStream(fileName, FileMode.Create, FileAccess.Write);
         fileStreamBack.Write(pdfFileData, 0, pdfFileData.Length);
         fileStreamBack.Close();
         return(true);
     }
     catch (Exception ex)
     {
         Program.Provider.Logger.Log("Error while saving data", ex);
         return(false);
     }
 }
 private bool SaveAttachmentData()
 {
     try
     {
         string     fileNameString = TermsProvider.GetTempFolderPath() + "\\" + file.FileName;
         FileStream fileStreamBack = new FileStream(fileNameString, FileMode.Create, FileAccess.Write);
         fileStreamBack.Write(file.FileData, 0, file.FileData.Length);
         fileStreamBack.Close();
         return(true);
     }
     catch (Exception ex)
     {
         Program.Provider.Logger.Log("Error while saving data", ex);
         return(false);
     }
 }
Beispiel #8
0
        private void TryDeleteFile()
        {
            string fileName = TermsProvider.GetTempFolderPath() + "\\" + currentJobCard.AirlineCardNumber + ".pdf";

            while (File.Exists(fileName))
            {
                try
                {
                    File.Delete(fileName);
                }
                catch
                {
                    Thread.Sleep(100);
                }
            }
            Thread.CurrentThread.Abort();
        }
        /// <summary>
        /// Сохраняет документ во временный файл
        /// </summary>
        /// <param name="document">Документ, который требуется сохранить</param>
        /// <returns>Значение ,показывающее было ли сохранение успешным</returns>
        public bool SaveReportToFile(Document document)
        {
            string fileName = TermsProvider.GetTempFolderPath() + "\\" + document.FileName;

            if (document.FileData == null)
            {
                return(false);
            }

            try
            {
                FileStream fileStreamBack = new FileStream(fileName, FileMode.Create, FileAccess.Write);
                fileStreamBack.Write(document.FileData, 0, document.FileData.Length);
                fileStreamBack.Close();
                return(true);
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error creating temp file", ex);
                return(false);
            }
        }
Beispiel #10
0
        private void OpenReport(object parameter)
        {
            BiWeekly biWeeklyReport  = (BiWeekly)parameter;
            string   path            = TermsProvider.GetTempFolderPath() + "\\" + biWeeklyReport.RealName;
            bool     successCreating = true;

            if (!File.Exists(path))
            {
                successCreating = biWeeklyReport.SaveReportToFile(path);
            }
            if (!successCreating)
            {
                return;
            }
            Process tempProcess = new Process();

            tempProcess.StartInfo = new ProcessStartInfo(path);
            try
            {
                tempProcess.Start();
                tempProcess.WaitForExit();
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while loading data", ex);
            }

            try
            {
                TryDeleteFile(path);
            }
            catch (Exception ex)
            {
                Program.Provider.Logger.Log("Error while deleting data", ex);
            }
        }