Exemplo n.º 1
0
 /// <summary>
 /// 更新网关表记录,可以是一条,也可以是多条记录
 /// </summary>
 /// <param name="sIdValue"></param>要设置的网关新id值,不改变为空
 /// <param name="sSipNumberValue"></param>要设置的网关新sip号码值,不改变为空
 /// <param name="sPocNumberValue"></param>要设置的网关新poc号码值,不改变为空
 /// <param name="sSpTypeValue"></param>要设置的网关新运营商类型值,不改变为空
 /// <param name="sBelongGroupidValue"></param>要设置的网关新所属groupid值,不改变为空
 /// <param name="sWhereIdValue"></param>要更改网关表的条件中id值,与这个值无关为空
 /// <param name="sWhereSipNumberValue"></param>要更改网关表的条件中sip号码值,与这个值无关为空
 /// <param name="sWherePocNumberValue"></param>要更改网关表的条件中poc号码值,与这个值无关为空
 /// <param name="sWhereSpTypeValue"></param>要更改网关表的条件中运营商类型值,与这个值无关为空
 /// <param name="sWhereBelongGroupidValue"></param>要更改网关表的条件中网关所属groupid值,与这个值无关为空
 /// <returns></returns>
 public int UpdateGateway(GATEWAY gateway, GATEWAY whereGateway)
 {
     string sSetString = "";
     string sWhereInfo = "";
     string sLogString = "UpdateGatewayTableRecords() ";
     int iRet = 0;
     int iFlag = 0;
     //生成set串
     if (!string.IsNullOrEmpty(gateway.name))
     {
         if (iFlag == 0)
         {
             sSetString += "name=" + "\"" + gateway.name + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",name=" + "\"" + gateway.name + "\"";
         }
     }
     if (!string.IsNullOrEmpty(gateway.sipNum))
     {
         if (iFlag == 0)
         {
             sSetString += "sipNum=" + "\"" + gateway.sipNum + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",sipNum=" + "\"" + gateway.sipNum + "\"";
         }
     }
     if (!string.IsNullOrEmpty(gateway.pocNum))
     {
         if (iFlag == 0)
         {
             sSetString += "pocNum=" + "\"" + gateway.pocNum + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",pocNum=" + "\"" + gateway.pocNum + "\"";
         }
     }
     if (!string.IsNullOrEmpty(gateway.groupid))
     {
         if (iFlag == 0)
         {
             sSetString += "groupid=" + "\"" + gateway.groupid + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",groupid=" + "\"" + gateway.groupid + "\"";
         }
     }
     if (!string.IsNullOrEmpty(gateway.groupNum))
     {
         if (iFlag == 0)
         {
             sSetString += "groupNum=" + "\"" + gateway.groupNum + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",groupNum=" + "\"" + gateway.groupNum + "\"";
         }
     }
     if (!string.IsNullOrEmpty(gateway.type))
     {
         if (iFlag == 0)
         {
             sSetString += "type=" + "\"" + gateway.type + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",type=" + "\"" + gateway.type + "\"";
         }
     }
     if (!string.IsNullOrEmpty(gateway.available))
     {
         if (iFlag == 0)
         {
             sSetString += "available=" + "\"" + gateway.available + "\"";
             iFlag = 1;
         }
         else
         {
             sSetString += ",available=" + "\"" + gateway.available + "\"";
         }
     }
     //生成where串
     iFlag = 0;
     if (!string.IsNullOrEmpty(whereGateway.name))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "name=" + "\"" + whereGateway.name + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and name=" + "\"" + whereGateway.name + "\"";
         }
     }
     if (!string.IsNullOrEmpty(whereGateway.sipNum))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "sipNum=" + "\"" + whereGateway.sipNum + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and sipNum=" + "\"" + whereGateway.sipNum + "\"";
         }
     }
     if (!string.IsNullOrEmpty(whereGateway.pocNum))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "pocNum=" + "\"" + whereGateway.pocNum + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and pocNum=" + "\"" + whereGateway.pocNum + "\"";
         }
     }
     if (!string.IsNullOrEmpty(whereGateway.groupid))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "groupid=" + "\"" + whereGateway.groupid + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and groupid=" + "\"" + whereGateway.groupid + "\"";
         }
     }
     if (!string.IsNullOrEmpty(whereGateway.groupNum))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "groupNum=" + "\"" + whereGateway.groupNum  + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and groupNum="  + "\"" + whereGateway.groupNum  + "\"";
         }
     }
     if (!string.IsNullOrEmpty(whereGateway.type))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "type=" + "\"" + whereGateway.type + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and type=" + "\"" + whereGateway.type + "\"";
         }
     }
     if (!string.IsNullOrEmpty(whereGateway.available))
     {
         if (iFlag == 0)
         {
             sWhereInfo += "available=" +  "\"" + whereGateway.available + "\"";
             iFlag = 1;
         }
         else
         {
             sWhereInfo += " and available=" + "\""+ whereGateway.available + "\"";
         }
     }
     sLogString += "sSetString is: " + sSetString + "\n"
                   + "sWhereInfo is: " + sWhereInfo + "\n";
     MysqlBasicMethods.WriteMysqlLog(sLogString);
     //调用基本的更新记录函数
     iRet = MysqlBasicMethods.UpdateRecordsOperation(sGatewayTableName, sSetString, sWhereInfo, 0);
     if (iRet > 0)
     {
         sLogString = "UpdateGatewayTableRecords() success. iRet is: " + iRet.ToString();
     }
     else
     {
         sLogString = "UpdateGatewayTableRecords() fail. iRet is: " + iRet.ToString();
     }
     MysqlBasicMethods.WriteMysqlLog(sLogString);
     return iRet;
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到网关表记录,可以是一条记录,也可以是多条记录
        /// </summary>
        /// <param name="sIdValue"></param>查找条件中的网关记录id值,如果无关为空
        /// <param name="sSipNumberValue"></param>查找条件中的网关记录sip_number值,如果无关为空
        /// <param name="sPocNumberValue"></param>查找条件中的网关记录poc_number值,如果无关为空
        /// <param name="sSpTypeValue"></param>查找条件中的网关记录网关所属运营商值,如果无关为空
        /// <param name="sBelongGroupidValue"></param>查找条件中的网关记录网关所属groupid值,如果无关为空
        /// <returns></returns>返回变长的数据结构数组,每条记录放在一个结构体中
        public GATEWAY[] GetGateway(GATEWAY gateway)
        {
            string sWhereInfo = "";
            string sLogString = "GetGatewayTableRecords_new() ";
            ArrayList alTmpRet = new ArrayList();
            Char[] cSplitColumnStr = { ';' };//分隔每一列的分隔符
            Char[] cSplitFieldStr = { ':' };//分隔每个列名称和列值的分隔符
            string[] sSplitColumninfo;
            string[] sSplitFieldinfo;
            GATEWAY[] stGatewayRecord;
            int iFlag = 0;

            //生成where串
            if (!string.IsNullOrEmpty(gateway.name))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "name=" + "\"" + gateway.name + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and name=" + "\"" + gateway.name + "\"";
                }
            }
            if (!string.IsNullOrEmpty(gateway.sipNum))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "sipNum=" + "\"" + gateway.sipNum + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and sipNum=" + "\"" + gateway.sipNum + "\"";
                }
            }
            if (!string.IsNullOrEmpty(gateway.pocNum))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "pocNum=" + "\"" + gateway.pocNum + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and pocNum=" + "\"" + gateway.pocNum + "\"";
                }
            }
            if (!string.IsNullOrEmpty(gateway.groupid))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "groupid=" + "\"" + gateway.groupid + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and groupid=" + "\"" + gateway.groupid + "\"";
                }
            }
            if (!string.IsNullOrEmpty(gateway.groupNum))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "groupNum=" + "\"" + gateway.groupNum + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and groupNum=" + "\""+gateway.groupNum  + "\"";
                }
            }
            if (!string.IsNullOrEmpty(gateway.type))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "type =" + "\"" + gateway.type + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and type =" + "\"" + gateway.type + "\"";
                }
            }
            if (!string.IsNullOrEmpty(gateway.available))
            {
                if (iFlag == 0)
                {
                    sWhereInfo += "available="  + "\"" + gateway.available  + "\"";
                    iFlag = 1;
                }
                else
                {
                    sWhereInfo += " and available="  + "\"" + gateway.available  + "\"";
                }
            }
            sLogString += "sWhereInfo is: " + sWhereInfo + "\n";
            MysqlBasicMethods.WriteMysqlLog(sLogString);
            //调用基本的GET记录函数
            alTmpRet = MysqlBasicMethods.GetRecordsOperation(sGatewayTableName, sWhereInfo);

            if (alTmpRet.Count > 0)
            {
                stGatewayRecord = new GATEWAY[alTmpRet.Count];
                for (int i = 0; i < alTmpRet.Count; i++)
                {
                    sSplitColumninfo = Convert.ToString(alTmpRet[i]).Split(cSplitColumnStr);
                    for (int j = 0; j < sSplitColumninfo.Length; j++)
                    {
                        sSplitFieldinfo = Convert.ToString(sSplitColumninfo[j]).Split(cSplitFieldStr);
                        switch (sSplitFieldinfo[0])
                        {
                            //case "id":
                            //    {
                            //        if (!string.IsNullOrEmpty(sSplitFieldinfo[1]))
                            //        {
                            //            stGatewayRecord[i].id = Convert.ToInt32(sSplitFieldinfo[1]);
                            //        }
                            //    }
                            //    break;
                            case "name":
                                {
                                    stGatewayRecord[i].name = sSplitFieldinfo[1];
                                }
                                break;
                            case "sipNum":
                                {
                                    stGatewayRecord[i].sipNum = sSplitFieldinfo[1];
                                }
                                break;
                            case "pocNum":
                                {
                                    stGatewayRecord[i].pocNum = sSplitFieldinfo[1];
                                }
                                break;
                            case "groupid":
                                {
                                    stGatewayRecord[i].groupid = sSplitFieldinfo[1];
                                }
                                break;
                            case "groupNum":
                                {
                                    stGatewayRecord[i].groupNum = sSplitFieldinfo[1];
                                }
                                break;
                            case "type":
                                {

                                    stGatewayRecord[i].type = sSplitFieldinfo[1];
                                }
                                break;
                            case "available":
                                {
                                    stGatewayRecord[i].available = sSplitFieldinfo[1];
                                }
                                break;
                            default:
                                break;
                        }
                    }

                }

                sLogString = "GetGatewayTableRecords_new() success.";
            }
            else
            {
                stGatewayRecord = new GATEWAY[0];
                sLogString = "GetGatewayTableRecords_new() fail.";
            }
            MysqlBasicMethods.WriteMysqlLog(sLogString);

            return stGatewayRecord;
        }
