本文整理汇总了C#中ShareCacheStruct.Update方法的典型用法代码示例。如果您正苦于以下问题:C# ShareCacheStruct.Update方法的具体用法?C# ShareCacheStruct.Update怎么用?C# ShareCacheStruct.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShareCacheStruct
的用法示例。
在下文中一共展示了ShareCacheStruct.Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
}
示例2: Process
//.........这里部分代码省略.........
}
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,
IsTasked = false,
TaskDate = MathUtils.SqlMinDate,
OpUserID = opUserID,
CreateDate = DateTime.Now,
HonourNum = honourNum,
Items = itemPackage,
};
var cacheSet = new ShareCacheStruct<UserTakePrize>();
cacheSet.Add(userPrizeLog, GameEnvironment.CacheGlobalPeriod);
cacheSet.Update();
PutCrystal(crystalList.Split(','), str);
// 发送系统信件
UserMail userMail = new UserMail(newGuid);
userMail.UserId = userID;
userMail.MailType = (int)MailType.System;
userMail.Title = LanguageManager.GetLang().St_SystemMailTitle;
userMail.Content = mailContent;
userMail.SendDate = DateTime.Now;
TjxMailService mailService=new TjxMailService(user);
mailService.Send(userMail);
}
catch (Exception ex)
{
new BaseLog().SaveLog(ex);
}
}
}