/// <summary> /// 得到游戏角色列表,客服主页用 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static DataSet GetGameRoleCRALL(string value) { try { string sql = @"SELECT F_Name,F_Value FROM T_GameConfig WITH(NOLOCK) where F_ParentID=1000"; DataSet dsc = DbHelperSQL.Query(sql); DataSetRowsLog(dsc, "GetGameRoleCRALL [step] T_GameConfig"); if (dsc == null) { return(null); } string url = ""; DataSet ds = null; string[] values = value.Split('|'); foreach (DataRow dr in dsc.Tables[0].Rows) { url = dr["F_Value"].ToString(); if (url.Trim().Length == 0) { continue; } else { webserv.Url = url; string.Format("{0}/{1}", url, "GetGameRoleCR").Logger(); webserv.Credentials = System.Net.CredentialCache.DefaultCredentials; byte[] bytes = webserv.GetGameRoleCR(values[1]); DataSet dstemp = DataSerialize.GetDatasetFromByte(bytes); if (dstemp != null) { dstemp.Tables[0].Columns.Add("F_BigZoneName", System.Type.GetType("System.String")); foreach (DataRow drt in dstemp.Tables[0].Rows) { drt["F_BigZoneName"] = dr["F_Name"].ToString(); } if (ds == null) { ds = dstemp.Copy(); } else { ds.Tables[0].Merge(dstemp.Tables[0]); } } } } DataSetRowsLog(ds, "GetGameRoleCRALL"); return(ds); } catch (System.Exception ex) { ex.Message.Logger(typeof(GSSServer.WebServiceLib).Name); //日志记录 ShareData.Log.Error("得到WEBSERVICE游戏角色列表错误\r\n" + ex.Message, ex); return(null); } }
/// <summary> /// 得到游戏角色列表,客服主页用 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static DataSet GetGameRoleCR(string value) { try { string.Format("GetGameRoleCR->param:[ {0} ]", value).Logger(); string[] values = value.Split('|'); string url = GetWebServUrl("1000", values[0]); string whereStr = values[1]; if (url.Trim().Length == 0) { string.Format("GetGameRoleCR->query url is null").Logger(); return(null); } else { webserv.Url = url; webserv.Credentials = System.Net.CredentialCache.DefaultCredentials; } string.Format("will call {0}/GetGameRoleCR", url).Logger(); byte[] bytes = webserv.GetGameRoleCR(whereStr); DataSet ds = DataSerialize.GetDatasetFromByte(bytes); DataSetRowTotalLog(ds, typeof(WebServiceLib).Name + ".GetGameRoleCR"); return(ds); } catch (System.Exception ex) { //日志记录 ShareData.Log.Error("得到WEBSERVICE游戏角色列表错误\r\n" + ex.Message, ex); return(null); } }
public byte[] QueryLiveGSLog(string querysql) { if (GetIP4Address() != GSSServerIP) { string erro = "非法请求,将拒绝对此请求提供服务,请求IP:" + GetIP4Address() + " "; Log.Warn(erro); return(DataSerialize.GetDataSetSurrogateZipBYtes(GetErrorDS(erro))); } if (ConnStrGsLogDB.Trim() == string.Empty) { string erro = "非法请求,将拒绝对此实时请求提供服务"; Log.Warn(erro); return(DataSerialize.GetDataSetSurrogateZipBYtes(GetErrorDS(erro))); } if (!CheckQuerySql(querysql)) { string erro = "非法请求,将拒绝对此实时请求提供服务(SQL)"; Log.Warn(erro); return(DataSerialize.GetDataSetSurrogateZipBYtes(GetErrorDS(erro))); } try { DbHelperMySQLP sp = new DbHelperMySQLP(ConnStrGsLogDB); DataSet ds = sp.Query(querysql); return(DataSerialize.GetDataSetSurrogateZipBYtes(ds)); } catch (System.Exception ex) { string erro = "MYSQL战区日志实时库查询(实时方式)查询操作错误[" + ex.Message + "]"; Log.Error(erro, ex); return(DataSerialize.GetDataSetSurrogateZipBYtes(GetErrorDS(erro))); } }
/// <summary> /// 从缓存文件中得到DATASET /// </summary> public static DataSet GetCacheDS() { string cachePath = System.Windows.Forms.Application.StartupPath; ("cache dir" + cachePath).Logger(); string fileName = cachePath + "\\GSSData\\GSSCache\\DBCache.dat"; FileInfo file = new FileInfo(fileName); //if (!file.Exists) //{ // return null; //} try { mtx.WaitOne(); StreamReader CacheInfo = new StreamReader(fileName); string cache = CacheInfo.ReadToEnd(); byte[] cachebytes = Convert.FromBase64String(cache); DataSet ds = DataSerialize.GetDatasetFromByte(cachebytes); CacheInfo.Close(); mtx.ReleaseMutex(); return(ds); } catch (System.Exception ex) { "ClientCache Exception ".ErrorLogger(); ex.ToString().ErrorLogger(); //日志记录 ShareData.Log.Error(ex); return(null); } }
/// <summary> /// 工单列表:从缓存文件中得到DATASET /// </summary> public static DataSet GetTaskCache(string cachename) { string fileName = System.Windows.Forms.Application.StartupPath + "\\GSSData\\GSSCache\\TaskCache" + cachename + ".dat"; FileInfo file = new FileInfo(fileName); if (!file.Exists) { return(null); } try { mtx.WaitOne(); StreamReader CacheInfo = new StreamReader(fileName); string cache = CacheInfo.ReadToEnd(); byte[] cachebytes = Convert.FromBase64String(cache); DataSet ds = DataSerialize.GetDatasetFromByte(cachebytes); CacheInfo.Close(); mtx.ReleaseMutex(); return(ds); } catch (System.Exception ex) { ex.ToString().ErrorLogger(); //日志记录 ShareData.Log.Error(ex); return(null); } }
private void lblDownTemplae_Click(object sender, EventArgs e) { //下载模本(从服务端下载) string lang = System.Threading.Thread.CurrentThread.CurrentCulture.Name; string file = typeof(FormSendEmail).Name + ".xlsx"; FolderBrowserDialog folderDialog = new FolderBrowserDialog(); if (folderDialog.ShowDialog() == DialogResult.OK) { //从服务器下载模本文件 GSSModel.TemplateFile tem = new GSSModel.TemplateFile() { TemplateName = file, SystemLang = lang }; GSSCSFrameWork.MsgStruts response = Client.DownloadTemplateFile(tem); if (response.msgsendstate != GSSCSFrameWork.msgSendState.None) { FileStream fs = new FileStream(folderDialog.SelectedPath + "//" + file, FileMode.Create, FileAccess.Write); fs.Write(response.Data, 0, response.Data.Length); fs.Close(); } else { string msg = DataSerialize.GetObjectFromByte(response.Data) as string; MsgBox.Show(msg, LanguageResource.Language.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// 查询GS日志同步库(离线) /// </summary> public static byte[] QuerySynGSLog(string zoneid, string querysql) { string url = ""; try { url = GetWebServUrlID1(zoneid.ToString()); if (url.Trim().Length == 0) { return(DataSerialize.GetDataSetSurrogateZipBYtes(GetErrorDS("WEBSERVICE查询GS日志同步库(离线)错误:获取URL错误"))); } else { WebServiceZone.Url = url; WebServiceZone.Credentials = System.Net.CredentialCache.DefaultCredentials; } byte[] bytes = WebServiceZone.QuerySynGSLog(querysql); return(bytes); } catch (System.Exception ex) { //日志记录 ShareData.Log.Error("WEBSERVICE查询GS日志同步库(离线)错误\r\n" + url + "" + ex.Message, ex); return(DataSerialize.GetDataSetSurrogateZipBYtes(GetErrorDS("WEBSERVICE查询GS日志同步库(离线)错误" + ex.Message))); } }
/// <summary> /// 编辑工单(服务端不回复信息) /// </summary> public void EditTaskNoReturn(GSSModel.Tasks task) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.EditTaskNoReturn; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.Data = DataSerialize.GetByteFromObject(task); _tcpcli.Send(msg); }
private void LoginComplateQueryCacheCallBack(object cache) { "loading cache end".Logger(); MsgStruts msgb = cache as MsgStruts; try { if (cache == null) { this.DialogResult = DialogResult.No; string tip = "Error,please see above tip. "; tip.Logger(); ShareData.Log.Info(tip); MsgBox.Show(LanguageResource.Language.Tip_LoseCacheRefuseComing, LanguageResource.Language.Tip_Tip, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); return; } System.Data.DataSet ds = DataSerialize.GetDatasetFromByte(msgb.Data); if (ds == null || ds.Tables.Count == 0) { string temp = "Because the network query Cache error.refuse use login,in fact use login success"; temp.Logger(); this.DialogResult = DialogResult.No; ShareData.Log.Info(temp); MsgBox.Show(LanguageResource.Language.Tip_LoseCacheRefuseComing, LanguageResource.Language.Tip_Tip, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); return; } int tables = ds.Tables.Count; if (SystemConfig.SyncVersionCache) { DataTable version = ds.Tables["T_Version"]; object obj = version.Rows[0]["F_DB_Version"]; ds.Tables["T_Version"].Dispose(); string ver = string.Empty; if (obj != null) { ver = obj.ToString(); } //转换为文件流 System.IO.StreamWriter sr = new System.IO.StreamWriter(System.Windows.Forms.Application.StartupPath + "/GSSDATA/Version.DAT", false); sr.Write(ver); sr.Close(); } (" [table]" + tables).Logger(); ClientCache.SetCache(msgb.Data); ShareData.UserPower = ClientCache.GetUserPower(ShareData.UserID); this.DialogResult = DialogResult.OK; "cache convert complae".Logger(); } catch (Exception ex) { ex.ToString().ErrorLogger(); MsgBox.Show(ex.Message, LanguageItems.BaseLanguageItem.Tip_Tip, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 增加工单 /// </summary> /// <param name="task"></param> public MsgStruts DownloadTemplateFile(GSSModel.TemplateFile task) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.DownloadTemplateFile; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.Data = DataSerialize.GetByteFromObject(task); MsgStruts msgb = _tcpcli.SendAndBack(msg); return(msgb); }
public void SendTextToService(GSSModel.Request.ClientData data, msgCommand command) { MsgStruts str = new MsgStruts() { msgsendstate = msgSendState.single, msgtype = msgType.SendText, command = command }; str.Data = DataSerialize.GetByteFromObject(data); _tcpcli.Send(str); }
/// <summary> /// 同步游戏中的战区和战线到GSS系统的配置表 /// </summary> /// <returns></returns> public static string SynGameZoneLine() { try { string sql = @"SELECT F_ID,F_Name, F_Value, F_ValueGame FROM T_GameConfig WHERE (F_ParentID = 1000)"; DataSet ds = DbHelperSQL.Query(sql); if (ds == null || ds.Tables[0].Rows.Count == 0) { return("true"); } string reback = ""; foreach (DataRow dr in ds.Tables[0].Rows) { string url = dr["F_Value"].ToString(); webserv.Url = url; webserv.Credentials = System.Net.CredentialCache.DefaultCredentials; DataSet dszl = DataSerialize.GetDatasetFromByte(webserv.GetZoneLine()); if (dszl == null || ds.Tables[0].Rows.Count == 0) { continue; } sql = @"delete from T_GameConfig where F_ParentID=" + dr["F_ID"].ToString() + " "; DbHelperSQL.ExecuteSql(sql); int i = 0; foreach (DataRow drz in dszl.Tables[0].Select("F_GParentID=0", "F_GID ASC")) { i++; string id = dr["F_ID"].ToString() + i.ToString().PadLeft(2, '0'); sql = @"INSERT INTO T_GameConfig (F_ID,F_ParentID, F_Name, F_Value, F_ValueGame, F_IsUsed, F_Sort) VALUES (" + id + "," + dr["F_ID"] + ", N'" + drz["F_GName"] + "', N'', N'" + drz["F_GID"] + "', 1, 0)"; DbHelperSQL.ExecuteSql(sql); sql = @"delete from T_GameConfig where F_ParentID=" + id + " "; DbHelperSQL.ExecuteSql(sql); int ii = 0; foreach (DataRow drl in dszl.Tables[0].Select(" F_GParentID=" + drz["F_GID"] + " and F_GParentID<>0 ")) { ii++; string idl = id + ii.ToString().PadLeft(2, '0'); sql = @"INSERT INTO T_GameConfig (F_ID,F_ParentID, F_Name, F_Value, F_ValueGame, F_IsUsed, F_Sort) VALUES (" + idl + "," + id + ", N'" + drl["F_GName"] + "', N'', N'" + drl["F_GID"] + "', 1, 0)"; DbHelperSQL.ExecuteSql(sql); } } } } catch (System.Exception ex) { ShareData.Log.Error(ex); return(ex.Message); } return("true"); }
public void SendTaskContainerLogicData(GSSModel.Request.ClientData data) { MsgStruts str = new MsgStruts() { msgsendstate = msgSendState.single, msgtype = msgType.SendText, command = msgCommand.CreateTaskContainerLogic }; str.Data = DataSerialize.GetByteFromObject(data); string.Format("command:[{0}] Client send service bytes:[{1}]", str.command, str.Data.Length); _tcpcli.Send(str); }
private void SendAlert(Session Client) { Session client = (Session)_tcpsvr.SessionTable[Client.ID]; DataSet ds = dbhandle.GetAlertNum(); MsgStruts msg = new MsgStruts(); msg.command = msgCommand.GetAlertNum; msg.msgtype = msgType.SendDataset; msg.msgsendstate = msgSendState.single; msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); _tcpsvr.Send(client, msg); }
/// <summary> /// 得到客户端缓存(同步) /// </summary> public bool GetCahceSyn(string userid) { TcpCli client = new TcpCli(ShareData.LocalIp, ShareData.LocalPort); MsgStruts msg = new MsgStruts(); msg.command = msgCommand.GetCache; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.Data = _coder.GetEncodingBytes(userid); MsgStruts msgb = client.SendAndBack(msg); DataSet ds = DataSerialize.GetDatasetFromByte(msgb.Data); return(ClientCache.SetCache(msgb.Data)); }
/// <summary> /// 执行存储过程 /// </summary> /// <param name="formid"></param> /// <param name="proname"></param> /// <param name="parameters"></param> public void ExcPro(string formid, string proname, SqlParameter parameters) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.ExcPro; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; string param = DataSerialize.GetStringFromSqlParameter(parameters); string sqlStr = formid + "|" + proname + "|" + param;//格式 窗口ID+存储过程+参数 msg.Data = _coder.GetEncodingBytes(sqlStr); _tcpcli.Send(msg); }
/// <summary> /// 编辑工单(同步) /// </summary> /// <param name="task"></param> public string EditTaskSyn(GSSModel.Tasks task) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.EditTask; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.Data = DataSerialize.GetByteFromObject(task); MsgStruts msgb = _tcpcli.SendAndBack(msg); string backStr = _coder.GetEncodingString(msgb.Data, msgb.Data.Length); return(backStr); }
/// <summary> /// 得到工单列表(同步) /// </summary> /// <param name="whereStr"></param> public DataSet GetAllTasksSyn(string whereStr) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.GetAllTasks; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.Data = _coder.GetEncodingBytes(whereStr); MsgStruts msgb = _tcpcli.SendAndBack(msg); DataSet ds = DataSerialize.GetDatasetFromByte(msgb.Data); ClientCache.SetTaskCache(msgb.Data, "TaskList"); return(ds); }
public void BindCommandWithSend(msgCommand cmd, int formid, GSSModel.Tasks task, object sendData) { MsgStruts msg = new MsgStruts(); msg.command = cmd; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; GSSModel.Request.ClientData client = new GSSModel.Request.ClientData(); client.FormID = formid; client.Data = new object[] { task, sendData }; //json 序列化 msg.Data = DataSerialize.GetByteFromObject(client); _tcpcli.Send(msg); }
public void AddFullServiceEmail(int formId, GSSModel.Request.LoginAwardTask awardTask) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.AddFullServiceEmail; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; GSSModel.Request.ClientData data = new GSSModel.Request.ClientData() { FormID = formId, Data = awardTask }; msg.Data = DataSerialize.GetByteFromObject(data); _tcpcli.Send(msg); }
/// <summary> /// 得到游戏用户列表,客服主页用 /// </summary> /// <param name="query"></param> /// <returns></returns> public DataSet GSSTool_GetGameUser(string bigzone, string query) { string sql = @"SELECT top 1 F_Name,F_Value FROM T_GameConfig WITH(NOLOCK) where F_ParentID=1000 and F_Name='" + bigzone + "'"; DataSet dsc = DbHelperSQL.Query(sql); if (dsc == null) { throw (new ApplicationException("没有此大区的配置项:" + bigzone)); } string url = ""; DataSet ds = null; url = dsc.Tables[0].Rows[0]["F_Value"].ToString(); if (url.Trim().Length == 0) { throw (new ApplicationException("此大区的URL为空:" + bigzone));; } else { // ServiceXLJ.ServiceXLJSoapClient webserv = new ServiceXLJ.ServiceXLJSoapClient(); ServiceXLJ.ServiceXLJSoapClient webserv = new ServiceXLJ.ServiceXLJSoapClient("ServiceXLJSoap", url); //webserv.Endpoint.Address=(System.ServiceModel.EndpointAddress)url; byte[] bytes = webserv.GetGameUsersC(query); DataSet dstemp = DataSerialize.GetDatasetFromByte(bytes); if (dstemp != null) { dstemp.Tables[0].Columns.Add("F_BigZoneName", System.Type.GetType("System.String")); foreach (DataRow drt in dstemp.Tables[0].Rows) { drt["F_BigZoneName"] = dsc.Tables[0].Rows[0]["F_Name"].ToString(); } if (ds == null) { ds = dstemp.Copy(); } else { ds.Tables[0].Merge(dstemp.Tables[0]); } } } return(ds); }
/// <summary> /// 增加工单(发奖) /// </summary> /// <param name="task"></param> public string AddTaskSynGA(GSSModel.Tasks task, DataSet ds) { task.F_URInfo = DataSerialize.GetStringFromObject(DataSerialize.GetDataSetSurrogateZipBYtes(ds)); MsgStruts msg = new MsgStruts(); msg.command = msgCommand.AddTask; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.MsgParam.p0 = "AddTaskGA"; msg.Data = DataSerialize.GetByteFromObject(task); MsgStruts msgb = _tcpcli.SendAndBack(msg); string backStr = _coder.GetEncodingString(msgb.Data, msgb.Data.Length); return(backStr); }
/// <summary> /// 得到工单列表(同步) /// </summary> /// <param name="whereStr"></param> public DataSet GetAllTasksSyn(string param, string whereStr, string OrderFieldName, string OrderType, int PageSize, int PageIndex) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.GetAllTasks; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.MsgParam.p0 = param; msg.MsgParam.p1 = OrderFieldName; msg.MsgParam.p2 = OrderType; msg.MsgParam.p3 = PageSize.ToString(); msg.MsgParam.p4 = PageIndex.ToString(); msg.Data = _coder.GetEncodingBytes(whereStr); MsgStruts msgb = _tcpcli.SendAndBack(msg); DataSet ds = DataSerialize.GetDatasetFromByte(msgb.Data); ClientCache.SetTaskCache(msgb.Data, "TaskList"); return(ds); }
/// <summary> /// 游戏工具:实时查询GS日志 /// </summary> public DataSet QueryLiveGSLog(string zoneid, string querysql) { MsgStruts msg = new MsgStruts(); msg.command = msgCommand.QueryLiveGSLog; msg.msgtype = msgType.SendText; msg.msgsendstate = msgSendState.single; msg.MsgParam.p0 = zoneid; msg.MsgParam.p1 = querysql; MsgStruts msgb = _tcpcli.SendAndBack(msg); if (msgb == null) { return(null); } DataSet ds = DataSerialize.GetDatasetFromByte(msgb.Data); ClientCache.SetTaskCache(msgb.Data, "QueryLiveGSLog"); return(ds); }
public void SendAlert() { try { lock (_tcpsvr.dic.Values) { List <object> clients = new List <object>(_tcpsvr.dic.Values); foreach (object client in clients) { Session Client = (Session)client; if (Client != null && Client.TypeOfExit == Session.ExitType.NoExit) { try { DataSet ds = dbhandle.GetAlertNum(); MsgStruts msg = new MsgStruts(); msg.command = msgCommand.GetAlertNum; msg.msgtype = msgType.SendDataset; msg.msgsendstate = msgSendState.single; msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); _tcpsvr.Send(Client, msg); System.Threading.Thread.Sleep(100); } catch (System.Exception ex) { ex.ToString().ErrorLogger(); //日志记录 ShareData.Log.Warn(ex); // _tcpsvr.CloseSession(Client); } } } } } catch (System.Exception ex) { ex.ToString().ErrorLogger(); //日志记录 ShareData.Log.Error("GSS发送提醒数字错误:", ex); } }
/// <summary> /// 得到游戏角色列表,客服主页用 /// </summary> /// <param name="userid"></param> /// <returns></returns> public static DataSet GetGameRoleC(string value) { try { value = value.Trim(); string.Format("class:{0},function:{1} is runing,param :[ {2} ]", typeof(WebServiceLib).Name, "GetGameRoleC", value).Logger(); string[] values = value.Split('|'); string url = GetWebServUrl("1000", values[0]); string userid = values[1]; if (url.Trim().Length == 0) { "query web url is: null".Logger(); return(null); } else { string.Format("query web url is :", url).Logger(); webserv.Url = url; webserv.Credentials = System.Net.CredentialCache.DefaultCredentials; } byte[] bytes = webserv.GetGameRoleC(userid); if (bytes == null) { "call wcf :[GetGameRoleC] ,query result is :null".Logger(); return(null); } else { string.Format("call wcf :[GetGameRoleC] ,query result is[byte]:{0}", bytes.Length).Logger(); } DataSet ds = DataSerialize.GetDatasetFromByte(bytes); return(ds); } catch (System.Exception ex) { ex.Message.Logger(); //日志记录 ShareData.Log.Error("得到WEBSERVICE游戏角色列表错误\r\n" + ex.Message, ex); return(null); } }
/// <summary> /// 处理接收到的请求 /// </summary> /// <param name="Client"></param> /// <param name="recevStr"></param> public void DoRequest(Session Client, MsgStruts msg) { if (Client == null || msg == null || Client.TypeOfExit != Session.ExitType.NoExit) { ShareData.Log.Info(msg.command + "未返回数据"); return; } string msgStr; DataSet ds; string backStr; string[] msgs; MsgStruts callBack = new MsgStruts() { msgsendstate = msgSendState.single, msgtype = msgType.SendText }; ClientData fromClientData; try { string.Format("command->" + msg.command).Logger(); switch (msg.command) { case msgCommand.GetLogin: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgs = msgStr.Split('|'); if (msgs.Length != 3) { backStr = "false"; } else { backStr = dbhandle.Login(msgs[0], msgs[1], msgs[2]); } msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GetCache: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); ds = dbhandle.GetCache(); msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); // ShareData.Log.Warn(msg.Data); _tcpsvr.Send(Client, msg); // _tcpsvr.SendDataContainerBuffer(Client, msg);//cache data to the client will change to some package System.Threading.Thread.Sleep(800); ((Session)TcpSvr.SessionTable[Client.ID]).UserID = msgStr; SendAlertNum(Client); break; case msgCommand.GetAlertNum: System.Threading.Thread.Sleep(800); SendAlertNum(); break; case msgCommand.GetAllTasks: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgStr.Logger(); ds = dbhandle.GetTask(msgStr, msg.MsgParam.p1, msg.MsgParam.p2, Convert.ToInt16(msg.MsgParam.p3), Convert.ToInt16(msg.MsgParam.p4)); WebServiceLib.DataSetRowsLog(ds, "Service query cmd:" + msgCommand.GetAllTasks); msg.MsgParam.p6 = dbhandle.GetTaskCount(msgStr).ToString(); msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); _tcpsvr.Send(Client, msg); //dbhandle.SysLog(((Session)TcpSvr.SessionTable[Client.ID]).UserID, "工单列表", msgStr); break; case msgCommand.GetTaskLog: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); ds = dbhandle.GetTaskLog(msgStr); msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); _tcpsvr.Send(Client, msg); break; case msgCommand.GetGameUsersC: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); "GetGameUsersC".Logger(); msgStr.Logger(); ds = WebServiceLib.GetGameUsersC(msgStr); if (ds != null && ds.Tables.Count > 0) { string.Format("Service Query game user number:[{0}]", ds.Tables[0].Rows.Count).Logger(); } else { string.Format("Service Query game user number:[{0}]", 0).Logger(); } msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); _tcpsvr.Send(Client, msg); break; case msgCommand.GetGameRolesC: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); "GetGameRoleC".Logger(); msgStr.Logger(); ds = WebServiceLib.GetGameRoleC(msgStr); WebServiceLib.DataSetRowsLog(ds, typeof(ServerHandle).Name + "." + msgCommand.GetGameRolesC); if (ds != null) { msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); } _tcpsvr.Send(Client, msg); break; case msgCommand.GetGameRolesCR: msgCommand.GetGameRolesCR.ToString().Logger(); msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); ("Query where:" + msgStr).Logger(); ds = WebServiceLib.GetGameRoleCRALL(msgStr); WebServiceLib.DataSetRowsLog(ds, msgCommand.GetGameRolesCR + " Totla"); msg.Data = DataSerialize.GetDataSetSurrogateZipBYtes(ds); _tcpsvr.Send(Client, msg); break; case msgCommand.AddTask: GSSModel.Tasks task = (GSSModel.Tasks)DataSerialize.GetObjectFromByte(msg.Data); int id = dbhandle.AddTask(task); if (task.F_Type.ToString() == "2203") { backStr = WebServiceLib.DisChatAdd(task); } else if (task.F_Type.ToString() == "2213") { backStr = WebServiceLib.DisChatDel(task); } msg.Data = _coder.GetEncodingBytes(id.ToString()); _tcpsvr.Send(Client, msg); System.Threading.Thread.Sleep(800); SendAlertNum(); break; case msgCommand.EditTask: task = (GSSModel.Tasks)DataSerialize.GetObjectFromByte(msg.Data); id = dbhandle.EditTask(task); msg.Data = _coder.GetEncodingBytes(id.ToString()); _tcpsvr.Send(Client, msg); System.Threading.Thread.Sleep(800); SendAlertNum(); break; case msgCommand.EditTaskNoReturn: task = (GSSModel.Tasks)DataSerialize.GetObjectFromByte(msg.Data); id = dbhandle.EditTask(task); msg.Data = _coder.GetEncodingBytes(id.ToString()); _tcpsvr.Send(Client, msg); break; case msgCommand.EditTaskLog: task = (GSSModel.Tasks)DataSerialize.GetObjectFromByte(msg.Data); id = dbhandle.EditTaskLog(task); msg.Data = _coder.GetEncodingBytes(id.ToString()); _tcpsvr.Send(Client, msg); System.Threading.Thread.Sleep(800); SendAlertNum(); break; case msgCommand.ExcSql: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); string[] formsql = msgStr.Split('|'); //分为两段,执行SQL语句的窗口ID和语句 int rowcount = dbhandle.ExeSql(formsql[1]); backStr = formsql[0] + "|" + rowcount; msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.ExcPro: msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); string[] pformsql = msgStr.Split('|');////格式 窗口ID+存储过程+参数 string proname = pformsql[1]; SqlParameter[] param = DataSerialize.GetSqlParameterFromString(pformsql[2]); break; case msgCommand.GameLockUR: //格式 窗口ID+封停用户还是角色+工单编号+封停时间 msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgs = GetParam(msgStr); string formid = msgs[0]; string doStr = WebServiceLib.URlock(msgs[1], msgs[2], msgs[3]); backStr = formid + "|" + doStr; msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameNoLockUR: //格式 窗口ID+封停用户还是角色+工单编号 msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgs = GetParam(msgStr); formid = msgs[0]; doStr = WebServiceLib.URNolock(msgs[1], msgs[2]); backStr = formid + "|" + doStr; msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameUserUse: //格式 窗口ID+工单编号 msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgs = GetParam(msgStr); formid = msgs[0]; doStr = WebServiceLib.GameUserUse(msgs[1], msgs[2]); backStr = formid + "|" + doStr; msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameUserNoUse: //格式 窗口ID+工单编号 msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgs = GetParam(msgStr); formid = msgs[0]; doStr = WebServiceLib.GameUserNoUse(msgs[1]); backStr = formid + "|" + doStr; msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameResetChildInfo: //格式 窗口ID+工单编号 msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); msgs = GetParam(msgStr); formid = msgs[0]; doStr = WebServiceLib.GameResetChildInfo(msgs[1]); backStr = formid + "|" + doStr; msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameNoticeStart: backStr = WebServiceLib.GameNoticeStart(msg.MsgParam.p0); msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameNoticeStop: backStr = WebServiceLib.GameNoticeStop(msg.MsgParam.p0); msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.DeleteFullServiceEmail: backStr = WebServiceLib.DeleteFullServiceEmail(msg.MsgParam.p0); msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.GameGiftAwardDo: backStr = WebServiceLib.GameGiftAwardDo(msg.MsgParam.p0); msg.Data = _coder.GetEncodingBytes(backStr); _tcpsvr.Send(Client, msg); break; case msgCommand.QuerySynGSLog: msg.Data = WebServiceLib.QuerySynGSLog(msg.MsgParam.p0, msg.MsgParam.p1); _tcpsvr.Send(Client, msg); break; case msgCommand.QueryLiveGSLog: msg.Data = WebServiceLib.QueryLiveGSLog(msg.MsgParam.p0, msg.MsgParam.p1); _tcpsvr.Send(Client, msg); break; case msgCommand.DownloadTemplateFile: //下载模本文件 object obj = DataSerialize.GetObjectFromByte(msg.Data); GSSModel.TemplateFile tem = obj as GSSModel.TemplateFile; System.IO.MemoryStream ms = new System.IO.MemoryStream(); System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); //二进制序列化类 if (tem != null) { msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); string path = AppDomain.CurrentDomain.BaseDirectory + "\\Resources\\Template\\"; string file = path + tem.SystemLang + "\\" + tem.TemplateName; if (!File.Exists(file)) { msg.msgsendstate = msgSendState.None; bf.Serialize(ms, string.Format(LanguageResource.Language.Tip_ServiceLackTemplateFormat, tem.TemplateName)); //将消息类转换为内存流 msg.Data = ms.ToArray(); } else { FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read); byte[] bb = new byte[1024]; List <byte> stream = new List <byte>(); int len = fs.Read(bb, 0, bb.Length); stream.AddRange(bb); while (len > 0) { len = fs.Read(bb, 0, bb.Length); stream.AddRange(bb); } msg.Data = stream.ToArray(); fs.Close(); msg.msgsendstate = msgSendState.single; } } else { msg.msgsendstate = msgSendState.None; bf.Serialize(ms, LanguageResource.Language.Tip_ClientRequestLack); } _tcpsvr.Send(Client, msg); break; case msgCommand.AddLoginAward: object data = DataSerialize.GetObjectFromByte(msg.Data); GSSModel.Request.ClientData client = data as GSSModel.Request.ClientData; GSSModel.Request.LoginAwardTask at = client.Data as GSSModel.Request.LoginAwardTask; msg.Data = null; client.Data = null; string message = ""; if (at.Task.F_Type.ToString() == "20000215") { message = dbhandle.AddLoginAward(at); } else if (at.Task.F_Type.ToString() == "20000217") { message = dbhandle.AddFullServiceEmail(at); } if (message != true.ToString()) { ShareData.Log.Error(message); } else { client.Success = true; } msg.Data = DataSerialize.GetByteFromObject(client);; msg.msgsendstate = msgSendState.single; _tcpsvr.Send(Client, msg); SendAlertNum(Client); break; case msgCommand.AddFullServiceEmail: object objData = DataSerialize.GetObjectFromByte(msg.Data); GSSModel.Request.ClientData clientData = objData as GSSModel.Request.ClientData; GSSModel.Request.LoginAwardTask atl = clientData.Data as GSSModel.Request.LoginAwardTask; msg.Data = null; clientData.Data = null; string strMessage = dbhandle.AddFullServiceEmail(atl); if (strMessage != true.ToString()) { ShareData.Log.Error(strMessage); } else { clientData.Success = true; } msg.Data = DataSerialize.GetByteFromObject(clientData);; msg.msgsendstate = msgSendState.single; _tcpsvr.Send(Client, msg); SendAlertNum(Client); break; case msgCommand.GameRoleRecovery: object d = DataSerialize.GetObjectFromByte(msg.Data); ClientData cd = d as ClientData; object[] arr = cd.Data as object[]; GSSModel.Tasks tsk = arr[0] as GSSModel.Tasks; id = dbhandle.AddTask(tsk); if (id < 1) { //创建工单失败 msg.Data = _coder.GetEncodingBytes(cd.FormID + "|" + "-1|" + LanguageResource.Language.Tip_CreateWorkOrderFailure); msg.msgsendstate = msgSendState.single; _tcpsvr.Send(Client, msg); return; } RoleData role = arr[1] as RoleData; string code = WebServiceLib.RecoveryRoleWithRollBack(role); if (code != true.ToString()) { System.Resources.ResourceManager rm = LanguageResource.Language.ResourceManager; string info = rm.GetString("Tip_RecoveryRoleStatue_" + code); if (string.IsNullOrEmpty(info)) { info = code; } msg.Data = _coder.GetEncodingBytes(cd.FormID + "|" + id + "|" + info); msg.msgsendstate = msgSendState.single; _tcpsvr.Send(Client, msg); return; } else { msg.Data = _coder.GetEncodingBytes(cd.FormID + "|" + id + "|" + true.ToString()); msg.msgsendstate = msgSendState.single; _tcpsvr.Send(Client, msg); } SendAlertNum(Client); break; case msgCommand.SendEmailToRoles: d = DataSerialize.GetObjectFromByte(msg.Data); GSSModel.Request.ClientData clientdata = d as GSSModel.Request.ClientData; GSSModel.SendEmailToRole email = clientdata.Data as GSSModel.SendEmailToRole; //通过调用接口进行数据传输 clientdata.Message = WebServiceLib.SetRolesEmail(email); clientdata.Data = null; MsgStruts reback = new MsgStruts() { command = msgCommand.SendEmailToRoles, msgsendstate = msgSendState.single }; if (string.IsNullOrEmpty(clientdata.Message)) { clientdata.Success = true; } reback.Data = DataSerialize.GetByteFromObject(clientdata); _tcpsvr.Send(Client, reback); SendAlertNum(Client); break; case msgCommand.ActiveFallGoods: d = DataSerialize.GetObjectFromByte(msg.Data); GSSModel.Request.ClientData request = d as GSSModel.Request.ClientData; GSSModel.Request.ActiveFallGoodsData fall = request.Data as GSSModel.Request.ActiveFallGoodsData; request.Data = null; request.Message = WebServiceLib.AddActiveFallConfig(fall); request.Success = true; callBack.command = msgCommand.ActiveFallGoods; callBack.Data = DataSerialize.GetByteFromObject(request); _tcpsvr.Send(Client, callBack); SendAlertNum(Client); break; case msgCommand.CreateTaskContainerLogic: //这是对于工单数据流程优化新增的传递方式 string.Format(" class:[{0}], command:[{1}]", typeof(ServerHandle).Name, msgCommand.CreateTaskContainerLogic); d = DataSerialize.GetObjectFromByte(msg.Data); msg.Data = null; fromClientData = d as GSSModel.Request.ClientData; try { SwitchDo(fromClientData); } catch (Exception ex) { ex.ToString().ErrorLogger(); fromClientData.Success = false; fromClientData.Message = ex.Message; } msg.Data = DataSerialize.GetByteFromObject(fromClientData); _tcpsvr.Send(Client, msg); SendAlertNum(Client); break; default: break; } } catch (System.Exception ex) { ex.Message.ErrorLogger(); msgStr = _coder.GetEncodingString(msg.Data, msg.Data.Length); ShareData.Log.Info(msgStr); ShareData.Log.Warn(ex); msg.Data = _coder.GetEncodingBytes("0"); _tcpsvr.Send(Client, msg); } }
/// <summary> /// 得到游戏用户列表,客服主页用 /// </summary> /// <param name="query"></param> /// <returns></returns> public static DataSet GetGameUsersC(string query) { try { string sql = @"SELECT F_Name,F_Value,F_ValueGame FROM T_GameConfig WITH(NOLOCK) where F_ParentID=1000 and F_IsUsed=1"; string.Format(typeof(WebServiceLib).Name + "\r\n" + query).Logger(); DataSet dsc = DbHelperSQL.Query(sql); if (dsc == null) { "query result:null".Logger(); return(null); } string url = ""; DataSet ds = null; "GetGameUsersC->url".Logger(); foreach (DataRow dr in dsc.Tables[0].Rows) { url = dr["F_Value"].ToString(); if (url.Trim().Length == 0) { continue; } else { webserv.Url = url; (typeof(WebServiceLib).Name + ":" + url).Logger(); webserv.Credentials = System.Net.CredentialCache.DefaultCredentials; string.Format(" webserv.Credentials :{0}", webserv.Credentials.ToString()).Logger(); string.Format("will call wcf:[GetGameUsersC] ->").Logger(); byte[] bytes = webserv.GetGameUsersC(query); string.Format("end call wcf:[GetGameUsersC] ->").Logger(); if (bytes != null) { string.Format("call wcf response byte:{0}", bytes.Length).Logger(); } else { string.Format("call wcf response byte:null").Logger(); return(null); } DataSet dstemp = DataSerialize.GetDatasetFromByte(bytes); if (dstemp != null) { DataTable table = dstemp.Tables[0]; table.Columns.Add("F_BigZoneName", System.Type.GetType("System.String")); table.Columns.Add("F_ValueGame", System.Type.GetType("System.String")); foreach (DataRow drt in dstemp.Tables[0].Rows) { drt["F_BigZoneName"] = dr["F_Name"].ToString(); drt["F_ValueGame"] = dr["F_ValueGame"].ToString(); } if (ds == null) { ds = dstemp.Copy(); } else { table.Merge(dstemp.Tables[0]); } ("GetGameUsersC Query Rows:" + table.Rows.Count).Logger(); } else { ("GetGameUsersC Query Rows: null").Logger(); } } } return(ds); } catch (System.Exception ex) { ex.Message.Logger(); //日志记录 ShareData.Log.Error("得到WEBSERVICE游戏用户列表错误\r\n" + ex.Message, ex); return(null); } }