コード例 #1
0
ファイル: Default.aspx.cs プロジェクト: tonchilling/PTTDA
        protected void Button1_Click(object sender, EventArgs e)
        {
            string path    = "";
            string desPath = System.Configuration.ConfigurationManager.AppSettings["UploadPlan"];

            T_PlaningDTO requestObj = new T_PlaningDTO();
            T_PlaningBAL planBAL    = null;

            planBAL             = new T_PlaningBAL();
            requestObj.PID      = "194,198";
            requestObj.Year     = "2018";
            requestObj.CreateBy = "4F12E624-F166-4046-839E-EF24F2E12E43";
            requestObj.UpdateBy = "4F12E624-F166-4046-839E-EF24F2E12E43";
            Byte[] b = planBAL.ExportPlanForExcel(requestObj, desPath, "test.xlsx");



            //Send output stream to client window
            Response.AddHeader("Content-Type", "application/vnd.ms-excel");
            Response.AddHeader("Content-Disposition", "attachment; filename=test.xlsx");
            Response.BinaryWrite(b);
            Response.Flush();
            Response.End();



            // ExportToPDF();
        }
コード例 #2
0
ファイル: PlanController.cs プロジェクト: tonchilling/PTTDA
        public HttpResponseMessage ClearPlan()
        {
            bal = new T_PlaningBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            try
            {
                var context = HttpContext.Current;

                T_PlaningDTO planingDTO = GetRequestToObject(context);
                string       UserID     = context.Request.Form["UserID"];
                if (ObjUtil.isEmpty(UserID))
                {
                    throw new Exception("UserID is require");
                }
                planingDTO.CreateBy = UserID;
                planingDTO.UpdateBy = UserID;

                response.statusCode = bal.ClearAlll(planingDTO);
            }
            catch (Exception ex)
            {
                logger.error("ClearPlan error:" + ex.ToString());
                response.statusText = ex.ToString();
            }

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


            dataTable = null;

            string procName = "sp_T_Planing_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())
                {
                    obj = ConvertX.GetListFromDataReader <T_PlaningDTO>(reader).ToList()[0];

                    obj.SpecSDate = ConvertX.DDMMYY(obj.SpecSDate);
                    obj.SpecEDate = ConvertX.DDMMYY(obj.SpecEDate);

                    obj.POSDate = ConvertX.DDMMYY(obj.POSDate);
                    obj.POEDate = ConvertX.DDMMYY(obj.POEDate);


                    obj.ActionSDate = ConvertX.DDMMYY(obj.ActionSDate);
                    obj.ActionEDate = ConvertX.DDMMYY(obj.ActionEDate);

                    reader.NextResult();

                    obj.UploadFileList = ConvertX.GetListFromDataReader <T_Planing_File>(reader).ToList();
                }
            }
            catch (Exception ex) { }
            finally
            {
                CloseConnection();
            }
            return(obj);
        }
コード例 #4
0
ファイル: PlanController.cs プロジェクト: tonchilling/PTTDA
        public HttpResponseMessage Search()
        {
            var deserializer = new JavaScriptSerializer();

            bal = new T_PlaningBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

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

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_PlaningDTO>();
                logger.debug("Search dto :" + dto.ToString());

                objList = bal.FindByObjList(dto);


                if (!ObjUtil.isEmpty(objList))
                {
                    foreach (T_PlaningDTO obj in objList)
                    {
                        obj.SpecSDate = ConvertX.DDMMYY(obj.SpecSDate);
                        obj.SpecEDate = ConvertX.DDMMYY(obj.SpecEDate);

                        obj.POSDate = ConvertX.DDMMYY(obj.POSDate);
                        obj.POEDate = ConvertX.DDMMYY(obj.POEDate);

                        obj.ActionSDate = ConvertX.DDMMYY(obj.ActionSDate);
                        obj.ActionEDate = ConvertX.DDMMYY(obj.ActionEDate);
                    }
                }

                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);
        }
