Ejemplo n.º 1
0
 public ResultModel GET_QUEUE_NUM([FromBody] BusinessModel param)
 {
     try
     {
         if (!PermissionCheck.Check(param))
         {
             return(new ResultModel {
                 statusCode = "000007", result = "没有权限"
             });
         }
         InputLog(param);
         var oo = new OracleOperation();
         return(new ResultModel {
             statusCode = "000000", bussinessModel = new BusinessModel {
                 queueNum = oo.GetOrdinal(param).ToString()
             }
         });
     }
     catch (Exception ex)
     {
         Log.Error("GET_QUEUE_NUM", ex);
         return(new ResultModel {
             statusCode = "000003", result = ex.Message
         });
     }
 }
Ejemplo n.º 2
0
 public ResultModel RetrieveCorporateInfo([FromBody] BusinessModel param)
 {
     try
     {
         if (!PermissionCheck.Check(param))
         {
             return(new ResultModel {
                 statusCode = "000007", result = "没有权限"
             });
         }
         var oo = new OracleOperation();
         Log.Info("RetrieveCorporateInfo 111");
         var a = oo.RetrieveCorporateInfo(param);
         Log.Info("RetrieveCorporateInfo 222");
         return(new ResultModel {
             statusCode = a.name == string.Empty ? "000000" : "000013", bussinessModel = a
         });
     }
     catch (Exception ex)
     {
         Log.Error("RetrieveCorporateInfo", ex);
         return(new ResultModel {
             statusCode = "000003", result = ex.Message
         });
     }
 }
Ejemplo n.º 3
0
        public ResultModel DueAndChangeCertification([FromBody] BusinessModel param)
        {
            try
            {
                if (!PermissionCheck.Check(param))
                {
                    return(new ResultModel {
                        statusCode = "000007", result = "没有权限"
                    });
                }
                InputLog(param);
                var oo  = new OracleOperation();
                var ret = oo.dueAndChangeCertification(param);

                return(new ResultModel {
                    statusCode = ret == 1?"000000":"000004", bussinessModel = new BusinessModel {
                        queueNum = oo.GetOrdinal(param).ToString()
                    }
                });
            }
            catch (Exception ex)
            {
                Log.Error("dueAndChangeCertification", ex);
                return(new ResultModel {
                    statusCode = "000003", result = ex.Message
                });
            }
        }
Ejemplo n.º 4
0
 public ResultModel SendCorporateInfo([FromBody] BusinessModel param)
 {
     try
     {
         if (!PermissionCheck.Check(param))
         {
             return(new ResultModel {
                 statusCode = "000007", result = "没有权限"
             });
         }
         var oo = new OracleOperation();
         Log.Info("SendCorporateInfo 111");
         var a = oo.SendCorporateInfo(param);
         Log.Info("SendCorporateInfo 222");
         return(new ResultModel {
             statusCode = a == 1 ? "000000" : "000012", bussinessModel = new BusinessModel()
         });
     }
     catch (Exception ex)
     {
         Log.Error("SendCorporateInfo", ex);
         return(new ResultModel {
             statusCode = "000003", result = ex.Message
         });
     }
 }
Ejemplo n.º 5
0
 public ResultModel RetrieveCellPhoneNumber([FromBody] BusinessModel param)
 {
     try
     {
         if (!PermissionCheck.Check(param))
         {
             return(new ResultModel {
                 statusCode = "000007", result = "没有权限"
             });
         }
         var oo = new OracleOperation();
         Log.Info("RetrieveCellPhoneNumber 111");
         var a = oo.RetrieveCellPhoneNumber(param);
         Log.Info("RetrieveCellPhoneNumber 222");
         return(new ResultModel {
             statusCode = a == string.Empty ? "000000" : "000011", bussinessModel = new BusinessModel {
                 phoneNum = a
             }
         });
     }
     catch (Exception ex)
     {
         Log.Error("RetrieveCellPhoneNumber", ex);
         return(new ResultModel {
             statusCode = "000003", result = ex.Message
         });
     }
 }
Ejemplo n.º 6
0
 public ResultModel GetOrdinal2(string code, string category)
 {
     try
     {
         Log.Info(string.Format("GetOrdinal input code={0},category={1}", code, category));
         //  var input = JsonConvert.DeserializeObject<OrdinalInput>(param);
         var input = new BusinessModel {
             countyCode = code, businessCategory = category
         };
         var oo = new OracleOperation();
         return(new ResultModel {
             statusCode = "000000", result = oo.GetOrdinal(input).ToString()
         });
     }
     catch (Exception ex)
     {
         Log.Error("GetOrdinal", ex);
         return(new ResultModel {
             statusCode = "000003", result = ex.Message
         });
     }
 }
Ejemplo n.º 7
0
 public ResultModel GetOrdinal(string param)
 {
     try
     {
         Log.Info("GetOrdinal input param" + param);
         var input = JsonConvert.DeserializeObject <BusinessModel>(param);
         Log.Info("aaa");
         var oo = new OracleOperation();
         Log.Info("bbb");
         var ret = oo.GetOrdinal(input);
         Log.Info("ccc");
         return(new ResultModel {
             statusCode = "000000", result = ret.ToString()
         });
     }
     catch (Exception ex)
     {
         Log.Error("GetOrdinal", ex);
         return(new ResultModel {
             statusCode = "000003", result = ex.Message
         });
     }
 }
