本文整理汇总了C#中ShareCacheStruct.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ShareCacheStruct.Add方法的具体用法?C# ShareCacheStruct.Add怎么用?C# ShareCacheStruct.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShareCacheStruct
的用法示例。
在下文中一共展示了ShareCacheStruct.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ServersDataProvider
//private MiddlewareSection section;
public ServersDataProvider()
{
if (_provider == null)
{
_provider = DbConnectionProvider.CreateDbProvider(ConnectKey);
var command = _provider.CreateCommandStruct("StaticServer", CommandMode.Inquiry,"ServerId,Name,Ip,Port");
command.Parser();
using (var dr = _provider.ExecuteReader(CommandType.Text, command.Sql, command.Parameters))
{
var serversDatas = new ShareCacheStruct<StaticServer>();
while (dr.Read())
{
StaticServer oneServerModel = new StaticServer();
oneServerModel.ServerId = Convert.ToInt32(dr["ServerId"]) ;
oneServerModel.Name = dr["Name"].ToString();
oneServerModel.Ip = dr["Ip"].ToString();
oneServerModel.Port = Convert.ToInt32(dr["Port"]);
//ServerList.Add(oneServerModel);
serversDatas.Add(oneServerModel);
}
}
//this.AddATestCache();
}
}
示例2: AddPrize
public static void AddPrize(string UserID, int itemID, string mailContent)
{
string ItemPackage = itemID + "=1=1";
var cacheset = new ShareCacheStruct<UserTakePrize>();
UserTakePrize takeprize = new UserTakePrize()
{
CreateDate = DateTime.Now,
CrystalPackage = string.Empty,
EnergyNum = 0,
ExpNum = 0,
GainBlessing = 0,
GameCoin = 0,
Gold = 0,
ID = Guid.NewGuid().ToString(),
ItemPackage = ItemPackage,
IsTasked = false,
MailContent = mailContent,
ObtainNum = 0,
OpUserID = 0,
SparePackage = string.Empty,
UserID = UserID.ToInt(),
VipLv = 0,
};
cacheset.Add(takeprize, GameEnvironment.CacheGlobalPeriod);
}
示例3: OnCreateAfter
/// <summary>
/// 创始成功之后处理事件
/// </summary>
public void OnCreateAfter(GameUser user)
{
var cacheSet = new ShareCacheStruct<UserNickName>();
UserNickName u = new UserNickName(user.UserId);
u.NickName = user.NickName;
cacheSet.Add(u);
}
示例4: Add
public bool Add(int type,int index,string code)
{
var cache = new ShareCacheStruct<ExchangeCode>();
int key = UniqueKey(type, index);
//if (null != cache.FindKey(key)) return false; // this type has been added
ExchangeCode ec = cache.FindKey(key);
if (null != ec)
{
return true;
}
else
{
ec = new ExchangeCode();
ec.key = key;
ec.Type = (byte)type;
ec.Index = index;
ec.Code = code;
if (ec.Type == (byte)GameConfigExchangeCode.ExchangeCodeType.ASType_NSNSDuiHuan_AnHuiTai_1 ||
ec.Type == (byte)GameConfigExchangeCode.ExchangeCodeType.ASType_NSNSDuiHuan_JiaRi_1)
{
ec.cnt = int.MaxValue;
}
cache.Add(ec);
}
return true;
}
示例5: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<UserRanking>();
var ranking = cache.Find(m => m.UserName == UserName);
if (ranking == null)
{
var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = UserName};
new PersonalCacheStruct<GameUser>().Add(user);
ranking = new UserRanking();
ranking.UserID = user.UserId;
ranking.UserName = UserName;
ranking.Score = Score;
if (!cache.Add(ranking))
{
ErrorCode = Language.Instance.ErrorCode;
ErrorInfo = string.Format("add fail, UserID {0} is exist.", ranking.UserID);
return false;
}
}
else
{
ranking.UserName = UserName;
ranking.Score = Score;
}
return true;
}
示例6: AddATestCache
private void AddATestCache()
{
var serversDatas = new ShareCacheStruct<StaticServer>();
{
StaticServer oneServerModel = new StaticServer();
oneServerModel.ServerId = 5;
oneServerModel.Name = "MQ";
oneServerModel.Ip = "127.0.0.1";
oneServerModel.Port = 9001;
serversDatas.Add(oneServerModel);
}
}
示例7: InitNotice
private void InitNotice()
{
var cacheSet = new ShareCacheStruct<Notice>();
for (int i = 0; i < 5; i++)
{
int id = (int)cacheSet.GetNextNo();
Notice notice = new Notice(id);
notice.Title = "tile" + id;
notice.Content = "Content" + id;
notice.CreateDate = DateTime.Now;
cacheSet.Add(notice);
}
}
示例8: TakeAction
public override bool TakeAction() {
var cache = new ShareCacheStruct<UserRanking>();
var ranking = cache.Find(m => m.UserName == userName);
if (ranking == null) {
var user = new GameUser() { UserId = (int)cache.GetNextNo(), NickName = userName };
new PersonalCacheStruct<GameUser>().Add(user);
ranking = new UserRanking();
ranking.UserId = user.UserId;
ranking.UserName = userName;
ranking.Score = score;
cache.Add(ranking);
} else {
ranking.UserName = userName;
ranking.Score = score;
}
return true;
}
示例9: GenerateId
/// <summary>
/// 生成Id
/// </summary>
/// <returns></returns>
public static int GenerateId()
{
lock (SyncRoot)
{
string userCode = "USER_CODE";
var userCache = new ShareCacheStruct<UserSet>();
UserSet userSet = userCache.FindKey(userCode);
if (userSet == null)
{
userSet = new UserSet() { Code = userCode, CurrUserId = 1000 };
userCache.Add(userSet);
}
userSet.CurrUserId++;
userCache.Update();
return userSet.CurrUserId;
}
}
示例10: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<testUpdate>();
var tu = new testUpdate();
tu.index = (int)cache.GetNextNo();
tu.itemID = 0;
tu.ModifyLocked(() => {
tu.itemID = 1;
});
tu = cache.FindKey(tu.index);
tu = new testUpdate();
tu.index = (int)cache.GetNextNo();
tu.itemID = 100;
cache.Add(tu);
tu = cache.FindKey(tu.index);
// try
// {
// var UA = new UserAnalysis();
// foreach (logData d in requestPack.items)
// {
// UA.DeviceId = d.DeviceID;
// UA.Channel = d.Channel;
// UA.SimType = d.SimType;
// UA.ActionType = (UserAnalysis.E_ActionType)d.ActionType;
// UA.ProductionId = d.ProductionId;
// UA.ActionTime = System.DateTime.Now;
// //DataSyncQueueManager.SendToDb(UA);
// Console.WriteLine("{0}GameSession:{1}", DateTime.Now.ToString("HH:mm:ss"), GameSession.Count);
// }
// responsePack = new ResponsePack();
// responsePack.ActionId = 80000;
// responsePack.ErrorCode = 101;
// responsePack.ErrorInfo = "Success";
// return true;
// }
// catch (Exception ex)
// {
// TraceLog.WriteError("TakeAction:{0} error:{1}", actionId, ex);
// return false;
// }
return true;
}
示例11: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<UserRanking>();
var ranking = cache.Find(m => m.UserName == UserName);
if (ranking == null)
{
ranking = new UserRanking();
ranking.UserID = (int)cache.GetNextNo();
ranking.UserName = UserName;
ranking.Score = Score;
cache.Add(ranking);
}
else
{
ranking.UserName = UserName;
ranking.Score = Score;
}
return true;
}
示例12: TakeAction
public override bool TakeAction()
{
var cache = new ShareCacheStruct<UserScore>();
var ranking = cache.Find(m => m.username == _username);
if (ranking == null)
{
var user = new User() { userid = (int)cache.GetNextNo(), nickname = _username };
new PersonalCacheStruct<User>().Add(user);
ranking = new UserScore();
ranking.userid = user.userid;
ranking.username = _username;
ranking.score = _score;
cache.Add(ranking);
}
else
{
ranking.username = _username;
ranking.score = _score;
}
return true;
}
示例13: InitNotices
void InitNotices()
{
/*
* new ShareCacheStruct<Notice> 实际上不是一个存储空间,
* 而是指向redis数据库的一个入口,
* 这里通过指定类型Notice来获得Notice表的指针,
* 然后就可以做查询或修改操作
*
* public abstract class BaseCacheStruct<T> : BaseDisposable where T : AbstractEntity, new()
* {
* static BaseCacheStruct()
* {
* // 这里根据<T>中的类型来确定表的名字,
* // 再根据T上面的EntityTable来确定连接的数据库,
* // [EntityTable(CacheType.Entity, "TestGameData")]
* //
* // 如果已经有表就操作表,没有就新建后操作,
* // 如果使用这个接口来将数据直接保存到sql数据库中的话,需要连接数据库,而且可能操作磁盘
* EntitySchemaSet.InitSchema(typeof(T));
* CacheFactory.RegistUpdateNotify(new DefaultCacheStruct<T>());
* }
* ...
* }
*/
var cacheSet = new ShareCacheStruct<Notice>();
for (int i = 0; i < 50; i++)
{
int id = (int)cacheSet.GetNextNo();
Notice notice = new Notice(id);
notice.title = "tile" + id;
notice.content = "Content" + id;
notice.time = DateTime.Now;
cacheSet.Add(notice);
}
}
示例14: TakeAction
public override bool TakeAction()
{
var cacheSet = new ShareCacheStruct<UserFriends>();
if (_friendId != "" && _friendId != ContextUser.UserID)
{
//找到本玩家的数据
List<UserFriends> friendArray = cacheSet.FindAll(m => m.UserID == ContextUser.UserID);
int friendNum = ConfigEnvSet.GetInt("UserFriends.MaxFriendNum");
//添加的好友上限
if (friendArray.Count >= friendNum)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St9103_TheMaximumReachedAFriend;
return false;
}
//查看是否在user库中有该玩家
GameUser userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId);
if (userInfo == null)
{
UserCacheGlobal.LoadOffline(_friendId);
userInfo = new GameDataCacheSet<GameUser>().FindKey(_friendId);
}
if (userInfo == null)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St9103_NotFriendsUserID;
return false;
}
//在好友表中查找本玩家 和添加好友的关系
var userFriend = cacheSet.FindKey(ContextUser.UserID, _friendId);
var userFriend1 = cacheSet.FindKey(_friendId, ContextUser.UserID);
//同意
if (_ops == 1)
{
//有信息表 没信息表
if (userFriend == null)
{
//创建新的数据 并且添加成关注类型
var friends = new UserFriends
{
UserID = ContextUser.UserID,
FriendID = _friendId,
FriendType = FriendType.Friend
};
cacheSet.Add(friends);
//todo test
friends.ChatTime = DateTime.Now;
}else
{
//玩家原来就有数据
//判断两个玩家的关系
if (userFriend.FriendType == FriendType.Friend)
{
ErrorCode = LanguageManager.GetLang().ErrorCode;
ErrorInfo = LanguageManager.GetLang().St9103_TheUserHasAFriendIn;
return false;
}
userFriend.FriendType = FriendType.Friend;
}
//判断对方是否有和本玩家的数据 如果没有创建 有改状态
if (userFriend1 == null)
{
var friends2 = new UserFriends
{
UserID = _friendId,
FriendID = ContextUser.UserID,
FriendType = FriendType.Friend,
};
cacheSet.Add(friends2);
//todo test
friends2.ChatTime = DateTime.Now;
}
else
{
userFriend1.FriendType = FriendType.Friend;
}
//加为好友成功后发送一条邮件
try
{
Guid newGuid = Guid.NewGuid();
UserMail userMail = new UserMail(newGuid);
userMail.UserId = Int32.Parse(_friendId);
userMail.MailType = (int)MailType.Friends;
userMail.Title = LanguageManager.GetLang().St_AskFirendMailTitle;
userMail.Content = string.Format(LanguageManager.GetLang().St_FirendNotice, ContextUser.NickName);
userMail.SendDate = DateTime.Now;
userMail.FromUserId = Int32.Parse(ContextUser.UserID);
userMail.FromUserName = ContextUser.NickName;
TjxMailService mailService = new TjxMailService(ContextUser);
mailService.Send(userMail);
var noticeMail = mailService.ReadMail(ContextUser.UserID, _mailId);
noticeMail.ReplyStatus = 1;
}
//.........这里部分代码省略.........
示例15: Process
public override void Process(JsonParameter[] paramList)
{
JsonParameterList parameters = JsonParameter.Convert(paramList);
string op = parameters["op"];
string[] UserList = Convert.ToString(parameters["UserID"]).Split(new char[] { ',' });
string itemPackage = Convert.ToString(parameters["Item"]);
string crystalList = Convert.ToString(parameters["Crystal"]);
string sparePackage = Convert.ToString(parameters["SparePackage"]);
string enchantPackage = Convert.ToString(parameters["EnchantPackage"]);
int obtainNum = 0;
if (parameters["ObtainNum"].Length > 0)
{
obtainNum = Convert.ToInt32(parameters["ObtainNum"]);
}
short energyNum = 0;
if (parameters["EnergyNum"].Length > 0)
{
energyNum = Convert.ToInt16(parameters["EnergyNum"]);
}
int gameCoin = 0;
if (parameters["GameCoin"].Length > 0)
{
gameCoin = Convert.ToInt32(parameters["GameCoin"]);
}
int gold = 0;
if (parameters["Gold"].Length > 0)
{
gold = Convert.ToInt32(parameters["Gold"]);
}
int expNum = 0;
if (parameters["ExpNum"].Length > 0)
{
expNum = Convert.ToInt32(parameters["ExpNum"]);
}
int vipLv = 0;
if (parameters["VipLv"].Length > 0)
{
vipLv = Convert.ToInt32(parameters["VipLv"]);
}
int gainBlessing = 0;
if (parameters["GainBlessing"].Length > 0)
{
gainBlessing = Convert.ToInt32(parameters["GainBlessing"]);
}
int honourNum = 0;
if (parameters["HonourNum"].Length > 0)
{
honourNum = Convert.ToInt32(parameters["HonourNum"]);
}
string mailContent = Convert.ToString(parameters["MailContent"]);
int opUserID = Convert.ToInt32(parameters["OpUserID"]);
//var cacheSetUserItem = new GameDataCacheSet<UserItemPackage>();
var cacheSetItemInfo = new ShareCacheStruct<ItemBaseInfo>();
var itemArray = itemPackage.Split(',');
foreach (string str in UserList)
{
try
{
int userID = str.Trim().ToInt();
var user = new GameDataCacheSet<GameUser>().FindKey(str);
if(user!=null)
{
user.GiftGold = MathUtils.Addition(user.GiftGold, gold);
user.ObtainNum = MathUtils.Addition(user.ObtainNum, obtainNum);
user.EnergyNum = MathUtils.Addition(user.EnergyNum, energyNum);
user.GameCoin = MathUtils.Addition(user.GameCoin, gameCoin);
user.ExpNum = MathUtils.Addition(user.ExpNum, expNum);
user.HonourNum = MathUtils.Addition(user.HonourNum, honourNum);
}
foreach (var item in itemArray)
{
if(item.Split('=').Length==2)
{
var itemInfo = cacheSetItemInfo.FindKey(item.Split('=')[0]);
if(itemInfo!=null)
{
UserItemHelper.AddUserItem(str, item.Split('=')[0].ToInt(), item.Split('=')[1].ToInt());
}
}
}
Guid newGuid = Guid.NewGuid();
UserTakePrize userPrizeLog = new UserTakePrize
{
ID = newGuid.ToString(),
UserID = userID,
ObtainNum = obtainNum,
EnergyNum = energyNum,
GameCoin = gameCoin,
Gold = gold,
ExpNum = expNum,
VipLv = vipLv,
GainBlessing = gainBlessing,
ItemPackage = itemPackage,
CrystalPackage = crystalList,
SparePackage = sparePackage,
EnchantPackage = enchantPackage,
MailContent = mailContent,
//.........这里部分代码省略.........