コード例 #5
0
ファイル: PlanController.cs プロジェクト: tonchilling/PTTDA
        public HttpResponseMessage GetProgressPlan()
        {
            bal = new T_PlaningBAL();

            T_PlaningDTO           dto     = null;
            List <ColumnReportDTO> objList = null;

            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_PlaningDTO>();
                string RoleLevel = context.Request.Form["RoleLevel"];
                if (ObjUtil.isEmpty(RoleLevel))
                {
                    throw new Exception("RoleLevel is require");
                }
                if (RoleLevel == "1")
                {
                    string UserID = context.Request.Form["UserID"];
                    if (ObjUtil.isEmpty(UserID))
                    {
                        throw new Exception("UserID is require");
                    }
                    dto.CreateBy = UserID;
                    dto.UpdateBy = UserID;
                }
                T_PlaningBAL bal = new T_PlaningBAL();
                objList = bal.GetGraphProgress(dto);

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

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #6
0
ファイル: PlanController.cs プロジェクト: tonchilling/PTTDA
        public HttpResponseMessage View()
        {
            var deserializer = new JavaScriptSerializer();

            bal = new T_PlaningBAL();
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

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

            try
            {
                var context = HttpContext.Current;

                dto = ConvertX.GetReqeustForm <T_PlaningDTO>();
                if (dto.Year == null || "".Equals(dto.Year))
                {
                    dto.Year = DateTime.Now.Year.ToString();
                }
                string UserID = context.Request.Form["UserID"];
                if (ObjUtil.isEmpty(UserID))
                {
                    throw new Exception("UserID is require");
                }
                dto.CreateBy = UserID;
                dto.UpdateBy = UserID;

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

                objList = bal.FindByObjListV2(dto);

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

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
コード例 #7
0
        public bool UpdateNewPlan(object dto)
        {
            T_PlaningDAO        planDAO       = new T_PlaningDAO();
            T_Planing_SpecPODTO planSpecPODTO = new T_Planing_SpecPODTO();
            T_PlaningDTO        newPlanDTO    = new T_PlaningDTO();
            PlanType            type          = new PlanType();
            bool isCanupdate = false;

            try
            {
                planSpecPODTO = (T_Planing_SpecPODTO)dto;

                newPlanDTO.PID = planSpecPODTO.PID;

                newPlanDTO = planDAO.FindByPK(newPlanDTO);

                if (planSpecPODTO.PlanType == "2")
                {
                    type = PlanType.Spec;
                }
                else if (planSpecPODTO.PlanType == "3")
                {
                    type = PlanType.PO;
                }
                else if (planSpecPODTO.PlanType == "4")
                {
                    type = PlanType.Action;
                }
                newPlanDTO = PlanUtils.ShipPlan(newPlanDTO, planSpecPODTO.StartDate, planSpecPODTO.EndDate, type);

                newPlanDTO.PlanType = planSpecPODTO.PlanType;
                newPlanDTO.EditNote = planSpecPODTO.EditNote;
                newPlanDTO.UpdateBy = planSpecPODTO.UpdateBy;
                isCanupdate         = dao.UpdateNewPlan(newPlanDTO);
            }
            catch (Exception ex)
            {
                Log((dto as T_Planing_SpecPODTO).Page, "Error", ex.ToString());
            }
            return(isCanupdate);
        }
コード例 #8
0
ファイル: PlanController.cs プロジェクト: tonchilling/PTTDA
        T_PlaningDTO GetRequestToObject(HttpContext context)
        {
            HttpPostedFile postFile   = null;
            T_PlaningDTO   planingDTO = ConvertX.GetReqeustForm <T_PlaningDTO>();

            if (context.Request.Files.Count > 0)
            {
                foreach (string fileUploadName in context.Request.Files)
                {
                    if (fileUploadName.ToLower().IndexOf("defect") > -1)
                    {
                        postFile = context.Request.Files[fileUploadName];
                        var fileName = System.IO.Path.GetFileName(postFile.FileName);
                        var ext      = System.IO.Path.GetExtension(postFile.FileName);
                        // fileName = string.Format("{0}.{1}", Guid.NewGuid(), ext);
                        logger.debug("Save file as :" + context.Server.MapPath("~/Files/" + fileName));
                        postFile.SaveAs(context.Server.MapPath("~/Files/" + fileName));

                        if (fileUploadName.ToLower().Equals("defect-0"))
                        {
                            planingDTO.FileName1 = fileName;
                        }
                        if (fileUploadName.ToLower().Equals("defect-1"))
                        {
                            planingDTO.FileName2 = fileName;
                        }
                        if (fileUploadName.ToLower().Equals("defect-2"))
                        {
                            planingDTO.FileName3 = fileName;
                        }
                        if (fileUploadName.ToLower().Equals("defect-3"))
                        {
                            planingDTO.FileName4 = fileName;
                        }
                    }
                }
            }
            return(planingDTO);
        }
コード例 #9
0
        public override bool Add(object planObj)
        {
            List <SqlParameter> parameterList = new List <SqlParameter>();

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

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

                command.CommandType = CommandType.StoredProcedure;



                if (planObj != null)
                {
                    ((T_PlaningDTO)planObj).SpecSDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).SpecSDate);
                    ((T_PlaningDTO)planObj).SpecEDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).SpecEDate);

                    ((T_PlaningDTO)planObj).POSDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).POSDate);
                    ((T_PlaningDTO)planObj).POEDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).POEDate);


                    ((T_PlaningDTO)planObj).ActionSDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).ActionSDate);
                    ((T_PlaningDTO)planObj).ActionEDate = ConvertX.MMddYY(((T_PlaningDTO)planObj).ActionEDate);


                    parameterList.AddRange(GetParameters(procName, planObj, transaction).ToArray());

                    command.Parameters.AddRange(parameterList.ToArray());
                    if (((T_PlaningDTO)planObj).PID == null ||
                        ((T_PlaningDTO)planObj).PID == "")
                    {
                        command.Parameters[0].Value = "";
                    }
                }

                command.ExecuteNonQuery();

                PID = command.Parameters[0].Value.ToString();

                if (((T_PlaningDTO)planObj).DeleteFiles != null && ((T_PlaningDTO)planObj).DeleteFiles.Length > 0)
                {
                    procName = "sp_T_Planing_Files_Delete";
                    foreach (var fileNo in ((T_PlaningDTO)planObj).DeleteFiles.Split(','))
                    {
                        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;
                            parameterList = new List <SqlParameter>();
                            parameterList.AddRange(GetParameters(procName, file, transaction).ToArray());

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

                        command.ExecuteNonQuery();
                    }
                }

                obj      = (T_PlaningDTO)planObj;
                obj.PID  = PID;
                procName = "sp_T_Planing_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();
                    }
                }

                transaction.Commit();
            }
            catch (Exception ex)
            {
                isCan = false;
                transaction.Rollback();
                throw new Exception(ex.Message);
            }
            finally
            {
                CloseConnection();
            }
            return(isCan);
        }
