本文整理汇总了C#中OperationContext.GetValueByField方法的典型用法代码示例。如果您正苦于以下问题:C# OperationContext.GetValueByField方法的具体用法?C# OperationContext.GetValueByField怎么用?C# OperationContext.GetValueByField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OperationContext
的用法示例。
在下文中一共展示了OperationContext.GetValueByField方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
//.........这里部分代码省略.........
if ((result.Result == CacheInsResult.Success || result.Result == CacheInsResult.SuccessNearEvicition) && _stateTransferKeyList != null &&
_stateTransferKeyList.ContainsKey(key))
{
result.Result = result.Result == CacheInsResult.Success ? CacheInsResult.SuccessOverwrite : CacheInsResult.SuccessOverwriteNearEviction;
}
// Not enough space, evict and try again.
if (result.Result == CacheInsResult.NeedsEviction || result.Result == CacheInsResult.SuccessNearEvicition
|| result.Result == CacheInsResult.SuccessOverwriteNearEviction)
{
Evict();
if (result.Result == CacheInsResult.SuccessNearEvicition) result.Result = CacheInsResult.Success;
if (result.Result == CacheInsResult.SuccessOverwriteNearEviction) result.Result = CacheInsResult.SuccessOverwrite;
}
// Operation completed!
if (result.Result == CacheInsResult.Success || result.Result == CacheInsResult.SuccessOverwrite)
{
// commented by muds
//remove the old hint from expiry index.
if (peExh != null)
_context.ExpiryMgr.RemoveFromIndex(key);
if (cacheEntry.ExpirationHint != null)
{
cacheEntry.ExpirationHint.CacheKey = (string)key;
if (isUserOperation)
{
try
{
_context.ExpiryMgr.ResetHint(peExh, cacheEntry.ExpirationHint);
}
catch (Exception e)
{
RemoveInternal(key, ItemRemoveReason.Removed, false, operationContext);
throw e;
}
}
else
{
cacheEntry.ExpirationHint.ReInitializeHint(Context);
}
_context.ExpiryMgr.UpdateIndex(key, cacheEntry);
}
if (IsSelfInternal)
{
_context.PerfStatsColl.IncrementCountStats((long)Count);
}
}
_stats.UpdateCount(this.Count);
switch (result.Result)
{
case CacheInsResult.Success:
break;
case CacheInsResult.SuccessOverwrite:
if (notify)
{
EventCacheEntry eventCacheEntry = CacheHelper.CreateCacheEventEntry(Runtime.Events.EventDataFilter.DataWithMetadata, cacheEntry); ;
EventCacheEntry oldEventCacheEntry = CacheHelper.CreateCacheEventEntry(Runtime.Events.EventDataFilter.DataWithMetadata, pe);
if (cbEtnry != null)
{
if (cbEtnry.ItemUpdateCallbackListener != null && cbEtnry.ItemUpdateCallbackListener.Count > 0)
{
if (!operationContext.Contains(OperationContextFieldName.EventContext)) //for atomic operations
{
eventId = EventId.CreateEventId(opId);
eventContext = new EventContext();
}
else //for bulk
{
eventId = ((EventContext)operationContext.GetValueByField(OperationContextFieldName.EventContext)).EventID;
}
eventContext = new EventContext();
eventId.EventType = EventType.ITEM_UPDATED_CALLBACK;
eventContext.Add(EventContextFieldName.EventID, eventId);
eventContext.Item = eventCacheEntry;
eventContext.OldItem = oldEventCacheEntry;
NotifyCustomUpdateCallback(key, cbEtnry.ItemUpdateCallbackListener, false, (OperationContext)operationContext.Clone(), eventContext);
}
}
}
break;
}
}
finally
{
}
if (_context.PerfStatsColl != null)
{
_context.PerfStatsColl.SetCacheSize(Size);
}
return result;
}
示例2: Remove
/// <summary>
/// Removes the object and key pair from the cache. The key is specified as parameter.
/// Moreover it take a removal reason and a boolean specifying if a notification should
/// be raised.
/// </summary>
/// <param name="key">key of the entry.</param>
/// <param name="removalReason">reason for the removal.</param>
/// <param name="notify">boolean specifying to raise the event.</param>
/// <param name="isUserOperation"></param>
/// <param name="lockId"></param>
/// <param name="accessType"></param>
/// <param name="operationContext"></param>
/// <returns>item value</returns>
public override CacheEntry Remove(object key, ItemRemoveReason removalReason, bool notify, bool isUserOperation, object lockId, LockAccessType accessType, OperationContext operationContext)
{
CacheEntry e = null;
CacheEntry pe = null;
{
object actualKey = key;
if (key is object[])
{
actualKey = ((object[])key)[0];
}
if (accessType != LockAccessType.IGNORE_LOCK)
{
pe = GetInternal(actualKey, false, operationContext);
if (pe != null)
{
if (pe.IsItemLocked() && !pe.CompareLock(lockId))
{
throw new LockingException("Item is locked.");
}
}
}
e = RemoveInternal(actualKey, removalReason, isUserOperation, operationContext);
EventId eventId = null;
EventContext eventContext = null;
OperationID opId = operationContext.OperatoinID;
if (e != null)
{
if (_stateTransferKeyList != null && _stateTransferKeyList.ContainsKey(key))
_stateTransferKeyList.Remove(key);
// commented by muds
try
{
if (e.ExpirationHint != null)
{
_context.ExpiryMgr.RemoveFromIndex(key);
((IDisposable)e.ExpirationHint).Dispose();
}
}
catch (Exception ex)
{
NCacheLog.Error("LocalCacheBase.Remove(object, ItemRemovedReason, bool):", ex.ToString());
}
if (IsSelfInternal)
{
// Disposed the one and only cache entry.
((IDisposable)e).Dispose();
if (removalReason == ItemRemoveReason.Expired)
{
_context.PerfStatsColl.IncrementExpiryPerSecStats();
}
else if (!_context.CacheImpl.IsEvictionAllowed && removalReason == ItemRemoveReason.Underused)
{
_context.PerfStatsColl.IncrementEvictPerSecStats();
}
_context.PerfStatsColl.IncrementCountStats((long)Count);
}
if (notify)
{
CallbackEntry cbEtnry = e.Value as CallbackEntry;// e.DeflattedValue(_context.SerializationContext);
if (cbEtnry != null && cbEtnry.ItemRemoveCallbackListener != null && cbEtnry.ItemRemoveCallbackListener.Count > 0)
{
//generate event id
if (!operationContext.Contains(OperationContextFieldName.EventContext)) //for atomic operations
{
eventId = EventId.CreateEventId(opId);
}
else //for bulk
{
eventId = ((EventContext)operationContext.GetValueByField(OperationContextFieldName.EventContext)).EventID;
}
eventId.EventType = EventType.ITEM_REMOVED_CALLBACK;
eventContext = new EventContext();
eventContext.Add(EventContextFieldName.EventID, eventId);
EventCacheEntry eventCacheEntry = CacheHelper.CreateCacheEventEntry(cbEtnry.ItemRemoveCallbackListener, e);
eventContext.Item = eventCacheEntry;
eventContext.Add(EventContextFieldName.ItemRemoveCallbackList, cbEtnry.ItemRemoveCallbackListener.Clone());
//Will always reaise the whole entry for old clients
NotifyCustomRemoveCallback(actualKey, e, removalReason, false, (OperationContext)operationContext.Clone(), eventContext);
//.........这里部分代码省略.........
示例3: GetClientLastViewId
protected internal long GetClientLastViewId(OperationContext operationContext)
{
long ClientLastViewId = -1;
object clientLastViewId = operationContext.GetValueByField(OperationContextFieldName.ClientLastViewId);
if (clientLastViewId != null)
{
ClientLastViewId = Convert.ToInt64(clientLastViewId);
}
return ClientLastViewId;
}
示例4: GetIntendedRecipient
protected internal string GetIntendedRecipient(OperationContext operationContext)
{
string IntendedRecipient = "";
object intendedRecipient = operationContext.GetValueByField(OperationContextFieldName.IntendedRecipient);
if (intendedRecipient != null)
{
IntendedRecipient = intendedRecipient.ToString();
}
return IntendedRecipient;
}
示例5: CreateEventContext
protected EventContext CreateEventContext(OperationContext operationContext, Alachisoft.NCache.Persistence.EventType eventType)
{
EventContext eventContext = new EventContext();
OperationID opId = operationContext != null ? operationContext.OperatoinID : null;
//generate event id
if (operationContext == null || !operationContext.Contains(OperationContextFieldName.EventContext)) //for atomic operations
{
eventContext.EventID = EventId.CreateEventId(opId);
}
else //for bulk
{
eventContext.EventID = ((EventContext)operationContext.GetValueByField(OperationContextFieldName.EventContext)).EventID;
}
eventContext.EventID.EventType = eventType;
return eventContext;
}
示例6: Remove
/// <summary>
/// Removes the object and key pair from the cache. The key is specified as parameter.
/// Moreover it take a removal reason and a boolean specifying if a notification should
/// be raised.
/// </summary>
/// <param name="key">key of the entry.</param>
/// <param name="ir"></param>
/// <param name="notify">boolean specifying to raise the event.</param>
/// <param name="lockId"></param>
/// <param name="accessType"></param>
/// <param name="operationContext"></param>
/// <param name="removalReason">reason for the removal.</param>
/// <returns>item value</returns>
public override CacheEntry Remove(object key, ItemRemoveReason ir, bool notify, object lockId, LockAccessType accessType, OperationContext operationContext)
{
CacheEntry entry = null;
if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("CacheSyncWrp.Remove_1", "enter");
Sync.AcquireWriterLock(Timeout.Infinite);
try
{
entry = Internal.Remove(key, ir, notify, lockId, accessType, operationContext);
object removeOnReplica = operationContext.GetValueByField(OperationContextFieldName.RemoveOnReplica);
if (entry != null)
{
#if !CLIENT
if (_context.CacheImpl.RequiresReplication)
_context.CacheImpl.EnqueueForReplication(key, (int)ClusterCacheBase.OpCodes.Remove, new object[] { key, operationContext });
}
else if (removeOnReplica != null)
{
_context.NCacheLog.Error("CacheSync Remove on Replica Key : " + key);
if (_context.CacheImpl.RequiresReplication)
_context.CacheImpl.EnqueueForReplication(key, (int)ClusterCacheBase.OpCodes.Remove, new object[] { key, operationContext });
#endif
}
}
finally
{
Sync.ReleaseWriterLock();
if (ServerMonitor.MonitorActivity) ServerMonitor.LogClientActivity("CacheSyncWrp.Remove_1", "exit");
}
return entry;
}
示例7: RaiseCustomRemoveCalbackNotifier
/// <summary>
/// handler for item remove callback event.
/// </summary>
void ICacheEventsListener.OnCustomRemoveCallback(object key, object entry, ItemRemoveReason removalReason,
OperationContext operationContext, EventContext eventContext)
{
bool notifyRemove = false;
//[Khurram] : change made after discussion with Mudassir 20-04-2011 (fix for two notification on single key removel)
// do not notify if explicitly removed by Remove()
object notifyRemoval = operationContext.GetValueByField(OperationContextFieldName.NotifyRemove);
if (notifyRemoval != null)
notifyRemove = (bool) notifyRemoval;
if ((removalReason == ItemRemoveReason.Removed) && !(bool) notifyRemove) return;
if (entry != null)
{
RaiseCustomRemoveCalbackNotifier(key, (CacheEntry) entry, removalReason, operationContext, eventContext);
}
}
示例8: RemoveSync
public override object RemoveSync(object[] keys, ItemRemoveReason reason, bool notify,
OperationContext operationContext)
{
try
{
Hashtable totalRemovedItems = new Hashtable();
CacheEntry entry = null;
IDictionaryEnumerator ide = null;
if (NCacheLog.IsInfoEnabled)
NCacheLog.Info("PartitionedCache.RemoveSync", "Keys = " + keys.Length.ToString());
for (int i = 0; i < keys.Length; i++)
{
try
{
if (keys[i] != null)
entry = Local_Remove(keys[i], reason, null, null, false, null, LockAccessType.IGNORE_LOCK, operationContext);
if (entry != null)
{
totalRemovedItems.Add(keys[i], entry);
}
}
catch (Exception ex)
{
throw;
}
}
ArrayList keysOfRemoveNotification = new ArrayList();
ArrayList entriesOfRemoveNotification = new ArrayList();
List<EventContext> eventContexts = new List<EventContext>();
int sizeThreshhold = 30*1024;
int countThreshhold = 50;
int size = 0;
ide = totalRemovedItems.GetEnumerator();
while (ide.MoveNext())
{
try
{
entry = ide.Value as CacheEntry;
if (entry != null)
{
if (entry.Value is CallbackEntry)
{
EventId eventId = null;
OperationID opId = operationContext.OperatoinID;
CallbackEntry cbEtnry = (CallbackEntry) entry.Value;
EventContext eventContext = null;
if (cbEtnry != null && cbEtnry.ItemRemoveCallbackListener != null &&
cbEtnry.ItemRemoveCallbackListener.Count > 0)
{
//generate event id
if (!operationContext.Contains(OperationContextFieldName.EventContext))
//for atomic operations
{
eventId = EventId.CreateEventId(opId);
}
else //for bulk
{
eventId =
((EventContext)
operationContext.GetValueByField(OperationContextFieldName.EventContext))
.EventID;
}
eventId.EventType = Alachisoft.NCache.Persistence.EventType.ITEM_REMOVED_CALLBACK;
eventContext = new EventContext();
eventContext.Add(EventContextFieldName.EventID, eventId);
EventCacheEntry eventCacheEntry =
CacheHelper.CreateCacheEventEntry(cbEtnry.ItemRemoveCallbackListener, entry);
eventContext.Item = eventCacheEntry;
eventContext.Add(EventContextFieldName.ItemRemoveCallbackList,
cbEtnry.ItemRemoveCallbackListener.Clone());
RaiseAsyncCustomRemoveCalbackNotifier(ide.Key, entry, reason, operationContext,
eventContext);
}
}
}
}
catch (Exception)
{
}
}
}
catch (Exception)
{
}
return null;
}
示例9: ClusteredInsert
//.........这里部分代码省略.........
for (int i = 0; i < currentKeys.Length; i++)
{
tmpResult[currentKeys[i]] = new GeneralFailureException(te.Message, te);
}
}
catch (BucketTransferredException ex)
{
tmpResult = new Hashtable();
for (int i = 0; i < currentKeys.Length; i++)
{
tmpResult[currentKeys[i]] = new OperationFailedException(ex.Message, ex);
}
}
if (tmpResult != null && tmpResult.Count > 0)
{
IDictionaryEnumerator ie = tmpResult.GetEnumerator();
while (ie.MoveNext())
{
if (ie.Value is StateTransferException)
{
totalRemainingKeys[ie.Key] = null;
}
else
{
if (ie.Value is Exception)
{
result[ie.Key] = ie.Value;
}
else if (ie.Value is CacheInsResultWithEntry)
{
CacheInsResultWithEntry res = ie.Value as CacheInsResultWithEntry;
switch (res.Result)
{
case CacheInsResult.Failure:
result[ie.Key] =
new OperationFailedException(
"Generic operation failure; not enough information is available.");
break;
case CacheInsResult.NeedsEviction:
result[ie.Key] =
new OperationFailedException(
"The cache is full and not enough items could be evicted.");
break;
case CacheInsResult.Success:
totalAddedKeys[ie.Key] = null;
break;
case CacheInsResult.SuccessOverwrite:
totalInsertedKeys[ie.Key] = ie.Value;
result[ie.Key] = ie.Value;
break;
}
}
}
}
}
}
}
keysToInsert = new ArrayList(totalRemainingKeys.Keys);
totalRemainingKeys.Clear();
} while (keysToInsert.Count > 0);
object generateQueryInfo = operationContext.GetValueByField(OperationContextFieldName.GenerateQueryInfo);
if (generateQueryInfo == null)
{
operationContext.Add(OperationContextFieldName.GenerateQueryInfo, true);
}
if (totalInsertedKeys.Count > 0)
{
IDictionaryEnumerator ide = totalInsertedKeys.GetEnumerator();
while (ide.MoveNext())
{
object key = ide.Key;
CacheInsResultWithEntry insResult = ide.Value as CacheInsResultWithEntry;
if (notify)
{
CacheEntry currentEntry = fullEntrySet[(string) ide.Key];
object value = insResult.Entry.Value;
if (value is CallbackEntry)
{
RaiseCustomUpdateCalbackNotifier(ide.Key, currentEntry, insResult.Entry, operationContext);
}
}
}
}
if (generateQueryInfo == null)
{
operationContext.RemoveValueByField(OperationContextFieldName.GenerateQueryInfo);
}
return result;
}