Exemplo n.º 3
0
        public int AddGateway(GATEWAY gateway)
        {
            string sColumnsInfo = "";
            string sColumnsValues = "";
            string sLogString = "AddGatewayTableRecord() ";
            int iRet = 0;
          
            if (!string.IsNullOrEmpty(gateway.name))
            {
                sColumnsInfo += "name";
                sColumnsValues += "\"" + gateway.name + "\"";
            }
            if (!string.IsNullOrEmpty(gateway.sipNum))
            {
                sColumnsInfo += ",sipNum";
                sColumnsValues += "," + "\"" + gateway.sipNum + "\"";
            }
            if (!string.IsNullOrEmpty(gateway.pocNum))
            {
                sColumnsInfo += ",pocNum";
                sColumnsValues += "," + "\"" + gateway.pocNum + "\"";
            }
            if (!string.IsNullOrEmpty(gateway.groupid))
            {
                sColumnsInfo += ",groupid";
                sColumnsValues += "," + "\"" + gateway.groupid + "\"";
            }
            if (!string.IsNullOrEmpty(gateway.groupNum))
            {
                sColumnsInfo += ",groupNum";
                sColumnsValues += "," + "\"" + gateway.groupNum + "\"";
            }
            if (!string.IsNullOrEmpty(gateway.type))
            {
                sColumnsInfo += ",type";
                sColumnsValues += "," + "\"" + gateway.type + "\"";
            }
            if (!string.IsNullOrEmpty(gateway.available))
            {
                sColumnsInfo += ",available";
                sColumnsValues += "," + "\"" + gateway.available + "\"";
            }

            sLogString += "sColumnsInfo is: " + sColumnsInfo + "\n"
                          + "; sColumnsValues is: " + sColumnsValues + "\n";
            MysqlBasicMethods.WriteMysqlLog(sLogString);
            //调用基本的增加记录函数
            iRet = MysqlBasicMethods.AddRecordOperation(sGatewayTableName, sColumnsInfo, sColumnsValues);
            if (iRet > 0)
            {
                sLogString = "AddGatewayTableRecord() success. iRet is: " + iRet.ToString();
            }
            else
            {
                sLogString = "AddGatewayTableRecord() fail. iRet is: " + iRet.ToString();
            }
            MysqlBasicMethods.WriteMysqlLog(sLogString);
            return iRet;
        }