Ejemplo n.º 8
0
        public async Task <ResultModel> PostBusinessFormInfo([FromBody] BusinessModel param)
        {
            try
            {
                if (!PermissionCheck.Check(param))
                {
                    return(new ResultModel {
                        statusCode = "000007", result = "没有权限"
                    });
                }
                //    Log.Info("PostBusinessFormInfo input is:" + JsonConvert.SerializeObject(param));

                var id = new OracleOperation().GetBusinessId();

                var currentdate  = DateTime.Now.Date;
                var scurrentdate = string.Format("{0}-{1}-{2}", currentdate.Year, currentdate.Month, currentdate.Day);

                var filepath = string.Format("{2}{0}\\{1}", param.countyCode, scurrentdate, @FileRootPath);
                //    Log.Info("path 11 =" + filepath);
                if (!Directory.Exists(@filepath))
                {
                    Log.Info("path=" + filepath);
                    Directory.CreateDirectory(@filepath);
                }
                var filename = string.Format("{0}\\{1}", filepath, id);
                //   Log.Info("file name=" + filename);
                File.WriteAllBytes(filename, param.zipFile);

                switch (param.countyCode)
                {
                case "haiyang":
                    using (var cd = new Business())
                    {
                        cd.Haiyangbusiness.Add(new haiyangbusiness {
                            ID = id, COUNTYCODE = param.countyCode, UNLOAD_TASK_NUM = param.unloadTaskNum, START_TIME = scurrentdate, STATUS = param.status, TYPE = param.type, NAME = param.name, ID_NUM = param.IDum, QUEUE_NUM = param.queueNum, ADDRESS = param.address, PHONE_NUM = param.phoneNum, ATTENTION = param.attention
                        });
                        cd.SaveChanges();
                    }
                    break;

                case "fushan":
                    using (var cd = new Business())
                    {
                        cd.Fushanbusiness.Add(new fushanbusiness {
                            ID = id, COUNTYCODE = param.countyCode, UNLOAD_TASK_NUM = param.unloadTaskNum, START_TIME = scurrentdate, STATUS = param.status, TYPE = param.type, NAME = param.name, ID_NUM = param.IDum, QUEUE_NUM = param.queueNum, ADDRESS = param.address, PHONE_NUM = param.phoneNum, ATTENTION = param.attention
                        });
                        cd.SaveChanges();
                    }
                    break;

                default:
                    using (var cd = new Business())
                    {
                        cd.Bussiness.Add(new BUSSINESS {
                            ID = id, COUNTYCODE = param.countyCode, UNLOAD_TASK_NUM = param.unloadTaskNum, START_TIME = scurrentdate, STATUS = param.status, TYPE = param.type, NAME = param.name, ID_NUM = param.IDum, QUEUE_NUM = param.queueNum, ADDRESS = param.address, PHONE_NUM = param.phoneNum, ATTENTION = param.attention
                        });
                        cd.SaveChanges();
                    }
                    break;
                }

                await MessagePush.PushVoiceMessage(new CdmMessage
                {
                    ClientType = ClientType.Voice,
                    Content    = param.queueNum,
                    CountyCode = param.countyCode,
                    VoiceType  = VoiceType.Fee
                });

                return(new ResultModel {
                    statusCode = "000000", bussinessModel = new BusinessModel()
                });
            }
            catch (DbEntityValidationException e)
            {
                var err = string.Empty;
                foreach (var eve in e.EntityValidationErrors)
                {
                    var err1 =
                        string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    err += err1;
                    Log.InfoFormat(err1);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        var err2 = string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                 ve.PropertyName, ve.ErrorMessage);
                        Log.InfoFormat(err2);
                        err += err2;
                    }
                }
                return(new ResultModel {
                    statusCode = "000003", result = "DbEntityValidationException:" + err
                });
            }
            catch (EntityDataSourceValidationException ex)
            {
                Log.Error("EntityDataSourceValidationException", ex);
                return(new ResultModel {
                    statusCode = "000003", result = ex.Message
                });
            }
            catch (Exception ex)
            {
                Log.Error("PostBusinessFormInfo", ex);
                return(new ResultModel {
                    statusCode = "000003", result = ex.Message
                });
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 写入临时表
        /// </summary>
        /// <param name="listParams"></param>
        /// <param name="AStrRent"></param>
        /// <returns></returns>
        public static OperationReturn InsertTempData(DataBaseConfig ADataBaseConfig, List <string> listParams, String AStrRent)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                if (listParams.Count < 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param count invalid");
                    return(optReturn);
                }
                //ListParams
                //0         tempID
                //1         count
                //2..       tempData(tempData property split by char 27, less than 5)
                string strTempID = listParams[0];
                string strCount  = listParams[1];
                int    intCount;
                if (!int.TryParse(strCount, out intCount) || intCount <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Resource count invalid");
                    return(optReturn);
                }
                if (listParams.Count < 2 + intCount)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Resource count invalid");
                    return(optReturn);
                }
                if (string.IsNullOrEmpty(strTempID))
                {
                    List <string> listGetSerialIDParams = new List <string>();
                    listGetSerialIDParams.Add("11");
                    listGetSerialIDParams.Add("911");
                    listGetSerialIDParams.Add(DateTime.Now.ToString("yyyyMMddHHmmss"));
                    OperationReturn getSerialIDReturn = GetSerialID(ADataBaseConfig, listGetSerialIDParams, AStrRent);
                    if (!getSerialIDReturn.Result)
                    {
                        return(getSerialIDReturn);
                    }
                    strTempID = getSerialIDReturn.Data.ToString();
                }
                string           strSql;
                IDbConnection    objConn;
                IDbDataAdapter   objAdapter;
                DbCommandBuilder objCmdBuilder;
                switch (ADataBaseConfig.IntDatabaseType)
                {
                //MSSQL
                case 2:
                    strSql        = string.Format("select * from t_00_901 where c001 = {0}", strTempID);
                    objConn       = MssqlOperation.GetConnection(ADataBaseConfig.StrDatabaseProfile);
                    objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                    objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                    break;

                //ORCL
                case 3:
                    strSql        = string.Format("select * from t_00_901 where c001 = {0}", strTempID);
                    objConn       = OracleOperation.GetConnection(ADataBaseConfig.StrDatabaseProfile);
                    objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                    objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not support");
                    return(optReturn);
                }
                if (objConn == null || objAdapter == null || objCmdBuilder == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("Db object is null");
                    return(optReturn);
                }
                objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                objCmdBuilder.SetAllValues   = false;
                try
                {
                    DataSet objDataSet = new DataSet();
                    objAdapter.Fill(objDataSet);

                    int number = 0;
                    for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                    {
                        number = Math.Max(number, Convert.ToInt32(objDataSet.Tables[0].Rows[i]["C002"]));
                    }
                    for (int i = 2; i < listParams.Count; i++)
                    {
                        DataRow  dr          = objDataSet.Tables[0].NewRow();
                        string   strTempData = listParams[i];
                        string[] arrTempData = strTempData.Split(new[] { AscCodeToChr(27) },
                                                                 StringSplitOptions.RemoveEmptyEntries);
                        dr["C001"] = strTempID;
                        dr["C002"] = number + i - 1;
                        if (arrTempData.Length > 0)
                        {
                            dr["C011"] = arrTempData[0];
                        }
                        if (arrTempData.Length > 1)
                        {
                            dr["C012"] = arrTempData[1];
                        }
                        if (arrTempData.Length > 2)
                        {
                            dr["C013"] = arrTempData[2];
                        }
                        if (arrTempData.Length > 3)
                        {
                            dr["C014"] = arrTempData[3];
                        }
                        if (arrTempData.Length > 4)
                        {
                            dr["C015"] = arrTempData[4];
                        }
                        objDataSet.Tables[0].Rows.Add(dr);
                    }
                    objAdapter.Update(objDataSet);
                    objDataSet.AcceptChanges();
                }
                catch (Exception ex)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                    optReturn.Message = ex.Message;
                }
                finally
                {
                    if (objConn.State == ConnectionState.Open)
                    {
                        objConn.Close();
                    }
                    objConn.Dispose();
                }

                optReturn.Data = strTempID;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }
            return(optReturn);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 得到录音表初统计分钟切片表或CTI统计表
        /// </summary>
        /// <param name="ADataBaseConfig"></param>
        /// <param name="AGlobalSetting"></param>
        /// <param name="ATableName"></param>
        /// <param name="ColumnName"></param>
        /// <param name="AObjectType">// 1座席 2分机  3用户 4真实分机 5机构  6 技能组</param>
        /// <param name="AStartTimeLocal"></param>
        /// <param name="AStopTimeLocal"></param>
        /// <param name="AObjectSerialID"></param>
        /// <param name="AStrSum">调用存储过程时的Sum内的列拼的字符串</param>
        /// <returns></returns>
        public static double GetStatisticsValueDayDown(DataBaseConfig ADataBaseConfig, GlobalSetting AGlobalSetting, string ATableName, string AColumnName, int AObjectType, string AStartTimeLocal, string AStopTimeLocal, string AObjectSerialID, KPIFormulaColumn AKpiFormulaColumn)
        {
            double Value01     = 0;
            string ProduceName = string.Empty;

            if (ATableName.Substring(6, 1) == "4")
            {
                ProduceName = "P_46_002";
            }
            else if (ATableName.Substring(6, 1) == "3")
            {
                ProduceName = "P_46_001";
            }
            if (AKpiFormulaColumn.SpecialObjectTypeNumber <= 0)
            {
                return(0);
            }

            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            int    errNum      = 0;
            string errMsg      = string.Empty;
            string AOutParam01 = string.Empty;

            try
            {
                switch (ADataBaseConfig.IntDatabaseType)
                {
                //MSSQL
                case 2:
                {
                    DbParameter[] mssqlParameters =
                    {
                        MssqlOperation.GetDbParameter("@ainparam01",      MssqlDataType.Varchar,    5),
                        MssqlOperation.GetDbParameter("@ainparam02",      MssqlDataType.Varchar,    5),
                        MssqlOperation.GetDbParameter("@ainparam03",      MssqlDataType.Varchar,   20),
                        MssqlOperation.GetDbParameter("@ainparam04",      MssqlDataType.Varchar,    5),
                        MssqlOperation.GetDbParameter("@ainparam05",      MssqlDataType.Varchar,   20),
                        MssqlOperation.GetDbParameter("@ainparam06",      MssqlDataType.Varchar,   20),
                        MssqlOperation.GetDbParameter("@ainparam07",      MssqlDataType.Varchar, 5000),
                        MssqlOperation.GetDbParameter("@AOutParam01",     MssqlDataType.Varchar,  100),
                        MssqlOperation.GetDbParameter("@aouterrornumber", MssqlDataType.Bigint,     0),
                        MssqlOperation.GetDbParameter("@aouterrorstring", MssqlDataType.Varchar, 200)
                    };
                    mssqlParameters[0].Value = AGlobalSetting.StrRent;
                    mssqlParameters[1].Value = AObjectType;
                    mssqlParameters[2].Value = AObjectSerialID;
                    mssqlParameters[3].Value = AKpiFormulaColumn.SpecialObjectTypeNumber.ToString();
                    mssqlParameters[4].Value = AStartTimeLocal;
                    mssqlParameters[5].Value = AStopTimeLocal;
                    mssqlParameters[6].Value = AColumnName;

                    mssqlParameters[7].Value     = AOutParam01;
                    mssqlParameters[8].Value     = errNum;
                    mssqlParameters[9].Value     = errMsg;
                    mssqlParameters[7].Direction = ParameterDirection.Output;
                    mssqlParameters[8].Direction = ParameterDirection.Output;
                    mssqlParameters[9].Direction = ParameterDirection.Output;
                    optReturn = MssqlOperation.ExecuteStoredProcedure(ADataBaseConfig.StrDatabaseProfile, ProduceName,
                                                                      mssqlParameters);

                    if (mssqlParameters[8].Value.ToString() != "0")
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                        optReturn.Message = mssqlParameters[9].Value.ToString();
                    }
                    else
                    {
                        Value01 = DoubleParse(mssqlParameters[7].Value.ToString(), 0);
                    }
                }
                break;

                //ORCL
                case 3:
                {
                    DbParameter[] orclParameters =
                    {
                        OracleOperation.GetDbParameter("ainparam01",      OracleDataType.Varchar2,    5),
                        OracleOperation.GetDbParameter("ainparam02",      OracleDataType.Varchar2,    5),
                        OracleOperation.GetDbParameter("ainparam03",      OracleDataType.Varchar2,   20),
                        OracleOperation.GetDbParameter("ainparam04",      OracleDataType.Varchar2,    5),
                        OracleOperation.GetDbParameter("ainparam05",      OracleDataType.Varchar2,   20),
                        OracleOperation.GetDbParameter("ainparam06",      OracleDataType.Varchar2,   20),
                        OracleOperation.GetDbParameter("ainparam07",      OracleDataType.Varchar2, 5000),
                        OracleOperation.GetDbParameter("AOutParam01",     OracleDataType.Varchar2,  100),
                        OracleOperation.GetDbParameter("aouterrornumber", OracleDataType.Int32,       0),
                        OracleOperation.GetDbParameter("aouterrorstring", OracleDataType.Varchar2, 200)
                    };
                    orclParameters[0].Value = AGlobalSetting.StrRent;
                    orclParameters[1].Value = AObjectType;
                    orclParameters[2].Value = AObjectSerialID;
                    orclParameters[3].Value = AKpiFormulaColumn.SpecialObjectTypeNumber.ToString();
                    orclParameters[4].Value = AStartTimeLocal;
                    orclParameters[5].Value = AStopTimeLocal;
                    orclParameters[6].Value = AColumnName;

                    orclParameters[7].Value     = AOutParam01;
                    orclParameters[8].Value     = errNum;
                    orclParameters[9].Value     = errMsg;
                    orclParameters[7].Direction = ParameterDirection.Output;
                    orclParameters[8].Direction = ParameterDirection.Output;
                    orclParameters[9].Direction = ParameterDirection.Output;
                    optReturn = OracleOperation.ExecuteStoredProcedure(ADataBaseConfig.StrDatabaseProfile, ProduceName,
                                                                       orclParameters);
                    if (orclParameters[8].Value.ToString() != "0")
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                        optReturn.Message = orclParameters[9].Value.ToString();
                    }
                    else
                    {
                        Value01 = DoubleParse(orclParameters[7].Value.ToString(), 0);
                    }
                }
                break;
                }
            }
            catch (Exception ex)
            {
                FileLog.WriteInfo("GetCallPeakValue()", "Error:" + ex.Message.ToString());
            }


            return(Value01);
        }
