예제 #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            Cursor saveCursor = Cursor.Current;
            try
            {
                Cursor.Current = Cursors.WaitCursor;

                HealthSystem system = IrmDbDataProvider.HealthSystemLoadByID(DataProvider.HealthSystemID);
                //if (!system.CopyFileToUploadPath(txtFileName.Text))
                //{
                //    throw new Exception("Unable to copy file to UploadFolder!");
                //}

                ImportedFileStatus status = new ImportedFileStatus()
                {
                    ClientOrganizationID = (int)gvClientOrgs.CurrentRow.Cells[0].Value,
                    ProcessFileTypeID = (int)ddlFileTypes.SelectedValue,
                    FileName = Path.GetFileName(txtFileName.Text),
                    ProcessStatusID = (int)ProcessStatus.Successful,
                    ProcessedBy = Environment.UserName
                };
                DataProvider.ImportedFileStatusSave(ref status);

                log.DebugFormat("Added file {0} to database.", txtFileName.Text);
                MessageBox.Show("Added");
            }
            finally
            {
                Cursor.Current = saveCursor;
            }
        }
 public void Execute(ref ImportedFileStatus importedFileStatus)
 {
     Parameters.AddWithValue("@ImportedFileStatusID", importedFileStatus.ImportedFileStatusID);
     Parameters.AddWithValue("@ClientOrganizationID", importedFileStatus.ClientOrganizationID);
     Parameters.AddWithValue("@ClientOrgName", string.Empty);
     Parameters.AddWithValue("@FileName", importedFileStatus.FileName);
     Parameters.AddWithValue("@ProcessFileTypeID", importedFileStatus.ProcessFileTypeID);
     Parameters.AddWithValue("@ProcessTypeID", importedFileStatus.ProcessTypeID);
     Parameters.AddWithValue("@ProcessStatusID", importedFileStatus.ProcessStatusID);
     Parameters.AddWithValue("@ProcessedBy", importedFileStatus.ProcessedBy);
     Parameters.AddWithValue("@JobID", importedFileStatus.UpdateJobID);
     Parameters.AddWithValue("@TotalRows", importedFileStatus.TotalRows);
     Parameters.AddWithValue("@ErrorCodeID", importedFileStatus.ErrorCodeID);
     ExecuteNonQuery();
 }
 public ImportedFileStatus Clone()
 {
     ImportedFileStatus result = new ImportedFileStatus();
     result.ImportedFileStatusID = this.ImportedFileStatusID;
     result.ClientOrganizationID = this.ClientOrganizationID;
     result.ClientOrgName = this.ClientOrgName;
     result.ProcessFileTypeID = this.ProcessFileTypeID;
     result.ProcessTypeID = this.ProcessTypeID;
     result.ProcessStatusID = this.ProcessStatusID;
     result.ProcessedBy = this.ProcessedBy;
     result.ProcessedDate = this.ProcessedDate;
     result.InsertJobID = this.InsertJobID;
     result.UpdateJobID = this.UpdateJobID;
     result.FileName = this.FileName;
     result.UploadedDT = this.UploadedDT;
     result.TotalRows = this.TotalRows;
     result.HasErrors = this.HasErrors;
     result.Errors = this.Errors;
     result.ErrorCodeID = this.ErrorCodeID;
     return result;
 }
        public void Execute(ref ImportedFileStatus importedFileStatus)
        {
            if (importedFileStatus.ClientOrganizationID == 0)
            {
                Parameters.AddWithValue("@ClientOrganizationID", DBNull.Value);
            }
            else
            {
                Parameters.AddWithValue("@ClientOrganizationID", importedFileStatus.ClientOrganizationID);
            }
            Parameters.AddWithValue("@ClientOrgName", string.Empty);
            Parameters.AddWithValue("@FileName", importedFileStatus.FileName);
            Parameters.AddWithValue("@ProcessFileTypeID", importedFileStatus.ProcessFileTypeID);
            Parameters.AddWithValue("@ProcessTypeID", importedFileStatus.ProcessTypeID);
            Parameters.AddWithValue("@ProcessStatusID", importedFileStatus.ProcessStatusID);
            Parameters.AddWithValue("@ProcessedBy", importedFileStatus.ProcessedBy);

            if (importedFileStatus.InsertJobID == 0)
            {
                Parameters.AddWithValue("@JobID", DBNull.Value);
            }
            else
            {
                Parameters.AddWithValue("@JobID", importedFileStatus.InsertJobID);
            }

            Parameters.AddWithValue("@ErrorCodeID", importedFileStatus.ErrorCodeID);

            DataTable t = ExecuteReader();
            if (t.Rows.Count > 0)
            {
                importedFileStatus.ImportedFileStatusID = t.Rows[0].Field<int>("ImportedFileStatusID");
                importedFileStatus.UploadedDT = t.Rows[0].Field<DateTime>("UploadedDT");
                importedFileStatus.ProcessedDate = t.Rows[0].Field<DateTime>("ProcessedDate");
                log.DebugFormat("Added ImportedFileStatusID: {0}", importedFileStatus.ImportedFileStatusID);
            }

        }
        private bool ValidateProcedureFile(ImportedFileStatus candidate)
        {
            IImportValidator<Formats.Procedure> validator = new DelimitedFileValidator<Formats.Procedure>();

            // Validate the file and record the results                        
            validator.Validate(candidate.FileName);
            StringBuilder sb = new StringBuilder();
            validator.Errors.ForEach(x => sb.AppendLine(x.ToString()));
            SystemDataProvider.ClientDataProvider.ValidateImportedFile(candidate.ImportedFileStatusID, validator.TotalRows, validator.HasErrors, sb.ToString());


            if (validator.HasErrors)
            {
                log.WarnFormat("Row {0} has {1} errors!", candidate.ImportedFileStatusID, validator.Errors.Count());
            }
            else
            {
                log.DebugFormat("Row {0} validated successfully!", candidate.ImportedFileStatusID);
            }


            return !validator.HasErrors;
        }
        private void RecordFileReceived(string fileName)
        {
            log.Debug("Recording File Received in database");
            ProcessFileType fileType = DetermineFileType();

            ImportedFileStatus status = new ImportedFileStatus();
            status.ClientOrganizationID = 0;
            status.ProcessFileTypeID = (int)fileType;
            status.ProcessTypeID = (int)ProcessType.FileReceived;
            //if national market set as inital validation else file received
            status.ProcessTypeID = fileType == ProcessFileType.NationalMarketDataFile ? (int)ProcessType.InitialValidation : (int) ProcessType.FileReceived;            
            status.ProcessStatusID = (int) ProcessStatus.Successful;
            status.FileName = Path.GetFileName(fileName);
            SystemDataProvider.ClientDataProvider.ImportedFileStatusSave(ref status);
        }
