コード例 #1
0
 public BatchProcess(IPeriodService service,
                     IIdentityService identityService,
                     ITrackService trackService,
                     IWasteStatisticService wasteStatisticService,
                     IBatchLogService batchLogService)
 {
     if (service == null)
     {
         throw new ArgumentNullException("service");
     }
     if (identityService == null)
     {
         throw new ArgumentNullException("identityService");
     }
     if (trackService == null)
     {
         throw new ArgumentNullException("trackService");
     }
     if (wasteStatisticService == null)
     {
         throw new ArgumentNullException("wasteStatisticService");
     }
     if (batchLogService == null)
     {
         throw new ArgumentNullException("batchLogService");
     }
     _service               = service;
     _identityService       = identityService;
     _trackService          = trackService;
     _wasteStatisticService = wasteStatisticService;
     _batchLogService       = batchLogService;
 }
コード例 #2
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();
        }
コード例 #3
0
ファイル: Sets.aspx.cs プロジェクト: PetrawareNagul/GHB
        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();
            }
        }
コード例 #4
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();
            }
        }
コード例 #5
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();
            }
        }