本文整理汇总了C#中System.Collections.Dictionary.Any方法的典型用法代码示例。如果您正苦于以下问题:C# Dictionary.Any方法的具体用法?C# Dictionary.Any怎么用?C# Dictionary.Any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Dictionary
的用法示例。
在下文中一共展示了Dictionary.Any方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DecodeRsaPrivateKey
/// <summary>
/// This helper function parses an RSA private key using the ASN.1 format
/// </summary>
/// <param name="privateKeyBytes">Byte array containing PEM string of private key.</param>
/// <returns>An instance of <see cref="RSACryptoServiceProvider"/> rapresenting the requested private key.
/// Null if method fails on retriving the key.</returns>
public static RSACryptoServiceProvider DecodeRsaPrivateKey(string privateKey,string password="")
{
Dictionary<string, string> extras = new Dictionary<string, string>();
byte[] bytes = Helpers.GetBytesFromPEM(privateKey, out extras);
if (extras.Any(x => x.Value.Contains("ENCRYPTED")) && extras.Any(x => x.Key.Contains("DEK-Inf")))
{
String saltstr = extras.First(x => x.Key.Contains("DEK-Inf")).Value.Split(',')[1].Trim();
byte[] salt = new byte[saltstr.Length / 2];
for (int i = 0; i < salt.Length; i++)
salt[i] = Convert.ToByte(saltstr.Substring(i * 2, 2), 16);
SecureString despswd = new SecureString(); // GetSecPswd("Enter password to derive 3DES key==>");
foreach (char c in password)
despswd.AppendChar(c);
byte[] decoded = DecryptRSAPrivatePEM(bytes, salt, despswd);
bytes = decoded;
}
return DecodeRsaPrivateKey(bytes);
}
示例2: OnLoaded
private void OnLoaded(object sender, RoutedEventArgs e)
{
_strokeThicknesses = this.Resources.OfType<DictionaryEntry>()
.Where(x => x.Value is double)
.Where(x => x.Key.ToString().ToLower().Contains("strokethickness"))
.ToDictionary(x => x.Key.ToString(), x => (double)x.Value);
if (!_strokeThicknesses.Any())
return;
var parentGrid = VisualTreeHelper.GetParent(this) as Grid;
if (parentGrid != null)
{
this.SetBinding(
ScaleFactorProperty,
new Binding("RenderTransform.ScaleX") { Source = parentGrid });
}
}
示例3: SerializeDebugData
//.........这里部分代码省略.........
}
}
else if (token is JArray)
{
jObject = new JObject();
jObject.Add("logArg", token);
var type = logObject.GetType();
if (type.IsArray)
{
var array = (Array)logObject;
if (array.Length > 0)
{
var child = array.GetValue(0);
var childtype = child.GetType();
if (childtype.IsPrimitive || childtype.Name == "String" || childtype.BaseType == typeof(ValueType))
{
}
else
{
jObject.Add("objectType", childtype.FullName);
}
}
}
else
{
var genericArgs = type.GetGenericArguments();
if (genericArgs.Any())
{
var childtype = genericArgs.First();
if (childtype.IsPrimitive || childtype.Name == "String" || childtype.BaseType == typeof(ValueType))
{
}
else
{
jObject.Add("objectType", childtype.FullName);
}
}
else
{
jObject.Add("objectType", type.FullName);
}
}
}
else if (token is JValue)
{
if (serializeSimpleTypes)
{
jObject = new JObject();
jObject.Add("logArg", token);
}
}
}
}
}
catch (Exception ex)
{
lock (_BadTypes)
示例4: DeviceDetect
/// <summary>
/// Device Detect
/// </summary>
/// <param name="data">Data for device detection : HTTP Headers usually</param>
/// <returns>true on success, false otherwise. Use getReply to inspect results on success.</returns>
public bool DeviceDetect(Dictionary<string, dynamic> data = null)
{
int id = 0;
if (data == null || !data.Any() || !data.ContainsKey("id"))
{
id = Convert.ToInt32(Config["site_id"]);
}
else
{
id = Convert.ToInt32(data["id"]);
}
Dictionary<string, dynamic> requestBody = new Dictionary<string, dynamic>();
foreach (KeyValuePair<string, dynamic> item in data)
{
if (requestBody.ContainsKey(item.Key.ToLower()))
{
requestBody[item.Key.ToLower()] = item.Value;
}
else
{
requestBody.Add(item.Key.ToLower(), item.Value);
}
}
string fastKey = "";
// If caching enabled then check cache
if (Cacherequests)
{
IOrderedEnumerable<dynamic> headersKeys = requestBody.Values.Select(c => c).OrderBy(c => c);
fastKey = Jss.Serialize(headersKeys).Replace(" ", "");
Dictionary<string, dynamic> objReply = _cache.Read<Dictionary<string, dynamic>>(fastKey);
if (objReply.Count > 0)
{
Reply = objReply;
SetRawReply();
return SetError(0, "OK");
}
}
try
{
bool result = false;
if (UseLocal)
{
result = _device.LocalDetect(requestBody);
// Log unknown headers if enabled
SetError(_device.GetStatus(), _device.GetMessage());
}
else
{
result = Remote(string.Format("/device/detect/{0}", id), requestBody);
}
if (Cacherequests)
{
_cache.Write(fastKey, GetReply());
}
return result;
}
catch (Exception ex)
{
SetError(299, "Exception : " + ex.Message + " " + ex.StackTrace);
return false;
}
}
示例5: ParseAidrMetatags
void ParseAidrMetatags(List<Hashtable> tweets)
{
var hasNominalLabels = tweets.Where(n => !n.ContainsKey(IGNORE) && tweetHasAidrTags(n));
if (!hasNominalLabels.Any())
return;
Dictionary<long, List<AidrLabel>> tweetLabels = new Dictionary<long, List<AidrLabel>>();
foreach (var item in hasNominalLabels)
{
long tweetID = Convert.ToInt64(item["id_str"]);
Hashtable aidr = (Hashtable)item["aidr"];
ArrayList nominalLabels = (ArrayList)aidr["nominal_labels"];
foreach (Hashtable labelData in nominalLabels)
{
AidrLabel label = new AidrLabel();
label.AttributeCode = labelData["attribute_code"].ToString();
label.AttributeName = labelData["attribute_name"].ToString();
label.LabelCode = labelData["label_code"].ToString();
label.LabelName = labelData["label_name"].ToString();
label.Confidence = Convert.ToDouble(labelData["confidence"], CultureInfo.InvariantCulture);
//Don't store null tags or tags with low confidence
if (label.LabelCode == "null" || label.Confidence < Settings.TweetParser_MinAidrLabelConficence)
continue;
if (!tweetLabels.ContainsKey(tweetID))
tweetLabels.Add(tweetID, new List<AidrLabel>());
tweetLabels[tweetID].Add(label);
}
}
if (!tweetLabels.Any())
return;
//Group all tweetLabels into an attribute->label structure
var attributeDefinitions =
from item in tweetLabels.Values.SelectMany(n => n)
group item by item.AttributeCode into attributeGroup
select new {
AttributeCode = attributeGroup.Key,
AttributeName = attributeGroup.First().AttributeName,
Labels = from label in attributeGroup.ToList()
group label by label.LabelCode into labelGroup
select new {
LabelCode = labelGroup.Key,
LabelName = labelGroup.First().LabelName
}
};
//Insert attribute definitions
StringBuilder sbAttr = new StringBuilder();
sbAttr.Append("insert into AidrAttribute (AttributeCode, AttributeName) values ");
bool firstLine = true;
foreach (var attribute in attributeDefinitions)
{
if (firstLine)
firstLine = false;
else
sbAttr.Append(",");
sbAttr.Append("('");
sbAttr.Append(attribute.AttributeCode);
sbAttr.Append("','");
sbAttr.Append(attribute.AttributeName);
sbAttr.Append("')");
}
sbAttr.Append(" on duplicate key update AttributeName=values(AttributeName)");
Helpers.RunSqlStatement(Name, sbAttr.ToString(), false);
//Get attribute IDs
//string attributeCodesStr = string.Join("','", attributeDefinitions.Select(n => n.AttributeCode).ToArray());
Dictionary<string, uint> attributeIDs = new Dictionary<string,uint>();
Helpers.RunSelect(Name,
"select AttributeID, AttributeCode from AidrAttribute",
attributeIDs,
(values, reader) => attributeIDs.Add(reader.GetString("AttributeCode"), reader.GetUInt32("AttributeID")));
//Insert label definitions
var labelDefinitions =
from attrDef in attributeDefinitions
from lblDef in attrDef.Labels
select new
{
AttributeID = attributeIDs[attrDef.AttributeCode],
LabelCode = lblDef.LabelCode,
LabelName = lblDef.LabelName
};
StringBuilder sbLabel = new StringBuilder();
sbLabel.Append("insert into AidrLabel (AttributeID, LabelCode, LabelName) values ");
firstLine = true;
foreach (var label in labelDefinitions)
{
if (firstLine)
firstLine = false;
else
sbLabel.Append(",");
sbLabel.Append("(");
sbLabel.Append(label.AttributeID);
//.........这里部分代码省略.........
示例6: AssignStoryIDToNewClusters
static void AssignStoryIDToNewClusters(ref long nextStoryID, Dictionary<long, SimpleTweetCluster> clusters, Dictionary<long, SimpleStory> stories)
{
if (!clusters.Any())
return;
foreach (SimpleTweetCluster cluster in clusters.Values)
{
//Get the distribution of similarity scores between this cluster and each of the most active stories
var similarities = stories.Values
.Select(n => new { StoryID = n.StoryID, Similarity = n.WordVector * cluster.WordVector })
.OrderByDescending(n => n.Similarity)
.ToList();
//Check if there is a rapid drop somewhere in the similarity distribution
bool distrHasRapidDrop = false;
if (similarities.Count > 1)
{
for (int i = 1; i < similarities.Count; i++)
{
if (similarities[i].Similarity > 0.01 && similarities[i].Similarity < Settings.TweetClusterer_SW_MergeDropScale * similarities[i - 1].Similarity)
{
distrHasRapidDrop = true;
break;
}
if (similarities[i].Similarity < Settings.TweetClusterer_SW_MergeThresholdWithDrop)
break;
}
}
//Assign a story ID to the cluster
if (stories.Count > 0
&& (similarities[0].Similarity > Settings.TweetClusterer_SW_MergeThreshold
|| similarities[0].Similarity > Settings.TweetClusterer_SW_MergeThresholdWithDrop && distrHasRapidDrop))
{
cluster.StoryID = similarities[0].StoryID;
}
else
{
cluster.StoryID = nextStoryID;
cluster.isNewStory = true;
nextStoryID++;
}
}
}
示例7: ExecuteUpdate
protected override int ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues) {
IDictionary<string, Exception> errors = new Dictionary<string, Exception>(StringComparer.OrdinalIgnoreCase);
QueryableDataSourceEditData editData = BuildUpdateObjects(keys, values, oldValues, errors);
if (errors.Any()) {
HandleValidationErrors(errors, DataSourceOperation.Update);
}
else {
return UpdateObject(editData.OriginalDataObject, editData.NewDataObject);
}
return -1;
}
示例8: ApplyColorCollection
private void ApplyColorCollection(ColorCollection collection, bool randomOrder)
{
if (!collection.Color.Any())
return;
bool skipElements = false;
int index = 0;
foreach (Element elem in TimelineControl.SelectedElements)
{
if (!SupportsColor(elem))
{
skipElements = true;
continue;
}
var colors = GetSupportedColorsFromCollection(elem, collection.Color);
var properties = MetadataRepository.GetProperties(elem.EffectNode.Effect).Where(x => (x.PropertyType == typeof(Color) ||
x.PropertyType == typeof(ColorGradient) || x.PropertyType == typeof(List<ColorGradient>) || x.PropertyType == typeof(List<GradientLevelPair>)) && x.IsBrowsable);
Dictionary<Element, Tuple<Object, PropertyDescriptor>> elementValues = new Dictionary<Element, Tuple<object, PropertyDescriptor>>();
foreach (var propertyData in properties)
{
if (propertyData.PropertyType == typeof (Color))
{
var color = randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count];
elementValues.Add(elem,
new Tuple<object, PropertyDescriptor>(propertyData.Descriptor.GetValue(elem.EffectNode.Effect),
propertyData.Descriptor));
UpdateEffectProperty(propertyData.Descriptor, elem, color);
}
else
{
//The rest take a gradient.
if (propertyData.PropertyType == typeof(ColorGradient))
{
var color = randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count];
elementValues.Add(elem,
new Tuple<object, PropertyDescriptor>(propertyData.Descriptor.GetValue(elem.EffectNode.Effect),
propertyData.Descriptor));
UpdateEffectProperty(propertyData.Descriptor, elem, new ColorGradient(color));
}
else if (propertyData.PropertyType == typeof(List<ColorGradient>))
{
var gradients = propertyData.Descriptor.GetValue(elem.EffectNode.Effect) as List<ColorGradient>;
if (gradients != null)
{
var newGradients = gradients.ToList();
for (int i = 0; i < newGradients.Count; i++)
{
newGradients[i] =
new ColorGradient(randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count]);
}
elementValues.Add(elem,
new Tuple<object, PropertyDescriptor>(gradients,
propertyData.Descriptor));
UpdateEffectProperty(propertyData.Descriptor, elem, newGradients);
}
}
else if (propertyData.PropertyType == typeof(List<GradientLevelPair>))
{
var gradients = propertyData.Descriptor.GetValue(elem.EffectNode.Effect) as List<GradientLevelPair>;
if (gradients != null)
{
var newGradients = gradients.ToList();
for (int i = 0; i < newGradients.Count; i++)
{
newGradients[i] = new GradientLevelPair(new ColorGradient(randomOrder ? GetRandomColorFromCollection(colors) : colors[index++ % colors.Count]), new Curve(gradients[i].Curve));
}
elementValues.Add(elem,
new Tuple<object, PropertyDescriptor>(gradients,
propertyData.Descriptor));
UpdateEffectProperty(propertyData.Descriptor, elem, newGradients);
}
}
}
}
if (elementValues.Any())
{
var undo = new EffectsPropertyModifiedUndoAction(elementValues);
AddEffectsModifiedToUndo(undo);
}
}
if (skipElements)
{
MessageBoxForm.msgIcon = SystemIcons.Information; //this is used if you want to add a system icon to the message form.
var messageBox = new MessageBoxForm("One or more effects were selected that do not support colors.\nAll effects that do were updated.",
@"Information", true, false);
messageBox.ShowDialog();
}
SequenceModified();
}
示例9: ConfigureLayerMenu
private void ConfigureLayerMenu(ContextSelectedEventArgs e)
{
if ((e.ElementsUnderCursor != null && e.ElementsUnderCursor.Any()) || TimelineControl.SelectedElements.Any())
{
var layers = Sequence.GetAllLayers();
if (layers.Count() > 1)
{
ToolStripMenuItem contextMenuToLayer = new ToolStripMenuItem("Layer")
{
Enabled = true,
Image = Resources.layers,
ToolTipText = @"Assign effects to a layer"
};
HashSet<Guid> layersUsed = new HashSet<Guid>();
var sequenceLayers = Sequence.GetSequenceLayerManager();
if (TimelineControl.SelectedElements.Any())
{
foreach (var selectedElement in TimelineControl.SelectedElements)
{
var curentLayer = sequenceLayers.GetLayer(selectedElement.EffectNode);
if (layersUsed.Contains(curentLayer.Id) == false)
{
layersUsed.Add(curentLayer.Id);
if (layersUsed.Count == sequenceLayers.Count)
{
break;
}
}
}
}
else
{
foreach (var elementUnderCursor in e.ElementsUnderCursor)
{
var curentLayer = sequenceLayers.GetLayer(elementUnderCursor.EffectNode);
if (layersUsed.Contains(curentLayer.Id) == false)
{
layersUsed.Add(curentLayer.Id);
if (layersUsed.Count == sequenceLayers.Count)
{
break;
}
}
}
}
Bitmap checkMarkColor;
int iconSize = (int)(24 * ScalingTools.GetScaleFactor());
if (layersUsed.Count == 1)
{
checkMarkColor = Tools.GetIcon(Resources.check_mark, iconSize);
}
else
{
checkMarkColor = Tools.GetIcon(Resources.check_markMedium, iconSize);
}
foreach (var layer in layers.Reverse())
{
var item = new ToolStripMenuItem(layer.LayerName);
item.Tag = layer;
item.ToolTipText = layer.FilterName;
if (layersUsed.Contains(layer.Id))
{
item.Image = checkMarkColor;
}
contextMenuToLayer.DropDownItems.Add(item);
item.Click += (sender, args) =>
{
var el = e.ElementsUnderCursor;
Dictionary<IEffectNode, ILayer> modifiedNodes = new Dictionary<IEffectNode, ILayer>();
var newLayer = (ILayer) item.Tag;
//First try to apply to selected elements
if (TimelineControl.SelectedElements.Any())
{
foreach (var selectedElement in TimelineControl.SelectedElements)
{
var curentLayer = sequenceLayers.GetLayer(selectedElement.EffectNode);
if (newLayer != curentLayer)
{
modifiedNodes.Add(selectedElement.EffectNode, curentLayer);
sequenceLayers.AssignEffectNodeToLayer(selectedElement.EffectNode, newLayer);
}
}
}
else if (el != null && el.Any())
{
//if there are no selected elements, then try to apply to the element under the cursor
foreach (var selectedElement in el)
{
var curentLayer = sequenceLayers.GetLayer(selectedElement.EffectNode);
if (newLayer != curentLayer)
{
modifiedNodes.Add(selectedElement.EffectNode, curentLayer);
sequenceLayers.AssignEffectNodeToLayer(selectedElement.EffectNode, newLayer);
}
}
}
//.........这里部分代码省略.........
示例10: AnyVariablesCouldBeAllScope
internal static bool AnyVariablesCouldBeAllScope(Dictionary<string, int> variableNames)
{
return variableNames.Any<KeyValuePair<string, int>>(keyValuePair => _allScopeVariables.ContainsKey(keyValuePair.Key));
}
示例11: BatchUpdate
private void BatchUpdate(string tableName, IEnumerable<JObject> items, List<ColumnDefinition> columns)
{
if (columns.Count <= 1)
{
return; // For update to work there has to be at least once column besides Id that needs to be updated
}
ValidateParameterCount(columns.Count);
string sqlBase = String.Format("UPDATE {0} SET ", SqlHelpers.FormatTableName(tableName));
foreach (JObject item in items)
{
var sql = new StringBuilder(sqlBase);
var parameters = new Dictionary<string, object>();
ColumnDefinition idColumn = columns.FirstOrDefault(c => c.Name.Equals(MobileServiceSystemColumns.Id));
if (idColumn == null)
{
continue;
}
foreach (var column in columns.Where(c => c != idColumn))
{
string paramName = AddParameter(item, parameters, column);
sql.AppendFormat("{0} = {1}", SqlHelpers.FormatMember(column.Name), paramName);
sql.Append(",");
}
if (parameters.Any())
{
sql.Remove(sql.Length - 1, 1); // remove the trailing comma
}
sql.AppendFormat(" WHERE {0} = {1}", SqlHelpers.FormatMember(MobileServiceSystemColumns.Id), AddParameter(item, parameters, idColumn));
this.ExecuteNonQuery(sql.ToString(), parameters);
}
}
示例12: ParseObjects
private IEnumerable<DatObject> ParseObjects(IEnumerable<string> lines)
{
var objects = new List<DatObject>();
var elements = new Dictionary<string, string>();
foreach (string line in lines.Where(line => !string.IsNullOrEmpty(line) && line[0] != '#'))
{
// Separator means finish the current object and start assembling a new one
if (line[0] == '-')
{
if (elements.Any())
objects.Add(new DatObject(elements, Pak, this));
elements = new Dictionary<string, string>();
continue;
}
var equalsIndex = line.IndexOf('=');
if (equalsIndex < 0 || line.Length == equalsIndex + 1)
continue;
var name = line.Substring(0, equalsIndex).TrimStart(' ').TrimEnd(' ').ToLower();
var value = line.Substring(equalsIndex + 1).TrimStart(' ').TrimEnd(' ').ToLower();
while (elements.ContainsKey(name))
name += "_dup";
elements.Add(name, value);
}
// Flush last object if no trailing separator
if (elements.Any())
objects.Add(new DatObject(elements, Pak, this));
return objects;
}
示例13: ProcessLabels
/// <summary>
/// Creates the labels.
/// </summary>
/// <param name="dataKeyArray">The data key array.</param>
/// <returns></returns>
private void ProcessLabels( DataKeyArray checkinArray )
{
// Make sure we can save the attendance and get an attendance code
if ( RunSaveAttendance )
{
var attendanceErrors = new List<string>();
if ( ProcessActivity( "Save Attendance", out attendanceErrors ) )
{
SaveState();
}
else
{
string errorMsg = "<ul><li>" + attendanceErrors.AsDelimited( "</li><li>" ) + "</li></ul>";
maAlert.Show( errorMsg, Rock.Web.UI.Controls.ModalAlertType.Warning );
return;
}
RunSaveAttendance = false;
}
var printQueue = new Dictionary<string, StringBuilder>();
bool printIndividually = GetAttributeValue( "PrintIndividualLabels" ).AsBoolean();
var designatedLabelGuid = GetAttributeValue( "DesignatedSingleLabel" ).AsGuidOrNull();
foreach ( var selectedFamily in CurrentCheckInState.CheckIn.Families.Where( p => p.Selected ) )
{
List<CheckInLabel> labels = new List<CheckInLabel>();
List<CheckInPerson> selectedPeople = selectedFamily.People.Where( p => p.Selected ).ToList();
List<CheckInGroupType> selectedGroupTypes = selectedPeople.SelectMany( gt => gt.GroupTypes )
.Where( gt => gt.Selected ).ToList();
List<CheckInGroup> availableGroups = null;
List<CheckInLocation> availableLocations = null;
List<CheckInSchedule> availableSchedules = null;
List<CheckInSchedule> personSchedules = null;
foreach ( DataKey dataKey in checkinArray )
{
var personId = Convert.ToInt32( dataKey["PersonId"] );
var groupId = Convert.ToInt32( dataKey["GroupId"] );
var locationId = Convert.ToInt32( dataKey["LocationId"] );
var scheduleId = Convert.ToInt32( dataKey["ScheduleId"] );
int groupTypeId = selectedGroupTypes.Where( gt => gt.Groups.Any( g => g.Group.Id == groupId ) )
.Select( gt => gt.GroupType.Id ).FirstOrDefault();
availableGroups = selectedGroupTypes.SelectMany( gt => gt.Groups ).ToList();
availableLocations = availableGroups.SelectMany( l => l.Locations ).ToList();
availableSchedules = availableLocations.SelectMany( s => s.Schedules ).ToList();
personSchedules = selectedPeople.SelectMany( p => p.PossibleSchedules ).ToList();
// Make sure only the current item is selected in the merge object
if ( printIndividually || checkinArray.Count == 1 )
{
// Note: This depends on PreSelected being set properly to undo changes later
selectedPeople.ForEach( p => p.Selected = ( p.Person.Id == personId ) );
selectedGroupTypes.ForEach( gt => gt.Selected = ( gt.GroupType.Id == groupTypeId ) );
availableGroups.ForEach( g => g.Selected = ( g.Group.Id == groupId ) );
availableLocations.ForEach( l => l.Selected = ( l.Location.Id == locationId ) );
availableSchedules.ForEach( s => s.Selected = ( s.Schedule.Id == scheduleId ) );
personSchedules.ForEach( s => s.Selected = ( s.Schedule.Id == scheduleId ) );
}
// Create labels for however many items are currently selected
// #TODO: Rewrite CreateLabels so it would accept a list of ID's
var labelErrors = new List<string>();
if ( ProcessActivity( "Create Labels", out labelErrors ) )
{
SaveState();
}
// mark the person as being checked in
var selectedSchedules = availableLocations.Where( l => l.Selected )
.SelectMany( s => s.Schedules ).Where( s => s.Selected ).ToList();
foreach ( var selectedSchedule in selectedSchedules )
{
var serviceStart = (DateTime)selectedSchedule.StartTime;
selectedSchedule.LastCheckIn = serviceStart.AddMinutes( (double)selectedSchedule.Schedule.CheckInEndOffsetMinutes );
}
// Add valid grouptype labels, excluding the one-time label (if set)
if ( printIndividually )
{
var selectedPerson = selectedPeople.FirstOrDefault( p => p.Person.Id == personId );
if ( selectedPerson != null )
{
labels.AddRange( selectedPerson.GroupTypes.Where( gt => gt.Labels != null )
.SelectMany( gt => gt.Labels )
.Where( l => ( !RemoveFromQueue || l.FileGuid != designatedLabelGuid ) )
);
}
RemoveFromQueue = RemoveFromQueue || labels.Any( l => l.FileGuid == designatedLabelGuid );
}
else
{
labels.AddRange( selectedGroupTypes.Where( gt => gt.Labels != null )
//.........这里部分代码省略.........
示例14: GetPrefetchingQueueStatusForDebug
internal static object GetPrefetchingQueueStatusForDebug(DocumentDatabase database)
{
var result = new List<object>();
foreach (var prefetchingBehavior in database.IndexingExecuter.PrefetchingBehaviors)
{
var prefetcherDocs = prefetchingBehavior.DebugGetDocumentsInPrefetchingQueue().ToArray();
var futureBatches = prefetchingBehavior.DebugGetDocumentsInFutureBatches();
var compareToCollection = new Dictionary<Etag, int>();
for (int i = 1; i < prefetcherDocs.Length; i++)
compareToCollection.Add(prefetcherDocs[i - 1].Etag, prefetcherDocs[i].Etag.CompareTo(prefetcherDocs[i - 1].Etag));
if (compareToCollection.Any(x => x.Value < 0))
{
result.Add(new
{
AdditionaInfo = prefetchingBehavior.AdditionalInfo,
HasCorrectlyOrderedEtags = false,
IncorrectlyOrderedEtags = compareToCollection.Where(x => x.Value < 0),
EtagsWithKeys = prefetcherDocs.ToDictionary(x => x.Etag, x => x.Key),
FutureBatches = futureBatches
});
}
else
{
var prefetcherDocsToTake = Math.Min(5, prefetcherDocs.Count());
var etagsWithKeysTail = Enumerable.Range(0, prefetcherDocsToTake).Select(
i => prefetcherDocs[prefetcherDocs.Count() - prefetcherDocsToTake + i]).ToDictionary(x => x.Etag, x => x.Key);
result.Add(new
{
AdditionaInfo = prefetchingBehavior.AdditionalInfo,
HasCorrectlyOrderedEtags = true,
EtagsWithKeysHead = prefetcherDocs.Take(5).ToDictionary(x => x.Etag, x => x.Key),
EtagsWithKeysTail = etagsWithKeysTail,
EtagsWithKeysCount = prefetcherDocs.Count(),
FutureBatches = futureBatches
});
}
}
return result;
}
示例15: GetTasksItems
public List<TasksItem> GetTasksItems(string k2User, int? page, int? pageSize, out int totalCount, string procInstID = null, string folio = null, DateTime? startDate = null, DateTime? endDate = null, string[] processNames = null, Dictionary<string, string> sorting = null)
{
k2User = K2User.ApplySecurityLabel(k2User);
totalCount = 0;
Client.WorklistCriteria filter = new Client.WorklistCriteria();
filter.Platform = "ASP";
filter.Count = (pageSize == null || pageSize <= 0) ? -1 : pageSize.Value;
filter.StartIndex = (page == null || page <= 0) ? 0 : (page.Value - 1) * filter.Count;
filter.AddFilterField(Client.WCField.WorklistItemStatus, Client.WCCompare.Equal, Client.WorklistStatus.Available);
filter.AddFilterField(Client.WCLogical.Or, Client.WCField.WorklistItemStatus, Client.WCCompare.Equal, Client.WorklistStatus.Open);
filter.AddFilterField(Client.WCLogical.And, Client.WCField.WorklistItemOwner, "Me", Client.WCCompare.Equal, Client.WCWorklistItemOwner.Me); //This will return all the user’s items
filter.AddFilterField(Client.WCLogical.Or, Client.WCField.WorklistItemOwner, "Other", Client.WCCompare.Equal, Client.WCWorklistItemOwner.Other); //This will return all the user’s shared items
if (startDate != null)
filter.AddFilterField(Client.WCLogical.And, Client.WCField.ProcessStartDate, Client.WCCompare.GreaterOrEqual, startDate);
if (endDate != null)
filter.AddFilterField(Client.WCLogical.And, Client.WCField.ProcessStartDate, Client.WCCompare.LessOrEqual, endDate);
if (!string.IsNullOrEmpty(folio))
filter.AddFilterField(Client.WCLogical.And, Client.WCField.ProcessFolio, Client.WCCompare.Like, string.Format("%{0}%", folio));
if (!string.IsNullOrEmpty(procInstID))
filter.AddFilterField(Client.WCLogical.And, Client.WCField.ProcessID, Client.WCCompare.Equal, procInstID);
if (processNames != null && processNames.Any())
{
int index = 0;
foreach (var processName in processNames)
{
index++;
if (index == 1)
filter.AddFilterField(Client.WCLogical.And, Client.WCField.ProcessFullName, Client.WCCompare.Equal, processName);
else
filter.AddFilterField(Client.WCLogical.Or, Client.WCField.ProcessFullName, Client.WCCompare.Equal, processName);
}
}
if (sorting == null || !sorting.Any())
filter.AddSortField(Client.WCField.EventStartDate, Client.WCSortOrder.Descending);
else
{
foreach (var field in sorting.Keys)
{
filter.AddSortField((Client.WCField)Enum.Parse(typeof(Client.WCField), field), (Client.WCSortOrder)Enum.Parse(typeof(Client.WCSortOrder), sorting[field]));
}
}
var worklit = Runtime.Worklist.OpenWorklist(_k2ConnectionString, k2User, new ArrayList(), filter, false, false, 0, null);
List<TasksItem> tasks = new List<TasksItem>();
foreach (Client.WorklistItem item in worklit)
{
Actions actions = new Actions();
foreach (Client.Action act in item.Actions)
{
var action = new ApproveAction();
action.Name = act.Name;
action.MetaData = act.MetaData;
actions.Add(action);
}
TasksItem task = new TasksItem()
{
ProcInstID = item.ProcessInstance.ID,
ActivityName = item.ActivityInstanceDestination.Name,
Destination = K2User.DelApplySecurityLabel(k2User),
Folio = item.ProcessInstance.Folio,
Originator = item.ProcessInstance.Originator.FQN,
//OriginatorDisName = item.ProcessInstance.Originator.DisplayName,
SN = item.SerialNumber,
StartDate = item.ProcessInstance.StartDate.ToString("yyyy-MM-dd HH:mm"),
SharedUser = item.AllocatedUser.Equals(k2User, StringComparison.OrdinalIgnoreCase) ? null : K2User.DelApplySecurityLabel(item.AllocatedUser), //判断是否SharedUser
Actions = actions
};
tasks.Add(task);
}
return tasks;
}