/// <summary>
        /// Sets a meta-data items' content.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="tag">The tag that specifies the context (usually the namespace).</param>
        /// <param name="content">The content.</param>
        /// <returns><c>true</c> if the content is set, <c>false</c> otherwise.</returns>
        public bool SetMetaDataItem(MetaDataItem item, string tag, string content)
        {
            try {
                MetadataEntity metadataEntity = null;
                _metadata.TryGetValue(item + "|" + tag, out metadataEntity);
                if (metadataEntity == null)
                {
                    metadataEntity = new MetadataEntity()
                    {
                        PartitionKey = _wiki,
                        RowKey       = item + "|" + tag,
                        Content      = content
                    };
                    _context.AddObject(MetadataTable, metadataEntity);
                }
                else
                {
                    metadataEntity.Content = content;
                    _context.UpdateObject(metadataEntity);
                }
                _context.SaveChangesStandard();

                // Invalidate metadataCache
                _metadataCache = null;

                return(true);
            }
            catch (Exception ex) {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public void WhenItemIsConstructedThenPropertiesAreSetAccordingArguments()
        {
            IMetaDataItem item = new MetaDataItem("name", "value");

            Assert.AreEqual("name", item.Name);
            Assert.AreEqual("value", item.Value);
        }
Ejemplo n.º 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            MetaDataItem item = ButtonMetaDataItemMapping[txtCurrentButton.Value];

            string tag = null;

            // These elements are global, all others are are namespace-specific
            if (!Settings.IsMetaDataItemGlobal(item))
            {
                tag = lstNamespace.SelectedValue;
            }

            Log.LogEntry("Metadata file change requested for " + item.ToString() +
                         (tag != null ? ", ns: " + tag : "") + lstNamespace.SelectedValue, EntryType.General, SessionFacade.CurrentUsername);

            var content = editor.GetContent();

            if (string.IsNullOrEmpty(content))
            {
                content = null;
            }

            Settings.Provider.SetMetaDataItem(item, tag, content);
            Content.ClearPseudoCache();

            pnlEditor.Visible = false;
            pnlList.Visible   = true;
        }
Ejemplo n.º 4
0
 public void Save()
 {
     if (!this.HasChanges || this.HasMultipleValues)
     {
         return;
     }
     foreach (var source in this.Sources)
     {
         var metaDataItem = default(MetaDataItem);
         if (!this.MetaDataItems.TryGetValue(source, out metaDataItem))
         {
             metaDataItem = new MetaDataItem(this.Name, this.Type);
             source.MetaDatas.Add(metaDataItem);
             this.MetaDataItems.Add(source, metaDataItem);
         }
         if (this.HasValue)
         {
             metaDataItem.Value = this.Value;
         }
         else
         {
             metaDataItem.Value = null;
         }
     }
 }
Ejemplo n.º 5
0
 protected virtual void AddSource(IFileData source, MetaDataItem metaDataItem)
 {
     this.Sources.Add(source);
     if (metaDataItem != null)
     {
         this.MetaDataItems.Add(source, metaDataItem);
     }
 }
Ejemplo n.º 6
0
 public static bool CanExport(MetaDataItem metaDataItem)
 {
     if (string.Equals(metaDataItem.Name, CommonStatistics.Rating, StringComparison.OrdinalIgnoreCase))
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 7
0
    private IEnumerator WaitForTexture(GameObject q, MetaDataItem mdi)
    {
        WWW www = new WWW("file:///" + this.imageDirectory + "/" + mdi.filename);

        yield return(www);

        q.renderer.material.mainTexture = www.texture;
    }
        } // constructor

        public CmsLocalFileOnDiskMetaItem(CmsLocalFileOnDisk res, MetaDataItem metaItem)
        {
            autoincid              = -1;
            resourceid             = res.ResourceId;
            resourcerevisionnumber = res.RevisionNumber;
            name      = metaItem.Name;
            itemvalue = metaItem.ItemValue;
        } // constructor
Ejemplo n.º 9
0
        public void SetMetaDataItem_GetMetaDataItem(MetaDataItem item, string newContent)
        {
            ISettingsStorageProviderV30 prov = GetProvider();

            Assert.IsTrue(prov.SetMetaDataItem(item, null, newContent), "SetMetaDataItem should return true");
            Assert.AreEqual(newContent, prov.GetMetaDataItem(item, null), "Wrong content");

            Assert.IsTrue(prov.SetMetaDataItem(item, "Tag", newContent + "Mod"), "SetMetaDataItem should return true");
            Assert.AreEqual(newContent + "Mod", prov.GetMetaDataItem(item, "Tag"), "Wrong content");
        }
 /// <summary>
 /// Gets a meta-data item's content.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="tag">The tag that specifies the context (usually the namespace).</param>
 /// <returns>The content.</returns>
 public string GetMetaDataItem(MetaDataItem item, string tag)
 {
     try {
         MetadataEntity metadataEntity = null;
         _metadata.TryGetValue(item + "|" + tag, out metadataEntity);
         return(metadataEntity == null ? "" : metadataEntity.Content + "");
     }
     catch (Exception ex) {
         throw ex;
     }
 }
Ejemplo n.º 11
0
        public IMetaDataItem ImportMetaDataItem(string groupName, string itemName, string itemValue)
        {
            if (!_metaData.ContainsKey(groupName))
            {
                _metaData[groupName] = new List <MetaDataItem>();
            }

            MetaDataItem item = new MetaDataItem(itemName, itemValue);

            _metaData[groupName].Add(item);
            return(item);
        }
Ejemplo n.º 12
0
        public IMetaDataItem ImportMetaDataItem(string groupName, string name, string value)
        {
            if (!_metaData.ContainsKey(groupName))
            {
                _metaData[groupName] = new List <IMetaDataItem>();
            }

            MetaDataItem metaDataItem = new MetaDataItem(name, value);

            _metaData[groupName].Add(metaDataItem);
            return(metaDataItem);
        }
Ejemplo n.º 13
0
        private void lvPlaylistsItem_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            MetaDataItem metaDataItem         = (MetaDataItem)((ListViewItem)sender).DataContext;
            ObservableCollection <Song> songs = new ObservableCollection <Song>();

            foreach (Song song in MediaUtils.AllSongs.Where(s => s.Artists.Equals(metaDataItem.Name)))
            {
                songs.Add(song);
            }
            Frame.CurrentPage = new SongsPage(songs, metaDataItem.Name);
            MediaUtils.SongsCurrentlySelected = songs;
        }
