Exemplo n.º 1
0
        public async Task <BatchLog> GetLastBatchLog()
        {
            var results = await _unitOfWork.Connection.QueryAsync <BatchLog>(
                "SELECT TOP 1 " +
                "[Period], " +
                "[BatchCreated], " +
                "[ScheduledDate], " +
                "[BatchNumber], " +
                "[NumberOfCertificates], " +
                "[NumberOfCoverLetters], " +
                "[CertificatesFileName], " +
                "[FileUploadStartTime], " +
                "[FileUploadEndTime], " +
                "[BatchData]" +
                "FROM BatchLogs ORDER BY BatchCreated DESC",
                transaction : _unitOfWork.Transaction);

            var batchLog = results.FirstOrDefault();

            if (batchLog == null)
            {
                batchLog = new BatchLog
                {
                    BatchNumber = 0
                };
                return(batchLog);
            }

            return(batchLog);
        }
        public async Task <ValidationResponse> UpdateBatchLogSentToPrinter(BatchLog updatedBatchLog)
        {
            var rowsAffected = await _unitOfWork.Connection.ExecuteAsync(
                @"UPDATE [BatchLogs] SET 
                    [BatchCreated] = @batchCreated, 
                    [NumberOfCertificates] = @numberOfCertificates, 
                    [NumberOfCoverLetters] = @numberOfCoverLetters, 
                    [CertificatesFileName] = @certificatesFileName, 
                    [FileUploadStartTime] = @fileUploadStartTime, 
                    [FileUploadEndTime] = @fileUploadEndTime, 
                    [BatchData] = @batchData 
                  WHERE 
                    [BatchNumber] = @batchNumber",
                param : new
            {
                updatedBatchLog.BatchNumber,
                updatedBatchLog.BatchCreated,
                updatedBatchLog.NumberOfCertificates,
                updatedBatchLog.NumberOfCoverLetters,
                updatedBatchLog.CertificatesFileName,
                updatedBatchLog.FileUploadStartTime,
                updatedBatchLog.FileUploadEndTime,
                updatedBatchLog.BatchData
            },
                transaction : _unitOfWork.Transaction);

            var response = new ValidationResponse();

            if (rowsAffected == 0)
            {
                response.Errors.Add(new ValidationErrorDetail("BatchNumber", $"Error the batch log {updatedBatchLog.BatchNumber} does not exist."));
            }

            return(response);
        }
