wzp
2021-07-28 864986e4cad03f6b9bba9a7e65379db496b62a6a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
namespace AsiaINFO.SMS.DBFactory
{
    using AsiaINFO.DBHelpers.MSSqlDB;
    using AsiaINFO.SMS.Entity;
    using System;
    using System.Data;
    using System.Data.SqlClient;
 
    public class MTFactory
    {
        public static int AddReportWait(ReportInfo report, int ismg)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, Guid.NewGuid().ToString()), DBHelper.MakeInParam("@MSGID", SqlDbType.VarChar, 50, report.MSGID), DBHelper.MakeInParam("@MOBILE_NO", SqlDbType.VarChar, 0x15, report.MOBILE_NO), DBHelper.MakeInParam("@MOBILE_NO_TYPE", SqlDbType.Char, 1, ismg), DBHelper.MakeInParam("@REPORT_SUCCESS", SqlDbType.VarChar, 1, Convert.ToInt32(report.SUCCESS)), DBHelper.MakeInParam("@REPORT_TIME", SqlDbType.DateTime, 20, report.REPORT_TIME), DBHelper.MakeInParam("@REPORT_STAT", SqlDbType.VarChar, 20, report.STAT) };
            string commandText = "INSERT INTO  SMS_REPORT_WAIT(GUID,MSGID,MOBILE_NO,MOBILE_NO_TYPE,REPORT_SUCCESS,REPORT_TIME,REPORT_STAT) VALUES(@GUID,@MSGID,@MOBILE_NO,@MOBILE_NO_TYPE,@REPORT_SUCCESS,@REPORT_TIME,@REPORT_STAT)";
            return DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Delete_MTWait_CM(string guid)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, guid) };
            string commandText = "DELETE FROM SMS_MT_CM_WAIT WHERE GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Delete_MTWait_CU(string guid)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, guid) };
            string commandText = "DELETE FROM SMS_MT_CU_WAIT WHERE GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Delete_MTWait_TEL(string guid)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, guid) };
            string commandText = "DELETE FROM SMS_MT_TEL_WAIT WHERE GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static DataTable GetItemList_MTWait_CM(int rows)
        {
            string commandText = "select top " + rows.ToString() + " * from SMS_MT_CM_WAIT where (DOWN_TIME<getdate() or DOWN_TIME IS NULL) and (OUT_GATEWAY_ID IS NULL OR len(OUT_GATEWAY_ID)<=0)";
            return DBHelper.ExecuteDataset(1, commandText).Tables[0];
        }
 
        public static DataTable GetItemList_MTWait_CU(int rows)
        {
            string commandText = "select top " + rows.ToString() + " * from SMS_MT_CU_WAIT where (DOWN_TIME<getdate() or DOWN_TIME IS NULL) and (OUT_GATEWAY_ID IS NULL OR len(OUT_GATEWAY_ID)<=0)";
            return DBHelper.ExecuteDataset(1, commandText).Tables[0];
        }
 
        public static DataTable GetItemList_MTWait_TEL(int rows)
        {
            string commandText = "select top " + rows.ToString() + " * from SMS_MT_TEL_WAIT where (DOWN_TIME<getdate() or DOWN_TIME IS NULL) and (OUT_GATEWAY_ID IS NULL OR len(OUT_GATEWAY_ID)<=0)";
            return DBHelper.ExecuteDataset(1, commandText).Tables[0];
        }
 
        public static void Update_MTWait_CM(string guid, string out_gateway_id)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@OUT_GATEWAY_ID", SqlDbType.VarChar, 20, out_gateway_id), DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, guid) };
            string commandText = "UPDATE  SMS_MT_CM_WAIT  SET OUT_GATEWAY_ID=@OUT_GATEWAY_ID WHERE GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Update_MTWait_CM_REPLACE(string out_gateway_id_src, string out_gateway_id_des)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@OUT_GATEWAY_ID_DES", SqlDbType.VarChar, 20, out_gateway_id_des), DBHelper.MakeInParam("@OUT_GATEWAY_ID_SRC", SqlDbType.VarChar, 20, out_gateway_id_src) };
            string commandText = "UPDATE  SMS_MT_CM_WAIT  SET OUT_GATEWAY_ID=@OUT_GATEWAY_ID_DES where OUT_GATEWAY_ID=@OUT_GATEWAY_ID_SRC";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Update_MTWait_CU(string guid, string out_gateway_id)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@OUT_GATEWAY_ID", SqlDbType.VarChar, 20, out_gateway_id), DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, guid) };
            string commandText = "UPDATE  SMS_MT_CU_WAIT  SET OUT_GATEWAY_ID=@OUT_GATEWAY_ID WHERE GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Update_MTWait_CU_REPLACE(string out_gateway_id_src, string out_gateway_id_des)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@OUT_GATEWAY_ID_DES", SqlDbType.VarChar, 20, out_gateway_id_des), DBHelper.MakeInParam("@OUT_GATEWAY_ID_SRC", SqlDbType.VarChar, 20, out_gateway_id_src) };
            string commandText = "UPDATE  SMS_MT_CU_WAIT  SET OUT_GATEWAY_ID=@OUT_GATEWAY_ID_DES where OUT_GATEWAY_ID=@OUT_GATEWAY_ID_SRC";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Update_MTWait_TEL(string guid, string out_gateway_id)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@OUT_GATEWAY_ID", SqlDbType.VarChar, 20, out_gateway_id), DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, guid) };
            string commandText = "UPDATE  SMS_MT_TEL_WAIT  SET OUT_GATEWAY_ID=@OUT_GATEWAY_ID WHERE GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void Update_MTWait_TEL_REPLACE(string out_gateway_id_src, string out_gateway_id_des)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@OUT_GATEWAY_ID_DES", SqlDbType.VarChar, 20, out_gateway_id_des), DBHelper.MakeInParam("@OUT_GATEWAY_ID_SRC", SqlDbType.VarChar, 20, out_gateway_id_src) };
            string commandText = "UPDATE  SMS_MT_TEL_WAIT  SET OUT_GATEWAY_ID=@OUT_GATEWAY_ID_DES where OUT_GATEWAY_ID=@OUT_GATEWAY_ID_SRC";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static int UpdateMTInfo(ReportInfo report)
        {
            if ((report.MOBILE_NO != null) && (report.MOBILE_NO.Length > 0))
            {
                SqlParameter[] parameterArray = new SqlParameter[] { DBHelper.MakeInParam("@REPORT_SUCCESS", SqlDbType.VarChar, 1, Convert.ToInt32(report.SUCCESS)), DBHelper.MakeInParam("@REPORT_TIME", SqlDbType.DateTime, 20, report.REPORT_TIME), DBHelper.MakeInParam("@REPORT_STAT", SqlDbType.VarChar, 20, report.STAT), DBHelper.MakeInParam("@REPORT_DONWTIME", SqlDbType.VarChar, 20, report.DONE_TIME), DBHelper.MakeInParam("@MSGID", SqlDbType.VarChar, 50, report.MSGID), DBHelper.MakeInParam("@MOBILE_NO", SqlDbType.VarChar, 320, report.MOBILE_NO) };
                string str = "UPDATE SMS_MT SET  REPORT=1,REPORT_SUCCESS=@REPORT_SUCCESS,REPORT_TIME=@REPORT_TIME,REPORT_STAT=@REPORT_STAT,REPORT_DONWTIME=@REPORT_DONWTIME WHERE MSGID=@MSGID AND MOBILE_NO=@MOBILE_NO";
                return DBHelper.ExecuteNonQuery(CommandType.Text, str, parameterArray);
            }
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@REPORT_SUCCESS", SqlDbType.VarChar, 1, Convert.ToInt32(report.SUCCESS)), DBHelper.MakeInParam("@REPORT_TIME", SqlDbType.DateTime, 20, report.REPORT_TIME), DBHelper.MakeInParam("@REPORT_STAT", SqlDbType.VarChar, 20, report.STAT), DBHelper.MakeInParam("@REPORT_DONWTIME", SqlDbType.VarChar, 20, report.DONE_TIME), DBHelper.MakeInParam("@MSGID", SqlDbType.VarChar, 50, report.MSGID) };
            string commandText = "UPDATE SMS_MT SET  REPORT=1,REPORT_SUCCESS=@REPORT_SUCCESS,REPORT_TIME=@REPORT_TIME,REPORT_STAT=@REPORT_STAT,REPORT_DONWTIME=@REPORT_DONWTIME WHERE MSGID=@MSGID";
            return DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
 
        public static void UpdateMTInfo(SubmitInfo submit)
        {
            SqlParameter[] commandParameters = new SqlParameter[] { DBHelper.MakeInParam("@MSGID", SqlDbType.VarChar, 50, submit.RespMsgID), DBHelper.MakeInParam("@FACT_DOWN_TIME", SqlDbType.DateTime, 20, submit.SubmitTime), DBHelper.MakeInParam("@SUBMIT_RESULT", SqlDbType.Int, 0x20, submit.Result), DBHelper.MakeInParam("@SUBMIT_RESEND", SqlDbType.Int, 0x20, submit.ReSend), DBHelper.MakeInParam("@GUID", SqlDbType.VarChar, 50, submit.MTWait.Guid) };
            string commandText = "UPDATE SMS_MT SET MSGID=@MSGID,FACT_DOWN_TIME=@FACT_DOWN_TIME,SUBMIT_RESULT=@SUBMIT_RESULT,SUBMIT_RESEND=@SUBMIT_RESEND,STATUS=0  where GUID=@GUID";
            DBHelper.ExecuteNonQuery(CommandType.Text, commandText, commandParameters);
        }
    }
}