Ejemplo n.º 14
0
        protected void btnCopyFrom_Click(object sender, EventArgs e)
        {
            MetaDataItem item = ButtonMetaDataItemMapping[txtCurrentButton.Value];

            if (Settings.IsMetaDataItemGlobal(item))
            {
                return;
            }

            string newValue = Settings.Provider.GetMetaDataItem(item, lstCopyFromNamespace.SelectedValue);

            editor.SetContent(newValue, Settings.UseVisualEditorAsDefault);
        }
Ejemplo n.º 15
0
        private static ItemsToAdd GenerateItemsToAddModel(List <QnAItem> qnaItemsToAdd)
        {
            var itemsToAddModel = new ItemsToAdd
            {
                qnaList = new KbItemToAdd[] { },
                urls    = new string[] { },
                users   = new object[] { }
            };

            var kbItemsToAdd = new List <KbItemToAdd>();

            foreach (var qnaItem in qnaItemsToAdd)
            {
                var kbItem = new KbItemToAdd
                {
                    answer    = qnaItem.Answer,
                    metadata  = new MetaDataItem[] { },
                    questions = new string[] { }
                };

                var questions = qnaItem.Questions;
                kbItem.questions = questions.ToArray();

                var metadata = new List <MetaDataItem>
                {
                    new MetaDataItem()
                    {
                        name  = "itemId",
                        value = qnaItem.ItemId
                    }
                };

                foreach (var metaDataItem in qnaItem.Metadata)
                {
                    var metaDataItemToAdd = new MetaDataItem
                    {
                        name  = metaDataItem.Key,
                        value = metaDataItem.Value
                    };
                    metadata.Add(metaDataItemToAdd);
                }

                kbItem.metadata = metadata.ToArray();

                kbItemsToAdd.Add(kbItem);
            }

            itemsToAddModel.qnaList = kbItemsToAdd.ToArray();

            return(itemsToAddModel);
        }