Exemplo n.º 3
0
        public BatchLog GetSingle(Int32 Id)
        {
            BatchLog obj = new BatchLog();

            try
            {
                string     query = "select * from batch_logs where ID = " + Id + "";
                SqlCommand cmd   = new SqlCommand(query, mySQLDBConnect.connection);
                mySQLDBConnect.OpenConnection();
                DataTable      dt = new DataTable();
                SqlDataAdapter dA = new SqlDataAdapter(cmd);
                dA.Fill(dt); dA.Dispose();
                obj = (from x in dt.AsEnumerable()
                       select new BatchLog
                {
                    Id = x.Field <Int32>("id"),
                    BatchId = x.Field <Int32>("batch_id"),
                    StageId = x.Field <Int32>("stage_id"),
                    BatchCount = x.Field <Int32>("batch_count"),
                    BatchUser = x.Field <String>("batch_user"),
                    UpdatedDate = x.Field <DateTime>("updated_date"),
                    UpdatedBy = x.Field <Int32>("updated_by"),
                    Status = x.Field <Int32>("status"),
                }).ToList().FirstOrDefault();
                mySQLDBConnect.CloseConnection();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(obj);
        }
Exemplo n.º 4
0
        public async Task <BatchLog> Create(BatchLog batchLog)
        {
            await _assessorDbContext.BatchLogs.AddAsync(batchLog);

            _assessorDbContext.SaveChanges();

            return(batchLog);
        }
Exemplo n.º 5
0
        public long StartBatch(string name)
        {
            var batchLog = new BatchLog
            {
                Name          = name,
                StartDateTime = DateTime.Now,
                InProgress    = true
            };

            return(_repository.Create(batchLog));
        }
Exemplo n.º 6
0
 public BatchLog UpdateData(BatchLog obj)
 {
     try
     {
         obj = IBatchLogRepo.UpdateData(obj);
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
     return(obj);
 }
Exemplo n.º 7
0
        public BatchLog DeleteData(Int32 Id)
        {
            BatchLog obj = new BatchLog();

            try
            {
                obj = IBatchLogRepo.DeleteData(Id);
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(obj);
        }
        public async Task <BatchLog> Create(BatchLog batchLog)
        {
            await _unitOfWork.Connection.ExecuteAsync(
                @"INSERT INTO BatchLogs ([Period], [ScheduledDate], [BatchNumber]) 
                  VALUES (@period, @scheduledDate, @batchNumber)",
                param : new
            {
                batchLog.Period,
                batchLog.ScheduledDate,
                batchLog.BatchNumber
            },
                transaction : _unitOfWork.Transaction);

            return(batchLog);
        }
Exemplo n.º 9
0
        public async Task <BatchLogResponse> Handle(CreateBatchLogRequest request, CancellationToken cancellationToken)
        {
            var lastBatchLog = await _batchLogQueryRepository.GetLastBatchLog();

            var batchLog = new BatchLog()
            {
                Period        = DateTime.UtcNow.ToString("MMyy"),
                ScheduledDate = request.ScheduledDate,
                BatchNumber   = lastBatchLog.BatchNumber + 1
            };

            batchLog = await _batchLogRepository.Create(batchLog);

            return(Mapper.Map <BatchLogResponse>(batchLog));
        }
Exemplo n.º 10
0
        public static void UpdateScharpBatchLog(OracleConnection connection, BatchLog log)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = Constant.SP_UpdateSFTP_BatchLog;
                command.CommandType = CommandType.StoredProcedure;
                command.BindByName  = true;

                command.Parameters.Add("p_batchTransactionStatus", OracleDbType.Varchar2, log.BatchTransactionStatus, ParameterDirection.Input);
                command.Parameters.Add("p_batchException", OracleDbType.Varchar2, log.BatchException, ParameterDirection.Input);
                command.Parameters.Add("p_batchID", OracleDbType.Varchar2, log.BatchID, ParameterDirection.Input);

                command.ExecuteNonQuery();
            }
        }
Exemplo n.º 11
0
 public BatchLog UpdateData(BatchLog obj)
 {
     try
     {
         string     query = obj.ObjectToQuery <BatchLog>("update");
         SqlCommand cmd   = new SqlCommand(query, mySQLDBConnect.connection);
         mySQLDBConnect.OpenConnection();
         cmd.ExecuteNonQuery();
         mySQLDBConnect.CloseConnection();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
     return(obj);
 }
Exemplo n.º 12
0
        public async Task <BatchLog> GetLastBatchLog()
        {
            var batchLog = await _assessorDbContext.BatchLogs
                           .OrderByDescending(q => q.BatchCreated)
                           .FirstOrDefaultAsync();

            if (batchLog == null)
            {
                batchLog = new BatchLog
                {
                    BatchNumber = 0
                };
                return(batchLog);
            }

            return(batchLog);
        }
Exemplo n.º 13
0
 public BatchLog PostData(BatchLog obj)
 {
     try
     {
         string     query = obj.ObjectToQuery <BatchLog>("insert") + "SELECT SCOPE_IDENTITY()";
         SqlCommand cmd   = new SqlCommand(query, mySQLDBConnect.connection);
         mySQLDBConnect.OpenConnection();
         //cmd.ExecuteNonQuery();
         obj.Id = Convert.ToInt32(cmd.ExecuteScalar());
         mySQLDBConnect.CloseConnection();
     }
     catch (Exception ex)
     {
         Console.Write(ex.ToString());
     }
     return(obj);
 }
Exemplo n.º 14
0
        public async Task <ValidationResponse> Handle(UpdateBatchLogPrintedRequest request, CancellationToken cancellationToken)
        {
            var updatedBatchLog = new BatchLog
            {
                BatchNumber = request.BatchNumber,
                BatchData   = new BatchData()
                {
                    BatchNumber           = request.BatchNumber,
                    BatchDate             = request.BatchDate,
                    PostalContactCount    = request.PostalContactCount,
                    TotalCertificateCount = request.TotalCertificateCount,
                    PrintedDate           = request.PrintedDate,
                    DateOfResponse        = request.DateOfResponse
                }
            };

            return(await _batchLogRepository.UpdateBatchLogPrinted(updatedBatchLog));
        }
        public async Task <ValidationResponse> Handle(UpdateBatchLogSentToPrinterRequest request, CancellationToken cancellationToken)
        {
            var updatedBatchLog = new BatchLog()
            {
                BatchNumber          = request.BatchNumber,
                BatchCreated         = request.BatchCreated,
                NumberOfCertificates = request.NumberOfCertificates,
                NumberOfCoverLetters = request.NumberOfCoverLetters,
                CertificatesFileName = request.CertificatesFileName,
                FileUploadStartTime  = request.FileUploadStartTime,
                FileUploadEndTime    = request.FileUploadEndTime,
                BatchData            = new BatchData()
                {
                    BatchNumber = request.BatchNumber
                }
            };

            return(await _batchLogRepository.UpdateBatchLogSentToPrinter(updatedBatchLog));
        }
Exemplo n.º 16
0
        public static void InsertScharpBatchLog(BatchLog log)
        {
            using (var connection = GetOracleConnection())
            {
                connection.Open();
                using (var command = connection.CreateCommand())
                {
                    command.CommandText = Constant.SP_InsertSFTP_BatchLog;
                    command.CommandType = CommandType.StoredProcedure;
                    command.BindByName  = true;

                    command.Parameters.Add("batchID", OracleDbType.Varchar2, log.BatchID, ParameterDirection.Input);
                    command.Parameters.Add("fileSource", OracleDbType.Varchar2, log.FileSource, ParameterDirection.Input);
                    command.Parameters.Add("fileName", OracleDbType.Varchar2, log.FileName, ParameterDirection.Input);

                    command.ExecuteNonQuery();
                }
            }
        }
Exemplo n.º 17
0
        private static void SaveSCHARPdata(List <EAE> summaries, string filename)
        {
            string _batchId = Constant.SCHARP + Utilities.GenerateBatchID();

            BatchLog log = new BatchLog
            {
                BatchID    = _batchId,
                FileSource = Constant.SCHARP,
                FileName   = filename
            };

            Utilities.InsertScharpBatchLog(log);

            if (summaries != null && summaries.Count() != 0)
            {
                using (var connection = Utilities.GetOracleConnection())
                {
                    connection.Open();
                    BulkCopyOracle.InsertSCHARPdataUsingArrayBinding(summaries, connection, _batchId);
                }
            }
        }
Exemplo n.º 18
0
        public Int32 DeleteBulkData(List <Int32> Ids)
        {
            Int32 result = 0;

            try
            {
                string query = "";
                Ids.ForEach(Id =>
                {
                    BatchLog obj = GetSingle(Id);
                    query       += obj.ObjectToQuery <BatchLog>("update");
                });
                SqlCommand cmd = new SqlCommand(query, mySQLDBConnect.connection);
                mySQLDBConnect.OpenConnection();
                result = cmd.ExecuteNonQuery();
                mySQLDBConnect.CloseConnection();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }
            return(result);
        }
        public async Task <ValidationResponse> UpdateBatchLogPrinted(BatchLog updatedBatchLog)
        {
            var rowsAffected = await _unitOfWork.Connection.ExecuteAsync(
                @"UPDATE [BatchLogs] SET 
                    [BatchData] = @batchData 
                  WHERE 
                    [BatchNumber] = @batchNumber",
                param : new
            {
                updatedBatchLog.BatchNumber,
                updatedBatchLog.BatchData
            },
                transaction : _unitOfWork.Transaction);

            var response = new ValidationResponse();

            if (rowsAffected == 0)
            {
                response.Errors.Add(new ValidationErrorDetail("BatchNumber", $"Error the batch log {updatedBatchLog.BatchNumber} does not exist."));
            }

            return(response);
        }
Exemplo n.º 20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["hdnNumberPerPage"] != "" && Request.QueryString["hdnNumberPerPage"] != null)
            {
                hdnNumberPerPage.Value = Request.QueryString["hdnNumberPerPage"].ToString();
            }
            if (Request.QueryString["hdnCurrentPageNo"] != "" && Request.QueryString["hdnCurrentPageNo"] != null)
            {
                hdnCurrentPageNo.Value = Request.QueryString["hdnCurrentPageNo"].ToString();
            }
            if (Request.QueryString["hdnTotalRecordsCount"] != "" && Request.QueryString["hdnTotalRecordsCount"] != null)
            {
                hdnTotalRecordsCount.Value = Request.QueryString["hdnTotalRecordsCount"].ToString();
            }

            StringBuilder filter = new StringBuilder();

            filter.Append(" 1=1 ");

            string columnNameIsReleased = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.IsReleased));

            filter.Append(" and " + columnNameIsReleased + " in (0, 2)");
            string columnNameRemarks = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.Remarks));

            filter.Append(" and " + columnNameRemarks + " != ''");

            if (Request.QueryString["IsNewSearch"] != "" && Request.QueryString["IsNewSearch"] != null)
            {
                IsNewSearch.Value = Request.QueryString["IsNewSearch"].ToString();
            }
            if (IsNewSearch.Value == "1")
            {
                hdnCurrentPageNo.Value = "";
            }
            if (Request.QueryString["Search"] != "" && Request.QueryString["Search"] != null)
            {
                Search.Value = Request.QueryString["Search"].ToString();
                string columnNameAaNo = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.AaNo));
                filter.Append(" and (" + columnNameAaNo + " like '%" + Search.Value + "%'");
                string columnNameAcNo = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.AccountNo));
                filter.Append(" or " + columnNameAcNo + " like '%" + Search.Value + "%')");
            }
            string fromdate = ""; string toDate = "";

            if (!string.IsNullOrEmpty(Request.QueryString["FromDate"]))
            {
                fromdate       = Request.QueryString["FromDate"];
                FromDate.Value = fromdate;
            }
            if (!string.IsNullOrEmpty(Request.QueryString["ToDate"]))
            {
                toDate       = Request.QueryString["ToDate"];
                ToDate.Value = toDate;
            }
            if (!string.IsNullOrEmpty(fromdate) && !string.IsNullOrEmpty(toDate))
            {
                filter.Append("  and created_date between '" + fromdate + "' and  '" + toDate + "'");
            }

            int skip = 0, take = 10;

            if (hdnCurrentPageNo.Value == "")
            {
                skip = 0;
                take = 10;
                hdnNumberPerPage.Value     = "10";
                hdnCurrentPageNo.Value     = "1";
                hdnTotalRecordsCount.Value = ISetService.GetCountByFilter(filter.ToString()).ToString();
            }
            else
            {
                skip = (Convert.ToInt32(hdnCurrentPageNo.Value) - 1) * 10;
                take = 10;
            }

            List <Set> objs = ISetService.GetDataByFilter(filter.ToString(), skip, take, true);

            StringBuilder asb   = new StringBuilder();
            int           index = 1;

            foreach (Set set in objs)
            {
                Batch b = IBatchService.GetSingle(set.BatchId);

                int setsCount      = ISetService.GetCountByFilter(" batch_id='" + b.Id + "'");
                int scanPagesCount = 0;

                filter = new StringBuilder();
                filter.Append(" 1=1");
                string BatchIdColumnName = Converter.GetColumnNameByPropertyName <BatchLog>(nameof(BatchLog.BatchId));
                filter.Append(" and " + BatchIdColumnName + " = '" + b.Id + "'");

                List <BatchLog> batchLogs    = IBatchLogService.GetDataByFilter(filter.ToString(), 0, 0, false);
                StringBuilder   batchLogHTML = new StringBuilder();
                foreach (BatchLog batchLog in batchLogs)
                {
                    batchLogHTML.Append(@"
                                                    <div class='mini-stat clearfix text-left'>
                                                        " + (batchLog.StageId == 1 ?
                                                             @"<span class='mini-stat-icon orange'><i class='fa fa-print'></i></span>" :
                                                             (batchLog.StageId == 2 ?
                                                              "<span class='mini-stat-icon tar'><i class='fa fa-check-square-o'></i></span>" :
                                                              (batchLog.StageId == 3 ?
                                                               "<span class='mini-stat-icon pink'><i class='fa fa-external-link'></i></span>" :
                                                               (batchLog.StageId == 4 ?
                                                                "<span class='mini-stat-icon green'><i class='fa fa-puzzle-piece'></i></span>" :
                                                                (batchLog.StageId == 5 ?
                                                                 "<span class='mini-stat-icon yellow-b'><i class='fa fa-files-o'></i></span>" :
                                                                 (batchLog.StageId == 6 ?
                                                                  "<span class='mini-stat-icon yellow-b'><i class='fa fa-hdd-o'></i></span>" : "")))))) + @"
                                                        <div class='mini-stat-info'>
                                                            " + (batchLog.StageId == 1 ?
                                                                 "<span>Scan</span>" :
                                                                 (batchLog.StageId == 2 ?
                                                                  "<span>Index</span>" :
                                                                  (batchLog.StageId == 3 ?
                                                                   "<span>Export <small>To Server</small></span>" :
                                                                   (batchLog.StageId == 4 ?
                                                                    "<span>Integrate <small>Sync Control</small></span>" :
                                                                    (batchLog.StageId == 5 ?
                                                                     "<span>Release <small>To Mimzy</small></span>" :
                                                                     (batchLog.StageId == 6 ?
                                                                      "<span>Document <small>By Mimzy</small></span>" : "")))))) + @"
                                                            " + batchLog.UpdatedDate.ToString("dd/MM/yyyy HH:mm:ss") + @" - <strong>" + batchLog.BatchUser + @"</strong>
                                                        </div>
                                                    </div>
                                ");
                }
                BatchLog firstBatchLog = batchLogs.FirstOrDefault();
                BatchLog lastBatchLog  = batchLogs.LastOrDefault();
                TimeSpan timeSpan      = lastBatchLog.UpdatedDate.Subtract(firstBatchLog.UpdatedDate);

                Branch     branch     = IBranchService.GetSingle(b.BranchId);
                Department department = IDepartmentService.GetSingle(b.DepartmentId);
                Stage      stage      = IStageService.GetSingle(b.StageId);
                filter = new StringBuilder();
                filter.Append(" 1=1");
                filter.Append(" and " + Converter.GetColumnNameByPropertyName <SetDocument>(nameof(SetDocument.SetId)) + "='" + set.Id + "'");
                filter.Append(" and " + Converter.GetColumnNameByPropertyName <SetDocument>(nameof(SetDocument.Status)) + "='1'");
                List <SetDocument> setDocuments     = ISetDocumentService.GetDataByFilter(filter.ToString(), 0, 0, false);
                StringBuilder      setDocumentsHTML = new StringBuilder();
                foreach (SetDocument setDocument in setDocuments)
                {
                    scanPagesCount += setDocument.PageCount;
                    string fileName = Path.GetFileName(setDocument.DocumentUrl);
                    string localUrl = Server.MapPath("/Content/Files/" + fileName);
                    //if (!File.Exists(localUrl))
                    //    File.Copy(setDocument.DocumentUrl, localUrl);
                    setDocumentsHTML.Append(@"<div style='min-width: 150px;'><a href='/Content/Files/" + fileName + "' target='_blank' data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + setDocument.DocType + @"</strong></a> ( <small> pages: <strong>" + setDocument.PageCount + @"</strong></small> )</div>");
                }
                string xmlFileName = Path.GetFileName(set.SetXmlPath);
                string localXMLUrl = Server.MapPath("/Content/Files/" + xmlFileName);
                if (set.SetXmlPath != null && set.SetXmlPath != "")
                {
                    //if (!File.Exists(localXMLUrl))
                    //    File.Copy(set.SetXmlPath, localXMLUrl);
                    string departmentCode = department.Code;
                    string deptCode       = departmentCode.Split('-')[0];
                    string jobCode        = departmentCode.Split('-')[1];
                    string columnData     = "";
                    if (departmentCode == "E-LIBRARY")
                    {
                        //AA NUMBER
                        //ACCOUNT NUMBER
                        columnData  = "AA No: " + set.AaNo;
                        columnData += "<br/>Account No: " + set.AccountNo;
                    }
                    else if (deptCode == "ETP")
                    {
                        if (jobCode == "LL")
                        {
                            columnData = "AA No: " + set.AaNo;
                        }
                        else if (jobCode == "LN")
                        {
                            columnData  = "AA No: " + set.AaNo;
                            columnData += "<br/>Account No: " + set.AccountNo;
                        }
                        else if (jobCode == "PR")
                        {
                            columnData = "Project Code: " + set.AaNo;
                        }
                        else if (jobCode == "WF")
                        {
                            columnData = "Welfare Code: " + set.AaNo;
                        }
                    }
                    else if (deptCode == "LOS")
                    {
                        columnData = "AA No: " + set.AaNo;
                    }

                    asb.Append(@"<tr>
                                     <td class='icheck'>
                                        <div class='square single-row'>
                                            <div class='checkbox'>
                                                <input type='checkbox' name='checkRow' class='checkRow' value='" + b.Id + @"' /> <label>" + index + @"</label><br/>
                                            </div>
                                        </div>
                                    </td>
                                    <td>" + branch.Code + @"</td>
                                    <td>" + department.Code + @"</td>
                                    <td class='text-center mb-5'>
                                        <span>" + b.BatchNo + @" 
                                        <a href='javascript:;' class='text-info view_batch_log'><sup>View Log</sup></a>
                                        <div class='div_batch_log hide draggableDiv'>
                                            <span class='log_close'>X</span>
                                            <table>
                                                <tr><td>Batch No: <strong>" + b.BatchNo + @"</strong></td><td>No. of sets: <strong>" + setsCount + @"</strong></td></tr>
                                                <tr><td colspan='2'><small>Duration: <label class='label label-primary'>" + timeSpan.Days + @" days, " + timeSpan.Hours + @" hours, " + timeSpan.Minutes + @" minutes, " + timeSpan.Seconds + @" seconds</label></small></tr>
                                            </table>
                                            " + batchLogHTML.ToString() + @"
                                        </div>
                                    <span> " + b.UpdatedDate + @"</span>
                                    </td>
                                    <td><a href='/Content/Files/" + xmlFileName + @"' target='_blank' data-original-title='Click to view XML' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + columnData + @"</strong></a></td>
                                    <td>" + setDocumentsHTML.ToString() + @"</td>
                                    <td>" + set.Remarks + @"</td>
                                </tr>");
                }
                index++;
            }
            exceptionSetsTbody.InnerHtml = asb.ToString();
        }
Exemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                Int32  UserId   = Convert.ToInt32(Session["UserId"].ToString());
                User   user     = IUserService.GetSingle(UserId);
                string userType = Session["UserType"].ToString();
                string userRole = Session["UserRole"].ToString();
                string setId    = "";

                if (!string.IsNullOrEmpty(Request.QueryString["hdnNumberPerPage"]))
                {
                    hdnNumberPerPage.Value = Request.QueryString["hdnNumberPerPage"].ToString();
                }
                if (Request.QueryString["hdnCurrentPageNo"] != "" && Request.QueryString["hdnCurrentPageNo"] != null)
                {
                    hdnCurrentPageNo.Value = Request.QueryString["hdnCurrentPageNo"].ToString();
                }
                if (Request.QueryString["hdnTotalRecordsCount"] != "" && Request.QueryString["hdnTotalRecordsCount"] != null)
                {
                    hdnTotalRecordsCount.Value = Request.QueryString["hdnTotalRecordsCount"].ToString();
                }

                StringBuilder filter = new StringBuilder();
                filter.Append(" join batches b on b.id = s.batch_id ");
                // filter.Append(" and s.status in (1,9) ");
                if (!string.IsNullOrEmpty(Request.QueryString["setId"]))
                {
                    filter.Append(" and s.ID=" + Request.QueryString["setId"] + " ");
                }

                List <Branch> branchList = IBranchService.GetDataByFilter(" status='1'", 0, 0, false);

                if (userRole == "Regional Admin")
                {
                    List <Branch> Branches = new List <Branch>();
                    if (user.IsAll == 0)
                    {
                        List <BranchUser> userBranches = IBranchUserService.GetDataByFilter(" user_id = '" + user.Id + "' and status='1'", 0, 0, false);
                        branchList = IBranchService.GetDataByFilter(" ID not in (" + String.Join(",", userBranches.Select(x => x.BranchId).ToArray()) + ")", 0, 0, false);
                    }
                }
                if (userRole == "Branch Admin")
                {
                    if (user.BranchId != 0)
                    {
                        Branch        branch   = IBranchService.GetSingle(user.BranchId);
                        List <Branch> branches = new List <Branch>();
                        branches.Add(branch);
                        branchList = branches;
                    }
                }

                if (userRole == "Regional Admin")
                {
                    filter.Append(" and b.branch_id in (" + String.Join(",", branchList.Select(x => x.Id).ToArray()) + ") ");
                }
                else if (userRole == "Branch Admin")
                {
                    filter.Append(" and b.branch_id in (" + user.BranchId + ") ");
                }

                if (Request.QueryString["IsNewSearch"] != "" && Request.QueryString["IsNewSearch"] != null)
                {
                    IsNewSearch.Value = Request.QueryString["IsNewSearch"].ToString();
                }
                if (IsNewSearch.Value == "1")
                {
                    hdnCurrentPageNo.Value = "";
                }
                if (Request.QueryString["Search"] != "" && Request.QueryString["Search"] != null)
                {
                    //Search.Value = Request.QueryString["Search"].ToString();
                    //bool isNumber = long.TryParse(Search.Value, out long number);
                    //if (isNumber)
                    //    Search.Value = number.ToString();
                    //string columnNameAaNo = Converter.GetColumnNameByPropertyName<Set>(nameof(Set.AaNo));
                    //filter.Append(" and (s." + columnNameAaNo + " like '%" + Search.Value + "%'");
                    //string columnNameAcNo = Converter.GetColumnNameByPropertyName<Set>(nameof(Set.AccountNo));
                    //filter.Append(" or s." + columnNameAcNo + " like '%" + Search.Value + "%'");
                    //string columnNameBatchNo = Converter.GetColumnNameByPropertyName<Batch>(nameof(Batch.BatchNo));
                    //filter.Append(" or b." + columnNameBatchNo + " like '%" + Search.Value + "%')");
                }


                int skip = 0, take = 10;
                if (hdnCurrentPageNo.Value == "")
                {
                    skip = 0;
                    take = 10;
                    hdnNumberPerPage.Value     = "10";
                    hdnCurrentPageNo.Value     = "1";
                    hdnTotalRecordsCount.Value = ISetService.GetCountByFilterNew(filter.ToString()).ToString();
                }
                else
                {
                    skip = (Convert.ToInt32(hdnCurrentPageNo.Value) - 1) * 10;
                    take = 10;
                }

                List <Set> objs = ISetService.GetDataByFilterNew(filter.ToString(), skip, take, true);

                StringBuilder asb   = new StringBuilder();
                int           index = 1;
                foreach (Set set in objs)
                {
                    Batch b = IBatchService.GetSingle(set.BatchId);

                    int setsCount      = ISetService.GetCountByFilter(" batch_id='" + b.Id + "'");
                    int scanPagesCount = 0;

                    filter = new StringBuilder();
                    filter.Append(" 1=1");
                    string BatchIdColumnName = Converter.GetColumnNameByPropertyName <BatchLog>(nameof(BatchLog.BatchId));
                    filter.Append(" and " + BatchIdColumnName + " = '" + b.Id + "'");

                    List <BatchLog> batchLogs    = IBatchLogService.GetDataByFilter(filter.ToString(), 0, 0, false);
                    StringBuilder   batchLogHTML = new StringBuilder();
                    foreach (BatchLog batchLog in batchLogs)
                    {
                        batchLogHTML.Append(@"
                                                    <div class='mini-stat clearfix text-left'>
                                                        " + (batchLog.StageId == 1 ?
                                                             @"<span class='mini-stat-icon orange'><i class='fa fa-print'></i></span>" :
                                                             (batchLog.StageId == 2 ?
                                                              "<span class='mini-stat-icon tar'><i class='fa fa-check-square-o'></i></span>" :
                                                              (batchLog.StageId == 3 ?
                                                               "<span class='mini-stat-icon pink'><i class='fa fa-external-link'></i></span>" :
                                                               (batchLog.StageId == 4 ?
                                                                "<span class='mini-stat-icon green'><i class='fa fa-puzzle-piece'></i></span>" :
                                                                (batchLog.StageId == 5 ?
                                                                 "<span class='mini-stat-icon yellow-b'><i class='fa fa-files-o'></i></span>" :
                                                                 (batchLog.StageId == 6 ?
                                                                  "<span class='mini-stat-icon yellow-b'><i class='fa fa-hdd-o'></i></span>" : "")))))) + @"
                                                        <div class='mini-stat-info'>
                                                            " + (batchLog.StageId == 1 ?
                                                                 "<span>Scan</span>" :
                                                                 (batchLog.StageId == 2 ?
                                                                  "<span>Index</span>" :
                                                                  (batchLog.StageId == 3 ?
                                                                   "<span><span>Export</span> <small>To Server</small></span>" :
                                                                   (batchLog.StageId == 4 ?
                                                                    "<span><span>Integrate</span> <small>Sync Control</small></span>" :
                                                                    (batchLog.StageId == 5 ?
                                                                     "<span><span>Release</span> <small>To Mimzy</small></span>" :
                                                                     (batchLog.StageId == 6 ?
                                                                      "<span><span>Document</span> <small>By Mimzy</small></span>" : "")))))) + @"
                                                            " + batchLog.UpdatedDate.ToString("dd/MM/yyyy HH:mm:ss") + @" - <strong>" + batchLog.BatchUser + @"</strong>
                                                        </div>
                                                    </div>
                                ");
                    }
                    BatchLog firstBatchLog = batchLogs.FirstOrDefault();
                    BatchLog lastBatchLog  = batchLogs.LastOrDefault();
                    TimeSpan timeSpan      = lastBatchLog.UpdatedDate.Subtract(firstBatchLog.UpdatedDate);

                    Branch     branch     = IBranchService.GetSingle(b.BranchId);
                    Department department = IDepartmentService.GetSingle(b.DepartmentId);
                    Stage      stage      = IStageService.GetSingle(b.StageId);
                    filter = new StringBuilder();
                    filter.Append(" 1=1");
                    filter.Append(" and " + Converter.GetColumnNameByPropertyName <SetDocument>(nameof(SetDocument.SetId)) + "='" + set.Id + "'");
                    filter.Append(" and " + Converter.GetColumnNameByPropertyName <SetDocument>(nameof(SetDocument.Status)) + "='1'");
                    List <SetDocument> setDocuments     = ISetDocumentService.GetDataByFilter(filter.ToString(), 0, 0, false);
                    StringBuilder      setDocumentsHTML = new StringBuilder();
                    StringBuilder      setDocumentsPdf  = new StringBuilder();



                    string departmentCode = department.Code;
                    string deptCode       = departmentCode.Split('-')[0];
                    string jobCode        = departmentCode.Split('-')[1];
                    string columnData     = "";
                    string accountNumber  = "";
                    if (departmentCode == "E-LIBRARY")
                    {
                        //AA NUMBER
                        //ACCOUNT NUMBER
                        columnData     = "AA No: " + set.AaNo;
                        columnData    += "<br/>Account No: " + set.AccountNo;
                        accountNumber += " <tr><td> AA Number </td><td> " + set.AaNo + " </td></tr>";
                        accountNumber += " <tr><td> Acount Number </td><td> " + set.AccountNo + " </td></tr>";
                    }
                    else if (deptCode == "ETP")
                    {
                        if (jobCode == "LN")
                        {
                            columnData     = "AA No: " + set.AaNo;
                            columnData    += "<br/>Account No: " + set.AccountNo;
                            accountNumber += " <tr><td> AA Number </td><td> " + set.AaNo + " </td></tr>";
                            accountNumber += " <tr><td> Acount Number </td><td> " + set.AccountNo + " </td></tr>";
                        }
                        else if (jobCode == "LL")
                        {
                            columnData     = "AA No: " + set.AaNo;
                            accountNumber += " <tr><td> AA Number </td><td> " + set.AaNo + " </td></tr>";
                        }
                        else if (jobCode == "PR")
                        {
                            columnData     = "Project Code: " + set.AaNo;
                            accountNumber += " <tr><td> Project Code </td><td> " + set.AaNo + " </td></tr>";
                        }
                        else if (jobCode == "WF")
                        {
                            columnData     = "Welfare Code: " + set.AaNo;
                            accountNumber += " <tr><td> Welfare Code </td><td> " + set.AaNo + " </td></tr>";
                        }
                    }
                    else if (deptCode == "LOS")
                    {
                        columnData     = "AA No: " + set.AaNo;
                        accountNumber += " <tr><td> AA Number </td><td> " + set.AaNo + " </td></tr>";
                    }


                    setDocumentsPdf.Append(@"<button class='rotate90' id='metaTag'>Meta Tag</button>
            <button class='rotate90' id='preView'>Preview</button>
            <h5><i class='fa fa-file-pdf-o'></i> <strong>" + department.Code + @" - " + set.AaNo + @"</strong></h5>
            <table id='tblView' class='table table-condensed table-striped'>" + accountNumber + @"
                           <tr><td> Branch </td><td>" + branch.Code + @"</td></tr>
                           <tr><td> Department </td><td>" + department.Code + @"</ td ></ tr >    
                                <tr><td> Date </td><td> " + set.CreatedDate + @" </td></tr>
                                <tr><td> M - File Status </td><td> " + (set.IsReleased == 1 ? "<i class='fa fa-file text-muted'></i>Pending " : (set.IsReleased == 2 && set.Status == 1 ? "<i class='fa fa-file text-success'></i>Mfile update has been Success" : "<i class='fa fa-file text-danger'></i>Mfile update has been Failed")) + @" </td></tr>
                                       <tr><td> Remarks </td><td>" + set.Remarks + @"</td></tr>
                                   </table> ");
                    foreach (SetDocument setDocument in setDocuments)
                    {
                        scanPagesCount += setDocument.PageCount;
                        string fileName = Path.GetFileName(setDocument.DocumentUrl);
                        string localUrl = Server.MapPath("/Content/Files/" + fileName);

                        if (File.Exists(setDocument.DocumentUrl) && !File.Exists(localUrl))
                        {
                            File.Copy(setDocument.DocumentUrl, localUrl);
                        }
                        setDocumentsHTML.Append(@" <div class='pdf-document'>
                            <a href='javascript:;' id='" + setDocument.DocType + @"' onclick='pdfview(this)'><i class='fa fa-file-pdf-o'></i> " + setDocument.DocType + @" Shown Documents from " + setDocument.UpdatedDate + @"</p>
                        </a> </div>");
                        // setDocumentsHTML.Append(@"<div style='min-width: 150px;'><a href='/Content/Files/" + fileName + "' target='_blank' data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + setDocument.DocType + @"</strong></a> ( <small> pages: <strong>" + setDocument.PageCount + @"</strong></small> )</div>");
                        setDocumentsPdf.Append(@"<div class='pdfView' id='pdf-" + setDocument.DocType + @"' style='display: none'> <iframe width='100%' height='100%' src='/Content/Files/" + fileName + @"'> </iframe></div>");
                    }
                    ResultHolder.InnerHtml = setDocumentsHTML.ToString();
                    FileHolder.InnerHtml   = setDocumentsPdf.ToString();
                    string xmlFileName = Path.GetFileName(set.SetXmlPath);
                    string localXMLUrl = Server.MapPath("/Content/Files/" + xmlFileName);
                    if (set.SetXmlPath != null && set.SetXmlPath != "")
                    {
                        if (File.Exists(set.SetXmlPath) && !File.Exists(localXMLUrl))
                        {
                            File.Copy(set.SetXmlPath, localXMLUrl);
                        }

                        asb.Append(@" <div>
                        " + columnData + @"
                       <br /> Branch : " + branch.Code + @" 
                       <br /> Department : " + department.Code + @"
                       <br /> Batch No : " + b.BatchNo + @"
                    </div>");
                        //  PropsHolder.InnerHtml = asb.ToString();
                        //                        asb.Append(@"<tr>
                        //                                    <td class='" + (set.IsReleased == 0 ? "" : "text-success") + @"'>
                        //                                        " + index + @"
                        //                                    </td>
                        //                                    <td>branch Code " + branch.Code + @"<br />Department - " + department.Code + @"<br />User Batch No " + b.BatchNo + @"<br />
                        //AA No " + b.BatchNo + @"<br />
                        //Acount Number " + b.BatchNo + @"<br /></td>
                        //                                    <td><a href='/Content/Files/" + xmlFileName + @"' target='_blank' data-original-title='Click to view XML' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + columnData + @"</strong></a></td>
                        //                                    <td style='text-align:left'>
                        //Created On " + (set.UpdatedDate == null ? set.CreatedDate.ToString("dd/MM/yyyy HH:mm:ss") : set.UpdatedDate.Value.ToString("dd/MM/yyyy HH:mm:ss")) + @"<br />
                        //                        "+ setDocumentsPdf.ToString() + @" </td>
                        //                                </tr>");
                    }
                    index++;
                }
                PropsHolder.InnerHtml = asb.ToString();
            }
        }
