コード例 #1
0
 public int Insert(P_Admin p_Admin)
 {
     using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.GisPlateform))
     {
         return(conn.Execute(DapperExtentions.MakeInsertSql(p_Admin), p_Admin));
     }
 }
コード例 #2
0
 public MessageEntity AddPointArea(PointAreaInfo pointTable)
 {
     using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide))
     {
         var            rows    = 0;
         string         sql     = $@"select count(0) as count from PointAreaInfo p where p.PlanAreaId = {pointTable.PlanAreaId} and p.PointName='{ pointTable.PointName}'";
         List <dynamic> pointcc = conn.Query <dynamic>(sql).ToList();
         if (pointcc[0].count > 0)
         {
             return(MessageEntityTool.GetMessage(ErrorType.NotUnique, "同一区域内不能添加相同关键点"));
         }
         var updateSql = DapperExtentions.MakeInsertSql(pointTable);
         if (string.IsNullOrEmpty(updateSql))
         {
             return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类"));
         }
         try
         {
             rows = conn.Execute(updateSql, pointTable);
             return(MessageEntityTool.GetMessage(rows));
         }
         catch (Exception e)
         {
             return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message));
         }
     }
 }
コード例 #3
0
 public MessageEntity AddEventType(M_EventType eventType)
 {
     using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide))
     {
         var rows      = 0;
         var insertSql = DapperExtentions.MakeInsertSql(eventType);
         if (string.IsNullOrEmpty(insertSql))
         {
             return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类"));
         }
         try
         {
             rows = conn.Execute(insertSql, eventType);
             return(MessageEntityTool.GetMessage(rows));
         }
         catch (Exception e)
         {
             return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message));
         }
     }
 }
コード例 #4
0
        public MessageEntity PostTaskEqument(L_Task_CompleteDetail task_CompleteDetail)
        {
            using (var conn = ConnectionFactory.GetDBConn(ConnectionFactory.DBConnNames.PipeInspectionBase_Gis_OutSide))
            {
                var rows      = 0;
                int recordNum = 0;
                var insertSql = DapperExtentions.MakeInsertSql(task_CompleteDetail);
                if (string.IsNullOrEmpty(insertSql))
                {
                    return(MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类"));
                }
                if (task_CompleteDetail.EquType != null)
                {
                    recordNum = conn.ExecuteScalar <int>("select count(0) from L_Task_CompleteDetail where TaskId=@TaskId and Devicesmid=@Devicesmid and EquType=@EquType", task_CompleteDetail);
                }
                else
                {
                    recordNum = conn.ExecuteScalar <int>("select count(0) from L_Task_CompleteDetail where TaskId=@TaskId and Devicesmid=@Devicesmid", task_CompleteDetail);
                }
                if (recordNum > 0)
                {
                    return(MessageEntityTool.GetMessage(ErrorType.NotUnique, null, "同一任务不能重复巡检设备"));
                }


                try
                {
                    rows = conn.Execute(insertSql, task_CompleteDetail);
                    return(MessageEntityTool.GetMessage(rows));
                }
                catch (Exception e)
                {
                    return(MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message));
                }
            }
        }
コード例 #5
0
        public int InsertEntity(object entity, ConnectionFactory.DBConnNames dBConnName, out MessageEntity messageEntity)
        {
            using (var conn = ConnectionFactory.GetDBConn(dBConnName))
            {
                var rows   = 0;
                var result = DapperExtentions.MakeInsertSql(entity);
                if (string.IsNullOrEmpty(result))
                {
                    messageEntity = MessageEntityTool.GetMessage(ErrorType.SqlError, "请检查实体类");
                    return(0);
                }
                try
                {
                    rows          = conn.Execute(result, entity);
                    messageEntity = MessageEntityTool.GetMessage(rows);
                }
                catch (Exception e)
                {
                    messageEntity = MessageEntityTool.GetMessage(ErrorType.SqlError, e.Message);
                }

                return(rows);
            }
        }