コード例 #10
0
        public static T_PlaningDTO ShipPlan(T_PlaningDTO dto, string cStartDate, string cEndDate, PlanType type)
        {
            // int moveDay = 0;

            int diffPODay     = 0;
            int diffActionDay = 0;

            int diffSpecPODay   = 0;
            int diffPOActionDay = 0;

            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            // spec
            DateTime SpecSTDate = Convert.ToDateTime(MMddYY(dto.SpecSDate));
            DateTime SpecETDate = Convert.ToDateTime(MMddYY(dto.SpecEDate));


            // po
            DateTime POSTDate = Convert.ToDateTime(MMddYY(dto.POSDate));
            DateTime POETDate = Convert.ToDateTime(MMddYY(dto.POEDate));

            diffPODay = (POETDate - POSTDate).Days;


            // action
            DateTime ActionSTDate = Convert.ToDateTime(MMddYY(dto.ActionSDate));
            DateTime ActionETDate = Convert.ToDateTime(MMddYY(dto.ActionEDate));

            diffActionDay = (ActionETDate - ActionSTDate).Days;



            diffSpecPODay = (POSTDate - SpecETDate).Days;

            diffPOActionDay = (ActionSTDate - POETDate).Days;;



            // Change
            DateTime ChangeSDate = Convert.ToDateTime(MMddYY(cStartDate));
            DateTime ChangeEDate = Convert.ToDateTime(MMddYY(cEndDate));

            //  moveDay = ChangeSDate.Day - SpecSTDate.Day;



            if (type == PlanType.Spec)
            {
                POSTDate = ChangeEDate.AddDays(diffSpecPODay); //15

                POETDate = POSTDate.AddDays(diffPODay);

                ActionSTDate = POETDate.AddDays(diffPOActionDay);

                ActionETDate = ActionSTDate.AddDays(diffActionDay);
            }
            else if (type == PlanType.PO)
            {
                POSTDate = ChangeSDate;
                POETDate = ChangeEDate;

                ActionSTDate = POETDate.AddDays(diffPOActionDay);

                ActionETDate = ActionSTDate.AddDays(diffActionDay);
            }
            else if (type == PlanType.Action)
            {
                ActionSTDate = ChangeSDate;
                ActionETDate = ChangeEDate;
            }

            /* if (POETDate.Day >= 25 && POETDate.Day <= 31)
             * {
             *   POETDate = new DateTime(POETDate.Year, POETDate.Month, 1).AddMonths(1).AddDays(-1);
             *
             * } else if (POETDate.Day > 14 && POETDate.Day <25)
             * {
             *   POETDate = new DateTime(POETDate.Year, POETDate.Month, 21);
             * }
             * else if (POETDate.Day > 14 && POETDate.Day < 21)
             * {
             *   POETDate = new DateTime(POETDate.Year, POETDate.Month, 14);
             * }
             * else if (POETDate.Day > 7 && POETDate.Day <= 13)
             * {
             *   POETDate = new DateTime(POETDate.Year, POETDate.Month, 7);
             * }
             * else if (POETDate.Day < 7)
             * {
             *   POETDate = POETDate.AddDays(-POETDate.Day);
             * }*/



            /*  if (ActionETDate.Day >= 25 && ActionETDate.Day <= 31)
             * {
             *    ActionETDate = new DateTime(ActionETDate.Year, ActionETDate.Month, 1).AddMonths(1).AddDays(-1);
             *
             * }
             * else if (ActionETDate.Day > 14 && ActionETDate.Day < 25)
             * {
             *    ActionETDate = new DateTime(ActionETDate.Year, ActionETDate.Month, 21);
             * }
             * else if (POETDate.Day > 14 && POETDate.Day < 21)
             * {
             *    POETDate = new DateTime(POETDate.Year, POETDate.Month, 14);
             * }
             * else if (ActionETDate.Day > 7 && ActionETDate.Day <= 13)
             * {
             *    ActionETDate = new DateTime(ActionETDate.Year, ActionETDate.Month, 7);
             * }
             * else if (ActionETDate.Day < 7)
             * {
             *    ActionETDate = ActionETDate.AddDays(-ActionETDate.Day);
             * }*/


            if (type == PlanType.Spec)
            {
                dto.SpecSDate = string.Format("{0}/{1}/{2}", ChangeSDate.Day.ToString("##00")
                                              , ChangeSDate.Month.ToString("##00")
                                              , ChangeSDate.Year.ToString());
                dto.SpecEDate = string.Format("{0}/{1}/{2}", ChangeEDate.Day.ToString("##00")
                                              , ChangeEDate.Month.ToString("##00")
                                              , ChangeEDate.Year.ToString());


                dto.POSDate = string.Format("{0}/{1}/{2}", POSTDate.Day.ToString("##00")
                                            , POSTDate.Month.ToString("##00")
                                            , POSTDate.Year.ToString());
                dto.POEDate = string.Format("{0}/{1}/{2}", POETDate.Day.ToString("##00")
                                            , POETDate.Month.ToString("##00")
                                            , POETDate.Year.ToString());



                dto.ActionSDate = string.Format("{0}/{1}/{2}", ActionSTDate.Day.ToString("##00")
                                                , ActionSTDate.Month.ToString("##00")
                                                , ActionSTDate.Year.ToString());
                dto.ActionEDate = string.Format("{0}/{1}/{2}", ActionETDate.Day.ToString("##00")
                                                , ActionETDate.Month.ToString("##00")
                                                , ActionETDate.Year.ToString());
            }
            else if (type == PlanType.PO)
            {
                dto.POSDate = string.Format("{0}/{1}/{2}", ChangeSDate.Day.ToString("##00")
                                            , ChangeSDate.Month.ToString("##00")
                                            , ChangeSDate.Year.ToString());
                dto.POEDate = string.Format("{0}/{1}/{2}", ChangeEDate.Day.ToString("##00")
                                            , ChangeEDate.Month.ToString("##00")
                                            , ChangeEDate.Year.ToString());


                dto.ActionSDate = string.Format("{0}/{1}/{2}", ActionSTDate.Day.ToString("##00")
                                                , ActionSTDate.Month.ToString("##00")
                                                , ActionSTDate.Year.ToString());
                dto.ActionEDate = string.Format("{0}/{1}/{2}", ActionETDate.Day.ToString("##00")
                                                , ActionETDate.Month.ToString("##00")
                                                , ActionETDate.Year.ToString());
            }
            else if (type == PlanType.Action)
            {
                dto.ActionSDate = string.Format("{0}/{1}/{2}", ChangeSDate.Day.ToString("##00")
                                                , ChangeSDate.Month.ToString("##00")
                                                , ChangeSDate.Year.ToString());
                dto.ActionEDate = string.Format("{0}/{1}/{2}", ChangeEDate.Day.ToString("##00")
                                                , ChangeEDate.Month.ToString("##00")
                                                , ChangeEDate.Year.ToString());
            }

            return(dto);
        }