예제 #7
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            Cursor saveCursor = Cursor.Current;
            bool IsNationalMarket = (int)ddlFileTypes.SelectedValue == 13;
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                string[] fileNames = txtFileName.Text.Split('|');                
                HealthSystem system = SystemDataProvider.HealthSystemLoadByID(healthSystemID);
                foreach (var filename in fileNames)
                { 
                    var fname = filename.Replace("|", "");

                    // handle the empty string at the end of the list of names
                    if (string.IsNullOrEmpty(fname))
                    {
                        continue;
                    }

                    // NationalMarket Update Files do not get copied again
                    if (!IsNationalMarket)
                    {
                        //TODO: Implement Copy logic
                        //if (!system.CopyFileToUploadPath(fname))
                        //{
                        //    throw new Exception(string.Format("Unable to copy file {0} to UploadFolder!", fname));
                        //}

                    }

                    ImportedFileStatus status = new ImportedFileStatus()
                    {
                        ClientOrganizationID = (int)gvClientOrgs.CurrentRow.Cells[0].Value,
                        ProcessFileTypeID = (int)ddlFileTypes.SelectedValue,
                        FileName = IsNationalMarket ? fname : Path.GetFileName(fname),
                        ProcessStatusID = (int)ProcessStatus.Successful,
                        ProcessedBy = Environment.UserName
                    };
                    SystemDataProvider.ClientDataProvider.ImportedFileStatusSave(ref status);

                    MessageBox.Show(string.Format("File {0} uploaded.", fname), "File Upload");
                    log.DebugFormat("Added file {0} to database.", txtFileName.Text);
                }
            }
            finally
            {
                Cursor.Current = saveCursor;
            }
        }
 public Job JobStart(ImportedFileStatus file)
 {
     Job result = new Job()
     { 
         /*TODO: Set ApplicationID*/ 
         /*Application = new Application();*/ 
         /*Application.RegisterApplication();*/
         FileID = file.ImportedFileStatusID,
         RunBy = Environment.UserName,
         Successful = false,
         Description = Path.GetFileName(file.FileName),
         ProcessFileTypeID = file.ProcessFileTypeID,
         StartDT = DateTime.Now,
         
     };
     this.JobSave(ref result);
     return result;
 }
        public List<ImportedFileStatus> ImportedFileStatusLoadByTypeStatusFileType(ProcessType processType, ProcessStatus processStatus, ProcessFileType processFileType)
        {
            List<ImportedFileStatus> result = new List<ImportedFileStatus>();

            StoredProcedure proc = new StoredProcedure(SQLResource.ImportedFileStatusSelectByTypeStatusFileType, ConnectionString);
            proc.Parameters.AddWithValue("@ProcessTypeID", processType);
            proc.Parameters.AddWithValue("@ProcessStatusID", processStatus);
            proc.Parameters.AddWithValue("@ProcessFileTypeID", processFileType);
            DataTable table = proc.ExecuteReader();
            foreach (DataRow row in table.Rows)
            {
                ImportedFileStatus file = new ImportedFileStatus(row);
                result.Add(file);
            }
            return result;
        }
 private int UpdateImportedFileStatus(ImportedFileStatus importedFileStatus)
 {
     spUpdateImportedFileStatus proc = new spUpdateImportedFileStatus(ConnectionString);
     proc.Execute(ref importedFileStatus);
     return importedFileStatus.ImportedFileStatusID;
 }
 private int AddImportedFileStatus(ImportedFileStatus importedFileStatus)
 {
     spAddImportedFileStatus proc = new spAddImportedFileStatus(ConnectionString);
     try
     {
         proc.Execute(ref importedFileStatus);
         return importedFileStatus.ImportedFileStatusID;
     }
     catch (SqlException ex)
     {
         log.LogSqlException(ex);
         throw;
     }
 }
 public void ImportedFileStatusSave(ref ImportedFileStatus importedFileStatus)
 {
     if (importedFileStatus.ImportedFileStatusID == 0)
     {
         importedFileStatus.ImportedFileStatusID = AddImportedFileStatus(importedFileStatus);
     }
     else
     {
         UpdateImportedFileStatus(importedFileStatus);
     }
 }
        public ImportedFileStatus ImportedFileStatusLoadByID(int importedFileStatusID)
        {
            ImportedFileStatus result = null;
            log.DebugFormat("Loading ImportedFileStatusID: {0}", importedFileStatusID);

            StoredProcedure proc = new StoredProcedure(SQLResource.ImportedFileStatusSelect, ConnectionString);
            proc.Parameters.AddWithValue("@ImportedFileStatusID", importedFileStatusID);
            DataTable table = proc.ExecuteReader();
            result = new ImportedFileStatus(table.Rows[0]);
            return result;
        }