Ejemplo n.º 16
0
 public static XtraTag FromMetaDataItem(MetaDataItem metaDataItem)
 {
     if (string.Equals(metaDataItem.Name, CommonStatistics.Rating, StringComparison.OrdinalIgnoreCase))
     {
         return(new XtraTag(
                    SharedUserRating,
                    new[]
         {
             new XtraTagPart(
                 XtraTagType.UInt64,
                 BitConverter.GetBytes(GetRatingMask(metaDataItem.Value))
                 )
         }
                    ));
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 17
0
        protected virtual void AddSource(IFileData source)
        {
            var metaDataItem = default(MetaDataItem);

            lock (source.MetaDatas)
            {
                metaDataItem = source.MetaDatas.FirstOrDefault(
                    element => string.Equals(element.Name, this.Name, StringComparison.OrdinalIgnoreCase)
                    );
                if (metaDataItem == null)
                {
                    metaDataItem = new MetaDataItem(this.Name, this.Type);
                    source.MetaDatas.Add(metaDataItem);
                }
            }
            this.AddSource(
                source,
                metaDataItem
                );
        }
Ejemplo n.º 18
0
        protected void btn_Click(object sender, EventArgs e)
        {
            Control senderControl = sender as Control;

            txtCurrentButton.Value = senderControl.ID;

            MetaDataItem item = ButtonMetaDataItemMapping[senderControl.ID];

            bool markupOnly = WikiMarkupOnlyItems.Contains(item);

            string content = Settings.Provider.GetMetaDataItem(item, lstNamespace.SelectedValue);

            editor.SetContent(content, !markupOnly && Settings.UseVisualEditorAsDefault);

            editor.VisualVisible  = !markupOnly;
            editor.PreviewVisible = !markupOnly;
            editor.ToolbarVisible = !markupOnly;

            pnlList.Visible   = false;
            pnlEditor.Visible = true;

            // Load namespaces for content copying
            lstCopyFromNamespace.Items.Clear();
            string currentNamespace = lstNamespace.SelectedValue;

            if (!string.IsNullOrEmpty(currentNamespace))
            {
                lstCopyFromNamespace.Items.Add(new ListItem("<root>", ""));
            }

            List <NamespaceInfo> namespaces = Pages.GetNamespaces();

            foreach (NamespaceInfo ns in namespaces)
            {
                if (currentNamespace != ns.Name)
                {
                    lstCopyFromNamespace.Items.Add(new ListItem(ns.Name, ns.Name));
                }
            }
            pnlInlineTools.Visible = lstCopyFromNamespace.Items.Count > 0 && !Settings.IsMetaDataItemGlobal(item);
        }
Ejemplo n.º 19
0
        public IEnumerable <IFileData> Save()
        {
            if (!this.HasChanges || this.HasMultipleValues)
            {
                Enumerable.Empty <IFileData>();
            }
            var fileDatas = new List <IFileData>();

            foreach (var source in this.Sources)
            {
                var metaDataItem = default(MetaDataItem);
                if (!this.MetaDataItems.TryGetValue(source, out metaDataItem))
                {
                    metaDataItem = new MetaDataItem(this.Name, this.Type);
                    lock (source.MetaDatas)
                    {
                        source.MetaDatas.Add(metaDataItem);
                    }
                    this.MetaDataItems.Add(source, metaDataItem);
                }
                if (this.HasValue)
                {
                    if (!string.Equals(metaDataItem.Value, this.Value))
                    {
                        metaDataItem.Value = this.Value;
                        fileDatas.Add(source);
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(metaDataItem.Value))
                    {
                        metaDataItem.Value = null;
                        fileDatas.Add(source);
                    }
                }
            }
            this.OriginalValue = this.Value;
            return(fileDatas);
        }
Ejemplo n.º 20
0
 protected virtual void Bind()
 {
     if (this.FileData == null)
     {
         this.MetaDataItem = null;
     }
     else
     {
         lock (this.FileData.MetaDatas)
         {
             var metaDataItem = this.FileData.MetaDatas.FirstOrDefault(
                 _metaDataItem => string.Equals(_metaDataItem.Name, CommonStatistics.Rating, StringComparison.OrdinalIgnoreCase)
                 );
             if (metaDataItem == null)
             {
                 metaDataItem = new MetaDataItem(CommonStatistics.Rating, MetaDataItemType.Tag);
                 this.FileData.MetaDatas.Add(metaDataItem);
             }
             this.MetaDataItem = metaDataItem;
         }
     }
 }
Ejemplo n.º 21
0
        public static CmsLocalFileOnDisk CreateFromFile(string filenameOnDisk)
        {
            CmsLocalFileOnDisk ret = new CmsLocalFileOnDisk();

            ret.filename      = Path.GetFileName(filenameOnDisk);
            ret.filepath      = filenameOnDisk;
            ret.fileDirectory = Path.GetDirectoryName(filenameOnDisk);
            ret.MimeType      = PageUtils.MimeTypeLookup(Path.GetExtension(filenameOnDisk));

            if (File.Exists(filenameOnDisk))
            {
                FileInfo fi = new FileInfo(filenameOnDisk);


                ret.FileSize      = fi.Length;
                ret.FileTimestamp = fi.LastWriteTime;

                MetaDataItem[] metaData = new MetaDataItem[0];
                if (MetaDataUtils.CanExtractImageMetaData(filenameOnDisk))
                {
                    metaData = MetaDataUtils.GetFromImageFile(filenameOnDisk);
                }
                else if (MetaDataUtils.CanExtractOLEMetaData(filenameOnDisk))
                {
                    metaData = MetaDataUtils.GetFromOLEDocument(filenameOnDisk);
                }
                else if (MetaDataUtils.CanExtractXmpData(filenameOnDisk))
                {
                    metaData = MetaDataUtils.GetXmpData(filenameOnDisk);
                }

                ret.MetaData = CmsLocalFileOnDiskMetaItem.FromMetaDataItems(ret, metaData);
            }

            return(ret);
        }
        public static void GenerateJSONs(Dictionary <string, bool> componentsSettings)
        {
            Logger.Add(eMessageType.note, "GenerateJSON pressed");

            Dictionary <string, List <PlayfieldItem> > playfields = new Dictionary <string, List <PlayfieldItem> >();
            Dictionary <string, Keymode> keymodes = new Dictionary <string, Keymode>();
            List <MetaDataItem>          metaData = new List <MetaDataItem>();

            Logger.Add(eMessageType.process, "Making playfield, keymode and metadataitem for each mode");
            foreach ((string, bool)mode in Info.modes)
            {
                string modeName = mode.Item1;
                bool   hasST    = mode.Item2;

                Logger.Add(eMessageType.value, "Mode: " + modeName);
                for (int i = 0; i < (hasST ? 2 : 1); i++)
                {
                    bool sidetracks = i == 0 ? false : true;

                    int keyAmount;
                    if (modeName == "4k")
                    {
                        keyAmount = 4;
                    }
                    else if (modeName == "5k")
                    {
                        keyAmount = 5;
                    }
                    else if (modeName == "6k")
                    {
                        keyAmount = 6;
                    }
                    else if (modeName == "8k")
                    {
                        keyAmount = 8;
                    }
                    else
                    {
                        keyAmount = 10;
                    }

                    Logger.Add(eMessageType.value, "Sidetracks: " + sidetracks);

                    Logger.Add(eMessageType.process, "Making playfield");
                    List <PlayfieldItem> playfield = PlayfieldItem.GetPlayfield(modeName, sidetracks, componentsSettings);

                    string keymodeName   = modeName + (sidetracks ? "2st" : "");
                    string playfieldName = "playfield" + keymodeName;
                    string name          = Info.skinName + " " + keymodeName;
                    string inputMode     = (keyAmount + (sidetracks ? 2 : 0)) + "key";
                    if (modeName.Contains("10k") && sidetracks)
                    {
                        inputMode = "10key2scratch";
                    }
                    else if (modeName.Contains("4k2fx4l"))
                    {
                        inputMode = "4bt2fx2laserleft2laserright";
                    }

                    Logger.Add(eMessageType.process, "Making keymode");
                    Keymode keymode = new Keymode()
                    {
                        name      = name,
                        playfield = Info.files[playfieldName],
                        images    = Image.GetImages(modeName, sidetracks),
                        notes     = Keymode.GetNotes(modeName, sidetracks),
                        cses      = new List <object[]>()
                        {
                            Info.cs
                        }
                    };

                    Logger.Add(eMessageType.process, "Making metadataitem");
                    MetaDataItem metaDataItem = new MetaDataItem()
                    {
                        name      = name,
                        inputMode = inputMode,
                        type      = "json:full-v2",
                        path      = Info.files[keymodeName]
                    };

                    playfields[playfieldName] = playfield;
                    keymodes[keymodeName]     = keymode;
                    metaData.Add(metaDataItem);
                }
            }
            Logger.Add(eMessageType.completion, "Making playfield, keymode and metadataitems for each mode complete");

            CreateJSONs(playfields, keymodes, metaData);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Determines whether a meta-data item is global or namespace-specific.
        /// </summary>
        /// <param name="item">The item to test.</param>
        /// <returns><c>true</c> if the meta-data item is global, <c>false</c> otherwise.</returns>
        public static bool IsMetaDataItemGlobal(MetaDataItem item)
        {
            int value = (int)item;

            return(value < 100);            // See MetaDataItem
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Determines whether a meta-data item is global or namespace-specific.
 /// </summary>
 /// <param name="item">The item to test.</param>
 /// <returns><c>true</c> if the meta-data item is global, <c>false</c> otherwise.</returns>
 public static bool IsMetaDataItemGlobal(MetaDataItem item)
 {
     int value = (int)item;
     return value < 100; // See MetaDataItem
 }
Ejemplo n.º 25
0
 private IEnumerator WaitForTexture(GameObject q, MetaDataItem mdi)
 {
     WWW www = new WWW ("file:///" + this.imageDirectory + "/" + mdi.filename);
     yield return www;
     q.renderer.material.mainTexture = www.texture;
 }
Ejemplo n.º 26
0
 public string GetMetaDataItem(MetaDataItem item, string tag, bool nullTagIfEmpty)
 {
     throw new NotImplementedException();
 }
		/// <summary>
		/// Sets a meta-data items' content.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <param name="tag">The tag that specifies the context (usually the namespace).</param>
		/// <param name="content">The content.</param>
		/// <returns><c>true</c> if the content is set, <c>false</c> otherwise.</returns>
		public bool SetMetaDataItem(MetaDataItem item, string tag, string content) {
			if(string.IsNullOrEmpty(tag)) tag = " ";
			if(string.IsNullOrEmpty(content)) content = " ";

			// 1. Delete old value, if any
			// 2. Store new value

			ICommandBuilder builder = GetCommandBuilder();
			DbConnection connection = builder.GetConnection(connString);
			DbTransaction transaction = BeginTransaction(connection);

			QueryBuilder queryBuilder = new QueryBuilder(builder);

			string query = queryBuilder.DeleteFrom("MetaDataItem");
			query = queryBuilder.Where(query, "Name", WhereOperator.Equals, "Name");
			query = queryBuilder.AndWhere(query, "Tag", WhereOperator.Equals, "Tag");

			List<Parameter> parameters = new List<Parameter>(2);
			parameters.Add(new Parameter(ParameterType.String, "Name", item.ToString()));
			parameters.Add(new Parameter(ParameterType.String, "Tag", tag));

			DbCommand command = builder.GetCommand(transaction, query, parameters);

			int rows = ExecuteNonQuery(command, false);

			if(rows == -1) {
				RollbackTransaction(transaction);
				return false;
			}

			query = queryBuilder.InsertInto("MetaDataItem", new string[] { "Name", "Tag", "Data" }, new string[] { "Name", "Tag", "Content" });

			parameters = new List<Parameter>(3);
			parameters.Add(new Parameter(ParameterType.String, "Name", item.ToString()));
			parameters.Add(new Parameter(ParameterType.String, "Tag", tag));
			parameters.Add(new Parameter(ParameterType.String, "Content", content));

			command = builder.GetCommand(transaction, query, parameters);

			rows = ExecuteNonQuery(command, false);

			if(rows == 1) CommitTransaction(transaction);
			else RollbackTransaction(transaction);

			return rows == 1;
		}
		/// <summary>
		/// Gets a meta-data item's content.
		/// </summary>
		/// <param name="item">The item.</param>
		/// <param name="tag">The tag that specifies the context (usually the namespace).</param>
		/// <returns>The content.</returns>
		public string GetMetaDataItem(MetaDataItem item, string tag) {
			if(string.IsNullOrEmpty(tag)) tag = " ";

			ICommandBuilder builder = GetCommandBuilder();
			QueryBuilder queryBuilder = new QueryBuilder(builder);

			string query = queryBuilder.SelectFrom("MetaDataItem", new string[] { "Data" });
			query = queryBuilder.Where(query, "Name", WhereOperator.Equals, "Name");
			query = queryBuilder.AndWhere(query, "Tag", WhereOperator.Equals, "Tag");

			List<Parameter> parameters = new List<Parameter>(2);
			parameters.Add(new Parameter(ParameterType.String, "Name", item.ToString()));
			parameters.Add(new Parameter(ParameterType.String, "Tag", tag));

			DbCommand command = builder.GetCommand(connString, query, parameters);

			string value = ExecuteScalar<string>(command, " ");

			return value;
		}
Ejemplo n.º 29
0
 /// <summary>
 /// Gets a meta-data item's content.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="tag">The tag that specifies the context (usually the namespace).</param>
 /// <returns>The content.</returns>
 public string GetMetaDataItem(MetaDataItem item, string tag)
 {
     lock(this) {
         string fullFile = GetFullPathForMetaDataItem(tag, MetaDataItemFiles[item]);
         if(!File.Exists(fullFile)) return "";
         else return File.ReadAllText(fullFile);
     }
 }
 public bool SetMetaDataItem(MetaDataItem item, string tag, string content)
 {
     throw new NotImplementedException();
 }
 public string GetMetaDataItem(MetaDataItem item, string tag)
 {
     throw new NotImplementedException();
 }
 public bool SetMetaDataItem(MetaDataItem item, string tag, string content)
 {
     throw new NotImplementedException();
 }
        public void SetMetaDataItem_GetMetaDataItem(MetaDataItem item, string newContent)
        {
            ISettingsStorageProviderV30 prov = GetProvider();

            Assert.IsTrue(prov.SetMetaDataItem(item, null, newContent), "SetMetaDataItem should return true");
            Assert.AreEqual(newContent, prov.GetMetaDataItem(item, null), "Wrong content");

            Assert.IsTrue(prov.SetMetaDataItem(item, "Tag", newContent + "Mod"), "SetMetaDataItem should return true");
            Assert.AreEqual(newContent + "Mod", prov.GetMetaDataItem(item, "Tag"), "Wrong content");
        }
Ejemplo n.º 34
0
 private string GetMetadataItemWithFallback(MetaDataItem item, string currentNamespace)
 {
     return(Settings.Provider.GetMetaDataItem(item, currentNamespace, true));
 }
Ejemplo n.º 35
0
        /// <summary>
        /// Sets a meta-data items' content.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="tag">The tag that specifies the context (usually the namespace).</param>
        /// <param name="content">The content.</param>
        /// <returns><c>true</c> if the content is set, <c>false</c> otherwise.</returns>
        public bool SetMetaDataItem(MetaDataItem item, string tag, string content)
        {
            if(content == null) content = "";

            lock(this) {
                File.WriteAllText(GetFullPathForMetaDataItem(tag, MetaDataItemFiles[item]), content);
                return true;
            }
        }
 public string GetMetaDataItem(MetaDataItem item, string tag)
 {
     throw new NotImplementedException();
 }