Beispiel #1
0
        //------------------------------------------------------------------------------------
        /// <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);
        }
Beispiel #3
0
        //------------------------------------------------------------------------------------
        /// <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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        //------------------------------------------------------------------------------------
        /// <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);
        }
Beispiel #7
0
        //------------------------------------------------------------------------------------
        /// <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);
        }