//------------------------------------------------------------------------------------ /// <summary> /// Adds the given text to the event log /// </summary> //------------------------------------------------------------------------------------ public void WriteToEventLog(string text) { try { if (!text.EndsWith(".")) { text += "."; } string entry = DateTime.Now.ToLongTimeString() + ": " + text; m_eventLog.Add(entry); } catch (Exception) { } }
public AsyncObservableCollection <T> ToCollection() { AsyncObservableCollection <T> newList = new AsyncObservableCollection <T>(); lock (SyncObject) { int index = 0; while (index < _list.Count) { newList.Add(_list[index]); index++; } } return(newList); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns an array of strings representing all the values in the specified enum /// type. /// </summary> //------------------------------------------------------------------------------------ public static AsyncObservableCollection <string> GetEnumValues <T>(bool excludeWildcardValues = false) { Array enumValues = typeof(T).GetEnumValues(); AsyncObservableCollection <string> values = new AsyncObservableCollection <string>(); foreach (T enumVal in enumValues) { string enumText = EnumToString <T>(enumVal); if (!excludeWildcardValues || (!enumText.StartsWith("<") && !enumText.StartsWith("aa"))) { values.Add(enumText); } } return(values); }
public AsyncObservableCollection <FileAttachment> GetAttachedFiles(StoreItem storeItem) { AsyncObservableCollection <FileAttachment> files = new AsyncObservableCollection <FileAttachment>(); DatastoreItem dsItem = storeItem.DSItem; OpenForRead(dsItem); foreach (ProductStudio.File file in dsItem.Files) { if (!IsInternalAttachedFile(file.FileName)) { files.Add(new FileAttachment(file)); } } return(files); }
public virtual void SetFieldAllowedValues(string propName, AllowedValue value) { if (FieldAllowedValues == null) { FieldAllowedValues = new Dictionary <string, AsyncObservableCollection <AllowedValue> >(); } if (!FieldAllowedValues.ContainsKey(propName)) { FieldAllowedValues.Add(propName, new AsyncObservableCollection <AllowedValue>()); } AsyncObservableCollection <AllowedValue> propValues = FieldAllowedValues[propName]; propValues.Add(value); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns the file names of all the attached files for this item. /// </summary> //------------------------------------------------------------------------------------ public AsyncObservableCollection <string> GetAttachedFileNames(StoreItem storeItem) { AsyncObservableCollection <string> filenames = new AsyncObservableCollection <string>(); DatastoreItem dsItem = storeItem.DSItem; OpenForRead(dsItem); foreach (ProductStudio.File file in dsItem.Files) { // Exclude internal-use-only attached files. if (!IsInternalAttachedFile(file.FileName)) { filenames.Add(file.FileName); } } return(filenames); }
//------------------------------------------------------------------------------------ /// <summary> /// Returns a list of all the allowed values for the given Product Studio field, given /// the current state of the given item. /// </summary> //------------------------------------------------------------------------------------ private AsyncObservableCollection <AllowedValue> GetFieldAllowedValues(DatastoreItem dsItem, string propName) { AsyncObservableCollection <AllowedValue> valueList = new AsyncObservableCollection <AllowedValue>(); if (dsItem != null) { ProductStudio.Field field = dsItem.Fields[propName]; ProductStudio.Values values = field.ValidValues; foreach (object value in values) { valueList.Add(new AllowedValue { Value = value }); } ResetDSItem(dsItem); } return(valueList); }