public List <DashboardInspection> getInspection(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " EXEC [SP_AUDITCUTDATE] "; sql += " @COMPANY = " + QuoteStr(d.Company) + ",@YR = " + QuoteStr(d.year) + ",@MN = " + QuoteStr(d.mn) + ",@YRMN = " + QuoteStr(d.yrmn); sql += ",@DEPMST = " + QuoteStr(d.depmst) + ",@SQNO = " + QuoteStr(d.sqno) + ","; if ((!d.Menu3 && !d.Menu4)) { sql += "@DEPCODEOL = " + QuoteStr(d.DEPCODEOL); } else { sql += "@DEPCODEOL = " + QuoteStr(""); } sql += ",@TYPECODE = " + QuoteStr(d.TYPECODE) + ",@GASTCODE = " + QuoteStr(d.GASTCODE) + ",@OFFICECODE = " + QuoteStr(d.OFFICECODE); var lst = Query <DashboardInspection>(sql, param, conStr).ToList(); return(lst); }
public List <Quantity> getQuantityByDep(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " select max (QTY_ASSET) QTY_ASSET, max (QTY_AUDIT) QTY_AUDIT from ("; sql += " SELECT SUM(SASSET1) AS QTY_ASSET , null AS QTY_AUDIT "; sql += " FROM ( SELECT COUNT(ASSETNO) AS SASSET1"; sql += " FROM FT_ASAUDITPOSTMSTTODEP_COMPANY(" + QuoteStr(d.Company) + ") B "; sql += " WHERE DEPMST = " + QuoteStr(d.depmst); sql += " and YR = " + QuoteStr(d.year); sql += " and MN = case when ISNULL(" + QuoteStr(d.mn) + ",'') <> '' THEN ISNULL(" + QuoteStr(d.mn) + ",'') else MN end "; sql += " and YRMN = case when ISNULL(" + QuoteStr(d.yrmn) + ",'') <> '' THEN ISNULL(" + QuoteStr(d.yrmn) + ",'') else YRMN end "; sql += " ) AS X"; sql += " union "; sql += " SELECT null AS QTY_ASSET, SUM(SAUDIT1) AS QTY_AUDIT"; sql += " FROM ( SELECT SUM(CASE WHEN isnull(PCODE,'') = '' THEN 0 ELSE 1 END) AS SAUDIT1"; sql += " FROM FT_ASAUDITPOSTMSTTODEP_COMPANY(" + QuoteStr(d.Company) + ") B "; sql += " WHERE DEPMST = " + QuoteStr(d.depmst); sql += " and YR = " + QuoteStr(d.year); sql += " and MN = case when ISNULL(" + QuoteStr(d.mn) + ",'') <> '' THEN ISNULL(" + QuoteStr(d.mn) + ",'') else MN end "; sql += " and YRMN = case when ISNULL(" + QuoteStr(d.yrmn) + ",'') <> '' THEN ISNULL(" + QuoteStr(d.yrmn) + ",'') else YRMN end "; sql += " ) AS Y"; sql += " ) as Z"; var res = Query <Quantity>(sql, param, conStr).ToList(); return(res); }
public DataTable getProblemByDepcodeol(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { string mn = ""; string yrmn = ""; if (!String.IsNullOrEmpty(d.mn)) { mn = d.mn; } if (!String.IsNullOrEmpty(d.yrmn)) { yrmn = d.yrmn; } DynamicParameters param = new DynamicParameters(); param.Add("@COMPANY", d.Company); param.Add("@YEAR", d.year); param.Add("@DEPMST", d.depmst); param.Add("@MN", mn); param.Add("@YRMN", yrmn); var obs = QuerySP <dynamic>("SP_ProblemByDepcodeol", param, conStr); //IList<dynamic> data = obs.ToList(); var dt = ToDataTable(obs); return(dt); }
public List <SummaryMONTHOFFICECODE> getMONTHOFFICECODE(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [RP_AuditSummary_MONTHOFFICECODE] (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.depmst) + "," + QuoteStr(d.DEPCODEOL) + ") as P"; var res = Query <SummaryMONTHOFFICECODE>(sql, param, conStr).ToList(); return(res); }
public List <SummaryRANKDEPMSTTOP3> getRANKDEPMSTTOP3(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [RP_AuditSummary_RANKDEPMSTTOP3] (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + ") as P"; var res = Query <SummaryRANKDEPMSTTOP3>(sql, param, conStr).ToList(); return(res); }
public List <SummaryASSETOWNER> getASSETOWNER(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [RP_AuditSummary_ASSETOWNER] (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.depmst) + ") as P"; var res = Query <SummaryASSETOWNER>(sql, param, conStr).ToList(); return(res); }
public SummaryFIXEDASSET getFIXEDASSET(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [RP_AuditSummary_FIXEDASSET] (" + QuoteStr(d.Company) + "," + QuoteStr(d.depmst) + ") as P"; var res = Query <SummaryFIXEDASSET>(sql, param, conStr).FirstOrDefault(); return(res); }
public List <SummaryDEPMSTDataDepcodeol> getDEPMSTDataDepcodeol(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [FT_SummaryAudit_DEPMSTDataDepcodeol] (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.depmst) + ") as P"; var res = Query <SummaryDEPMSTDataDepcodeol>(sql, param, conStr).ToList(); return(res); }
public List <SummaryYearOfficecode> getYearOfficecode(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [FT_SummaryAudit_YearOfficecode] (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + ") as P"; var res = Query <SummaryYearOfficecode>(sql, param, conStr).ToList(); return(res); }
public SummaryDEPMSTTotal getDEPMSTTotal(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " Select * from [FT_SummaryAudit_DEPMSTTotal] (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.depmst) + ") as P"; var res = Query <SummaryDEPMSTTotal>(sql, param, conStr).FirstOrDefault(); return(res); }
public List <AsFixedAsset> getFixedAsset(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = "SELECT * FROM [FT_ASFIXEDASSET] (" + QuoteStr("") + ") where 1 = 1"; if (!String.IsNullOrEmpty(d.Company)) { sql += " and company = " + QuoteStr(d.Company); } if (!String.IsNullOrEmpty(d.depmst)) { sql += " and stcode = " + QuoteStr(d.depmst); } var res = Query <AsFixedAsset>(sql, param, conStr).ToList(); return(res); }
public List <DashboardInspection> getInspectionByASSETNO(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = "select * from FT_AUDITASSETNOBYOFFICECODE(" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.mn) + "," + QuoteStr(d.OFFICECODE) + "," + QuoteStr(d.yrmn) + ") "; sql += " where 1 =1"; if (d.isdept) { sql += " and isnull(Audit_NO,'') like 'DU%' "; } else { sql += " and isnull(Audit_NO,'') like 'AU%' "; } var res = Query <DashboardInspection>(sql, param, conStr).ToList(); return(res); }
protected override void ExecuteChild(AUDITPOSTMSTReq dataReq, ResponseAPI dataRes) { var res = new AuditPostRes(); try { DBMode = dataReq.DBMode; res._result.ServerAddr = ConnectionString(); res._result.DBMode = DBMode; var req = new ASSETKKF_MODEL.Request.Asset.AUDITPOSTMSTReq() { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, LEADERNAME = dataReq.LEADERNAME, AREACODE = dataReq.AREACODE, AREANAME = dataReq.AREANAME, UCODE = dataReq.UCODE, ASSETNO = dataReq.ASSETNO, FINDY = dataReq.FINDY, PCODE = dataReq.PCODE, PNAME = dataReq.PNAME, MEMO1 = dataReq.MEMO1, IMGPATH = dataReq.IMGPATH, FileToUpload = dataReq.FileToUpload, PFLAG = dataReq.PFLAG, isdept = dataReq.isdept }; //var updateAuditPost = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(dataReq); var updateAuditPost = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(dataReq, null, conString)); updateAuditPost.Wait(); if (!String.IsNullOrEmpty(req.IMGPATH)) { res.IMGPATH = FilesUtilSvc.uploadCamera(req.IMGPATH); req.IMGPATH = res.IMGPATH; dataReq.IMGPATH = res.IMGPATH; } if (req.FileToUpload != null) { res.IMGPATH = FilesUtilSvc.uploadImgFile(req.FileToUpload); req.IMGPATH = res.IMGPATH; } if (!String.IsNullOrEmpty(res.IMGPATH)) { //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().UpdateAUDITPOSTMSTImage(dataReq); var task2 = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().UpdateAUDITPOSTMSTImage(dataReq, null, conString)); task2.Wait(); res.IMGSRC = FilesUtilSvc.getImageURL(res.IMGPATH); } res._result._code = "201"; res._result._message = ""; res._result._status = "Created"; } catch (SqlException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Execute exception Error"; } catch (InvalidOperationException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Connection Exception Error"; } catch (Exception ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Internal Server Error"; } finally { var req1 = new ASSETKKF_MODEL.Request.Asset.AuditPostReq() { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, AREACODE = dataReq.AREACODE, UCODE = dataReq.UCODE, isdept = dataReq.isdept }; res.AUDITPOSTTRNLST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTTRN(req1, null, conString); var lstAUDITPOSTMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req1, null, null, conString); //var lstWait = lstAUDITPOSTMST.Where(p => String.IsNullOrEmpty(p.PCODE)).ToList(); var lstChecked = lstAUDITPOSTMST.Where(p => !String.IsNullOrEmpty(p.PCODE)).ToList(); var lstWait = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST_WAIT(req1, null, null, conString); res.AUDITPOSTMSTWAITLST = lstWait; res.AUDITPOSTMSTCHECKEDLST = lstChecked; res.AUDITPOSTMSTNOPROBLEMLST = lstChecked.Where(x => x.PFLAG != "Y").ToList(); res.AUDITPOSTMSTPROBLEMLST = lstChecked.Where(x => x.PFLAG == "Y").ToList(); var lstAUDITCUTDATE = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITCUTDATE(req1, null, conString); res.AUDITCUTDATELST = lstAUDITCUTDATE; res.AUDITPOSTMST = lstAUDITPOSTMST.Where(x => x.INPID == dataReq.UCODE && x.ASSETNO == dataReq.ASSETNO && x.SQNO == dataReq.SQNO).FirstOrDefault(); AuditSummaryReq reqSum = new AuditSummaryReq() { Company = dataReq.COMPANY, year = res.AUDITPOSTMST.YR.ToString(), mn = res.AUDITPOSTMST.MN.ToString(), sqno = dataReq.SQNO, isdept = dataReq.isdept }; //var lstSum = ASSETKKF_ADO.Mssql.Asset.DashboardADO.GetInstant().getInspectionByDEPMST(reqSum, null, conString); //res.DashboardInspectionLST = lstSum; res.AREACODE = dataReq.AREACODE; res.COMPANY = dataReq.COMPANY; res.DEPCODEOL = dataReq.DEPCODEOL; res.LEADERCODE = dataReq.LEADERCODE; res.SQNO = dataReq.SQNO; } dataRes.data = res; }
public List <DashboardInspection> getAuditOFFICECODE(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); int isdep = d.isdept ? 1 : 0; sql = @"Select COMPANY,YR,MN,DEPMST,SQNO,Flag,DEPCODEOL,OFFICECODE,OFNAME,SUM(QTY_TOTAL) as QTY_TOTAL,SUM(QTY_CHECKED) as QTY_CHECKED ,SUM(QTY_PROBLEM) as QTY_PROBLEM,SUM(QTY_NOPROBLEM) as QTY_NOPROBLEM,SUM(QTY_TRN) as QTY_TRN,SUM(QTY_WAIT) as QTY_WAIT,MIN(MIN_INPDT) as StartDT ,MAX(MAX_INPDT) as LastDT ,case when SUM(QTY_Total) > 0 then CAST(((CAST(SUM(QTY_CHECKED) as DECIMAL(9,2))/CAST(SUM(QTY_Total) as DECIMAL(9,2)))*100)as DECIMAL(9,2)) else 0 end as PROGRESS "; sql += " from AuditSummary_company (" + QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.mn) + "," + QuoteStr(d.yrmn) + "," + isdep + ")"; sql += " where 1 =1"; if ((!d.Menu3 && !d.Menu4)) { sql += " and ("; if (!String.IsNullOrEmpty(d.DEPCODEOL)) { sql += " DEPCODEOL = '" + d.DEPCODEOL + "'"; } if (d.DEPTCODELST != null && d.DEPTCODELST.Length > 0) { var arrDept = d.DEPTCODELST.Split(","); foreach (string s in arrDept) { sql += " or DEPCODEOL like ' " + s + "%'"; } } sql += " )"; } if (!String.IsNullOrEmpty(d.yrmn)) { sql += " and YRMN =" + QuoteStr(d.yrmn); } if (!String.IsNullOrEmpty(d.depmst)) { sql += " and DEPMST =" + QuoteStr(d.depmst); } if (!String.IsNullOrEmpty(d.sqno)) { sql += " AND SQNO =" + QuoteStr(d.sqno); } if (!String.IsNullOrEmpty(d.TYPECODE)) { sql += " AND TYPECODE =" + QuoteStr(d.TYPECODE); } if (!String.IsNullOrEmpty(d.GASTCODE)) { sql += " AND GASTCODE =" + QuoteStr(d.GASTCODE); } if (!String.IsNullOrEmpty(d.OFFICECODE)) { sql += " AND OFFICECODE =" + QuoteStr(d.OFFICECODE); } if (d.isdept) { sql += " and isnull(Audit_NO,'') like 'DU%' "; } else { sql += " and isnull(Audit_NO,'') like 'AU%' "; } sql += " Group BY COMPANY,YR,MN,DEPMST,SQNO,Flag,DEPCODEOL,OFFICECODE,OFNAME"; var res = Query <DashboardInspection>(sql, param, conStr).ToList(); return(res); }
public List <DashboardInspection> getInspectionByGASTCODE(AuditSummaryReq d, SqlTransaction transac = null, string conStr = null) { DynamicParameters param = new DynamicParameters(); sql = " select *, (QTY_Total - QTY_CHECKED) as QTY_WAIT , "; sql += " CAST(((CAST(QTY_CHECKED as DECIMAL(9,2))/CAST(QTY_Total as DECIMAL(9,2)))*100)as DECIMAL(9,2)) as PROGRESS from ("; sql += " SELECT COMPANY,YR,MN,GASTCODE,GASTNAME,TYPECODE,TYPENAME,max(C.flag) as flag,MIN(INPDT) as StartDT,SUM(QTY) as QTY_Total "; sql += " ,( select COUNT(ASSETNO) from ( select ASSETNO from [FT_ASAUDITPOSTMST_COMPANY] (" + QuoteStr(d.Company) + ") P"; sql += " where FLAG in ('P') and (PCODE is not null and PCODE <> '' ) and P.GASTCODE = C.GASTCODE and 'Y' <> ISNULL(SNDST,'')"; sql += " and P.COMPANY = " + QuoteStr(d.Company) + " and P.YR = " + QuoteStr(d.year) + " and MN = " + QuoteStr(d.mn); if ((!d.Menu3 && !d.Menu4)) { sql += " and ("; if (!String.IsNullOrEmpty(d.DEPCODEOL)) { sql += " DEPCODEOL = '" + d.DEPCODEOL + "'"; } if (d.DEPTCODELST != null && d.DEPTCODELST.Length > 0) { var arrDept = d.DEPTCODELST.Split(","); foreach (string s in arrDept) { sql += " or DEPCODEOL like ' " + s + "%'"; } } sql += " )"; } sql += " group by ASSETNO ) as P) as QTY_CHECKED "; sql += " ,( select COUNT(P.ASSETNO) from ( select P.ASSETNO from [FT_ASAUDITPOSTMST_COMPANY] (" + QuoteStr(d.Company) + ") P"; sql += " left outer join [dbo].[FT_ASAUDITPOSTMST_PHONE_COMPANY] (" + QuoteStr(d.Company) + ") AS PM "; sql += " on PM.SQNO = P.SQNO and PM.Company = P.Company and PM.ASSETNO = P.ASSETNO and PM.INPDT = P.INPDT"; sql += " where P.FLAG in ('P') and (PCODE is not null and PCODE <> '' ) and 'Y' = ISNULL(PFLAG,'') and P.GASTCODE = C.GASTCODE and 'Y' <> ISNULL(SNDST,'') "; sql += " and P.COMPANY = " + QuoteStr(d.Company) + " and P.YR = " + QuoteStr(d.year) + " and MN = " + QuoteStr(d.mn); if ((!d.Menu3 && !d.Menu4)) { sql += " and ("; if (!String.IsNullOrEmpty(d.DEPCODEOL)) { sql += " DEPCODEOL = '" + d.DEPCODEOL + "'"; } if (d.DEPTCODELST != null && d.DEPTCODELST.Length > 0) { var arrDept = d.DEPTCODELST.Split(","); foreach (string s in arrDept) { sql += " or DEPCODEOL like ' " + s + "%'"; } } sql += " )"; } sql += " group by P.ASSETNO ) as P) as QTY_PROBLEM "; sql += " ,( select COUNT(P.ASSETNO) from ( select P.ASSETNO from [FT_ASAUDITPOSTMST_COMPANY] (" + QuoteStr(d.Company) + ") P"; sql += " left outer join [dbo].[FT_ASAUDITPOSTMST_PHONE_COMPANY] (" + QuoteStr(d.Company) + ") AS PM "; sql += " on PM.SQNO = P.SQNO and PM.Company = P.Company and PM.ASSETNO = P.ASSETNO and PM.INPDT = P.INPDT"; sql += " where P.FLAG in ('P') and (PCODE is not null and PCODE <> '' ) and 'Y' <> ISNULL(PFLAG,'') and P.GASTCODE = C.GASTCODE and 'Y' <> ISNULL(SNDST,'') "; sql += " and P.COMPANY = " + QuoteStr(d.Company) + " and P.YR = " + QuoteStr(d.year) + " and MN = " + QuoteStr(d.mn); if ((!d.Menu3 && !d.Menu4)) { sql += " and ("; if (!String.IsNullOrEmpty(d.DEPCODEOL)) { sql += " DEPCODEOL = '" + d.DEPCODEOL + "'"; } if (d.DEPTCODELST != null && d.DEPTCODELST.Length > 0) { var arrDept = d.DEPTCODELST.Split(","); foreach (string s in arrDept) { sql += " or DEPCODEOL like ' " + s + "%'"; } } sql += " )"; } sql += " group by P.ASSETNO ) as P) as QTY_NOPROBLEM "; sql += " ,(select MAX(P.INPDT) from [FT_ASAUDITPOSTMST_COMPANY] (" + QuoteStr(d.Company) + ") P"; sql += " where FLAG in ('P') and (PCODE is not null and PCODE <> '' ) and P.GASTCODE = C.GASTCODE and 'Y' <> ISNULL(SNDST,'')"; sql += " and P.COMPANY = " + QuoteStr(d.Company) + " and P.YR = " + QuoteStr(d.year) + " and MN = " + QuoteStr(d.mn); if ((!d.Menu3 && !d.Menu4)) { sql += " and ("; if (!String.IsNullOrEmpty(d.DEPCODEOL)) { sql += " DEPCODEOL = '" + d.DEPCODEOL + "'"; } if (d.DEPTCODELST != null && d.DEPTCODELST.Length > 0) { var arrDept = d.DEPTCODELST.Split(","); foreach (string s in arrDept) { sql += " or DEPCODEOL like ' " + s + "%'"; } } sql += " )"; } sql += " ) as LastDT"; sql += " ,( select COUNT(ASSETNO) from [FT_ASAUDITPOSTTRN_COMPANY] (" + QuoteStr(d.Company) + ") as P where P.GASTCODE = C.GASTCODE and 'Y' <> ISNULL(SNDST,'')"; sql += " and P.COMPANY = " + QuoteStr(d.Company) + " and P.YR = " + QuoteStr(d.year) + " and MN = " + QuoteStr(d.mn); sql += " ) as QTY_TRN"; sql += " FROM [dbo].[FT_AUDITCUTDATE] ("; sql += QuoteStr(d.Company) + "," + QuoteStr(d.year) + "," + QuoteStr(d.mn); sql += " ) as C where 1 = 1"; if (String.IsNullOrEmpty(d.yrmn)) { //sql += " and YRMN = (select max(YRMN) from FT_ASAUDITCUTDATE() T where T.COMPANY = " + QuoteStr(d.Company) + " and T.YR = " + QuoteStr(d.year) + " and T.MN = " + QuoteStr(d.mn) + " and T.DEPMST = C.DEPMST and AUDIT_NO is not null)"; } else { sql += " and YRMN =" + QuoteStr(d.yrmn); } if (!String.IsNullOrEmpty(d.depmst)) { sql += " and DEPMST =" + QuoteStr(d.depmst); } if (!String.IsNullOrEmpty(d.sqno)) { sql += " AND SQNO =" + QuoteStr(d.sqno); } if ((!d.Menu3 && !d.Menu4)) { if (!String.IsNullOrEmpty(d.DEPCODEOL)) { sql += " AND DEPCODEOL =" + QuoteStr(d.DEPCODEOL); } } if (!String.IsNullOrEmpty(d.TYPECODE)) { sql += " AND TYPECODE =" + QuoteStr(d.TYPECODE); } if (!String.IsNullOrEmpty(d.GASTCODE)) { sql += " AND GASTCODE =" + QuoteStr(d.GASTCODE); } if (!String.IsNullOrEmpty(d.OFFICECODE)) { sql += " AND OFFICECODE =" + QuoteStr(d.OFFICECODE); } sql += " group by COMPANY,YR,MN,GASTCODE,GASTNAME,TYPECODE,TYPENAME ) as D"; var res = Query <DashboardInspection>(sql, param, conStr).ToList(); return(res); }
protected override void ExecuteChild(AuditPostReq dataReq, ResponseAPI dataRes) { var res = new AuditPostRes(); var req = new ASSETKKF_MODEL.Request.Asset.AuditPostReq() { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, AREACODE = dataReq.AREACODE, UCODE = dataReq.UCODE, LEADERNAME = dataReq.LEADERNAME, AREANAME = dataReq.AREANAME, IMGPATH = dataReq.IMGPATH, YEAR = dataReq.YEAR, MN = dataReq.MN, DEPMST = dataReq.DEPMST, cutdt = dataReq.cutdt, OFFICECODE = dataReq.OFFICECODE, TYPECODE = dataReq.TYPECODE, GASTCODE = dataReq.GASTCODE, AREA = dataReq.AREA, isdept = dataReq.isdept }; List <ASAUDITPOSTMST> lstAUDITPOSTMST = new List <ASAUDITPOSTMST>(); var stadd = 0; try { DBMode = dataReq.DBMode; res._result.ServerAddr = ConnectionString(); res._result.DBMode = DBMode; var reqASSETOFFICECODE = new ASSETOFFICECODEReq() { COMPANY = dataReq.COMPANY, DEPCODEOL = dataReq.DEPCODEOL, }; var reqASSETASSETNO = new ASSETASSETNOReq() { COMPANY = dataReq.COMPANY, }; //var objAUDITCUTDATEMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITCUTDATEMST(req); var lstAUDITCUTDATE = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITCUTDATE(req, null, conString); // var validAUDITCUTDATEMST = objAUDITCUTDATEMST != null; var validAUDITCUTDATE = lstAUDITCUTDATE != null && lstAUDITCUTDATE.Count > 0; res.AUDITCUTDATELST = lstAUDITCUTDATE; if (validAUDITCUTDATE) { lstAUDITPOSTMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req, null, null, conString); //var lstAUDITPOSTTRN = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTTRN(req); /*var lstASSETOFFICECODE = ASSETKKF_ADO.Mssql.Asset.AUDITPOSTTRNADO.GetInstant().getASSETOFFICECODELST(reqASSETOFFICECODE); * var lstASSETASSETNO = ASSETKKF_ADO.Mssql.Asset.AUDITPOSTTRNADO.GetInstant().getASSETASSETNOLST(reqASSETASSETNO); * * res.ASSETOFFICECODELST = lstASSETOFFICECODE; * res.ASSETASSETNOLST = lstASSETASSETNO;*/ //res.AUDITPOSTTRNLST = lstAUDITPOSTTRN; if (lstAUDITPOSTMST == null || ((lstAUDITPOSTMST != null) && (lstAUDITPOSTMST.Count == 0))) { //var addAuditPost = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().addAUDITPOSTMST(req); var addAuditPost = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().addAUDITPOSTMST(req, null, conString)); addAuditPost.Wait(); stadd = 1; //lstAUDITPOSTMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req); } if (lstAUDITPOSTMST == null || ((lstAUDITPOSTMST != null) && (lstAUDITPOSTMST.Count == 0))) { res._result._code = "204"; res._result._message = "ไม่พบข้อมูล"; res._result._status = "No Content"; } else { res._result._code = "200"; res._result._message = ""; res._result._status = "OK"; } res.AREACODE = dataReq.AREACODE; res.COMPANY = dataReq.COMPANY; res.DEPCODEOL = dataReq.DEPCODEOL; res.LEADERCODE = dataReq.LEADERCODE; res.SQNO = dataReq.SQNO; } else { res._result._code = "404"; res._result._message = "ไม่พบข้อมูล"; res._result._status = "Not Found"; } } catch (SqlException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Execute exception Error"; } catch (InvalidOperationException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Connection Exception Error"; } catch (Exception ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Internal Server Error"; } finally { if (stadd > 0) { lstAUDITPOSTMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req, null, null, conString); } var lstAUDITPOSTTRN = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTTRN(req, null, conString); res.AUDITPOSTTRNLST = lstAUDITPOSTTRN; //var lstWait = lstAUDITPOSTMST.Where(p => String.IsNullOrEmpty(p.PCODE)).ToList(); var lstChecked = lstAUDITPOSTMST.Where(p => !String.IsNullOrEmpty(p.PCODE)).ToList(); var lstWait = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST_WAIT(req, null, null, conString); res.AUDITPOSTMSTWAITLST = lstWait; res.AUDITPOSTMSTCHECKEDLST = lstChecked; res.AUDITPOSTMSTNOPROBLEMLST = lstChecked.Where(x => x.PFLAG != "Y").ToList(); res.AUDITPOSTMSTPROBLEMLST = lstChecked.Where(x => x.PFLAG == "Y").ToList(); AuditSummaryReq reqSum = new AuditSummaryReq() { Company = dataReq.COMPANY, year = dataReq.YEAR, mn = dataReq.MN, sqno = dataReq.SQNO, isdept = dataReq.isdept }; //var lstSum = ASSETKKF_ADO.Mssql.Asset.DashboardADO.GetInstant().getInspectionByDEPMST(reqSum, null, conString); //res.DashboardInspectionLST = lstSum; } dataRes.data = res; }
protected override void ExecuteChild(AuditPostCheckReq dataReq, ResponseAPI dataRes) { var res = new AuditPostRes(); DBMode = dataReq.DBMode; res._result.ServerAddr = ConnectionString(); res._result.DBMode = DBMode; var req1 = new ASSETKKF_MODEL.Request.Asset.AuditPostReq() { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, AREACODE = dataReq.AREACODE, UCODE = dataReq.UCODE, isdept = dataReq.isdept }; try { List <ASAUDITPOSTMST> lst = new List <ASAUDITPOSTMST>(); //var lst = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().checkAUDITAssetNo(dataReq); var t1 = System.Threading.Tasks.Task.Factory.StartNew(() => lst = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().checkAUDITAssetNo(dataReq, transac, conString)); t1.Wait(); if (lst == null || (lst != null && lst.Count == 0)) { res._result._code = "404"; res._result._message = "ไม่พบข้อมูล"; res._result._status = "Bad Request"; ASSETASSETNOReq req = new ASSETASSETNOReq() { ASSETNO = dataReq.ASSETNO }; ASSETASSETNO obj = ASSETKKF_ADO.Mssql.Asset.AUDITPOSTTRNADO.GetInstant().checkASSETASSETNO(req, transac, conString); res.ASSETASSETNO = obj; } else { if (dataReq.MODE != null && dataReq.MODE.ToLower() == "check") { var obj = lst.Where(x => x.INPID == dataReq.UCODE).FirstOrDefault(); res.AUDITPOSTMST = obj; res._result._code = "200"; res._result._message = "พบข้อมูล"; res._result._status = "OK"; } else if (dataReq.MODE != null && dataReq.MODE.ToLower() == "detail") { res.AUDITPOSTMST = lst.FirstOrDefault(); res._result._code = "200"; res._result._message = "พบข้อมูล"; res._result._status = "OK"; } else { var reqProblem = new STProblemReq { Company = dataReq.COMPANY }; var lstProblem = ASSETKKF_ADO.Mssql.Asset.STProblemADO.GetInstant().Search(reqProblem, transac, conString); var objProblem = lstProblem.FirstOrDefault(); var reqPostMst = new AUDITPOSTMSTReq { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, LEADERNAME = dataReq.LEADERNAME, AREACODE = dataReq.AREACODE, AREANAME = dataReq.AREANAME, ASSETNO = dataReq.ASSETNO, FINDY = objProblem != null? objProblem.FINDY:null, PCODE = objProblem != null ? objProblem.Pcode : null, PNAME = objProblem != null ? objProblem.Pname : null, UCODE = dataReq.UCODE, PFLAG = objProblem != null ? objProblem.PFLAG : null, isdept = dataReq.isdept }; var reqPostMstPhone = new AUDITPOSTMSTReq(); reqPostMstPhone = reqPostMst; //เคยบันทึกแล้ว มาบันทึกซ้ำ var objDuplicate = lst.Where(x => x.INPID == dataReq.UCODE && !String.IsNullOrEmpty(x.PCODE)).FirstOrDefault(); //บันทึกครั้งแรก เป็นคน Export var objFirstEx = lst.Where(x => x.INPID == dataReq.UCODE && String.IsNullOrEmpty(x.PCODE)).FirstOrDefault(); //บันทึกครั้งแรก ไม่ได้เป็นผู้ Export //var objFirst = lst.Where(x => x.INPID != dataReq.UCODE && String.IsNullOrEmpty(x.PCODE)).FirstOrDefault(); var objFirst = new ASAUDITPOSTMST(); //บันทึกครั้งแรก แต่มีคนมาบันทึกก่อนหน้าแล้ว var objSecound = lst.Where(x => x.INPID != dataReq.UCODE && !String.IsNullOrEmpty(x.PCODE)).FirstOrDefault(); if (objDuplicate != null) { res._result._code = "202"; res._result._message = objDuplicate.INPID + "เคยบันทึกผลการตรวจสอบทรัพย์สิน " + objDuplicate.ASSETNO + " เป็น " + objDuplicate.PCODE + " : " + objDuplicate.PNAME; res._result._message += " เมื่อ " + objDuplicate.INPDT; res._result._status = "Accepted "; res.AUDITPOSTMST = objDuplicate; } else if (objSecound != null) { if (!String.IsNullOrEmpty(dataReq.status)) { reqPostMst.MODE = ""; //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst); var task1 = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst, transac, conString)); task1.Wait(); reqPostMstPhone.MODE = "Edit"; //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMSTPHONE(reqPostMstPhone); var task2 = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMSTPHONE(reqPostMstPhone, transac, conString)); task2.Wait(); res.AUDITPOSTMST = objSecound; res._result._code = "201"; res._result._message = objSecound.INPID + "บันทึกผลการตรวจสอบทรัพย์สิน " + objSecound.ASSETNO + " เรียบร้อยแล้ว"; res._result._status = "Created"; } else { res._result._code = "208"; res._result._message = objSecound.INPID + "บันทึกผลการตรวจสอบทรัพย์สิน " + objSecound.ASSETNO + " เป็น " + objSecound.PCODE + " : " + objSecound.PNAME; res._result._message += " เมื่อ " + objSecound.INPDT; res._result._status = "Already Saved "; res.AUDITPOSTMST = objSecound; } } else if (objFirstEx != null) { reqPostMst.MODE = ""; //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst); var task1 = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst, transac, conString)); task1.Wait(); reqPostMstPhone.MODE = "Edit"; //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMSTPHONE(reqPostMstPhone); var task2 = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMSTPHONE(reqPostMstPhone, transac, conString)); task2.Wait(); res.AUDITPOSTMST = objFirstEx; res._result._code = "201"; res._result._message = objFirstEx.INPID + "บันทึกผลการตรวจสอบทรัพย์สิน " + objFirstEx.ASSETNO + " เรียบร้อยแล้ว"; res._result._status = "Created"; } else if (objFirst != null) { reqPostMst.MODE = "ADD"; //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst); var task1 = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst, transac, conString)); task1.Wait(); res.AUDITPOSTMST = objFirst; res._result._code = "201"; res._result._message = objFirst.INPNAME + "บันทึกผลการตรวจสอบทรัพย์สิน " + objFirst.ASSETNO + " เรียบร้อยแล้ว"; res._result._status = "Created"; } else { var obj = lst.FirstOrDefault(); res._result._code = "404"; res._result._message = "ไม่พบข้อมูลตามเงื่อนไข :: ผู้ตรวจสอบ " + obj.INPID + " ,ทรัพย์สิน " + obj.ASSETNO + " : " + obj.ASSETNAME + " " + obj.PCODE; res._result._status = "Bad Request"; } } } } catch (SqlException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Execute exception Error"; } catch (InvalidOperationException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Connection Exception Error"; } catch (Exception ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Internal Server Error"; } finally { var lstAUDITCUTDATE = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITCUTDATE(req1, transac, conString); res.AUDITCUTDATELST = lstAUDITCUTDATE; var req = new ASSETKKF_MODEL.Request.Asset.AuditPostReq() { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, AREACODE = dataReq.AREACODE, UCODE = dataReq.UCODE, LEADERNAME = dataReq.LEADERNAME, AREANAME = dataReq.AREANAME, IMGPATH = dataReq.IMGPATH, YEAR = dataReq.YEAR, MN = dataReq.MN, DEPMST = dataReq.DEPMST, cutdt = dataReq.cutdt, OFFICECODE = dataReq.OFFICECODE, TYPECODE = dataReq.TYPECODE, GASTCODE = dataReq.GASTCODE, isdept = dataReq.isdept }; var lstAUDITPOSTMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req, null, null, conString); var lstAUDITPOSTTRN = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTTRN(req, null, conString); res.AUDITPOSTTRNLST = lstAUDITPOSTTRN; //var lstWait = lstAUDITPOSTMST.Where(p => String.IsNullOrEmpty(p.PCODE)).ToList(); var lstChecked = lstAUDITPOSTMST.Where(p => !String.IsNullOrEmpty(p.PCODE)).ToList(); var lstWait = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST_WAIT(req, null, null, conString); res.AUDITPOSTMSTWAITLST = lstWait; res.AUDITPOSTMSTCHECKEDLST = lstChecked; res.AUDITPOSTMSTNOPROBLEMLST = lstChecked.Where(x => x.PFLAG != "Y").ToList(); res.AUDITPOSTMSTPROBLEMLST = lstChecked.Where(x => x.PFLAG == "Y").ToList(); //res.AUDITPOSTMST = lstAUDITPOSTMST.Where(x => x.INPID == dataReq.UCODE && x.ASSETNO == dataReq.ASSETNO && x.SQNO == dataReq.SQNO).FirstOrDefault(); AuditSummaryReq reqSum = new AuditSummaryReq() { Company = dataReq.COMPANY, year = dataReq.YEAR, mn = dataReq.MN, sqno = dataReq.SQNO, isdept = dataReq.isdept }; //var lstSum = ASSETKKF_ADO.Mssql.Asset.DashboardADO.GetInstant().getInspectionByDEPMST(reqSum,transac,conString); //res.DashboardInspectionLST = lstSum; } dataRes.data = res; }
protected override void ExecuteChild(ASSETASSETNOReq dataReq, ResponseAPI dataRes) { var res = new ASSETKKF_MODEL.Response.Asset.ASSETASSETNORes(); try { DBMode = dataReq.DBMode; res._result.ServerAddr = ConnectionString(); res._result.DBMode = DBMode; var reqProblem = new STProblemReq { Company = dataReq.COMPANY }; var lstProblem = ASSETKKF_ADO.Mssql.Asset.STProblemADO.GetInstant().Search(reqProblem, null, conString); var objProblem = lstProblem.FirstOrDefault(); var reqPostMst = new AUDITPOSTMSTReq { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, LEADERNAME = dataReq.LEADERNAME, AREACODE = dataReq.AREACODE, AREANAME = dataReq.AREANAME, ASSETNO = dataReq.ASSETNO, FINDY = objProblem.FINDY, PCODE = objProblem.Pcode, PNAME = objProblem.Pname, UCODE = dataReq.UCODE, isdept = dataReq.isdept }; var reqPostChk = new AuditPostCheckReq { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, LEADERNAME = dataReq.LEADERNAME, AREACODE = dataReq.AREACODE, AREANAME = dataReq.AREANAME, ASSETNO = dataReq.ASSETNO, UCODE = dataReq.UCODE, isdept = dataReq.isdept }; var req1 = new ASSETKKF_MODEL.Request.Asset.AuditPostReq() { SQNO = dataReq.SQNO, DEPCODEOL = dataReq.DEPCODEOL, COMPANY = dataReq.COMPANY, LEADERCODE = dataReq.LEADERCODE, AREACODE = dataReq.AREACODE, UCODE = dataReq.UCODE, isdept = dataReq.isdept }; reqPostMst.MODE = "EDIT"; //ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst); var editAuditPost = System.Threading.Tasks.Task.Factory.StartNew(() => ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().updateAUDITPOSTMST(reqPostMst, null, conString)); editAuditPost.Wait(); //res.AUDITPOSTMSTWAITLST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req1, ""); //res.AUDITPOSTMSTCHECKEDLST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req1, "Y"); //res.AUDITPOSTTRNLST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTTRN(req1); //var lstAUDITAssetNo = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().checkAUDITAssetNo(reqPostChk); //res.AUDITPOSTMST = lstAUDITAssetNo.FirstOrDefault(); var lstAUDITPOSTMST = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST(req1,null, null, conString); var lstAUDITPOSTTRN = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTTRN(req1, null, conString); res.AUDITPOSTTRNLST = lstAUDITPOSTTRN; // var lstWait = lstAUDITPOSTMST.Where(p => String.IsNullOrEmpty(p.PCODE)).ToList(); var lstChecked = lstAUDITPOSTMST.Where(p => !String.IsNullOrEmpty(p.PCODE)).ToList(); var lstWait = ASSETKKF_ADO.Mssql.Asset.AuditCutADO.GetInstant().getAUDITPOSTMST_WAIT(req1, null, null, conString); res.AUDITPOSTMSTWAITLST = lstWait; res.AUDITPOSTMSTCHECKEDLST = lstChecked; res.AUDITPOSTMSTNOPROBLEMLST = lstChecked.Where(x => x.PFLAG != "Y").ToList(); res.AUDITPOSTMSTPROBLEMLST = lstChecked.Where(x => x.PFLAG == "Y").ToList(); res.AUDITPOSTMST = lstAUDITPOSTMST.Where(x => x.INPID == dataReq.UCODE).FirstOrDefault(); AuditSummaryReq reqSum = new AuditSummaryReq() { Company = dataReq.COMPANY, year = res.AUDITPOSTMST.YR.ToString(), mn = res.AUDITPOSTMST.MN.ToString(), sqno = dataReq.SQNO, isdept = dataReq.isdept }; //var lstSum = ASSETKKF_ADO.Mssql.Asset.DashboardADO.GetInstant().getInspectionByDEPMST(reqSum, null, conString); //res.DashboardInspectionLST = lstSum; res._result._code = "200"; res._result._message = ""; res._result._status = "OK"; } catch (SqlException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Execute exception Error"; } catch (InvalidOperationException ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Connection Exception Error"; } catch (Exception ex) { res._result._code = "500 "; res._result._message = ex.Message; res._result._status = "Internal Server Error"; } dataRes.data = res; }