Ejemplo n.º 11
0
        private OperationReturn ExtDBCommand(List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //ListParams
                //参考S000A1Codes中的定义
                if (listParams == null || listParams.Count < 2)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strUserID = listParams[0];
                string strSql    = listParams[1];
                WriteOperationLog(
                    string.Format("GetDBInfo:\tUserID:{0};Sql:{1}",
                                  strUserID,
                                  strSql));
                strSql    = DecryptFromClient(strSql);
                optReturn = ReadDatabaseInfo();
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                DatabaseInfo dbInfo = optReturn.Data as DatabaseInfo;
                if (dbInfo == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DatabaseInfo is null");
                    return(optReturn);
                }
                string strConn = dbInfo.GetConnectionString();
                switch (dbInfo.TypeID)
                {
                case 2:
                    optReturn = MssqlOperation.ExecuteSql(strConn, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;

                case 3:
                    optReturn = OracleOperation.ExecuteSql(strConn, strSql);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid.\t{0}", dbInfo.TypeID);
                    return(optReturn);
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                return(optReturn);
            }
            return(optReturn);
        }
Ejemplo n.º 12
0
        private void LoadBugInfoList()
        {
            try
            {
                mListBugInfos.Clear();
                if (mDatabaseInfo == null)
                {
                    return;
                }
                if (mCurrentVersion == null)
                {
                    return;
                }
                string          strVersion = mCurrentVersion.StrValue;
                string          strSql;
                OperationReturn optReturn;
                switch (mDatabaseInfo.TypeID)
                {
                case 2:
                    strSql = string.Format("SELECT * FROM T_UPDATE_LIST WHERE C001 LIKE '{0}%' ORDER BY C001",
                                           strVersion);
                    optReturn = MssqlOperation.GetDataSet(mDBConnectionString, strSql);
                    break;

                case 3:
                    strSql = string.Format("SELECT * FROM T_UPDATE_LIST WHERE C001 LIKE '{0}%' ORDER BY C001",
                                           strVersion);
                    optReturn = OracleOperation.GetDataSet(mDBConnectionString, strSql);
                    break;

                default:
                    ShowException(string.Format("DBType invalid."));
                    return;
                }
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                DataSet objDataSet = optReturn.Data as DataSet;
                if (objDataSet == null)
                {
                    ShowException(string.Format("Fail. DataSet is null"));
                    return;
                }
                int count = objDataSet.Tables[0].Rows.Count;
                for (int i = 0; i < count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];

                    UpdateModule info = new UpdateModule();
                    info.SerialNo     = dr["C001"].ToString();
                    info.Type         = Convert.ToInt32(dr["C002"]);
                    info.ModuleID     = Convert.ToInt32(dr["C003"]);
                    info.ModuleName   = dr["C004"].ToString();
                    info.OptDate      = dr["C005"].ToString();
                    info.Level        = Convert.ToInt32(dr["C006"]);
                    info.Content      = dr["C007"].ToString();
                    info.LangID       = dr["C008"].ToString();
                    info.ModuleLangID = dr["C009"].ToString();
                    mListBugInfos.Add(info);
                }

                AppendMessage(string.Format("LoadBugInfoList end.\t{0}", count));
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Ejemplo n.º 13
0
        private void Login()
        {
            try
            {
                if (DatabaseInfo == null)
                {
                    ShowException(string.Format("Fail.\t DatabaseInfo is null"));
                    return;
                }

                string strAccount  = TxtAccount.Text.Trim();
                string strPassword = TxtPassword.Password.Trim();

                if (string.IsNullOrEmpty(strAccount) ||
                    string.IsNullOrEmpty(strPassword))
                {
                    ShowException(string.Format("Account or password empty!"));
                    return;
                }

                SetBusy(true, App.GetLanguageInfo("N008", string.Format("Checking login information, please wait for a moment...")));
                bool             isFail   = true;
                string           strError = string.Empty;
                OperationReturn  optReturn;
                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (s, de) =>
                {
                    try
                    {
                        string strAccountEncrypt = App.EncryptStringM002(strAccount);
                        int    dbType            = DatabaseInfo.TypeID;
                        string strSql;
                        string strConn      = DatabaseInfo.GetConnectionString();
                        string strRentToken = string.Format("00000");
                        switch (dbType)
                        {
                        case 2:
                            strSql = string.Format("SELECT * FROM T_11_005_{0} WHERE C002 = '{1}'",
                                                   strRentToken,
                                                   strAccountEncrypt);
                            optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                            break;

                        case 3:
                            strSql = string.Format("SELECT * FROM T_11_005_{0} WHERE C002 = '{1}'",
                                                   strRentToken,
                                                   strAccountEncrypt);
                            optReturn = OracleOperation.GetDataSet(strConn, strSql);
                            break;

                        default:
                            strError = string.Format("Database type not support.\t{0}", dbType);
                            return;
                        }
                        if (!optReturn.Result)
                        {
                            strError = string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message);
                            return;
                        }
                        DataSet objDataSet = optReturn.Data as DataSet;
                        if (objDataSet == null ||
                            objDataSet.Tables.Count <= 0)
                        {
                            strError = string.Format("DataSet is null");
                            return;
                        }
                        if (objDataSet.Tables[0].Rows.Count <= 0)
                        {
                            strError = string.Format("Account not exist.\t{0}", strAccount);
                            return;
                        }
                        DataRow dr       = objDataSet.Tables[0].Rows[0];
                        long    userID   = Convert.ToInt64(dr["C001"]);
                        string  strPass  = dr["C004"].ToString();
                        string  strTemp  = string.Format("{0}{1}", userID, strPassword);
                        byte[]  byteTemp = ServerHashEncryption.EncryptBytes(Encoding.Unicode.GetBytes(strTemp),
                                                                             EncryptionMode.SHA512V00Hex);
                        var aes = ServerAESEncryption.EncryptBytes(byteTemp, EncryptionMode.AES256V02Hex);
                        strTemp = ServerEncryptionUtils.Byte2Hex(aes);
                        if (!strTemp.Equals(strPass))
                        {
                            strError = string.Format("Password error.");
                            return;
                        }
                        IsLogined = true;
                        UserInfo userInfo = new UserInfo();
                        userInfo.UserID   = userID;
                        userInfo.Account  = strAccount;
                        userInfo.Password = strPassword;
                        UserInfo          = userInfo;
                        isFail            = false;
                    }
                    catch (Exception ex)
                    {
                        strError = string.Format("Fail.\t{0}", ex.Message);
                    }
                };
                worker.RunWorkerCompleted += (s, re) =>
                {
                    worker.Dispose();
                    SetBusy(false, string.Empty);

                    if (isFail)
                    {
                        ShowException(strError);
                        return;
                    }
                    DialogResult = true;
                    Close();
                };
                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 创建主键
        /// </summary>
        /// <param name="listParams"></param>
        /// <param name="AStrRent"></param>
        /// <returns></returns>
        public static OperationReturn GetSerialID(DataBaseConfig ADataBaseConfig, List <string> listParams, string AStrRent)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                //ListParams
                //0     模块编码
                //1     模块内编码
                //2     时间变量
                if (listParams == null || listParams.Count < 3)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string moduleID    = listParams[0];
                string resourceID  = listParams[1];
                string dateFormat  = listParams[2];
                string rentToken   = AStrRent;
                string strSerialID = string.Empty;
                long   errNumber   = 0;
                string strErrMsg   = string.Empty;
                switch (ADataBaseConfig.IntDatabaseType)
                {
                case 2:
                    DbParameter[] mssqlParameters =
                    {
                        MssqlOperation.GetDbParameter("@AInParam01",      MssqlDataType.Varchar,   2),
                        MssqlOperation.GetDbParameter("@AInParam02",      MssqlDataType.Varchar,   3),
                        MssqlOperation.GetDbParameter("@AInParam03",      MssqlDataType.Varchar,   5),
                        MssqlOperation.GetDbParameter("@Ainparam04",      MssqlDataType.Varchar,  20),
                        MssqlOperation.GetDbParameter("@AOutParam01",     MssqlDataType.Varchar,  20),
                        MssqlOperation.GetDbParameter("@AOutErrorNumber", MssqlDataType.Bigint,    0),
                        MssqlOperation.GetDbParameter("@AOutErrorString", MssqlDataType.NVarchar, 4000)
                    };
                    mssqlParameters[0].Value     = moduleID;
                    mssqlParameters[1].Value     = resourceID;
                    mssqlParameters[2].Value     = rentToken;
                    mssqlParameters[3].Value     = dateFormat;
                    mssqlParameters[4].Value     = strSerialID;
                    mssqlParameters[5].Value     = errNumber;
                    mssqlParameters[6].Value     = strErrMsg;
                    mssqlParameters[4].Direction = ParameterDirection.Output;
                    mssqlParameters[5].Direction = ParameterDirection.Output;
                    mssqlParameters[6].Direction = ParameterDirection.Output;
                    optReturn = MssqlOperation.ExecuteStoredProcedure(ADataBaseConfig.StrDatabaseProfile, "P_00_001",
                                                                      mssqlParameters);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    if (mssqlParameters[5].Value.ToString() != "0")
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                        optReturn.Message = string.Format("{0}\t{1}", mssqlParameters[5].Value, mssqlParameters[6].Value);
                    }
                    else
                    {
                        strSerialID    = mssqlParameters[4].Value.ToString();
                        optReturn.Data = strSerialID;
                    }
                    break;

                case 3:
                    DbParameter[] orclParameters =
                    {
                        OracleOperation.GetDbParameter("AInParam01",      OracleDataType.Varchar2,   2),
                        OracleOperation.GetDbParameter("AInParam02",      OracleDataType.Varchar2,   3),
                        OracleOperation.GetDbParameter("AInParam03",      OracleDataType.Varchar2,   5),
                        OracleOperation.GetDbParameter("Ainparam04",      OracleDataType.Varchar2,  20),
                        OracleOperation.GetDbParameter("AOutParam01",     OracleDataType.Varchar2,  20),
                        OracleOperation.GetDbParameter("AOutErrorNumber", OracleDataType.Int32,      0),
                        OracleOperation.GetDbParameter("AOutErrorString", OracleDataType.Nvarchar2, 4000)
                    };
                    orclParameters[0].Value     = moduleID;
                    orclParameters[1].Value     = resourceID;
                    orclParameters[2].Value     = rentToken;
                    orclParameters[3].Value     = dateFormat;
                    orclParameters[4].Value     = strSerialID;
                    orclParameters[5].Value     = errNumber;
                    orclParameters[6].Value     = strErrMsg;
                    orclParameters[4].Direction = ParameterDirection.Output;
                    orclParameters[5].Direction = ParameterDirection.Output;
                    orclParameters[6].Direction = ParameterDirection.Output;
                    optReturn = OracleOperation.ExecuteStoredProcedure(ADataBaseConfig.StrDatabaseProfile, "P_00_001",
                                                                       orclParameters);
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    if (orclParameters[5].Value.ToString() != "0")
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_DBACCESS_FAIL;
                        optReturn.Message = string.Format("{0}\t{1}", orclParameters[5].Value, orclParameters[6].Value);
                    }
                    else
                    {
                        strSerialID    = orclParameters[4].Value.ToString();
                        optReturn.Data = strSerialID;
                    }
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Database type not surpport.\t{0}", ADataBaseConfig.IntDatabaseType);
                    return(optReturn);
                }
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
                return(optReturn);
            }
            return(optReturn);
        }
