Inheritance: System.Exception
Ejemplo n.º 1
0
        void CheckPortion(Guid portionId)
        {
            Portion portion = importRepo.PortionRepo.Get(portionId);

            if (portion != null)
            {
                var ex = new ImportException(Program.LanguageManager.GetString(StringResources.Import_SamePortion));
                log.Error(ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 2
0
        void CheckWorkstationType(WorkstationType workstationType)
        {
            var project = importRepo.ProjectRepo.GetSingle();

            if (project.WorkstationType == WorkstationType.Construction &&
                workstationType != WorkstationType.Master)
            {
                var ex = new ImportException(Program.LanguageManager.GetString(StringResources.Import_WrongWorkstationType));
                log.Error(ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 3
0
      protected ImportResult FireError(ImportException e)
      {
         if (OnError != null)
         {
            OnError(e);
            return ImportResult.Failed;
         }

         var ex = new ImportException(e.Message, e);
         log.Error(ex.Message);
         throw ex;

      }
Ejemplo n.º 4
0
        protected ImportResult FireError(ImportException e)
        {
            if (OnError != null)
            {
                OnError(e);
                return(ImportResult.Failed);
            }

            var ex = new ImportException(e.Message, e);

            log.Error(ex.Message);
            throw ex;
        }
Ejemplo n.º 5
0
        protected void ValidateChecksum(string fileName)
        {
            if (!System.IO.File.Exists(fileName))
            {
                var ex = new ImportException(string.Format("File {0} does not exists.", fileName));
                log.Error(ex.Message);
                throw ex;
            }

            string hashFileName = fileName + ".sha1";

            if (!System.IO.File.Exists(hashFileName))
            {
                var ex = new ImportException(string.Format("Hash file {0} does not exists.", hashFileName));
                log.Error(ex.Message);
                throw ex;
            }

            string hash = System.IO.File.ReadAllText(hashFileName);

            byte[] bytes;
            using (FileStream fs = new FileStream(fileName, FileMode.Open))
            {
                bytes = new byte[fs.Length];
                fs.Read(bytes, 0, bytes.Length);
                fs.Close();
            }

            string actualHash = hasher.GetHash(bytes);

            if (actualHash != hash)
            {
                var ex = new ImportException(string.Format("SHA-1 hashsum for file '{0}' does not match with actual.", fileName));
                log.Error(ex.Message);
                throw ex;
            }
        }
Ejemplo n.º 6
0
      protected void ValidateChecksum(string fileName)
      {
         if (!System.IO.File.Exists(fileName))
         {
            var ex = new ImportException(string.Format("File {0} does not exists.", fileName));
            log.Error(ex.Message);
            throw ex;
         }

         string hashFileName = fileName + ".sha1";
         if (!System.IO.File.Exists(hashFileName))
         {
            var ex = new ImportException(string.Format("Hash file {0} does not exists.", hashFileName));
            log.Error(ex.Message);
            throw ex;
         }

         string hash = System.IO.File.ReadAllText(hashFileName);

         byte[] bytes;
         using (FileStream fs = new FileStream(fileName, FileMode.Open))
         {
            bytes = new byte[fs.Length];
            fs.Read(bytes, 0, bytes.Length);
            fs.Close();
         }

         string actualHash = hasher.GetHash(bytes);

         if (actualHash != hash)
         {
             var ex = new ImportException(string.Format("SHA-1 hashsum for file '{0}' does not match with actual.", fileName));
             log.Error(ex.Message);
             throw ex;
         }
      }
Ejemplo n.º 7
0
 private void OnErrorMessaging(ImportException e)
 {
    string msg = e.Message;
    if (e.StackTrace != null)
       msg += "\n " + e.StackTrace;
    MessageBox.Show(msg, 
        Program.LanguageManager.GetString(StringResources.Message_ErrorHeader), MessageBoxButtons.OK, MessageBoxIcon.Error);
    ResetControls();
 }
Ejemplo n.º 8
0
 void importer_OnError(ImportException e)
 {
     if (this.InvokeRequired && !importer.IsDisposed)
     {
         this.Invoke(new Action(() => { OnErrorMessaging(e); }));
     }
     else
     {
         OnErrorMessaging(e);
     }
 }