Пример #1
0
        public static void UpdateTask(string conn, Task task, string tableName, bool isRolllback)
        {
            StringBuilder sb    = new StringBuilder();
            DateTime      empty = new DateTime();

            sb.Append("update " + tableName + " set ");
            //移机标记 1 拆机 2 装机
            if (!isRolllback)
            {
                sb.Append("[exeCount]=exeCount+1,");
            }

            sb.Append("[netInterrupt]='" + task.NetInterrupt + "'");
            sb.Append(",[taskStatus]='" + IdlUtil.ParseTaskStatusToString(task.Status) + "'");
            sb.Append(",[receiveTime]=" + (task.ReceiveTime == empty ? "null" : ("'" + task.ReceiveTime.ToString() + "'")));
            sb.Append(",[responseMsg]=" + (task.ResponseMsg == null ? "null" : ("'" + task.ResponseMsg.Replace("'", "''") + "'")));
            sb.Append(",[executeTime]=" + (task.ExecuteTime == empty ? "null" : ("'" + task.ExecuteTime.ToString() + "'")));
            sb.Append(",[completeTime]=" + (task.CompleteTime == empty ? "null" : ("'" + task.CompleteTime.ToString() + "'")));
            sb.Append(",[responseTime]=" + (task.ResponseTime == empty ? "null" : ("'" + task.ResponseTime.ToString() + "'")));
            if (task.Status == TaskStatus.Fail && !isRolllback)
            {
                sb.Append(",[isRollback]='" + task.Rollback.ToString() + "'");
            }
            if (task.Status == TaskStatus.Fail)
            {
                sb.Append(",[errorDesc]='" + Enum.GetName(typeof(ErrorDesc), task.Error) + "'");
            }
            sb.Append(" where taskid='" + task.TaskID.ToString() + "'");
            SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sb.ToString());
        }
Пример #2
0
        public static Task GetRelocateRollbackTask(string taskID)
        {
            DataSet ds  = new DataSet();
            string  sql = "select taskID, taskType, oldcity,oldmanufacturer, oldomcName, oldoltID, oldponID, oldonuID, oldonuType,oldsvlan,oldcvlan,oldPhone," +
                          "receiveTime,oldmuvlan,oldywvlan,oldmvlan,oldfeNumber,oldpotsNumber,IsContainIMS,imsSvlan,imsCvlan,imsUV from task where taskid='" + taskID + "'";

            SqlHelper.FillDataset(s_conn, CommandType.Text, sql, ds, new string[] { "Task" });
            if (ds.Tables["Task"].Rows.Count == 0)
            {
                return(null);
            }
            else
            {
                DataRow dr = ds.Tables["Task"].Rows[0];
                return(new Task(taskID,
                                IdlUtil.ParseStringToTaskType(dr["taskType"].ToString()),
                                dr["oldcity"].ToString(),
                                dr["oldmanufacturer"].ToString(),
                                dr["oldomcName"].ToString(),
                                dr["oldoltID"].ToString(),
                                (dr["oldponID"] == DBNull.Value ? null : dr["oldponID"].ToString()),
                                (dr["oldonuID"] == DBNull.Value ? null : dr["oldonuID"].ToString()),
                                (dr["oldonuType"] == DBNull.Value ? null : dr["oldonuType"].ToString()),
                                (dr["oldsvlan"] == DBNull.Value ? -1 : int.Parse(dr["oldsvlan"].ToString())),
                                (dr["oldcvlan"] == DBNull.Value ? -1 : int.Parse(dr["oldcvlan"].ToString())),
                                dr["oldPhone"].ToString(), DateTime.Parse(dr["receiveTime"].ToString()),
                                (dr["oldmuvlan"] == DBNull.Value ? -1 : int.Parse(dr["oldmuvlan"].ToString())),
                                (dr["oldywvlan"] == DBNull.Value ? -1 : int.Parse(dr["oldywvlan"].ToString())),
                                (dr["oldmvlan"] == DBNull.Value ? -1 : int.Parse(dr["oldmvlan"].ToString())),
                                (dr["oldfeNumber"] == DBNull.Value ? -1 : int.Parse(dr["oldfeNumber"].ToString())),
                                (dr["oldpotsNumber"] == DBNull.Value ? -1 : int.Parse(dr["oldpotsNumber"].ToString())),
                                (dr["IsContainIMS"] == DBNull.Value ? null : dr["IsContainIMS"].ToString()),
                                (dr["imsSvlan"] == DBNull.Value ? -1 : int.Parse(dr["imsSvlan"].ToString())),
                                (dr["imsCvlan"] == DBNull.Value ? -1 : int.Parse(dr["imsCvlan"].ToString())),
                                (dr["imsUV"] == DBNull.Value ? -1 : int.Parse(dr["imsUV"].ToString()))
                                ));
            }
        }