Ejemplo n.º 15
0
        private void DoSyncRealExtData()
        {
            try
            {
                if (mSession == null ||
                    mSession.DatabaseInfo == null)
                {
                    OnDebug(LogMode.Error, string.Format("SessionInfo or DatabaseInfo is null"));
                    return;
                }
                DatabaseInfo    dbInfo    = mSession.DatabaseInfo;
                string          strConn   = dbInfo.GetConnectionString();
                int             dbType    = dbInfo.TypeID;
                string          rentToken = mSession.RentInfo.Token;
                string          strSql;
                DataSet         objDataSet;
                OperationReturn optReturn;
                int             pbxDeviceCount = 0;
                int             extCount       = 0;
                long            longValue;
                int             intValue;
                string          strValue;

                List <ResourceConfigInfo> listResourceInfos = new List <ResourceConfigInfo>();
                List <RealExtInfo>        listExtInfos      = new List <RealExtInfo>();


                #region 获取PBXDevice资源

                switch (dbType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_11_101_{0} WHERE C001 > {1} AND C001 < {2} AND C002 = 1 ORDER BY C001, C002",
                            rentToken,
                            Service07Consts.RESOURCE_PBXDEVICE * 10000000000000000,
                            (Service07Consts.RESOURCE_PBXDEVICE + 1) * 10000000000000000);
                    optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                    if (!optReturn.Result)
                    {
                        OnDebug(LogMode.Error,
                                string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_11_101_{0} WHERE C001 > {1} AND C001 < {2} AND C002 = 1 ORDER BY C001, C002",
                            rentToken,
                            Service07Consts.RESOURCE_PBXDEVICE * 10000000000000000,
                            (Service07Consts.RESOURCE_PBXDEVICE + 1) * 10000000000000000);
                    optReturn = OracleOperation.GetDataSet(strConn, strSql);
                    if (!optReturn.Result)
                    {
                        OnDebug(LogMode.Error,
                                string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    OnDebug(LogMode.Error, string.Format("Database type not support.\t{0}", dbInfo.TypeID));
                    return;
                }
                if (objDataSet == null)
                {
                    OnDebug(LogMode.Error, string.Format("ObjDataSet is null"));
                    return;
                }
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];

                    PBXDeviceConfigInfo pbxDevice = new PBXDeviceConfigInfo();
                    pbxDevice.ObjType = Service07Consts.RESOURCE_PBXDEVICE;
                    long objID = Convert.ToInt64(dr["C001"]);
                    pbxDevice.ObjID = objID;

                    var temp = listResourceInfos.FirstOrDefault(r => r.ObjID == pbxDevice.ObjID);
                    if (temp != null)
                    {
                        listResourceInfos.Remove(temp);
                    }
                    listResourceInfos.Add(pbxDevice);
                    pbxDeviceCount++;
                }

                #endregion


                #region 获取PBXDevice的配置信息

                for (int i = 0; i < listResourceInfos.Count; i++)
                {
                    var resource = listResourceInfos[i];
                    if (resource.ObjType != Service07Consts.RESOURCE_PBXDEVICE)
                    {
                        continue;
                    }
                    var pbxDevice = resource as PBXDeviceConfigInfo;
                    if (pbxDevice == null)
                    {
                        continue;
                    }
                    switch (dbType)
                    {
                    case 2:
                        strSql =
                            string.Format(
                                "SELECT * FROM T_11_101_{0} WHERE C001 ={1} and (C002 = 1 OR C002 = 2 OR C002 = 93) ORDER BY C001, C002",
                                rentToken,
                                pbxDevice.ObjID);
                        optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                        if (!optReturn.Result)
                        {
                            OnDebug(LogMode.Error,
                                    string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                            return;
                        }
                        objDataSet = optReturn.Data as DataSet;
                        break;

                    case 3:
                        strSql =
                            string.Format(
                                "SELECT * FROM T_11_101_{0} WHERE C001 ={1} and (C002 = 1 OR C002 = 2 OR C002 = 93) ORDER BY C001, C002",
                                rentToken,
                                pbxDevice.ObjID);
                        optReturn = OracleOperation.GetDataSet(strConn, strSql);
                        if (!optReturn.Result)
                        {
                            OnDebug(LogMode.Error,
                                    string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                            return;
                        }
                        objDataSet = optReturn.Data as DataSet;
                        break;

                    default:
                        OnDebug(LogMode.Error, string.Format("Database type not support.\t{0}", dbInfo.TypeID));
                        return;
                    }
                    if (objDataSet == null)
                    {
                        OnDebug(LogMode.Error, string.Format("ObjDataSet is null"));
                        return;
                    }
                    for (int j = 0; j < objDataSet.Tables[0].Rows.Count; j++)
                    {
                        DataRow dr = objDataSet.Tables[0].Rows[j];

                        int row = Convert.ToInt32(dr["C002"]);
                        if (row == 1)
                        {
                            int key = Convert.ToInt32(dr["C011"]);
                            pbxDevice.Key = key;
                            int id = Convert.ToInt32(dr["C012"]);
                            pbxDevice.ID = id;
                        }
                        if (row == 2)
                        {
                            strValue = dr["C012"].ToString();
                            if (int.TryParse(strValue, out intValue))
                            {
                                pbxDevice.CTIType = intValue;
                            }
                            else
                            {
                                pbxDevice.CTIType = 0;
                            }
                            strValue = dr["C013"].ToString();
                            if (int.TryParse(strValue, out intValue))
                            {
                                pbxDevice.DeviceType = intValue;
                            }
                            else
                            {
                                pbxDevice.DeviceType = 0;
                            }
                            strValue = dr["C014"].ToString();
                            if (int.TryParse(strValue, out intValue))
                            {
                                pbxDevice.MonitorType = intValue;
                            }
                            else
                            {
                                pbxDevice.MonitorType = 0;
                            }
                            pbxDevice.DeviceName = dr["C015"].ToString();
                        }
                        if (row == 93)
                        {
                            pbxDevice.XmlKey = dr["C011"].ToString();
                        }
                    }
                }

                #endregion


                #region 获取真实分机资源

                switch (dbType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_11_101_{0} WHERE C001 > {1} AND C001 < {2} AND C002 = 1 ORDER BY C001, C002",
                            rentToken,
                            Service07Consts.RESOURCE_REALEXT * 10000000000000000,
                            (Service07Consts.RESOURCE_REALEXT + 1) * 10000000000000000);
                    optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                    if (!optReturn.Result)
                    {
                        OnDebug(LogMode.Error,
                                string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT * FROM T_11_101_{0} WHERE C001 > {1} AND C001 < {2} AND C002 = 1 ORDER BY C001, C002",
                            rentToken,
                            Service07Consts.RESOURCE_REALEXT * 10000000000000000,
                            (Service07Consts.RESOURCE_REALEXT + 1) * 10000000000000000);
                    optReturn = OracleOperation.GetDataSet(strConn, strSql);
                    if (!optReturn.Result)
                    {
                        OnDebug(LogMode.Error,
                                string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        return;
                    }
                    objDataSet = optReturn.Data as DataSet;
                    break;

                default:
                    OnDebug(LogMode.Error, string.Format("Database type not support.\t{0}", dbInfo.TypeID));
                    return;
                }
                if (objDataSet == null)
                {
                    OnDebug(LogMode.Error, string.Format("ObjDataSet is null"));
                    return;
                }
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];

                    RealExtInfo realExt = new RealExtInfo();
                    realExt.ObjType = Service07Consts.RESOURCE_REALEXT;
                    long objID = Convert.ToInt64(dr["C001"]);
                    realExt.ObjID = objID;

                    var temp = listExtInfos.FirstOrDefault(r => r.ObjID == realExt.ObjID);
                    if (temp != null)
                    {
                        listExtInfos.Remove(temp);
                    }
                    listExtInfos.Add(realExt);
                    extCount++;
                }

                #endregion


                #region 获取真实分机配置信息

                for (int i = 0; i < listExtInfos.Count; i++)
                {
                    var resource = listExtInfos[i];
                    if (resource.ObjType != Service07Consts.RESOURCE_REALEXT)
                    {
                        continue;
                    }
                    var ext = resource;
                    switch (dbType)
                    {
                    case 2:
                        strSql =
                            string.Format(
                                "SELECT * FROM T_11_101_{0} WHERE C001 ={1} and (C002 = 1 OR C002 = 2) ORDER BY C001, C002",
                                rentToken,
                                ext.ObjID);
                        optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                        if (!optReturn.Result)
                        {
                            OnDebug(LogMode.Error,
                                    string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                            return;
                        }
                        objDataSet = optReturn.Data as DataSet;
                        break;

                    case 3:
                        strSql =
                            string.Format(
                                "SELECT * FROM T_11_101_{0} WHERE C001 ={1} and (C002 = 1 OR C002 = 2) ORDER BY C001, C002",
                                rentToken,
                                ext.ObjID);
                        optReturn = OracleOperation.GetDataSet(strConn, strSql);
                        if (!optReturn.Result)
                        {
                            OnDebug(LogMode.Error,
                                    string.Format("LoadResourceInfo fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                            return;
                        }
                        objDataSet = optReturn.Data as DataSet;
                        break;

                    default:
                        OnDebug(LogMode.Error, string.Format("Database type not support.\t{0}", dbInfo.TypeID));
                        return;
                    }
                    if (objDataSet == null)
                    {
                        OnDebug(LogMode.Error, string.Format("ObjDataSet is null"));
                        return;
                    }
                    for (int j = 0; j < objDataSet.Tables[0].Rows.Count; j++)
                    {
                        DataRow dr = objDataSet.Tables[0].Rows[j];

                        int row = Convert.ToInt32(dr["C002"]);
                        if (row == 1)
                        {
                            strValue = dr["C011"].ToString();
                            if (long.TryParse(strValue, out longValue))
                            {
                                ext.OrgID = longValue;
                            }
                            else
                            {
                                ext.OrgID = 0;
                            }
                            ext.Status     = dr["C012"].ToString();
                            ext.IsNew      = dr["C013"].ToString() == "1";
                            ext.IsLock     = dr["C014"].ToString() == "1";
                            ext.LockMethod = dr["C015"].ToString();
                            ext.SourceType = dr["C016"].ToString();
                            strValue       = dr["C017"].ToString();
                            strValue       = DecryptFromDB(strValue);
                            ext.Name       = strValue;
                            string[] arrValue = strValue.Split(new[] { ConstValue.SPLITER_CHAR },
                                                               StringSplitOptions.RemoveEmptyEntries);
                            if (arrValue.Length > 0)
                            {
                                ext.Extension = arrValue[0];
                            }
                            strValue     = dr["C018"].ToString();
                            strValue     = DecryptFromDB(strValue);
                            ext.ChanName = strValue;
                        }
                        if (row == 2)
                        {
                        }
                    }
                }

                #endregion


                OnDebug(LogMode.Debug,
                        string.Format(
                            "LoadResourceInfos end.\tPBXDeviceCount:{0};\tRealExtCount:{1};",
                            pbxDeviceCount,
                            extCount));

                List <RealExtInfo> listAddExtensions    = new List <RealExtInfo>();
                List <RealExtInfo> listModifyExtensions = new List <RealExtInfo>();
                List <RealExtInfo> listDeleteExtensions = new List <RealExtInfo>();


                #region  步分机信息

                for (int i = 0; i < listResourceInfos.Count; i++)
                {
                    var resource = listResourceInfos[i];
                    if (resource.ObjType == Service07Consts.RESOURCE_PBXDEVICE)
                    {
                        var pbxDevice = resource as PBXDeviceConfigInfo;
                        if (pbxDevice == null)
                        {
                            continue;
                        }
                        if (pbxDevice.DeviceType != 1)
                        {
                            continue;
                        }                                               //只需处理设备类型为1(坐席分机)设备
                        string strExt    = pbxDevice.DeviceName;
                        var    extension = listExtInfos.FirstOrDefault(e => e.Extension == strExt);
                        if (extension == null)
                        {
                            //不存在,则增加
                            optReturn = GetSerialID(Service07Consts.MODULE_BASEMODULE, Service07Consts.RESOURCE_REALEXT, true);
                            if (!optReturn.Result)
                            {
                                OnDebug(LogMode.Error,
                                        string.Format("GetSerialID fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                                continue;
                            }
                            extension         = new RealExtInfo();
                            extension.ObjID   = Convert.ToInt64(optReturn.Data);
                            extension.ObjType = Service07Consts.RESOURCE_REALEXT;

                            extension.OrgID      = ConstValue.ORG_ROOT;
                            extension.Status     = "1";
                            extension.IsNew      = true;
                            extension.IsLock     = false;
                            extension.LockMethod = "N";
                            extension.SourceType = "09";
                            extension.Name       = string.Format("{0}", strExt);
                            extension.Extension  = strExt;
                            extension.ChanName   = strExt;

                            //不能添加重复的分机
                            var temp = listAddExtensions.FirstOrDefault(e => e.Extension == extension.Extension);
                            if (temp == null)
                            {
                                listAddExtensions.Add(extension);
                            }

                            //listAddExtensions.Add(extension);
                        }
                        else
                        {
                            //更新
                            strValue           = extension.Status;
                            extension.Status   = strValue == "0" ? "1" : strValue; //如果原来是被删除的分机,重新恢复成正常的分机
                            extension.ChanName = strExt;

                            listModifyExtensions.Add(extension);
                        }
                    }
                }

                #endregion


                #region  除的分机打上删除标记

                for (int i = 0; i < listExtInfos.Count; i++)
                {
                    //即不在listAddExtensions列表中,又不在listModifyExtensions中的分机是要被删除的分机,需要打上删除标记
                    var extension = listExtInfos[i];
                    if (!listAddExtensions.Contains(extension) &&
                        !listModifyExtensions.Contains(extension))
                    {
                        extension.Status = "0";
                        listDeleteExtensions.Add(extension);
                    }
                }
                for (int i = 0; i < listDeleteExtensions.Count; i++)
                {
                    //删除的分机也添加到listModifyExtensions列表中,以便后面写入到数据中
                    var extension = listDeleteExtensions[i];
                    listModifyExtensions.Add(extension);
                }

                #endregion


                #region 新增的分机写入数据库

                if (listAddExtensions.Count > 0)
                {
                    int count = listAddExtensions.Count;
                    OnDebug(LogMode.Debug, string.Format("Begin add extension to database.\t{0}", count));

                    var gp = mListGlobalParamInfos.FirstOrDefault(p => p.ParamID == Service07Consts.GP_DEFULT_PASSWORD);
                    if (gp == null)
                    {
                        OnDebug(LogMode.Error, string.Format("DefaultPassword param is null"));
                        return;
                    }
                    string strDefaultPassword = gp.ParamValue;
                    if (string.IsNullOrEmpty(strDefaultPassword))
                    {
                        OnDebug(LogMode.Error, string.Format("DefaultPassword param invalid"));
                        return;
                    }

                    IDbConnection    objConn;
                    IDbDataAdapter   objAdapter;
                    DbCommandBuilder objCmdBuilder;
                    switch (dbType)
                    {
                    case 2:
                        strSql        = string.Format("SELECT * FROM T_11_101_{0} WHERE 1 = 2", rentToken);
                        objConn       = MssqlOperation.GetConnection(strConn);
                        objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                        objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                        break;

                    case 3:
                        strSql        = string.Format("SELECT * FROM T_11_101_{0} WHERE 1 = 2", rentToken);
                        objConn       = OracleOperation.GetConnection(strConn);
                        objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                        objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                        break;

                    default:
                        OnDebug(LogMode.Error, string.Format("Database type invalid.\t{0}", dbType));
                        return;
                    }
                    if (objConn == null || objAdapter == null || objCmdBuilder == null)
                    {
                        OnDebug(LogMode.Error, string.Format("ObjDataAdapter is null"));
                        return;
                    }
                    objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                    objCmdBuilder.SetAllValues   = false;
                    try
                    {
                        objDataSet = new DataSet();
                        objAdapter.Fill(objDataSet);

                        for (int i = 0; i < listAddExtensions.Count; i++)
                        {
                            var ext = listAddExtensions[i];

                            DataRow dr1 = objDataSet.Tables[0].NewRow();
                            DataRow dr2 = objDataSet.Tables[0].NewRow();

                            dr1["C001"] = ext.ObjID;
                            dr1["C002"] = 1;
                            dr1["C011"] = ext.OrgID;
                            dr1["C012"] = ext.Status;
                            dr1["C013"] = ext.IsNew ? "1" : "0";
                            dr1["C014"] = ext.IsLock ? "1" : "0";
                            dr1["C015"] = ext.LockMethod;
                            dr1["C016"] = ext.SourceType;
                            strValue    = ext.Name;
                            strValue    = EncryptToDB(strValue);
                            dr1["C017"] = strValue;
                            strValue    = ext.ChanName;
                            strValue    = EncryptToDB(strValue);
                            dr1["C018"] = strValue;
                            strValue    = ext.ObjID.ToString();
                            strValue    = string.Format("{0}{1}", strValue, strDefaultPassword);
                            strValue    = EncryptSHA512(strValue);
                            dr1["C020"] = strValue;

                            dr2["C001"] = ext.ObjID;
                            dr2["C002"] = 2;
                            dr2["C011"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                            dr2["C012"] = 0;
                            dr2["C013"] = 0;

                            objDataSet.Tables[0].Rows.Add(dr1);
                            objDataSet.Tables[0].Rows.Add(dr2);


                            #region 增加住户管理员的管理权限

                            optReturn = null;
                            switch (dbType)
                            {
                            case 2:
                                strSql = string.Format("INSERT INTO T_11_201_{0} VALUES (0, 0, {1}, {2}, '{3}', '{4}')",
                                                       rentToken,
                                                       string.Format("102{0}00000000001", rentToken),
                                                       ext.ObjID,
                                                       DateTime.Parse("2014/1/1").ToString("yyyy-MM-dd HH:mm:ss"),
                                                       DateTime.Parse("2199/12/31 23:59:59").ToString("yyyy-MM-dd HH:mm:ss"));
                                optReturn = MssqlOperation.ExecuteSql(strConn, strSql);
                                break;

                            case 3:
                                strSql = string.Format("INSERT INTO T_11_201_{0} VALUES (0, 0, {1}, {2}, TO_DATE('{3}','YYYY-MM-DD HH24:MI:SS'), TO_DATE('{4}','YYYY-MM-DD HH24:MI:SS'))",
                                                       rentToken,
                                                       string.Format("102{0}00000000001", rentToken),
                                                       ext.ObjID,
                                                       DateTime.Parse("2014/1/1").ToString("yyyy-MM-dd HH:mm:ss"),
                                                       DateTime.Parse("2199/12/31 23:59:59").ToString("yyyy-MM-dd HH:mm:ss"));
                                optReturn = OracleOperation.ExecuteSql(strConn, strSql);
                                break;

                            default:
                                OnDebug(LogMode.Error, string.Format("Database type invalid.\t{0}", dbType));
                                break;
                            }
                            if (optReturn != null &&
                                !optReturn.Result)
                            {
                                OnDebug(LogMode.Error,
                                        string.Format("Insert11201 fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                            }

                            #endregion
                        }

                        objAdapter.Update(objDataSet);
                        objDataSet.AcceptChanges();
                    }
                    catch (Exception ex)
                    {
                        OnDebug(LogMode.Error, string.Format("Add extension fail.\t{0}", ex.Message));
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                        objConn.Dispose();
                    }
                }

                #endregion


                #region 修改的分机(包括打上删除标记的分机)写入数据库

                if (listModifyExtensions.Count > 0)
                {
                    int count = listModifyExtensions.Count;
                    OnDebug(LogMode.Debug, string.Format("Begin modify extension to database.\t{0}", count));

                    for (int i = 0; i < listModifyExtensions.Count; i++)
                    {
                        var ext = listModifyExtensions[i];

                        IDbConnection    objConn;
                        IDbDataAdapter   objAdapter;
                        DbCommandBuilder objCmdBuilder;
                        switch (dbType)
                        {
                        case 2:
                            strSql = string.Format("SELECT * FROM T_11_101_{0} WHERE C001 = {1} ORDER BY C001,C002", rentToken,
                                                   ext.ObjID);
                            objConn       = MssqlOperation.GetConnection(strConn);
                            objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                            objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                            break;

                        case 3:
                            strSql = string.Format("SELECT * FROM T_11_101_{0} WHERE C001 = {1} ORDER BY C001,C002", rentToken,
                                                   ext.ObjID);
                            objConn       = OracleOperation.GetConnection(strConn);
                            objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                            objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                            break;

                        default:
                            OnDebug(LogMode.Error, string.Format("Database type invalid.\t{0}", dbType));
                            return;
                        }
                        if (objConn == null || objAdapter == null || objCmdBuilder == null)
                        {
                            OnDebug(LogMode.Error, string.Format("ObjDataAdapter is null"));
                            return;
                        }
                        objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                        objCmdBuilder.SetAllValues   = false;
                        try
                        {
                            objDataSet = new DataSet();
                            objAdapter.Fill(objDataSet);

                            for (int j = 0; j < objDataSet.Tables[0].Rows.Count; j++)
                            {
                                DataRow dr = objDataSet.Tables[0].Rows[j];

                                int rowID = Convert.ToInt32(dr["C002"]);
                                if (rowID == 1)
                                {
                                    dr["C012"] = ext.Status;
                                    strValue   = ext.ChanName;
                                    strValue   = EncryptToDB(strValue);
                                    dr["C018"] = strValue;
                                }
                                if (rowID == 2)
                                {
                                }
                            }

                            objAdapter.Update(objDataSet);
                            objDataSet.AcceptChanges();
                        }
                        catch (Exception ex)
                        {
                            OnDebug(LogMode.Error, string.Format("Modify extension fail.\t{0}", ex.Message));
                        }
                        finally
                        {
                            if (objConn.State == ConnectionState.Open)
                            {
                                objConn.Close();
                            }
                            objConn.Dispose();
                        }
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                OnDebug(LogMode.Error, string.Format("DoSyncRealExtData fail.\t{0}", ex.Message));
            }
        }
Ejemplo n.º 16
0
        void BtnTest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                #region 生成配置文件

                //UpdateConfig config = new UpdateConfig();
                //config.CurrentVersion = "803001P02000";
                //ModuleInfo module = new ModuleInfo();
                //module.ModuleID = 3102;
                //module.MasterID = 31;
                //module.ModuleName = "Query";
                //module.Display = "查询";
                //config.ListModuleInfos.Add(module);

                //string strPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, UpdateConfig.FILE_NAME);
                //OperationReturn optReturn = XMLHelper.SerializeFile(config, strPath);
                //if (!optReturn.Result)
                //{
                //    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                //    return;
                //}

                //AppendMessage(string.Format("End.\t{0}", strPath));

                #endregion


                #region 导出语言包

                DatabaseInfo dbInfo = new DatabaseInfo();
                dbInfo.TypeID       = 3;
                dbInfo.Host         = "192.168.4.182";
                dbInfo.Port         = 1521;
                dbInfo.DBName       = "PFOrcl";
                dbInfo.LoginName    = "PFDEV832";
                dbInfo.Password     = "******";
                dbInfo.RealPassword = dbInfo.Password;

                List <int> listLangIDs = new List <int>();
                listLangIDs.Add(1033);
                listLangIDs.Add(1028);
                listLangIDs.Add(1041);
                listLangIDs.Add(2052);

                for (int i = 0; i < listLangIDs.Count; i++)
                {
                    int             langTypeID  = listLangIDs[i];
                    string          strLangName = langTypeID.ToString();
                    string          strConn     = dbInfo.GetConnectionString();
                    string          strSql;
                    OperationReturn optReturn;
                    switch (dbInfo.TypeID)
                    {
                    case 2:
                        strSql    = string.Format("SELECT * FROM T_00_005 WHERE C001 = {0} ORDER BY C001,C002", langTypeID);
                        optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                        break;

                    case 3:
                        strSql    = string.Format("SELECT * FROM T_00_005 WHERE C001 = {0} ORDER BY C001,C002", langTypeID);
                        optReturn = OracleOperation.GetDataSet(strConn, strSql);
                        break;

                    default:
                        AppendMessage(string.Format("Fail.\t DBType invalid"));
                        continue;
                    }
                    if (!optReturn.Result)
                    {
                        AppendMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        continue;
                    }
                    DataSet objDataSet = optReturn.Data as DataSet;
                    if (objDataSet == null ||
                        objDataSet.Tables.Count <= 0)
                    {
                        AppendMessage(string.Format("DataSet is null or DataTable not exist."));
                        continue;
                    }
                    LangLister lister = new LangLister();
                    lister.LangID   = langTypeID;
                    lister.LangName = strLangName;
                    lister.Path     = string.Format("{0}.XML", langTypeID);
                    int count = objDataSet.Tables[0].Rows.Count;
                    for (int j = 0; j < count; j++)
                    {
                        DataRow dr = objDataSet.Tables[0].Rows[j];

                        LanguageInfo langInfo = new LanguageInfo();
                        langInfo.LangID    = langTypeID;
                        langInfo.Name      = dr["C002"].ToString();
                        langInfo.Module    = Convert.ToInt32(dr["C009"]);
                        langInfo.SubModule = Convert.ToInt32(dr["C010"]);
                        langInfo.Page      = dr["C011"].ToString();
                        langInfo.ObjName   = dr["C012"].ToString();
                        string display = string.Empty;
                        display         += dr["C005"].ToString();
                        display         += dr["C006"].ToString();
                        display         += dr["C007"].ToString();
                        display         += dr["C008"].ToString();
                        langInfo.Display = display;

                        lister.ListLangInfos.Add(langInfo);
                    }

                    string strPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, lister.Path);
                    optReturn = XMLHelper.SerializeFile(lister, strPath);
                    if (!optReturn.Result)
                    {
                        AppendMessage(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                        continue;
                    }
                    AppendMessage(string.Format("End.\t{0}\t{1}", strPath, count));
                }
                AppendMessage(string.Format("End."));

                #endregion
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Ejemplo n.º 17
0
        private void ModifyBugInfos()
        {
            try
            {
                var item = LvBugList.SelectedItem as BugItem;
                if (item == null)
                {
                    return;
                }
                var info = item.Info;
                if (info == null)
                {
                    return;
                }
                var bugType = ComboBugTypes.SelectedItem as ComboItem;
                if (bugType == null)
                {
                    ShowException(string.Format("Bug Type invalid!"));
                    return;
                }
                info.Type = bugType.IntValue;
                DateTime dtValue;
                if (!DateTime.TryParse(TxtUpdateDate.Text + " 00:00:00", out dtValue))
                {
                    ShowException(string.Format("UpdateDate invalid!"));
                    return;
                }
                info.OptDate = dtValue.ToString("yyyyMMdd");
                int intValue;
                if (!int.TryParse(TxtLevel.Text, out intValue) ||
                    intValue < 0 ||
                    intValue > 10)
                {
                    ShowException(string.Format("Level invalid!"));
                    return;
                }
                info.Level   = intValue;
                info.Content = TxtContent.Text;

                if (mDatabaseInfo == null)
                {
                    return;
                }
                bool bIsSucess = false;

                BackgroundWorker worker = new BackgroundWorker();
                worker.DoWork += (s, de) =>
                {
                    try
                    {
                        string           strConn = mDatabaseInfo.GetConnectionString();
                        int              dbType  = mDatabaseInfo.TypeID;
                        string           strSql;
                        IDbConnection    objConn;
                        IDbDataAdapter   objAdapter;
                        DbCommandBuilder objCmdBuilder;
                        switch (dbType)
                        {
                        case 2:
                            strSql        = string.Format("SELECT * FROM T_UPDATE_LIST WHERE C001 = '{0}'", info.SerialNo);
                            objConn       = MssqlOperation.GetConnection(strConn);
                            objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                            objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                            break;

                        case 3:
                            strSql        = string.Format("SELECT * FROM T_UPDATE_LIST WHERE C001 = '{0}'", info.SerialNo);
                            objConn       = OracleOperation.GetConnection(strConn);
                            objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                            objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                            break;

                        default:
                            ShowException(string.Format("DatabaseType invalid!"));
                            bIsSucess = false;
                            return;
                        }
                        if (objConn == null || objAdapter == null || objCmdBuilder == null)
                        {
                            ShowException(string.Format("DBObject is null"));
                            bIsSucess = false;
                            return;
                        }
                        objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                        objCmdBuilder.SetAllValues   = false;
                        try
                        {
                            DataSet objDataSet = new DataSet();
                            objAdapter.Fill(objDataSet);

                            if (objDataSet.Tables[0].Rows.Count <= 0)
                            {
                                ShowException(string.Format("Fail.\tDataRow not exist.\t{0}", info.SerialNo));
                                return;
                            }
                            DataRow dr = objDataSet.Tables[0].Rows[0];
                            dr["C001"] = info.SerialNo;
                            dr["C002"] = info.Type;
                            dr["C003"] = info.ModuleID;
                            dr["C004"] = info.ModuleName;
                            dr["C005"] = info.OptDate;
                            dr["C006"] = info.Level;
                            dr["C007"] = info.Content;
                            dr["C008"] = info.LangID;
                            dr["C009"] = info.ModuleLangID;
                            dr["C010"] = mCurrentVersion.Display;

                            objAdapter.Update(objDataSet);
                            objDataSet.AcceptChanges();

                            bIsSucess = true;
                        }
                        catch (Exception ex)
                        {
                            ShowException(string.Format("Fail.\t{0}", ex.Message));
                            bIsSucess = false;
                        }
                        finally
                        {
                            if (objConn.State == ConnectionState.Open)
                            {
                                objConn.Close();
                            }
                            objConn.Dispose();
                        }
                    }
                    catch (Exception ex)
                    {
                        ShowException(ex.Message);
                    }
                };
                worker.RunWorkerCompleted += (s, re) =>
                {
                    worker.Dispose();

                    if (bIsSucess)
                    {
                        AppendMessage(string.Format("Modify end.\t{0}", info.SerialNo));

                        ReloaddBugInfos();
                    }
                };
                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }
Ejemplo n.º 18
0
        public static OperationReturn GetAllMachines(DatabaseInfo dbInfo)
        {
            Dictionary <int, MachineInfo> lstMachines = new Dictionary <int, MachineInfo>();
            string          strConnectString          = dbInfo.GetConnectionString();
            OperationReturn optReturn = new OperationReturn();
            string          strSql    = string.Empty;

            switch (dbInfo.TypeID)
            {
            case 2:
                strSql = "select a.C001,a.C012,b.c011,a.c002 as A002 ,b.c002 as B002,a.C017,c.C012 as D012 from t_11_101_{0} a " +
                         "left join t_11_101_{0} b on a.c001 = b.c001 " +
                         "left join t_11_101_{0} c on a.c001 = c.c001 " +
                         "where a.C001 >2210000000000000000 and a.C001 <2220000000000000000 and a.C002 =1 " +
                         "and  b.C001 >2210000000000000000 and b.C001 <2220000000000000000 and b.C002 =3 " +
                         " and c.C001 >2210000000000000000 and c.C001 <2220000000000000000 and c.C002 =2 ";
                strSql    = string.Format(strSql, "00000", "00000");
                optReturn = MssqlOperation.GetDataSet(strConnectString, strSql);
                break;

            case 3:
                strSql = "select a.C001,a.C012,b.c011,a.c002 as A002 ,b.c002 as B002,a.C017,c.C012 as D012 from t_11_101_{0} a " +
                         "left join t_11_101_{0} b on a.c001 = b.c001 " +
                         "left join t_11_101_{0} c on a.c001 = c.c001 " +
                         "where a.C001 >2210000000000000000 and a.C001 <2220000000000000000 and a.C002 =1 " +
                         "and  b.C001 >2210000000000000000 and b.C001 <2220000000000000000 and b.C002 =3 " +
                         " and c.C001 >2210000000000000000 and c.C001 <2220000000000000000 and c.C002 =2 ";
                strSql    = string.Format(strSql, "00000", "00000");
                optReturn = OracleOperation.GetDataSet(strConnectString, strSql);
                break;
            }
            if (!optReturn.Result)
            {
                optReturn.Message = "GetAllMachines error ,sql = " + strSql;
                return(optReturn);
            }
            DataSet ds = optReturn.Data as DataSet;

            if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
            {
                optReturn.Data = lstMachines;
                return(optReturn);
            }
            MachineInfo machine = null;

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                try
                {
                    machine     = new MachineInfo();
                    machine.Key = int.Parse(row["C012"].ToString());
                    machine.ReplaceModuleNumber = row["C011"].ToString();
                    machine.ResID       = long.Parse(row["C001"].ToString());
                    machine.Host        = Common.DecodeEncryptValue(row["C017"].ToString());
                    machine.StandByRole = row["D012"].ToString();
                    lstMachines.Add(machine.Key, machine);
                }
                catch (Exception ex)
                {
                }
                //lstMachines.Add(int.Parse(row["C012"].ToString()), row["C011"].ToString());
            }
            optReturn.Data = lstMachines;
            return(optReturn);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 主机接替备机时 更新资源表
        /// </summary>
        /// <param name="dbInfo">数据库连接信息</param>
        /// <param name="strRelpaceModuleNumber">要接替的主机key</param>
        /// <param name="strResourceKey">备机key</param>
        /// <returns></returns>
        public static OperationReturn UpdateReplaceModuleNumberInDB(DatabaseInfo dbInfo, string strRelpaceModuleNumber, string strResourceKey)
        {
            OperationReturn optReturn = new OperationReturn();

            try
            {
                string strConnectString = dbInfo.GetConnectionString();
                //先找到备机对应的资源ID
                string strSql = string.Empty;
                switch (dbInfo.TypeID)
                {
                case 2:
                    strSql    = "select * from t_11_101_{0} where C001 >2210000000000000000 and C001 <2220000000000000000 and C002 =1 and C014 in( {1},{2})";
                    strSql    = string.Format(strSql, "00000", strResourceKey, strRelpaceModuleNumber);
                    optReturn = MssqlOperation.GetDataSet(strConnectString, strSql);
                    break;

                case 3:
                    strSql    = "select * from t_11_101_{0} where C001 >2210000000000000000 and C001 <2220000000000000000 and C002 =1 and C014 in( {1},{2})";
                    strSql    = string.Format(strSql, "00000", strResourceKey, strRelpaceModuleNumber);
                    optReturn = OracleOperation.GetDataSet(strConnectString, strSql);
                    break;
                }

                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                DataSet ds = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Result = false;
                    return(optReturn);
                }
                //定义两个变量 来保存主备机器的资源ID
                string strMainResID   = string.Empty;
                string strBackupResID = string.Empty;
                string strKey         = string.Empty;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    strKey = row["C012"].ToString();
                    if (strKey == strResourceKey)
                    {
                        strBackupResID = row["C001"].ToString();
                        continue;
                    }
                    else if (strKey == strRelpaceModuleNumber)
                    {
                        strMainResID = row["C001"].ToString();
                    }
                }

                //判断备机资源的standbyrole是不是3
                switch (dbInfo.TypeID)
                {
                case 2:
                    strSql    = "select * from t_11_101_{0} where C001 ={1} and C002 = 2";
                    strSql    = string.Format(strSql, "00000", strBackupResID);
                    optReturn = MssqlOperation.GetDataSet(strConnectString, strSql);
                    break;

                case 3:
                    strSql    = "select * from t_11_101_{0} where C001 ={1} and C002 = 2";
                    strSql    = string.Format(strSql, "00000", strBackupResID);
                    optReturn = OracleOperation.GetDataSet(strConnectString, strSql);
                    break;
                }
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                ds = optReturn.Data as DataSet;
                if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0)
                {
                    optReturn.Result = false;
                    return(optReturn);
                }
                string strStandbyrole = ds.Tables[0].Rows[0]["C012"].ToString();
                if (strStandbyrole != "3")
                {
                    optReturn.Result = false;
                    return(optReturn);
                }
                //更新备机的RelpaceModuleNumber
                switch (dbInfo.TypeID)
                {
                case 2:
                    strSql    = "update t_11_101_{0} set C011 = '{1}' where C001 = {2} and C002 = 3";
                    strSql    = string.Format(strSql, "00000", strRelpaceModuleNumber, strBackupResID);
                    optReturn = MssqlOperation.ExecuteSql(strConnectString, strSql);
                    break;

                case 3:
                    strSql    = "UPDATE t_11_101_{0} SET C011 = '{1}' where C001 = {2} and C002 = 3";
                    strSql    = string.Format(strSql, "00000", strRelpaceModuleNumber, strBackupResID);
                    optReturn = OracleOperation.ExecuteSql(strConnectString, strSql);
                    break;
                }
                if (!optReturn.Result)
                {
                    return(optReturn);
                }

                //更新主机的RelpaceModuleNumber
                switch (dbInfo.TypeID)
                {
                case 2:
                    strSql    = "update t_11_101_{0} set C011 = '{1}' where C001 = {2} and C002 = 3";
                    strSql    = string.Format(strSql, "00000", strResourceKey, strMainResID);
                    optReturn = MssqlOperation.ExecuteSql(strConnectString, strSql);
                    break;

                case 3:
                    strSql    = "UPDATE t_11_101_{0} SET C011 = '{1}' where C001 = {2} and C002 = 3";
                    strSql    = string.Format(strSql, "00000", strResourceKey, strMainResID);
                    optReturn = OracleOperation.ExecuteSql(strConnectString, strSql);
                    break;
                }
                if (!optReturn.Result)
                {
                    return(optReturn);
                }

                optReturn.Result = true;
                optReturn.Code   = Defines.RET_SUCCESS;
            }
            catch (Exception ex)
            {
                optReturn.Result  = false;
                optReturn.Code    = Defines.RET_FAIL;
                optReturn.Message = ex.Message;
            }

            return(optReturn);
        }
Ejemplo n.º 20
0
        private OperationReturn SyncExtension(List <string> listParams)
        {
            OperationReturn optReturn = new OperationReturn();

            optReturn.Result = true;
            optReturn.Code   = 0;
            try
            {
                #region 解析参数

                //ListParams
                //参考S000ACodes中的说明,此处从略
                if (listParams == null || listParams.Count < 3)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Request param is null or count invalid");
                    return(optReturn);
                }
                string strUserID         = listParams[0];
                string strTenantOrgToken = listParams[1];
                string strCount          = listParams[2];
                WriteOperationLog(string.Format("SyncExtension:\tUserID:{0};TenantOrgToken:{1};Count:{2}", strUserID,
                                                strTenantOrgToken, strCount));

                #endregion


                #region 检查参数有效性

                int tenantOrgToken;
                if (!int.TryParse(strTenantOrgToken, out tenantOrgToken) ||
                    tenantOrgToken <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param TenantOrgToken invalid.");
                    return(optReturn);
                }
                int intCount;
                if (!int.TryParse(strCount, out intCount) ||
                    intCount < 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Param Count invalid.");
                    return(optReturn);
                }
                if (listParams.Count < intCount + 3)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("Extension Count invalid.");
                    return(optReturn);
                }

                #endregion


                #region 得到分机列表

                List <ExtensionInfo> listExtensions = new List <ExtensionInfo>();
                for (int i = 0; i < intCount; i++)
                {
                    string     strInfo = listParams[i + 3];
                    JsonObject jsonExt = null;
                    try
                    {
                        jsonExt = new JsonObject(strInfo);
                    }
                    catch { }
                    if (jsonExt != null)
                    {
                        ExtensionInfo info = new ExtensionInfo();
                        if (jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_EXTENSION] != null)
                        {
                            info.Extension = jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_EXTENSION].Value;
                        }
                        if (jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_CHANNELNAME] != null)
                        {
                            info.ChannelName = jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_CHANNELNAME].Value;
                        }
                        if (jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_SERVERIP] != null)
                        {
                            info.ServerIP = jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_SERVERIP].Value;
                        }
                        if (jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_CHANNELID] != null)
                        {
                            info.ChannelID = (int)jsonExt[S000AConsts.FIELD_NAME_EXTENSIONINFO_CHANNELID].Number;
                        }
                        listExtensions.Add(info);
                    }
                }
                WriteOperationLog(string.Format("ListExtension:{0}", listExtensions.Count));

                #endregion


                #region 获取数据库信息

                optReturn = ReadDatabaseInfo();
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                DatabaseInfo dbInfo = optReturn.Data as DatabaseInfo;
                if (dbInfo == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DatabaseInfo is null");
                    return(optReturn);
                }
                WriteOperationLog(string.Format("DatabaseInfo:{0}", dbInfo));

                #endregion


                #region 根据TenantOrgToken获取数据库中分机信息列表

                string        strConn      = dbInfo.GetConnectionString();
                string        strRentToken = "00000";
                string        strSql;
                int           dbType = dbInfo.TypeID;
                DataSet       objDataSet;
                int           addNum     = 0;
                int           modifyNum  = 0;
                List <string> listReturn = new List <string>();


                #region 租户机构编号

                string strOrgID   = string.Format("10114010100000{0}", tenantOrgToken.ToString("00000"));
                long   orgID      = long.Parse(strOrgID);
                long   orgAdminID = 0;

                #endregion


                #region 获取租户管理员编号

                if (tenantOrgToken > 0)
                {
                    switch (dbType)
                    {
                    case 2:
                        strSql = string.Format("SELECT * FROM T_11_005_{0} WHERE C006 = {1} AND C027 = '1'",
                                               strRentToken, orgID);
                        optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                        break;

                    case 3:
                        strSql = string.Format("SELECT * FROM T_11_005_{0} WHERE C006 = {1} AND C027 = '1'",
                                               strRentToken, orgID);
                        optReturn = OracleOperation.GetDataSet(strConn, strSql);
                        break;

                    default:
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                        optReturn.Message = string.Format("DBType invalid");
                        return(optReturn);
                    }
                    if (!optReturn.Result)
                    {
                        return(optReturn);
                    }
                    objDataSet = optReturn.Data as DataSet;
                    if (objDataSet == null)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_OBJECT_NULL;
                        optReturn.Message = string.Format("DataSet is null.");
                        return(optReturn);
                    }
                    if (objDataSet.Tables[0].Rows.Count <= 0)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_NOT_EXIST;
                        optReturn.Message = string.Format("TenantOrg admin not exist.");
                        return(optReturn);
                    }
                    DataRow dr = objDataSet.Tables[0].Rows[0];
                    orgAdminID = Convert.ToInt64(dr["C001"]);
                }
                if (orgAdminID <= 0)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("TenantOrg admin invalid.");
                    return(optReturn);
                }

                #endregion


                #region 首先获取该TenantOrgToken下的分机编号

                List <ExtensionInfo> listExts = new List <ExtensionInfo>();
                switch (dbType)
                {
                case 2:
                    strSql =
                        string.Format(
                            "SELECT C001 FROM T_11_101_{0} WHERE C001 > 1040000000000000000 AND C001 < 1050000000000000000 AND C002 = 3 AND C011 = '{1}' ORDER BY C001, C002",
                            strRentToken, tenantOrgToken);
                    optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                    break;

                case 3:
                    strSql =
                        string.Format(
                            "SELECT C001 FROM T_11_101_{0} WHERE C001 > 1040000000000000000 AND C001 < 1050000000000000000 AND C002 = 3 AND C011 = '{1}' ORDER BY C001, C002",
                            strRentToken, tenantOrgToken);
                    optReturn = OracleOperation.GetDataSet(strConn, strSql);
                    break;

                default:
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_PARAM_INVALID;
                    optReturn.Message = string.Format("DBType invalid");
                    return(optReturn);
                }
                if (!optReturn.Result)
                {
                    return(optReturn);
                }
                objDataSet = optReturn.Data as DataSet;
                if (objDataSet == null)
                {
                    optReturn.Result  = false;
                    optReturn.Code    = Defines.RET_OBJECT_NULL;
                    optReturn.Message = string.Format("DataSet is null");
                    return(optReturn);
                }
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow       dr   = objDataSet.Tables[0].Rows[i];
                    long          id   = Convert.ToInt64(dr["C001"]);
                    ExtensionInfo info = new ExtensionInfo();
                    info.ObjID = id;
                    listExts.Add(info);
                }

                #endregion


                IDbConnection    objConn;
                IDbDataAdapter   objAdapter;
                DbCommandBuilder objCmdBuilder;


                #region 遍历每个分机,获取分机的配置信息,然后更新分机信息

                bool isModify;
                for (int i = 0; i < listExts.Count; i++)
                {
                    ExtensionInfo extInfo = listExts[i];
                    long          id      = extInfo.ObjID;
                    switch (dbType)
                    {
                    case 2:
                        strSql = string.Format("SELECT * FROM T_11_101_{0} WHERE C001 = {1} ORDER BY C001, C002",
                                               strRentToken, id);
                        objConn       = MssqlOperation.GetConnection(strConn);
                        objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                        objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                        break;

                    case 3:
                        strSql = string.Format("SELECT * FROM T_11_101_{0} WHERE C001 = {1} ORDER BY C001, C002",
                                               strRentToken, id);
                        objConn       = OracleOperation.GetConnection(strConn);
                        objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                        objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                        break;

                    default:
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                        optReturn.Message = string.Format("DBType invalid");
                        return(optReturn);
                    }
                    if (objConn == null || objAdapter == null || objCmdBuilder == null)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_OBJECT_NULL;
                        optReturn.Message = string.Format("Database object is null");
                        return(optReturn);
                    }
                    objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                    objCmdBuilder.SetAllValues   = false;
                    try
                    {
                        objDataSet = new DataSet();
                        objAdapter.Fill(objDataSet);

                        for (int j = 0; j < objDataSet.Tables[0].Rows.Count; j++)
                        {
                            DataRow dr = objDataSet.Tables[0].Rows[j];

                            #region 更新

                            isModify = false;
                            int rowID = Convert.ToInt32(dr["C002"]);
                            if (rowID == 1)
                            {
                                string strExt01017 = dr["C017"].ToString();     //01017代表分机名称(分机号+IP的形式)
                                strExt01017 = DecryptFromDB(strExt01017);
                                string[] arrInfos = strExt01017.Split(new[] { ConstValue.SPLITER_CHAR },
                                                                      StringSplitOptions.None);
                                if (arrInfos.Length > 0)
                                {
                                    string strExt = arrInfos[0];
                                    extInfo.Extension = strExt;
                                }
                                string strExt01018 = dr["C018"].ToString();
                                strExt01018         = DecryptFromDB(strExt01018);
                                extInfo.ChannelName = strExt01018;
                            }
                            var temp = listExtensions.FirstOrDefault(e => e.Extension == extInfo.Extension);
                            if (temp != null)
                            {
                                temp.ObjID          = id;
                                extInfo.ChannelName = temp.ChannelName;
                                isModify            = true;
                                modifyNum++;
                            }
                            if (isModify)
                            {
                                string strExt01018 = extInfo.ChannelName;
                                strExt01018 = EncryptToDB(strExt01018);
                                if (rowID == 1)
                                {
                                    dr["C012"] = "1";
                                    dr["C013"] = "0";
                                    dr["C014"] = "0";
                                    dr["C015"] = "N";
                                    dr["C018"] = strExt01018;
                                }
                            }

                            #endregion
                        }

                        objAdapter.Update(objDataSet);
                        objDataSet.AcceptChanges();
                    }
                    catch (Exception ex)
                    {
                        optReturn.Result    = false;
                        optReturn.Code      = Defines.RET_FAIL;
                        optReturn.Message   = ex.Message;
                        optReturn.Exception = ex;
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                        objConn.Dispose();
                    }
                }

                #endregion


                #region 遍历每个分机,如果是需要新增的,增加分机信息

                bool isAdd = false;
                for (int i = 0; i < listExtensions.Count; i++)
                {
                    ExtensionInfo extInfo = listExtensions[i];
                    long          id      = extInfo.ObjID;
                    if (id <= 0)
                    {
                        isAdd = isAdd || true;
                    }
                }
                if (isAdd)
                {
                    switch (dbType)
                    {
                    case 2:
                        strSql = string.Format("SELECT * FROM T_11_101_{0} WHERE 1 = 2 ORDER BY C001, C002",
                                               strRentToken);
                        objConn       = MssqlOperation.GetConnection(strConn);
                        objAdapter    = MssqlOperation.GetDataAdapter(objConn, strSql);
                        objCmdBuilder = MssqlOperation.GetCommandBuilder(objAdapter);
                        break;

                    case 3:
                        strSql = string.Format("SELECT * FROM T_11_101_{0} WHERE 1 = 2 ORDER BY C001, C002",
                                               strRentToken);
                        objConn       = OracleOperation.GetConnection(strConn);
                        objAdapter    = OracleOperation.GetDataAdapter(objConn, strSql);
                        objCmdBuilder = OracleOperation.GetCommandBuilder(objAdapter);
                        break;

                    default:
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                        optReturn.Message = string.Format("DBType invalid");
                        return(optReturn);
                    }
                    if (objConn == null || objAdapter == null || objCmdBuilder == null)
                    {
                        optReturn.Result  = false;
                        optReturn.Code    = Defines.RET_OBJECT_NULL;
                        optReturn.Message = string.Format("Database object is null");
                        return(optReturn);
                    }
                    objCmdBuilder.ConflictOption = ConflictOption.OverwriteChanges;
                    objCmdBuilder.SetAllValues   = false;

                    try
                    {
                        objDataSet = new DataSet();
                        objAdapter.Fill(objDataSet);

                        for (int i = 0; i < listExtensions.Count; i++)
                        {
                            ExtensionInfo extInfo = listExtensions[i];
                            long          id      = extInfo.ObjID;
                            if (id <= 0)
                            {
                                #region 生成流水号

                                List <string> listSubParams = new List <string>();
                                listSubParams.Add("11");
                                listSubParams.Add("104");
                                listSubParams.Add(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                                optReturn = GetSerialID(listSubParams);
                                if (!optReturn.Result)
                                {
                                    return(optReturn);
                                }
                                id            = Convert.ToInt64(optReturn.Data.ToString());
                                extInfo.ObjID = id;

                                #endregion


                                #region 新增

                                DataRow dr1 = objDataSet.Tables[0].NewRow();
                                dr1["C001"] = id;
                                dr1["C002"] = 1;
                                dr1["C011"] = orgID;
                                dr1["C012"] = "1";
                                dr1["C013"] = "1";
                                dr1["C014"] = "0";
                                dr1["C015"] = "N";
                                dr1["C016"] = "05";
                                string str01017 = string.Format("{0}{1}{2}", extInfo.Extension, ConstValue.SPLITER_CHAR,
                                                                extInfo.ServerIP);
                                str01017    = EncryptToDB(str01017);
                                dr1["C017"] = str01017;
                                string str01018 = extInfo.ChannelName;
                                str01018    = EncryptToDB(str01018);
                                dr1["C018"] = str01018;

                                DataRow dr2 = objDataSet.Tables[0].NewRow();
                                dr2["C001"] = id;
                                dr2["C002"] = 2;

                                DataRow dr3 = objDataSet.Tables[0].NewRow();
                                dr3["C001"] = id;
                                dr3["C002"] = 3;
                                dr3["C011"] = tenantOrgToken;

                                objDataSet.Tables[0].Rows.Add(dr1);
                                objDataSet.Tables[0].Rows.Add(dr2);
                                objDataSet.Tables[0].Rows.Add(dr3);

                                addNum++;

                                #endregion


                                #region 新增的分机要添加到系统管理员权限列表中

                                if (id > 0)
                                {
                                    switch (dbType)
                                    {
                                    case 2:
                                        strSql =
                                            string.Format(
                                                "INSERT INTO T_11_201_{0} VALUES (0, 0, {1}, {2}, '2014/1/1', '2199/12/31')",
                                                strRentToken, ConstValue.USER_ADMIN, id);
                                        optReturn = MssqlOperation.ExecuteSql(strConn, strSql);
                                        break;

                                    case 3:
                                        strSql =
                                            string.Format(
                                                "INSERT INTO T_11_201_{0} VALUES (0, 0, {1}, {2}, TO_DATE('2014/1/1','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2199/12/31','YYYY-MM-DD HH24:MI:SS'))",
                                                strRentToken, ConstValue.USER_ADMIN, id);
                                        optReturn = OracleOperation.ExecuteSql(strConn, strSql);
                                        break;

                                    default:
                                        optReturn.Result  = false;
                                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                                        optReturn.Message = string.Format("DBType invalid");
                                        return(optReturn);
                                    }
                                    if (!optReturn.Result)
                                    {
                                        return(optReturn);
                                    }
                                }

                                #endregion


                                #region 新增的分机要添加到租户管理员的管理权限列表中

                                if (id > 0)
                                {
                                    switch (dbType)
                                    {
                                    case 2:
                                        strSql =
                                            string.Format(
                                                "INSERT INTO T_11_201_{0} VALUES (0, 0, {1}, {2}, '2014/1/1', '2199/12/31')",
                                                strRentToken, orgAdminID, id);
                                        optReturn = MssqlOperation.ExecuteSql(strConn, strSql);
                                        break;

                                    case 3:
                                        strSql =
                                            string.Format(
                                                "INSERT INTO T_11_201_{0} VALUES (0, 0, {1}, {2}, TO_DATE('2014/1/1','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2199/12/31','YYYY-MM-DD HH24:MI:SS'))",
                                                strRentToken, orgAdminID, id);
                                        optReturn = OracleOperation.ExecuteSql(strConn, strSql);
                                        break;

                                    default:
                                        optReturn.Result  = false;
                                        optReturn.Code    = Defines.RET_PARAM_INVALID;
                                        optReturn.Message = string.Format("DBType invalid");
                                        return(optReturn);
                                    }
                                    if (!optReturn.Result)
                                    {
                                        return(optReturn);
                                    }
                                }

                                #endregion
                            }
                        }

                        objAdapter.Update(objDataSet);
                        objDataSet.AcceptChanges();
                    }
                    catch (Exception ex)
                    {
                        optReturn.Result    = false;
                        optReturn.Code      = Defines.RET_FAIL;
                        optReturn.Message   = ex.Message;
                        optReturn.Exception = ex;
                    }
                    finally
                    {
                        if (objConn.State == ConnectionState.Open)
                        {
                            objConn.Close();
                        }
                        objConn.Dispose();
                    }
                }

                #endregion


                listReturn.Add(addNum.ToString());
                listReturn.Add(modifyNum.ToString());
                optReturn.Data = listReturn;

                #endregion
            }
            catch (Exception ex)
            {
                optReturn.Result    = false;
                optReturn.Code      = Defines.RET_FAIL;
                optReturn.Message   = ex.Message;
                optReturn.Exception = ex;
            }
            return(optReturn);
        }
