コード例 #1
0
        public HttpResponseMessage Delete()
        {
            bal = new T_Planing_Action_AfterRemovalBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_AfterRemovalDTO dto = null;

            try
            {
                var context = HttpContext.Current;
                context.Response.ContentType = "multipart/form-data";

                dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterRemovalDTO>();

                logger.debug("Delete dto:" + dto.ToString());
                bal.Delete(dto);

                response.statusCode = true;
                response.data       = "Delete success";
            }
            catch (Exception ex)
            {
                logger.error("Delete error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #2
0
        public HttpResponseMessage SearchAllWallThickness()
        {
            bal = new T_Planing_Action_AfterRemovalBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_AfterRemovalDTO dto = null;
            List <T_Planing_Action_AfterRemoval_WallThicknessDTO> objList = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterRemovalDTO>();

                logger.debug("PlanActionAfterRemovalController SearchAllWallThickness dto:" + dto.ToString());
                objList = bal.FindAllWallThickness(dto);

                response.statusCode = true;
                response.data       = objList;
            }
            catch (Exception ex)
            {
                logger.error("PlanActionAfterRemovalController SearchAllWallThickness error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #3
0
        public HttpResponseMessage Search()
        {
            bal = new T_Planing_Action_AfterRemovalBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_AfterRemovalDTO        dto     = null;
            List <T_Planing_Action_AfterRemovalDTO> objList = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterRemovalDTO>();

                objList = bal.FindByObjList(dto);

                foreach (T_Planing_Action_AfterRemovalDTO mainDTO in objList)
                {
                    //Find detail and push to main object in list
                    T_Planing_Action_AfterRemovalDTO detailDTO = new T_Planing_Action_AfterRemovalDTO();
                    detailDTO.PID = mainDTO.PID;
                    detailDTO     = bal.FindByPK(detailDTO);

                    mainDTO.RepairLength        = detailDTO.RepairLength;
                    mainDTO.WallThicknessNumber = detailDTO.WallThicknessNumber;
                    mainDTO.RepairLength        = detailDTO.RepairLength;
                    mainDTO.DefectList          = detailDTO.DefectList;
                    mainDTO.WallThicknessList   = detailDTO.WallThicknessList;

                    if (!ObjUtil.isEmpty(mainDTO.UploadFileList))
                    {
                        foreach (T_Planing_File file in mainDTO.UploadFileList)
                        {
                            file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName);
                            string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName;
                            file.Base64File = Utility.convertFileToBase64(fullPath);
                        }
                    }
                }

                response.statusCode = true;
                response.data       = objList;
            }
            catch (Exception ex)
            {
                logger.error("Search error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #4
0
        public HttpResponseMessage SearchAllFiles()
        {
            bal = new T_Planing_Action_AfterRemovalBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_AfterRemovalDTO dto     = null;
            List <T_Planing_File>            objList = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterRemovalDTO>();

                logger.debug("PlanActionAfterRemovalController SearchAllFiles dto:" + dto.ToString());
                objList = bal.FindAllFiles(dto);

                if (!ObjUtil.isEmpty(objList))
                {
                    foreach (T_Planing_File file in objList)
                    {
                        file.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + file.PID + "/" + file.UploadType + "/" + file.FileName);
                        string fullPath = context.Server.MapPath(planPath) + @"\" + file.PID + @"\" + file.UploadType + @"\" + file.FileName;
                        logger.debug("fullPath:" + fullPath);
                        file.Base64File = Utility.convertFileToBase64(fullPath);
                    }
                }

                response.statusCode = true;
                response.data       = objList;
            }
            catch (Exception ex)
            {
                logger.error("PlanActionAfterRemovalController SearchAllFiles error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #5
0
        public HttpResponseMessage View()
        {
            bal = new T_Planing_Action_AfterRemovalBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            T_Planing_Action_AfterRemovalDTO dto = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_Planing_Action_AfterRemovalDTO>();

                logger.debug("View dto:" + dto.ToString());
                dto = bal.FindByPK(dto);

                if (dto != null && dto.UploadFileList != null)
                {
                    foreach (var uploadFile in dto.UploadFileList)
                    {
                        uploadFile.HtmlFile = System.Web.VirtualPathUtility.ToAbsolute(planPath + "/" + dto.PID + "/" + uploadFile.UploadType + "/" + uploadFile.FileName);
                        string fullPath = context.Server.MapPath(planPath) + @"\" + uploadFile.PID + @"\" + uploadFile.UploadType + @"\" + uploadFile.FileName;
                        uploadFile.Base64File = Utility.convertFileToBase64(fullPath);
                    }
                }

                response.statusCode = true;
                response.data       = dto;
            }
            catch (Exception ex)
            {
                logger.error("View error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #6
0
        public T_Planing_Action_AfterRemovalDTO FindByPK(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();
            var obj = new T_Planing_Action_AfterRemovalDTO();


            dataTable = null;

            string procName = "sp_T_Planing_Action_AfterRemoval_FindByPK";

            try
            {
                dataTable = new DataTable();
                adapter   = new SqlDataAdapter();
                SqlConnection conn = OpenConnection();
                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, data).ToArray());
                }
                command             = new SqlCommand(procName, conn);
                command.CommandType = CommandType.StoredProcedure;
                if (data != null)
                {
                    command.Parameters.AddRange(parameterList.ToArray());
                }



                using (SqlDataReader reader = command.ExecuteReader())
                {
                    objList = ConvertX.GetListFromDataReader <T_Planing_Action_AfterRemovalDTO>(reader).ToList();

                    if (objList.Count == 0)
                    {
                        obj = new T_Planing_Action_AfterRemovalDTO();
                        obj.RepairLength = command.Parameters["@repairLength2"].SqlValue.ToString();
                    }
                    else
                    {
                        obj = objList.FirstOrDefault();
                    }

                    reader.NextResult();

                    if (reader.Read())
                    {
                        obj.WallThicknessNumber = reader[0].ToString();
                    }


                    reader.NextResult();

                    if (reader.Read())
                    {
                        obj.RepairLength = reader[0].ToString();
                    }
                    reader.NextResult();

                    obj.DefectList = ConvertX.GetListFromDataReader <T_Planing_Action_AfterRemoval_DefectDTO>(reader).ToList();



                    reader.NextResult();
                    obj.WallThicknessList = ConvertX.GetListFromDataReader <T_Planing_Action_AfterRemoval_WallThicknessDTO>(reader).ToList();
                }
            }
            catch (Exception ex) { }
            finally
            {
                CloseConnection();
            }
            return(obj);
        }
コード例 #7
0
        public override bool Add(object data)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

            string         procName    = "sp_T_Planing_Action_AfterRemoval_Insert";
            string         PID         = "";
            SqlConnection  conn        = OpenConnection();
            SqlTransaction transaction = conn.BeginTransaction();

            isCan = true;
            try
            {
                obj     = (T_Planing_Action_AfterRemovalDTO)data;
                command = new SqlCommand(procName, conn, transaction);

                command.CommandType = CommandType.StoredProcedure;



                if (data != null)
                {
                    parameterList.AddRange(GetParameters(procName, obj, transaction).ToArray());
                    command.Parameters.AddRange(parameterList.ToArray());
                }

                command.ExecuteNonQuery();

                PID = obj.PID;



                if (obj.DeleteDefectFiles != null && obj.DeleteDefectFiles.Length > 0)
                {
                    procName = "[sp_T_Planing_Action_AfterRemoval_Defect_Delete]";
                    foreach (var fileNo in obj.DeleteDefectFiles.Split(','))
                    {
                        if (fileNo != "")
                        {
                            command = new SqlCommand(procName, conn, transaction);

                            command.CommandType = CommandType.StoredProcedure;
                            if (fileNo != null)
                            {
                                T_Planing_File file = new T_Planing_File();
                                file.PID        = PID;
                                file.No         = fileNo;
                                file.UploadType = "1";
                                parameterList   = new List <SqlParameter>();
                                parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                                command.Parameters.AddRange(parameterList.ToArray());
                                //  command.Parameters[0].Value = "";
                            }

                            command.ExecuteNonQuery();
                        }
                    }
                }



                procName = "sp_T_Planing_Action_AfterRemoval_Files_Insert";
                if (obj.UploadFileList != null && obj.UploadFileList.Count > 0)
                {
                    foreach (T_Planing_File file in obj.UploadFileList)
                    {
                        file.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (file != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }


                procName = "[sp_T_Planing_Action_AfterRemoval_Defect_Insert]";
                if (obj.DefectList != null && obj.DefectList.Count > 0)
                {
                    foreach (T_Planing_Action_AfterRemoval_DefectDTO dto in obj.DefectList)
                    {
                        dto.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (dto != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, dto, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }


                procName = "[sp_T_Planing_Action_AfterRemoval_WallThickness_Insert]";
                if (obj.WallThicknessList != null && obj.WallThicknessList.Count > 0)
                {
                    foreach (T_Planing_Action_AfterRemoval_WallThicknessDTO dto in obj.WallThicknessList)
                    {
                        dto.PID = PID;

                        command = new SqlCommand(procName, conn, transaction);

                        command.CommandType = CommandType.StoredProcedure;
                        if (dto != null)
                        {
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, dto, transaction).ToArray());

                            command.Parameters.AddRange(parameterList.ToArray());
                            //  command.Parameters[0].Value = "";
                        }

                        command.ExecuteNonQuery();
                    }
                }



                transaction.Commit();
            }
            catch (Exception ex)
            {
                isCan = false;
                transaction.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            return(isCan);
        }