Пример #3
0
        /// <summary>
        /// 补齐字段,加空值判断
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="task"></param>
        public static void InsertTask(string conn, Task task)
        {
            #region 之前的代码
            ////StringBuilder sb = new StringBuilder();
            ////sb.Append("insert into Task ([taskID],[taskType],[city],[manufacturer],[omcName]," +
            ////    "[oltID],[ponID],[onuID],[onuPort],[onuType],[svlan],[cvlan]," +
            ////    "[phone],[receiveTime]) values('");
            ////sb.Append(task.TaskID.ToString());
            ////sb.Append("','");
            ////sb.Append(IdlUtil.ParseTaskTypeToString(task.Type));
            ////sb.Append("','");
            ////sb.Append(task.City);
            ////sb.Append("','");
            ////sb.Append(task.Manufacturer);
            ////sb.Append("','");
            ////sb.Append(task.OmcName);
            ////sb.Append("',");
            ////sb.Append(task.OltID == null ? "null" : ("'" + task.OltID + "'"));
            ////sb.Append(",");
            ////sb.Append(task.PonID == null ? "null" : ("'" + task.PonID + "'"));
            ////sb.Append(",");
            ////sb.Append(task.OnuID == null ? "null" : ("'" + task.OnuID + "'"));
            ////sb.Append(",");
            ////sb.Append(task.OnuType == null ? "null" : ("'" + task.OnuType + "'"));
            ////sb.Append(",");
            ////sb.Append(task.Svlan == -1 ? "null" : task.Svlan.ToString());
            ////sb.Append(",");
            ////sb.Append(task.Cvlan == -1 ? "null" : task.Cvlan.ToString());
            ////sb.Append(",'");
            ////sb.Append(task.Phone);
            ////sb.Append("',");
            ////sb.Append(",'");
            //////sb.Append(task.ResponseBoss);
            //////sb.Append("','");
            ////sb.Append(task.ReceiveTime.ToString());
            ////sb.Append("')");
            ////SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sb.ToString());
            #endregion

            System.Data.SqlClient.SqlParameter sp_taskID       = new System.Data.SqlClient.SqlParameter("@taskID", task.TaskID);
            System.Data.SqlClient.SqlParameter sp_taskType     = new System.Data.SqlClient.SqlParameter("@taskType", IdlUtil.ParseTaskTypeToString(task.Type));
            System.Data.SqlClient.SqlParameter sp_city         = new System.Data.SqlClient.SqlParameter("@city", task.City);
            System.Data.SqlClient.SqlParameter sp_manufacturer = new System.Data.SqlClient.SqlParameter("@manufacturer", task.Manufacturer);
            System.Data.SqlClient.SqlParameter sp_omcName      = new System.Data.SqlClient.SqlParameter("@omcName", task.OmcName);
            System.Data.SqlClient.SqlParameter sp_oltID        = new System.Data.SqlClient.SqlParameter("@oltID", task.OltID);
            System.Data.SqlClient.SqlParameter sp_ponID        = new System.Data.SqlClient.SqlParameter("@ponID", task.PonID);
            System.Data.SqlClient.SqlParameter sp_onuID        = new System.Data.SqlClient.SqlParameter("@onuID", task.OnuID);
            System.Data.SqlClient.SqlParameter sp_svlan        = new System.Data.SqlClient.SqlParameter("@svlan", task.Svlan);
            System.Data.SqlClient.SqlParameter sp_cvlan        = new System.Data.SqlClient.SqlParameter("@cvlan", task.Cvlan);
            System.Data.SqlClient.SqlParameter sp_phone        = new System.Data.SqlClient.SqlParameter("@phone", task.Phone);
            System.Data.SqlClient.SqlParameter sp_receiveTime  = new System.Data.SqlClient.SqlParameter("@receiveTime", task.ReceiveTime);
            System.Data.SqlClient.SqlParameter sp_mvlan        = new System.Data.SqlClient.SqlParameter("@mvlan", task.Mvlan);
            System.Data.SqlClient.SqlParameter sp_feNumber     = new System.Data.SqlClient.SqlParameter("@feNumber", task.FENumber);
            System.Data.SqlClient.SqlParameter sp_potsNumber   = new System.Data.SqlClient.SqlParameter("@potsNumber", task.POTSNumber);
            SQLUtil.ExecProc(conn, "spInsertTask", sp_taskID, sp_taskType, sp_city, sp_manufacturer, sp_omcName, sp_oltID, sp_ponID, sp_onuID, sp_svlan,
                             sp_cvlan, sp_phone, sp_receiveTime, sp_mvlan, sp_feNumber, sp_potsNumber);
        }