Пример #1
0
        public HttpResponseMessage Add()
        {
            ResposeType         response   = new ResposeType();
            HttpResponseMessage mapMessage = null;

            try
            {
                var context = HttpContext.Current;

                T_PlaningMobileDTO planingDTO = GetRequestToObjectMobile(context);
                T_PlaningCoatingRepairMobileDTO planingCoatingRepairDTO = ConvertX.GetReqeustForm <T_PlaningCoatingRepairMobileDTO>();

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

                T_PlaningMobileBAL mobileBal = new T_PlaningMobileBAL();

                logger.debug("PlanController Add planingDTO:" + planingDTO.ToString());
                logger.debug("PlanController Add planingCoatingRepairDTO:" + planingCoatingRepairDTO.ToString());

                string TPID = mobileBal.AddFromMobile(planingDTO, planingCoatingRepairDTO, null, null, null);

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

            mapMessage = Request.CreateResponse(HttpStatusCode.OK, response);
            return(mapMessage);
        }
Пример #2
0
        public string AddFromMobile(object planObj
                                    , object coatingRepairObj
                                    , List <object> coatingDefectObj
                                    , List <object> pipeDefectObj
                                    , List <object> environmentObj)
        {
            string TPID = "";

            if (planObj != null)
            {
                List <SqlParameter> parameterList = new List <SqlParameter>();

                string procName = "sp_T_Planing_Mobile_Insert";

                SqlConnection  conn        = OpenConnection();
                SqlTransaction transaction = conn.BeginTransaction(IsolationLevel.Serializable);

                command             = new SqlCommand(procName, conn);
                command.Transaction = transaction;
                command.CommandType = CommandType.StoredProcedure;
                try
                {
                    T_PlaningMobileDTO planDTO = (T_PlaningMobileDTO)planObj;
                    planDTO.SpecSDate = ConvertX.MMddYY(planDTO.SpecSDate);
                    planDTO.SpecEDate = ConvertX.MMddYY(planDTO.SpecEDate);

                    planDTO.POSDate = ConvertX.MMddYY(planDTO.POSDate);
                    planDTO.POEDate = ConvertX.MMddYY(planDTO.POEDate);

                    planDTO.ActionSDate = ConvertX.MMddYY(planDTO.ActionSDate);
                    planDTO.ActionEDate = ConvertX.MMddYY(planDTO.ActionEDate);

                    parameterList.AddRange(GetParametersExactly(procName, planDTO, transaction).ToArray());

                    command             = new SqlCommand(procName, conn);
                    command.Transaction = transaction;
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddRange(parameterList.ToArray());

                    command.ExecuteNonQuery();

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

                    if (coatingRepairObj != null)
                    {
                        T_PlaningCoatingRepairMobileDTO coatingRepairDTo = (T_PlaningCoatingRepairMobileDTO)coatingRepairObj;

                        procName = "sp_T_Planing_CoatingRepair_Mobile_Insert";

                        parameterList = new List <SqlParameter>();

                        if (coatingRepairDTo != null)
                        {
                            coatingRepairDTo.TPID = TPID;
                            parameterList.AddRange(GetParametersExactly(procName, coatingRepairDTo, transaction).ToArray());

                            command             = new SqlCommand(procName, conn);
                            command.Transaction = transaction;
                            command.CommandType = CommandType.StoredProcedure;

                            command.Parameters.AddRange(parameterList.ToArray());

                            command.ExecuteNonQuery();
                        }
                    }
                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    if (transaction != null)
                    {
                        transaction.Rollback();
                    }
                    logger.error("AddFromMobile error :" + ex.ToString());
                    throw ex;
                }
                finally
                {
                    CloseConnection();
                }
            }
            return(TPID);
        }