Ejemplo n.º 21
0
        void BtnTest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (mSession == null)
                {
                    return;
                }
                var dbInfo = mSession.DatabaseInfo;
                if (dbInfo == null)
                {
                    return;
                }
                int             dbType = dbInfo.TypeID;
                OperationReturn optReturn;
                List <LicModel> listLicModels = new List <LicModel>();
                string          strSql;
                string          strConn = dbInfo.GetConnectionString();
                switch (dbType)
                {
                case 2:
                    //strSql = string.Format("SELECT A.C001 AS AC001, A.C002 AS AC002, A.C003 AS AC003, A.C004 AS AC004, A.C016 AS AC016, B.C005 AS BC005 FROM T_11_003_00000 A, T_00_005 B WHERE 'FO'+ A.C002 = B.C002 AND A.C016 > 0  AND B.C001 = '1033' ORDER BY A.C001,A.C002");
                    strSql    = string.Format("SELECT * FROM T_11_003_00000 WHERE C016 > 0 ORDER BY C002");
                    optReturn = MssqlOperation.GetDataSet(strConn, strSql);
                    break;

                case 3:
                    //strSql = string.Format("SELECT A.C001 AS AC001, A.C002 AS AC002, A.C003 AS AC003, A.C004 AS AC004, A.C016 AS AC016, B.C005 AS BC005 FROM T_11_003_00000 A, T_00_005 B WHERE 'FO'|| A.C002 = B.C002 AND A.C016 > 0  AND B.C001 = '1033' ORDER BY A.C001,A.C002");
                    strSql    = string.Format("SELECT * FROM T_11_003_00000 WHERE C016 > 0  ORDER BY C002");
                    optReturn = OracleOperation.GetDataSet(strConn, strSql);
                    break;

                default:
                    ShowException(string.Format("DBType invalid"));
                    return;
                }
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                DataSet objDataSet = optReturn.Data as DataSet;
                if (objDataSet == null)
                {
                    ShowException(string.Format("DataSet is null"));
                    return;
                }
                for (int i = 0; i < objDataSet.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = objDataSet.Tables[0].Rows[i];

                    LicModel info = new LicModel();
                    //info.MasterID = Convert.ToInt32(dr["AC001"]);
                    //info.OptID = Convert.ToInt64(dr["AC002"]);
                    //info.ParentID = Convert.ToInt64(dr["AC003"]);
                    //info.SortID = Convert.ToInt32(dr["AC004"]);
                    //info.LicNo = Convert.ToInt32(dr["AC016"]);
                    //info.LicID = 1000000000 + info.OptID;
                    //info.OptName = dr["BC005"].ToString();
                    info.MasterID = Convert.ToInt32(dr["C001"]);
                    info.OptID    = Convert.ToInt64(dr["C002"]);
                    info.ParentID = Convert.ToInt64(dr["C003"]);
                    long parentID = info.ParentID;
                    if (parentID > 9999)
                    {
                        parentID      = int.Parse(parentID.ToString().Substring(0, 4));
                        info.ParentID = parentID;
                    }
                    info.SortID  = Convert.ToInt32(dr["C004"]);
                    info.LicNo   = Convert.ToInt32(dr["C016"]);
                    info.LicID   = 1000000000 + info.OptID;
                    info.OptName = dr["C017"].ToString();
                    listLicModels.Add(info);
                }
                LicDefineFile licFile = new LicDefineFile();
                licFile.LicID = 1100101;
                for (int i = 0; i < listLicModels.Count; i++)
                {
                    licFile.ListLics.Add(listLicModels[i]);
                }
                string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, LicDefineFile.FILE_NAME);
                optReturn = XMLHelper.SerializeFile(licFile, path);
                if (!optReturn.Result)
                {
                    ShowException(string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message));
                    return;
                }
                MessageBox.Show("End", "Demo", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                ShowException(ex.Message);
            }
        }