예제 #14
0
 /// <summary>
 /// Read the values that we need from ImportedFileStatus table
 /// </summary>
 /// <param name="importedFileStatusID">ImportedFileStatus Primary Key to read.</param>
 private void GetFileValues(int importedFileStatusID)
 {
     var sw = new Stopwatch();
     sw.Start();
     try
     {
         file = SystemDataProvider.ClientDataProvider.ImportedFileStatusLoadByID(importedFileStatusID);
         file.ProcessStatusID = (int)ProcessStatus.Processing;
         SystemDataProvider.ClientDataProvider.ImportedFileStatusSave(ref file);
         clientOrg = SystemDataProvider.ClientDataProvider.ClientOrganizationLoadByID(file.ClientOrganizationID.Value);
     }
     catch (Exception ex)
     {
         log.Error("GetFileValues", ex);
         throw;
     }
     finally
     {
         sw.Stop();
         log.Debug(RecordTiming(System.Reflection.MethodBase.GetCurrentMethod().Name, sw));
     }
 }
예제 #15
0
        /// <summary>
        /// Create a row that indicates we are processing a Community Update
        /// </summary>
        public void UpdateCommunityData()
        {
                // Add a row to the ImportedFileStatus table that indicates 
                // that we are running a community Update

            Int32 ImportedFileStatusID = 0;
            ImportedFileStatus file = new ImportedFileStatus()
            {
                ClientOrganizationID = 1,
                FileName = string.Empty,
                ProcessedBy = Environment.UserName,
                ProcessFileTypeID = (int) ProcessFileType.CommunityDataFile,
                ProcessStatusID = (int) ProcessStatus.Processing,
                ProcessTypeID = (int) ProcessType.FileLoad,
                InsertJobID = 0,
                ErrorCodeID = 0
            };
            SystemDataProvider.ClientDataProvider.ImportedFileStatusSave(ref file);
            ImportedFileStatusID = file.ImportedFileStatusID;

            //TODO:  Modify constructor to accept list of ZipCodes to process for

            ProcessCommunityUpdate process = new ProcessCommunityUpdate(SystemDataProvider)
            {
                UpdateProductionData = true
            };
            try
            { 
                process.Execute(ImportedFileStatusID);
                file.ProcessStatusID = (int)ProcessStatus.Successful;
                SystemDataProvider.ClientDataProvider.ImportedFileStatusSave(ref file);
            }
            catch(Exception ex)
            {
                log.Error("Error updating Community Data", ex);
                file.ProcessStatusID = (int)ProcessStatus.Failure;
                SystemDataProvider.ClientDataProvider.ImportedFileStatusSave(ref file);
            }
        }