Exemplo n.º 22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string idString           = Request.QueryString["id"];
            string stageIdString      = Request.QueryString["stageid"];
            string departmentIdString = Request.QueryString["departmentid"];
            string fromDate           = Request.QueryString["fromdate"];
            string toDate             = Request.QueryString["todate"];

            if (!string.IsNullOrEmpty(idString))
            {
                int    branchId = Convert.ToInt32(idString);
                Branch branch   = IBranchService.GetSingle(branchId);
                branchName.InnerHtml = branch.Name;

                if (Request.QueryString["hdnNumberPerPage"] != "" && Request.QueryString["hdnNumberPerPage"] != null)
                {
                    hdnNumberPerPage.Value = Request.QueryString["hdnNumberPerPage"].ToString();
                }
                if (Request.QueryString["hdnCurrentPageNo"] != "" && Request.QueryString["hdnCurrentPageNo"] != null)
                {
                    hdnCurrentPageNo.Value = Request.QueryString["hdnCurrentPageNo"].ToString();
                }
                if (Request.QueryString["hdnTotalRecordsCount"] != "" && Request.QueryString["hdnTotalRecordsCount"] != null)
                {
                    hdnTotalRecordsCount.Value = Request.QueryString["hdnTotalRecordsCount"].ToString();
                }

                StringBuilder filter  = new StringBuilder();
                StringBuilder filter1 = new StringBuilder();

                filter.Append(" 1=1");
                filter.Append(" and (status='1' or status='9')");

                string branchIdColumnName = Converter.GetColumnNameByPropertyName <Batch>(nameof(Batch.BranchId));
                filter.Append(" and " + branchIdColumnName + "='" + branch.Id + "'");

                if (!string.IsNullOrEmpty(stageIdString))
                {
                    int   stageId = Convert.ToInt32(stageIdString);
                    Stage stage   = IStageService.GetSingle(stageId);

                    string stageIdColumnName = Converter.GetColumnNameByPropertyName <Batch>(nameof(Batch.StageId));
                    filter.Append(" and " + stageIdColumnName + "='" + stage.Id + "'");

                    if (string.IsNullOrEmpty(fromDate) && !string.IsNullOrEmpty(toDate))
                    {
                        if (stage.Id >= 5)
                        {
                            string createdDateColumnName = Converter.GetColumnNameByPropertyName <Batch>(nameof(Batch.CreatedDate));
                            //filter.Append(" and DATE_FORMAT(DATE_SUB(" + createdDateColumnName + ", INTERVAL 0 YEAR),'%Y-%m-%d') = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' ");
                            //SQL
                            filter.Append(" and CAST(DATEADD(year, " + DateInterval + ", " + createdDateColumnName + ") as DATE) = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' ");
                            //MYSQL
                            //filter.Append(" and DATE_FORMAT(DATE_SUB(" + createdDateColumnName + ", INTERVAL " + DateInterval + " YEAR),'%Y-%m-%d') = '" + DateTime.Now.ToString("yyyy-MM-dd") + "' ");
                        }
                    }
                }
                if (!string.IsNullOrEmpty(fromDate) && !string.IsNullOrEmpty(toDate))
                {
                    filter.Append(" and created_date between '" + fromDate + "' and  '" + toDate + "' ");
                }

                if (!string.IsNullOrEmpty(departmentIdString))
                {
                    int        departmentId = Convert.ToInt32(departmentIdString);
                    Department department   = IDepartmentService.GetSingle(departmentId);

                    string departmentIdColumnName = Converter.GetColumnNameByPropertyName <Batch>(nameof(Batch.DepartmentId));
                    filter.Append(" and " + departmentIdColumnName + "='" + department.Id + "'");
                }
                // New code fro paging
                int skip = 0, take = 10;
                if (hdnCurrentPageNo.Value == "")
                {
                    skip = 0;
                    take = 10;
                    hdnNumberPerPage.Value     = "10";
                    hdnCurrentPageNo.Value     = "1";
                    hdnTotalRecordsCount.Value = IBatchService.GetCountByFilter(filter.ToString()).ToString();
                }
                else
                {
                    if (hdnCurrentPageNo.Value.Contains(","))
                    {
                        hdnCurrentPageNo.Value = hdnCurrentPageNo.Value.Split(',').Last();
                    }
                    skip = (Convert.ToInt32(hdnCurrentPageNo.Value) - 1) * 10;
                    take = 10;
                }

                List <Batch>    batches = IBatchService.GetDataByFilter(filter.ToString(), skip, take, true);
                List <BatchLog> batchLogs = new List <BatchLog>();

                List <int> batchIdList = batches.Select(a => a.Id).ToList();
                if (batchIdList != null && batchIdList.Count != 0)
                {
                    filter = new StringBuilder();
                    filter.Append(" 1=1");
                    string        BatchIdColumnName = Converter.GetColumnNameByPropertyName <BatchLog>(nameof(BatchLog.BatchId));
                    List <string> branchIds         = batches.Select(x => x.Id.ToString()).ToList <string>();
                    filter.Append(" and " + BatchIdColumnName + " in (" + String.Join(",", branchIds.ToArray()) + ")");
                    batchLogs = IBatchLogService.GetDataByFilter(filter.ToString(), 0, 0, false);
                }
                //End New code


                StringBuilder innerHTML = new StringBuilder();
                var           groupByDepartments = batches.Where(x => x.BranchId == branch.Id).ToList().GroupBy(x => x.DepartmentId).Select(grp => grp.ToList()).ToList();
                if (groupByDepartments.Count > 0)
                {
                    foreach (List <Batch> deptBatches in groupByDepartments)
                    {
                        Department department = IDepartmentService.GetSingle(deptBatches.FirstOrDefault().DepartmentId);
                        filter = new StringBuilder();
                        filter.Append(" 1=1");
                        //List<string> batchIds = deptBatches.Select(x => x.Id.ToString()).ToList<string>();
                        //string BatchIdColumnName = Converter.GetColumnNameByPropertyName<Set>(nameof(Set.BatchId));
                        //filter.Append(" and " + BatchIdColumnName + " in (" + String.Join(",", batchIds.ToArray()) + ")");

                        StringBuilder batchesHTML = new StringBuilder();
                        foreach (Batch batch in deptBatches)
                        {
                            filter = new StringBuilder();
                            filter.Append(" 1=1");
                            string BatchIdColumnName = Converter.GetColumnNameByPropertyName <BatchLog>(nameof(BatchLog.BatchId));
                            filter.Append(" and " + BatchIdColumnName + " = '" + batch.Id + "'");

                            //  batchLogs = IBatchLogService.GetDataByFilter(filter.ToString(), 0, 0, false);

                            filter = new StringBuilder();
                            filter.Append(" 1=1");
                            BatchIdColumnName = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.BatchId));
                            filter.Append(" and " + BatchIdColumnName + " = '" + batch.Id + "'");
                            filter.Append(" and status in (1, 9)");

                            List <Set>    sets     = ISetService.GetDataByFilter(filter.ToString(), 0, 0, false);
                            StringBuilder setsHTML = new StringBuilder();
                            setsHTML.Append("<table cellspacing='0' width='100%'>");
                            setsHTML.Append("<thead><tr><th>Code No</th><th>Documents</th></tr></thead>");
                            setsHTML.Append("<tbody>");
                            int documentsCount = 0;
                            int setsCount      = 0;
                            int scanPagesCount = 0;
                            if (sets.Count > 0)
                            {
                                foreach (Set set in sets)
                                {
                                    List <SetDocument> setDocuments = ISetDocumentService.GetDataByPropertyName(nameof(SetDocument.SetId), set.Id.ToString(), true, 0, 0, false);
                                    setDocuments    = setDocuments.Where(x => x.Status == 1).ToList();
                                    documentsCount += setDocuments.Count;
                                    StringBuilder setDocumentsHTML = new StringBuilder();
                                    foreach (SetDocument setDocument in setDocuments)
                                    {
                                        scanPagesCount += setDocument.PageCount;
                                        //string NetworkPath = ConfigurationManager.AppSettings["NetworkPath"].ToString();
                                        //string NetworkDrive = ConfigurationManager.AppSettings["NetworkDrive"].ToString();
                                        //string mapLocalUrl = setDocument.DocumentUrl.Replace(NetworkPath, NetworkDrive);

                                        //string fileName = Path.GetFileName(setDocument.DocumentUrl);
                                        //string localUrl = Server.MapPath("/Content/Files/" + fileName);
                                        //if (File.Exists(setDocument.DocumentUrl) && !File.Exists(localUrl))
                                        //{
                                        //    File.Copy(setDocument.DocumentUrl, localUrl);
                                        //}
                                        // setDocumentsHTML.Append(@"<div><a href='/Content/Files/" + fileName + "' target='_blank' data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + setDocument.DocType + @"</strong></a> ( <small> pages: <strong>" + setDocument.PageCount + @"</strong></small> )</div>");
                                        setDocumentsHTML.Append(@"<div><a href='#' data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + setDocument.DocType + @"</strong></a> ( <small> pages: <strong>" + setDocument.PageCount + @"</strong></small> )</div>");
                                    }
                                    string xmlFileName    = Path.GetFileName(set.SetXmlPath);
                                    string localXMLUrl    = Server.MapPath("/Content/Files/" + xmlFileName);
                                    string departmentCode = department.Code;
                                    string deptCode       = departmentCode.Split('-')[0];
                                    string jobCode        = departmentCode.Split('-')[1];
                                    string columnData     = "";
                                    if (departmentCode == "E-LIBRARY")
                                    {
                                        //AA NUMBER
                                        //ACCOUNT NUMBER
                                        columnData  = "AA No: " + set.AaNo;
                                        columnData += "<br/>Account No: " + set.AccountNo;
                                    }
                                    else if (deptCode == "ETP")
                                    {
                                        if (jobCode == "LN")
                                        {
                                            columnData  = "AA No: " + set.AaNo;
                                            columnData += "<br/>Account No: " + set.AccountNo;
                                        }
                                        else if (jobCode == "LL")
                                        {
                                            columnData = "AA No: " + set.AaNo;
                                        }
                                        else if (jobCode == "PR")
                                        {
                                            columnData = "Project Code: " + set.AaNo;
                                        }
                                        else if (jobCode == "WF")
                                        {
                                            columnData = "Welfare Code: " + set.AaNo;
                                        }
                                    }
                                    else if (deptCode == "LOS")
                                    {
                                        columnData = "AA No: " + set.AaNo;
                                    }
                                    if (!string.IsNullOrEmpty(set.SetXmlPath))
                                    {
                                        setsCount++;
                                        //if (File.Exists(set.SetXmlPath) && !File.Exists(localXMLUrl))
                                        //    File.Copy(set.SetXmlPath, localXMLUrl);
                                        //setsHTML.Append(@"
                                        //    <tr>
                                        //        <td><a href='/Content/Files/" + xmlFileName + @"' target='_blank' data-original-title='Click to view XML' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + columnData + @"</strong></a></td>
                                        //        <td>" + setDocumentsHTML.ToString() + @"</td>
                                        //    </tr>
                                        //");


                                        setsHTML.Append(@"
                                            <tr>
                                                <td><a href='SetView.aspx?setId=" + set.Id + @"' target='_blank' data-original-title='Click to view Files' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + columnData + @" <i class='fa fa-eye'></i></strong></a>
                                            </td>
                                                <td>" + setDocumentsHTML.ToString() + @"</td>
                                            </tr>
                                        ");
                                    }
                                }
                            }
                            setsHTML.Append("</tbody>");
                            setsHTML.Append("</table>");

                            StringBuilder batchLogHTML = new StringBuilder();
                            foreach (BatchLog batchLog in batchLogs.Where(a => a.BatchId == batch.Id).ToList())
                            {
                                batchLogHTML.Append(@"
                                                    <div class='mini-stat clearfix text-left'>
                                                        " + (batchLog.StageId == 1 ?
                                                             @"<span class='mini-stat-icon orange'><i class='fa fa-print'></i></span>" :
                                                             (batchLog.StageId == 2 ?
                                                              "<span class='mini-stat-icon tar'><i class='fa fa-check-square-o'></i></span>" :
                                                              (batchLog.StageId == 3 ?
                                                               "<span class='mini-stat-icon pink'><i class='fa fa-external-link'></i></span>" :
                                                               (batchLog.StageId == 4 ?
                                                                "<span class='mini-stat-icon green'><i class='fa fa-puzzle-piece'></i></span>" :
                                                                (batchLog.StageId == 5 ?
                                                                 "<span class='mini-stat-icon yellow-b'><i class='fa fa-files-o'></i></span>" :
                                                                 (batchLog.StageId == 6 ?
                                                                  "<span class='mini-stat-icon yellow-b'><i class='fa fa-hdd-o'></i></span>" :
                                                                  "")))))) + @"
                                                        <div class='mini-stat-info'>
                                                            " + (batchLog.StageId == 1 ?
                                                                 "<span>Scan</span>" :
                                                                 (batchLog.StageId == 2 ?
                                                                  "<span>Index</span>" :
                                                                  (batchLog.StageId == 3 ?
                                                                   "<span><span>Export</span> <small>To Server</small></span>" :
                                                                   (batchLog.StageId == 4 ?
                                                                    "<span><span>Integrate</span> <small>Sync Control</small></span>" :
                                                                    (batchLog.StageId == 5 ?
                                                                     "<span><span>Release</span> <small>To Mimzy</small></span>" :
                                                                     (batchLog.StageId == 6 ?
                                                                      "<span><span>Document</span> <small>By Mimzy</small></span>" : "")))))) + @"
                                                            " + batchLog.UpdatedDate.ToString("dd/MM/yyyy HH:mm:ss") + @" - <strong>" + batchLog.BatchUser + @"</strong>
                                                        </div>
                                                    </div>
                                ");
                            }

                            BatchLog firstBatchLog = batchLogs.FirstOrDefault();
                            BatchLog lastBatchLog  = batchLogs.LastOrDefault();
                            TimeSpan timeSpan      = lastBatchLog.UpdatedDate.Subtract(firstBatchLog.UpdatedDate);

                            int    isReleased      = 0;
                            int    isException     = 0;
                            string mFIleStatus     = "";
                            int    isSetCount      = sets.Count();
                            var    releasedStatus2 = sets.Where(x => x.IsReleased == 2).ToList();
                            if (releasedStatus2 == null)
                            {
                                isReleased = 0;
                            }
                            else if (sets.Count != releasedStatus2.Count)
                            {
                                isReleased = 1;
                            }
                            else if (sets.Count == releasedStatus2.Count)
                            {
                                isReleased = 2;
                                if (releasedStatus2.Count(x => x.Status == 9) == 0)
                                {
                                    isException = 0;
                                }
                                else if (releasedStatus2.Count(x => x.Status == 9) != sets.Count)
                                {
                                    isException = 1;
                                }
                                else if (releasedStatus2.Count(x => x.Status == 9) == sets.Count)
                                {
                                    isException = 2;
                                }
                            }

                            batchesHTML.Append(@"
                                <tr>
                                    <td>
                                        <div class='text-center mb-5'>
                                            " + branch.Code + @" : <strong class='" + (batch.Status == 9 ? "text-danger" : "") + @"'>" + batch.BatchNo + @"</strong>
                                            <a href='javascript:;' class='text-info view_batch_log'><sup>View Log</sup></a>
                                            <div class='div_batch_log hide draggableDiv'>
                                                <span class='log_close'>X</span>
                                                <table>
                                                    <tr><td colspan='2' class='text-center'><strong>Batch log</strong></td></tr>
                                                    <tr><td>Batch No: <strong>" + batch.BatchNo + @"</strong></td><td>No. of sets: <strong>" + setsCount + @"</strong></td></tr>
                                                    <tr><td colspan='2'><small>Duration: <label class='label label-primary'>" + timeSpan.Days + @" days, " + timeSpan.Hours + @" hours, " + timeSpan.Minutes + @" minutes, " + timeSpan.Seconds + @" seconds</label></small></tr>
                                                </table>
                                                " + batchLogHTML.ToString() + @"
                                                 <div>
                                                    Total scan pages: <strong>" + scanPagesCount + @"</strong>
                                                </div>");

                            if (isSetCount != 0)
                            {
                                batchesHTML.Append(@"<div>
                                                    M - Files Status: <span clas = 'fs-14'> " + (isReleased == 0 || isReleased == 1 ? " <i class='fa fa-file text-muted'></i>" : (isReleased == 2 && isException == 0 ? "<i class='fa fa-file text-success'></i>" : (isReleased == 2 && isException == 1 ? "<i class='fa fa-file text-warning'></i>" : (isReleased == 2 && isException == 2 ? "<i class='fa fa-file text-danger'></i>" : "")))) + @"</span>
                                                </div>");
                            }
                            batchesHTML.Append(@" </div>
                                        </div>
                                    </td>
                                    <td>
                                        " + batch.BatchUser + @"
                                    </td>
                                    <td>
                                        " + batch.CreatedDate.ToString("dd/MM/yyyy HH:mm:ss") + @"
                                    </td>
                                    <td>
                                        " + setsHTML.ToString() + @"
                                        </td>
                                </tr>
                            ");
                        }

                        innerHTML.Append(@"
                        <section class='panel my-panel'>
                            <header class='panel-heading'>
                                Department: <strong>" + department.Name + @"</strong>
                                <span class='tools pull-right'>
                                    <a href='javascript:;' class='fa fa-chevron-up panel-oc'></a>
                                </span>
                            </header>
                            <div class='panel-body' style='display: none;'>
                                <table class='display responsive nowrap table table-bordered dataTable' cellspacing='0' width='100%'>
                                    <thead>
                                        <tr>
                                            <th>Batch No</th>
                                            <th>Batch user</th>
                                            <th>Batch date</th>
                                            <th>Sets</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        " + batchesHTML + @"
                                    </tbody>
                                </table>
                            </div>
                        </section>");
                    }
                }
                panelBatches.InnerHtml = innerHTML.ToString();
            }
        }
Exemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserId"] == null)
            {
                Response.Redirect("Login.aspx");
            }
            else
            {
                Int32  UserId   = Convert.ToInt32(Session["UserId"].ToString());
                User   user     = IUserService.GetSingle(UserId);
                string userType = Session["UserType"].ToString();
                string userRole = Session["UserRole"].ToString();


                if (Request.QueryString["hdnNumberPerPage"] != "" && Request.QueryString["hdnNumberPerPage"] != null)
                {
                    hdnNumberPerPage.Value = Request.QueryString["hdnNumberPerPage"].ToString();
                }
                if (Request.QueryString["hdnCurrentPageNo"] != "" && Request.QueryString["hdnCurrentPageNo"] != null)
                {
                    hdnCurrentPageNo.Value = Request.QueryString["hdnCurrentPageNo"].ToString();
                }
                if (Request.QueryString["hdnTotalRecordsCount"] != "" && Request.QueryString["hdnTotalRecordsCount"] != null)
                {
                    hdnTotalRecordsCount.Value = Request.QueryString["hdnTotalRecordsCount"].ToString();
                }

                StringBuilder filter = new StringBuilder();
                filter.Append(" join batches b on b.id = s.batch_id ");
                // filter.Append(" and s.status = '1' ");
                filter.Append(" and s.status in (1,9) ");

                List <Branch> branchList = IBranchService.GetDataByFilter(" status='1'", 0, 0, false);

                if (userRole == "Regional Admin")
                {
                    List <Branch> Branches = new List <Branch>();
                    if (user.IsAll == 0)
                    {
                        List <BranchUser> userBranches = IBranchUserService.GetDataByFilter(" user_id = '" + user.Id + "' and status='1'", 0, 0, false);
                        branchList = IBranchService.GetDataByFilter(" ID not in (" + String.Join(",", userBranches.Select(x => x.BranchId).ToArray()) + ")", 0, 0, false);
                    }
                }
                if (userRole == "Branch Admin")
                {
                    if (user.BranchId != 0)
                    {
                        Branch        branch   = IBranchService.GetSingle(user.BranchId);
                        List <Branch> branches = new List <Branch>();
                        branches.Add(branch);
                        branchList = branches;
                    }
                }

                if (userRole == "Regional Admin")
                {
                    filter.Append(" and b.branch_id in (" + String.Join(",", branchList.Select(x => x.Id).ToArray()) + ") ");
                }
                else if (userRole == "Branch Admin")
                {
                    filter.Append(" and b.branch_id in (" + user.BranchId + ") ");
                }

                if (Request.QueryString["IsNewSearch"] != "" && Request.QueryString["IsNewSearch"] != null)
                {
                    IsNewSearch.Value = Request.QueryString["IsNewSearch"].ToString();
                }
                if (IsNewSearch.Value == "1")
                {
                    hdnCurrentPageNo.Value = "";
                }
                if (Request.QueryString["Search"] != "" && Request.QueryString["Search"] != null)
                {
                    Search.Value = Request.QueryString["Search"].ToString();
                    bool isNumber = long.TryParse(Search.Value, out long number);
                    if (isNumber)
                    {
                        Search.Value = number.ToString();
                    }
                    string columnNameAaNo = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.AaNo));
                    filter.Append(" and (s." + columnNameAaNo + " like '%" + Search.Value + "%'");
                    string columnNameAcNo = Converter.GetColumnNameByPropertyName <Set>(nameof(Set.AccountNo));
                    filter.Append(" or s." + columnNameAcNo + " like '%" + Search.Value + "%'");
                    string columnNameBatchNo = Converter.GetColumnNameByPropertyName <Batch>(nameof(Batch.BatchNo));
                    filter.Append(" or b." + columnNameBatchNo + " like '%" + Search.Value + "%')");
                }
                string fromdate = ""; string toDate = "";
                if (!string.IsNullOrEmpty(Request.QueryString["FromDate"]))
                {
                    FromDate.Value = fromdate = Request.QueryString["FromDate"];
                }

                if (!string.IsNullOrEmpty(Request.QueryString["ToDate"]))
                {
                    ToDate.Value = toDate = Request.QueryString["ToDate"];
                }

                if (!string.IsNullOrEmpty(fromdate) && !string.IsNullOrEmpty(toDate))
                {
                    filter.Append("  and s.created_date between '" + fromdate + "' and  '" + toDate + "'");
                }

                int skip = 0, take = 10;
                if (hdnCurrentPageNo.Value == "")
                {
                    skip = 0;
                    take = 10;
                    hdnNumberPerPage.Value     = "10";
                    hdnCurrentPageNo.Value     = "1";
                    hdnTotalRecordsCount.Value = ISetService.GetCountByFilterNew(filter.ToString()).ToString();
                }
                else
                {
                    skip = (Convert.ToInt32(hdnCurrentPageNo.Value) - 1) * 10;
                    take = 10;
                }

                List <Set> objs = ISetService.GetDataByFilterNew(filter.ToString(), skip, take, true);

                StringBuilder asb   = new StringBuilder();
                int           index = 1;
                foreach (Set set in objs)
                {
                    Batch b = IBatchService.GetSingle(set.BatchId);

                    int setsCount      = ISetService.GetCountByFilter(" batch_id='" + b.Id + "'");
                    int scanPagesCount = 0;

                    filter = new StringBuilder();
                    filter.Append(" 1=1");
                    string BatchIdColumnName = Converter.GetColumnNameByPropertyName <BatchLog>(nameof(BatchLog.BatchId));
                    filter.Append(" and " + BatchIdColumnName + " = '" + b.Id + "'");

                    List <BatchLog> batchLogs    = IBatchLogService.GetDataByFilter(filter.ToString(), 0, 0, false);
                    StringBuilder   batchLogHTML = new StringBuilder();
                    foreach (BatchLog batchLog in batchLogs)
                    {
                        batchLogHTML.Append(@"
                                                    <div class='mini-stat clearfix text-left'>
                                                        " + (batchLog.StageId == 1 ?
                                                             @"<span class='mini-stat-icon orange'><i class='fa fa-print'></i></span>" :
                                                             (batchLog.StageId == 2 ?
                                                              "<span class='mini-stat-icon tar'><i class='fa fa-check-square-o'></i></span>" :
                                                              (batchLog.StageId == 3 ?
                                                               "<span class='mini-stat-icon pink'><i class='fa fa-external-link'></i></span>" :
                                                               (batchLog.StageId == 4 ?
                                                                "<span class='mini-stat-icon green'><i class='fa fa-puzzle-piece'></i></span>" :
                                                                (batchLog.StageId == 5 ?
                                                                 "<span class='mini-stat-icon yellow-b'><i class='fa fa-files-o'></i></span>" :
                                                                 (batchLog.StageId == 6 ?
                                                                  "<span class='mini-stat-icon yellow-b'><i class='fa fa-hdd-o'></i></span>" : "")))))) + @"
                                                        <div class='mini-stat-info'>
                                                            " + (batchLog.StageId == 1 ?
                                                                 "<span>Scan</span>" :
                                                                 (batchLog.StageId == 2 ?
                                                                  "<span>Index</span>" :
                                                                  (batchLog.StageId == 3 ?
                                                                   "<span><span>Export</span> <small>To Server</small></span>" :
                                                                   (batchLog.StageId == 4 ?
                                                                    "<span><span>Integrate</span> <small>Sync Control</small></span>" :
                                                                    (batchLog.StageId == 5 ?
                                                                     "<span><span>Release</span> <small>To Mimzy</small></span>" :
                                                                     (batchLog.StageId == 6 ?
                                                                      "<span><span>Document</span> <small>By Mimzy</small></span>" : "")))))) + @"
                                                            " + batchLog.UpdatedDate.ToString("dd/MM/yyyy HH:mm:ss") + @" - <strong>" + batchLog.BatchUser + @"</strong>
                                                        </div>
                                                    </div>
                                ");
                    }
                    BatchLog firstBatchLog = batchLogs.FirstOrDefault();
                    BatchLog lastBatchLog  = batchLogs.LastOrDefault();
                    TimeSpan timeSpan      = lastBatchLog.UpdatedDate.Subtract(firstBatchLog.UpdatedDate);

                    Branch     branch     = IBranchService.GetSingle(b.BranchId);
                    Department department = IDepartmentService.GetSingle(b.DepartmentId);
                    Stage      stage      = IStageService.GetSingle(b.StageId);
                    filter = new StringBuilder();
                    filter.Append(" 1=1");
                    filter.Append(" and " + Converter.GetColumnNameByPropertyName <SetDocument>(nameof(SetDocument.SetId)) + "='" + set.Id + "'");
                    filter.Append(" and " + Converter.GetColumnNameByPropertyName <SetDocument>(nameof(SetDocument.Status)) + "='1'");
                    List <SetDocument> setDocuments     = ISetDocumentService.GetDataByFilter(filter.ToString(), 0, 0, false);
                    StringBuilder      setDocumentsHTML = new StringBuilder();
                    foreach (SetDocument setDocument in setDocuments)
                    {
                        scanPagesCount += setDocument.PageCount;
                        //    string fileName = Path.GetFileName(setDocument.DocumentUrl);
                        //    string localUrl = Server.MapPath("/Content/Files/" + fileName);

                        //    if (!File.Exists(localUrl))
                        //        File.Copy(setDocument.DocumentUrl, localUrl);
                        //    setDocumentsHTML.Append(@"<div style='min-width: 150px;'><a href='/Content/Files/" + fileName + "' target='_blank' data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + setDocument.DocType + @"</strong></a> ( <small> pages: <strong>" + setDocument.PageCount + @"</strong></small> )</div>");
                        setDocumentsHTML.Append(@"<div style='min-width: 150px;'><a href='#' data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info'><strong>" + setDocument.DocType + @"</strong></a> ( <small> pages: <strong>" + setDocument.PageCount + @"</strong></small> )</div>");
                    }
                    string xmlFileName = Path.GetFileName(set.SetXmlPath);
                    string localXMLUrl = Server.MapPath("/Content/Files/" + xmlFileName);
                    if (!string.IsNullOrEmpty(set.SetXmlPath))
                    {
                        //if (File.Exists(set.SetXmlPath) && !File.Exists(localXMLUrl))
                        //    File.Copy(set.SetXmlPath, localXMLUrl);
                        string departmentCode = department.Code;
                        string deptCode       = departmentCode.Split('-')[0];
                        string jobCode        = departmentCode.Split('-')[1];
                        string columnData     = "";
                        if (departmentCode == "E-LIBRARY")
                        {
                            //AA NUMBER
                            //ACCOUNT NUMBER
                            columnData  = "AA No: " + set.AaNo;
                            columnData += "<br/>Account No: " + set.AccountNo;
                        }
                        else if (deptCode == "ETP")
                        {
                            if (jobCode == "LN")
                            {
                                columnData  = "AA No: " + set.AaNo;
                                columnData += "<br/>Account No: " + set.AccountNo;
                            }
                            else if (jobCode == "LL")
                            {
                                columnData = "AA No: " + set.AaNo;
                            }
                            else if (jobCode == "PR")
                            {
                                columnData = "Project Code: " + set.AaNo;
                            }
                            else if (jobCode == "WF")
                            {
                                columnData = "Welfare Code: " + set.AaNo;
                            }
                        }
                        else if (deptCode == "LOS")
                        {
                            columnData = "AA No: " + set.AaNo;
                        }

                        asb.Append(@"<tr>
                                    <td class='" + (set.IsReleased == 0 ? "" : "text-success") + @"'>
                                        " + index + @"
                                    </td>
                                    <td>" + branch.Code + @"</td>
                                    <td>" + department.Code + @"</td>
                                    <td class='text-center mb-5'>
                                        " + b.BatchNo + @"
                                        <a href='javascript:;' class='text-info view_batch_log'><sup>View Log</sup></a>
                                        <div class='div_batch_log hide draggableDiv'>
                                            <span class='log_close'>X</span>
                                            <table>
                                                <tr><td><strong>Set Log</strong></td><td>Batch No: <strong>" + b.BatchNo + @"</strong></td></tr>
                                                <tr><td colspan='2'><small>Duration: <label class='label label-primary'>" + timeSpan.Days + @" days, " + timeSpan.Hours + @" hours, " + timeSpan.Minutes + @" minutes, " + timeSpan.Seconds + @" seconds</label></small></tr>
                                            </table>
                                            " + batchLogHTML.ToString() + @"
                                            <div>
                                                M-Files Status: <span clas='fs-14'>" + (set.IsReleased == 1 ? "<i class='fa fa-file text-muted'></i>" : (set.IsReleased == 2 && set.Status == 1 ? "<i class='fa fa-file text-success'></i>" : "<i class='fa fa-file text-danger'></i>")) + @"</span>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div><strong>" + columnData + @"</strong><div>
                                        <a data-original-title='Click to view' data-trigger='hover' data-placement='bottom' class='popovers text-info' href='SetView.aspx?setId=" + set.Id + @"' target='_blank'><i class='fa fa-eye'></i></a>
                                    </td>
                                    <td>" + setDocumentsHTML.ToString() + @"</td>
                                    <td>" + stage.Name + @"</td>
                                    <td>" + (b.StageId == 6 && set.IsReleased == 1 ? "<i class='fa fa-file text-muted'></i>" : (b.StageId == 6 && set.IsReleased == 2 && set.Status == 1 ? "<i class='fa fa-file text-success'></i> Success " : (b.StageId == 6 && set.IsReleased == 2 && set.Status == 9 ? " < i class='fa fa-file text-danger'></i>" + set.Remarks : ""))) + @"</td>
                                    <td>" + (set.UpdatedDate == null ? set.CreatedDate.ToString("dd/MM/yyyy HH:mm:ss") : set.UpdatedDate.Value.ToString("dd/MM/yyyy HH:mm:ss")) + @"</td>
                                </tr>");
                    }
                    index++;
                }
                setsTbody.InnerHtml = asb.ToString();
            }
        }