コード例 #11
0
ファイル: PlanController.cs プロジェクト: tonchilling/PTTDA
        public HttpResponseMessage DraftToSession()
        {
            var deserializer               = new JavaScriptSerializer();
            JavaScriptSerializer json      = new JavaScriptSerializer();
            string              jsonString = "";
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            try
            {
                var context = HttpContext.Current;

                string       tabNumber  = context.Request.Form["tab"];
                T_PlaningDTO planingDTO = context.Session["TPlan"] != null ? (T_PlaningDTO)context.Session["TPlan"] : GetRequestToObject(context);
                List <T_Planing_DefectDTO> objOrgList    = null;
                List <T_Planing_DefectDTO> objOutputList = null;

                switch (tabNumber)
                {
                case "3":
                    planingDTO.CoatingDefectList = GetDefect(context, planingDTO.CoatingDefectList);

                    objOutputList = new List <T_Planing_DefectDTO>();

                    foreach (T_Planing_DefectDTO dto in planingDTO.CoatingDefectList)
                    {
                        objOutputList.Add(dto.clone());
                    }
                    jsonString = json.Serialize(objOutputList);

                    break;

                case "4":
                    planingDTO.PipeDefectList = GetDefect(context, planingDTO.PipeDefectList);
                    objOrgList = planingDTO.PipeDefectList;

                    objOutputList = new List <T_Planing_DefectDTO>();

                    foreach (T_Planing_DefectDTO dto in planingDTO.PipeDefectList)
                    {
                        objOutputList.Add(dto.clone());
                    }
                    jsonString = json.Serialize(objOutputList);

                    break;

                case "5":
                    planingDTO.EnvironmentList = GetEnvironment(context, planingDTO.EnvironmentList);
                    jsonString = json.Serialize(planingDTO.EnvironmentList);
                    break;
                }

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

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }