/// <summary> /// 上传关键词文件 /// </summary> /// <param name="session"></param> /// <param name="lstParams"></param> /// lstParams[0] : 关键词文件源路径 /// <returns></returns> private OperationReturn UploadKeyWorldXml(SessionInfo session, List <string> lstParams) { OperationReturn optReturn = new OperationReturn(); try { string strSql = string.Empty; string strToken = session.RentInfo.Token; //获得可用的设备 switch (session.DBType) { case 2: strSql = "select C001,C016 from T_11_101_{0} where C001 > 2810000000000000000 and C001<2820000000000000000 and C002 = 1"; strSql = string.Format(strSql, strToken); optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql); break; case 3: strSql = "select C001,C016 from T_11_101_{0} where C001 > 2810000000000000000 and C001<2820000000000000000 and C002 = 1"; strSql = string.Format(strSql, strToken); optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql); break; } optReturn.Message += ";" + strSql; if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.CanNotFindEnabledMachine; return(optReturn); } DataSet ds = optReturn.Data as DataSet; if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.PCMDeviceIsNull; return(optReturn); } string strMachineID = ds.Tables[0].Rows[0]["C001"].ToString(); //获得PCMDeviceID switch (session.DBType) { case 2: strSql = "select C011 from T_11_101_{0} where C001 = {1} and C002 = 2"; strSql = string.Format(strSql, strToken, strMachineID); optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql); break; case 3: strSql = "select C011 from T_11_101_{0} where C001 ={1} and C002 = 2"; strSql = string.Format(strSql, strToken, strMachineID); optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql); break; } optReturn.Message += ";" + strSql; if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.GetPCMDeviceIDError; return(optReturn); } ds = optReturn.Data as DataSet; if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.PCMDeviceIsNull; return(optReturn); } int PCMDeviceID = 0; try { PCMDeviceID = int.Parse(ds.Tables[0].Rows[0][0].ToString()); } catch (Exception ex) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.PCMDeviceIDIsError; return(optReturn); } //根据DeviceID找到对应的存储设备 获得IP端口等相关信息 switch (session.DBType) { case 2: strSql = "select * from T_11_101_{0} where C001 in " + "(select C001 from T_11_101_{1} where C001 > 2140000000000000000 and C001<2150000000000000001 and C002=1 and C012={2})"; strSql = string.Format(strSql, strToken, strToken, PCMDeviceID); optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql); break; case 3: strSql = "select * from T_11_101_{0} where C001 in " + "(select C001 from T_11_101_{1} where C001 > 2140000000000000000 and C001<2150000000000000001 and C002=1 and C012={2})"; strSql = string.Format(strSql, strToken, strToken, PCMDeviceID); optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql); break; } optReturn.Message = strSql; if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.GetStorageDeviceError; return(optReturn); } ds = optReturn.Data as DataSet; ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["C001"], ds.Tables[0].Columns["C002"] }; if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0 || ds.Tables[0].Rows.Count < 5) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.CanNotFindStorageDevice; return(optReturn); } string[] keys = new string[2]; keys[0] = ds.Tables[0].Rows[0]["C001"].ToString(); keys[1] = "2"; DataRow row = ds.Tables[0].Rows.Find(keys); string strDeviceType = row["C011"].ToString(); string strHost = S5100EncryptOperation.DecodeEncryptValue(row["C013"].ToString()); string strPort = S5100EncryptOperation.DecodeEncryptValue(row["C015"].ToString()); string strTargetDir = row["C014"].ToString(); string strSourceDir = lstParams[0]; //如果是本地 直接拷贝文件到指定目录 if (strDeviceType == "0") { strTargetDir = strTargetDir.Trim('\\'); strTargetDir += "\\KeyWord.xml"; optReturn = Common.CopyFile(strSourceDir, strTargetDir); if (!optReturn.Result) { //optReturn.Result = false; //optReturn.Code = (int)S5100WcfErrorCode.UploadKeyWorldXmlFailed; //optReturn.Message += " ; strTargetDir = "+strTargetDir; return(optReturn); } } //如果是共享目录 else if (strDeviceType == "1") { keys[1] = "92"; row = ds.Tables[0].Rows.Find(keys); string strUser = S5100EncryptOperation.DecodeEncryptValue(row["C011"].ToString()); string strPwd = S5100EncryptOperation.DecodeEncryptValue(row["C012"].ToString()); int iUploadCount = 0; do { optReturn = Common.UpLoadFile(strSourceDir, strTargetDir, strUser, strPwd); iUploadCount++; } while (optReturn.Result == false && iUploadCount < 3); if (!optReturn.Result) { return(optReturn); } } optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; } catch (Exception ex) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.UploadKeyWorldXmlException; optReturn.Message = ex.Message; } return(optReturn); }
private OperationReturn DeleteKeyWorld(SessionInfo session, List <string> lstParams) { OperationReturn optReturn = new OperationReturn(); try { if (lstParams == null || lstParams.Count < 1) { optReturn.Result = false; optReturn.Code = Defines.RET_PARAM_INVALID; optReturn.Message = string.Format("Request param is null or count invalid"); return(optReturn); } string rentToken = session.RentInfo.Token; string strKeyWorldID = lstParams[0]; string strSql = string.Empty; optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; switch (session.DBType) { case 2: strSql = " update T_11_009_{0} SET C010 = '1' where C001 = {1}"; strSql = string.Format(strSql, rentToken, strKeyWorldID); optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql); break; case 3: strSql = " update T_11_009_{0} SET C010 = '1' where C001 = {1}"; strSql = string.Format(strSql, rentToken, strKeyWorldID); optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql); break; } optReturn.Message += ";" + strSql; if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.AddBookmarkLevelError; return(optReturn); } optReturn = GenerateKeyWorldXml(session, null); if (!optReturn.Result) { return(optReturn); } List <string> lstParamInUpload = new List <string>(); lstParamInUpload.Add(optReturn.StringValue); optReturn = UploadKeyWorldXml(session, lstParamInUpload); if (!optReturn.Result) { return(optReturn); } optReturn.Data = strKeyWorldID.ToString(); } catch (Exception ex) { optReturn.Result = false; optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; optReturn.Exception = ex; } return(optReturn); }
/// <summary> /// 获得所有关键词 /// </summary> /// <param name="session"></param> /// <param name="lstParams"></param> /// <returns></returns> private OperationReturn GetAllKeyWorlds(SessionInfo session, List <string> lstParams) { OperationReturn optReturn = new OperationReturn(); try { string strToken = session.RentInfo.Token; string strSql = string.Empty; switch (session.DBType) { case 2: strSql = "select a.C001 as keyworldID,a.C006 as keyworldContent,b.C001 as levelID,b.C006 as levelColor ,b.C009 as LevelName" + " from T_11_009_{0} as a left join T_11_009_{1} as b " + " on a.C009 = b.C001 where a.C000=4 and b.C000=3 and a.C010 <>'1'"; strSql = string.Format(strSql, strToken, strToken); optReturn = MssqlOperation.GetDataSet(session.DBConnectionString, strSql); break; case 3: strSql = "select a.C001 as keyworldID,a.C006 as keyworldContent,b.C001 as levelID,b.C006 as levelColor ,b.C009 as LevelName" + " from T_11_009_{0} a left join T_11_009_{1} b " + " on a.C009 = b.C001 where a.C000=4 and b.C000=3 and a.C010 <>'1'"; strSql = string.Format(strSql, strToken, strToken); optReturn = OracleOperation.GetDataSet(session.DBConnectionString, strSql); break; } optReturn.Message = strSql; if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.GetAllKeyWorldsError; return(optReturn); } List <string> lstRecords = new List <string>(); DataSet ds = optReturn.Data as DataSet; if (ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) { optReturn.Data = lstRecords; return(optReturn); } KeyWorldsEntity keyWorld = null; foreach (DataRow row in ds.Tables[0].Rows) { keyWorld = new KeyWorldsEntity(); keyWorld.KeyWorldID = row["keyworldID"].ToString(); keyWorld.KeyWorldContent = S5100EncryptOperation.DecryptWithM002(row["keyworldContent"].ToString()); keyWorld.BookmarkLevelID = row["levelID"].ToString(); keyWorld.BookmarkLevelcolor = S5100EncryptOperation.DecryptWithM002(row["levelColor"].ToString()); keyWorld.LevelName = row["LevelName"].ToString(); optReturn = XMLHelper.SeriallizeObject <KeyWorldsEntity>(keyWorld); if (optReturn.Result) { lstRecords.Add(optReturn.Data as string); } } optReturn.Data = lstRecords; 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); }
/// <summary> /// 添加关键词 /// </summary> /// <param name="session"></param> /// <param name="lstParams"></param> /// lstParams[0] : 关键词 /// lstParams[1] : 等级ID /// <returns></returns> private OperationReturn AddKeyWorld(SessionInfo session, List <string> lstParams) { OperationReturn optReturn = new OperationReturn(); try { if (lstParams == null || lstParams.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 rentToken = session.RentInfo.Token; string strLevelID = lstParams[1]; string strKeyWorld = S5100EncryptOperation.EncryptWithM002(lstParams[0]); string strSql = string.Empty; optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; List <string> lst = new List <string>(); lst.Add("51"); lst.Add("501"); optReturn = GetSerialID(session, lst); if (!optReturn.Result) { return(optReturn); } string str = optReturn.Data as string; long keyWorldID = 0; long.TryParse(str, out keyWorldID); if (keyWorldID == 0) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.SerialIDConvertError; optReturn.Message = str; return(optReturn); } switch (session.DBType) { case 2: strSql = "insert into T_11_009_{4} (C000,C001,C002,C003,C004,C005,C006,C007,C008,C009,C010)" + "values (4,{0},0,0,'1',0,'{1}','{2}','kw','{3}','0')"; strSql = string.Format(strSql, keyWorldID, strKeyWorld, session.UserID, strLevelID, rentToken); optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql); break; case 3: strSql = "insert into T_11_009_{4} (C000,C001,C002,C003,C004,C005,C006,C007,C008,C009,C010)" + "values (4,{0},0,0,'1',0,'{1}','{2}','kw','{3}','0')"; strSql = string.Format(strSql, keyWorldID, strKeyWorld, session.UserID, strLevelID, rentToken); optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql); break; } optReturn.Message += ";" + strSql; if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.AddBookmarkLevelError; return(optReturn); } optReturn = GenerateKeyWorldXml(session, null); if (!optReturn.Result) { optReturn.Data = keyWorldID.ToString(); return(optReturn); } List <string> lstParamInUpload = new List <string>(); lstParamInUpload.Add(optReturn.StringValue); optReturn = UploadKeyWorldXml(session, lstParamInUpload); if (!optReturn.Result) { optReturn.Data = keyWorldID.ToString(); return(optReturn); } optReturn.Data = keyWorldID.ToString(); } catch (Exception ex) { optReturn.Result = false; optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; optReturn.Exception = ex; } return(optReturn); }
/// <summary> /// 添加标签等级 /// </summary> /// <param name="session"></param> /// <param name="lstParams"></param> /// lstParams[0] : 等级名称 /// lstParams[1] : 等级颜色 /// <returns></returns> private OperationReturn AddBookmarkLevel(SessionInfo session, List <string> lstParams) { OperationReturn optReturn = new OperationReturn(); try { //ListParam //0 用户编号 if (lstParams == null || lstParams.Count < 1) { optReturn.Result = false; optReturn.Code = Defines.RET_PARAM_INVALID; optReturn.Message = string.Format("Request param is null or count invalid"); return(optReturn); } string rentToken = session.RentInfo.Token; string strSql = string.Empty; optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; List <string> lst = new List <string>(); lst.Add("51"); lst.Add("309"); optReturn = GetSerialID(session, lst); if (!optReturn.Result) { return(optReturn); } string str = optReturn.Data as string; long levelID = 0; long.TryParse(str, out levelID); if (levelID == 0) { optReturn.Result = false; optReturn.Code = (int)S5100WcfErrorCode.SerialIDConvertError; optReturn.Message = str; return(optReturn); } switch (session.DBType) { case 2: strSql = "insert into T_11_009_{0}(C000,C001,C002,C003,C004,C005,C006,C007,C008,C009,C010)" + "values (3,{1},0,0,'1',0,'{2}','{3}','BM','{4}','0')"; strSql = string.Format(strSql, rentToken, levelID, S5100EncryptOperation.EncryptWithM002(lstParams[1]), session.UserID, lstParams[0]); optReturn = MssqlOperation.ExecuteSql(session.DBConnectionString, strSql); break; case 3: strSql = "insert into T_11_009_{0}(C000,C001,C002,C003,C004,C005,C006,C007,C008,C009,C010)" + "values (3,{1},0,0,'1',0,'{2}','{3}','BM','{4}',0)"; strSql = string.Format(strSql, rentToken, levelID, S5100EncryptOperation.EncryptWithM002(lstParams[1]), session.UserID, lstParams[0]); optReturn = OracleOperation.ExecuteSql(session.DBConnectionString, strSql); break; } if (!optReturn.Result) { optReturn.Code = (int)S5100WcfErrorCode.AddBookmarkLevelError; return(optReturn); } optReturn.Data = levelID.ToString(); } catch (Exception ex) { optReturn.Result = false; optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; optReturn.Exception = ex; } return(optReturn); }