Exemplo n.º 24
0
        internal static void InsertSCHARPdataUsingArrayBinding(List <EAE> Summaries, OracleConnection connection, string batchId)
        {
            using (OracleTransaction transaction = connection.BeginTransaction())
            {
                string[] _BatchID = new string[Summaries.Count];
                _BatchID = Populate(_BatchID, batchId);
                string[] _EAENumber             = Summaries.Select(s => s.EAENumber).ToArray();
                string[] _ProtocolNumber        = Summaries.Select(s => s.ProtocolNumber).ToArray();
                string[] _ParticipantIdentifier = Summaries.Select(s => s.ParticipantIdentifier).ToArray();
                string[] _PrimaryAE             = Summaries.Select(s => s.PrimaryAE).ToArray();
                string[] _MEDDRACodePT          = Summaries.Select(s => s.MedDRACodePT).ToArray();
                string[] _OnsetDate             = Summaries.Select(s => s.OnsetDate).ToArray();
                string[] _RelationToPrimaryAE   = Summaries.Select(s => s.RelationshipToPrimaryAE).ToArray();
                string[] _SeverityGrade         = Summaries.Select(s => s.SeverityGrade).ToArray();
                string[] _DateOfDeath           = Summaries.Select(s => s.DateOfDeath).ToArray();

                try
                {
                    using (var command = connection.CreateCommand())
                    {
                        //string query = "INSERT INTO SCHARP_EAESUMMARY(BATCHID,CREATEDDATE,DOCUMENTID, EAENUMBER, PROTOCOLNUMBER, PARTICIPANTIDENTIFIER, PRIMARYAE, MEDDRACODEPT, ONSETDATE, RELATIONTOPRIMARYAE, SEVERITYGRADE, DATEOFDEATH)VALUES(:BatchID, sysdate,:DocumentID,:EAENumber,:ProtocolNumber,:ParticipantIdentifier,:PrimaryAE,:MEDDRAcodePT,:OnsetDate,:RelationToPrimaryAE,:SeverityGrade,:DateOfDeath)";
                        command.CommandText    = Constant.SP_InsertScharp_EAESummary;
                        command.CommandType    = CommandType.StoredProcedure;
                        command.BindByName     = true;
                        command.ArrayBindCount = Summaries.Count();

                        command.Parameters.Add("BatchID", OracleDbType.Varchar2, _BatchID, ParameterDirection.Input);
                        command.Parameters.Add("EAENumber", OracleDbType.Varchar2, _EAENumber, ParameterDirection.Input);
                        command.Parameters.Add("ProtocolNumber", OracleDbType.Varchar2, _ProtocolNumber, ParameterDirection.Input);
                        command.Parameters.Add("ParticipantIdentifier", OracleDbType.Varchar2, _ParticipantIdentifier, ParameterDirection.Input);
                        command.Parameters.Add("PrimaryAE", OracleDbType.Varchar2, _PrimaryAE, ParameterDirection.Input);
                        command.Parameters.Add("MEDDRACodePT", OracleDbType.Varchar2, _MEDDRACodePT, ParameterDirection.Input);
                        command.Parameters.Add("OnsetDate", OracleDbType.Varchar2, _OnsetDate, ParameterDirection.Input);
                        command.Parameters.Add("RelationToPrimaryAE", OracleDbType.Varchar2, _RelationToPrimaryAE, ParameterDirection.Input);
                        command.Parameters.Add("SeverityGrade", OracleDbType.Varchar2, _SeverityGrade, ParameterDirection.Input);
                        command.Parameters.Add("DateOfDeath", OracleDbType.Varchar2, _DateOfDeath, ParameterDirection.Input);

                        command.ExecuteNonQuery();
                    }

                    //Insert ICHSeriousnessCriteria
                    var seriousnessCriteria = Summaries.SelectMany(i => i.SeriousnessCriteria);
                    if (seriousnessCriteria.Count() != 0)
                    {
                        string[] _sBatchID = new string[seriousnessCriteria.Count()];
                        _sBatchID = Populate(_sBatchID, batchId);
                        string[] _sParticipantIdentifier  = seriousnessCriteria.Select(s => s.ParticipantIdentifier).ToArray();
                        string[] _sSeriousnessDescription = seriousnessCriteria.Select(s => s.ICHSeriousnessCriterionDescription).ToArray();

                        using (var command = connection.CreateCommand())
                        {
                            //string query = "INSERT INTO SCHARP_ICHSERIOUSNESSCRITERION (BATCHID,CREATEDDATE,PARTICIPANTIDENTIFIER,SERIOUSNESSDESCRIPTION)VALUES(:sBatchID, sysdate,:sParticipantIdentifier,:sSeriousnessDescription)";
                            command.CommandText    = Constant.SP_InsertScharp_IchCriterion;
                            command.CommandType    = CommandType.StoredProcedure;
                            command.BindByName     = true;
                            command.ArrayBindCount = seriousnessCriteria.Count();

                            command.Parameters.Add("sBatchID", OracleDbType.Varchar2, _sBatchID, ParameterDirection.Input);
                            command.Parameters.Add("sParticipantIdentifier", OracleDbType.Varchar2, _sParticipantIdentifier, ParameterDirection.Input);
                            command.Parameters.Add("sSeriousnessDescription", OracleDbType.Varchar2, _sSeriousnessDescription, ParameterDirection.Input);

                            command.ExecuteNonQuery();
                        }
                    }

                    BatchLog log = new BatchLog
                    {
                        BatchID = batchId,
                        BatchTransactionStatus = "Success",
                        BatchException         = ""
                    };
                    Utilities.UpdateScharpBatchLog(connection, log);
                    transaction.Commit();
                }
                catch (Exception e)
                {
                    transaction.Rollback();
                    connection.Close();
                    connection.Dispose();

                    BatchLog log = new BatchLog
                    {
                        BatchID = batchId,
                        BatchTransactionStatus = "Failure",
                        BatchException         = e.Message
                    };
                    Utilities.UpdateScharpBatchLog(log);
                    throw;
                }
            }
        }