private void LoadAllItems()
    {
        SqliteDataReader reader = Database.Query("SELECT id, name, data FROM meta");

        while (reader.Read())
        {
            uint id = Convert.ToUInt32(reader [0]);

            string name = reader [1].ToString();

            string data = null;
            if (reader [2] != null)
            {
                data = reader [2].ToString();
            }

            MetaItem item = new MetaItem(id, name, data);

            AddToCache(item);
        }

        reader.Close();

        if (FSpotVersion.Value != FSpot.Defines.VERSION)
        {
            FSpotVersion.Value = FSpot.Defines.VERSION;
            Commit(FSpotVersion);
        }
    }
Exemple #2
0
        public static MetaItem[] ToMetaItems(IGalleryObjectMetadataItemCollection metadataItems, IGalleryObject galleryObject)
        {
            var metaItems  = new MetaItem[metadataItems.Count];
            var metaDefs   = Factory.LoadGallerySetting(galleryObject.GalleryId).MetadataDisplaySettings;
            var moProfiles = ProfileController.GetProfile().MediaObjectProfiles;

            for (int i = 0; i < metaItems.Length; i++)
            {
                IGalleryObjectMetadataItem md = metadataItems[i];

                metaItems[i] = new MetaItem
                {
                    Id         = md.MediaObjectMetadataId,
                    MediaId    = galleryObject.Id,
                    MTypeId    = (int)md.MetadataItemName,
                    GTypeId    = (int)galleryObject.GalleryObjectType,
                    Desc       = md.Description,
                    Value      = md.Value,
                    IsEditable = metaDefs.Find(md.MetadataItemName).IsEditable
                };

                if (md.MetadataItemName == MetadataItemName.Rating)
                {
                    ReplaceAvgRatingWithUserRating(metaItems[i], moProfiles);
                }
            }

            return(metaItems);
        }
    public override void Commit(DbItem dbitem)
    {
        MetaItem item = dbitem as MetaItem;

        Database.ExecuteNonQuery(new DbCommand("UPDATE meta SET data = :data WHERE name = :name", "name", item.Name, "data", item.Value));

        EmitChanged(item);
    }
Exemple #4
0
        public ActionResult create(MetaItem meta)
        {
            if (ModelState.IsValid)
            {
                MetaItem.Insert(meta);
                return RedirectToAction("index");
            }

            return View(meta);
        }
Exemple #5
0
        /// <summary>
        /// When the current user has previously rated an item, replace the average user rating with user's
        /// own rating.
        /// </summary>
        /// <param name="metaItem">The meta item. It must be a <see cref="MetadataItemName.Rating" /> item.</param>
        /// <param name="moProfiles"></param>
        private static void ReplaceAvgRatingWithUserRating(MetaItem metaItem, IMediaObjectProfileCollection moProfiles)
        {
            var moProfile = moProfiles.Find(metaItem.MediaId);

            if (moProfile != null)
            {
                metaItem.Desc  = Resources.GalleryServerPro.UC_Metadata_UserRated_Rating_Lbl;
                metaItem.Value = moProfile.Rating;
            }
        }
Exemple #6
0
        public ActionResult edit(MetaItem meta)
        {
            if (ModelState.IsValid)
            {
                MetaItem.Update(meta);
                return RedirectToAction("index");
            }

            return View("create", meta);
        }
Exemple #7
0
        void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MetaItem item = (MetaItem)this.listView.SelectedItem;

            if (item != null)
            {
                string symbol = item.Symbol;
                if (OnSymbolSelected != null)
                {
                    OnSymbolSelected(symbol);
                }
            }
        }
        protected void repValue_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem itm         = e.Item;
            MetaItem     currentItem = e.Item.DataItem as MetaItem;

            Label lbl = (Label)itm.FindControl("lblValueName");

            lbl.Text = currentItem.Name;

            Repeater rep = (Repeater)itm.FindControl("repValueLinks");

            rep.DataSource = currentItem.Links;
            rep.DataBind();
        }
    private MetaItem Create(string name, string data)
    {
        uint id = (uint)Database.Execute(new DbCommand("INSERT INTO meta (name, data) VALUES (:name, :data)",
                                                       "name", name, "data", (data == null) ? "NULL" : data));

        //FIXME This smells bad. This line used to be *before* the
        //Command.executeNonQuery. It smells of a bug, but there might
        //have been a reason for this

        MetaItem item = new MetaItem(id, name, data);


        AddToCache(item);
        EmitAdded(item);

        return(item);
    }
        public void Test1()
        {
            MetaItem meta1 = new MetaItem()
            {
                Id = 1, Name = "MetaItem1"
            };
            MetaItem meta2 = new MetaItem()
            {
                Id = 1, Name = "MetaItem 1.1"
            };
            Item meta3 = new Item()
            {
                Id = 101, Name = "Item 1"
            };

            meta1.ChildItems.Add(meta3);             // this line should not compile.
            meta1.ChildItems.Add(meta2);             // This is valid and gets compiled.
        }
        private List <MetaItem> GetVariableLinks()
        {
            List <MetaItem> lst = new List <MetaItem>();

            PCAxis.Paxiom.Variable variable = PCAxis.Web.Core.Management.PaxiomManager.PaxiomModel.Meta.Variables.GetByCode(cboVariables.SelectedValue);

            MetaItem itm = new MetaItem();

            itm.Name = variable.Name;

            if (!string.IsNullOrWhiteSpace(variable.MetaId))
            {
                itm.Links = _linkManager.GetVariableLinks(variable.MetaId, LocalizationManager.CurrentCulture.Name).ToList();
            }

            // Only display the variable if it has metadata links
            if (itm.Links.Count > 0)
            {
                lst.Add(itm);
            }

            return(lst);
        }
	private MetaItem Create (string name, string data)
	{

		uint id = (uint)Database.Execute(new DbCommand("INSERT INTO meta (name, data) VALUES (:name, :data)",
				"name", name, "data", (data == null) ? "NULL" : data ));
		
		//FIXME This smells bad. This line used to be *before* the
		//Command.executeNonQuery. It smells of a bug, but there might
		//have been a reason for this

		MetaItem item = new MetaItem (id, name, data);

		
		AddToCache (item);
		EmitAdded (item);

		return item;
	}
	private void LoadAllItems ()
	{
		SqliteDataReader reader = Database.Query("SELECT id, name, data FROM meta");

		while (reader.Read ()) {
			uint id = Convert.ToUInt32 (reader [0]);

			string name = reader [1].ToString ();

			string data = null;
			if (reader [2] != null)
				data = reader [2].ToString ();

			MetaItem item = new MetaItem (id, name, data);

			AddToCache (item);
		}

		reader.Close ();

		if (FSpotVersion.Value != FSpot.Defines.VERSION) {
			FSpotVersion.Value = FSpot.Defines.VERSION;
			Commit (FSpotVersion);
		}
	}
		public static void Run (Db database)
		{
			db = database;
			db_version = db.Meta.DatabaseVersion;

			if (updates.Count == 0)
				return;

			Version current_version = new Version (db_version.Value);

			if (current_version == LatestVersion)
				return;
			else if (current_version > LatestVersion) {
				Console.WriteLine ("The existing database version is more recent than this version of F-Spot expects.");
				return;
			}

			Console.WriteLine ("Updating F-Spot Database");

			// Only create and show the dialog if one or more of the updates to be done is
			// marked as being slow
			bool slow = false;
			foreach (Version version in updates.Keys) {
				if (version > current_version && (updates[version] as Update).IsSlow)
					slow = true;
					break;
			}

			if (slow) {
				dialog = new ProgressDialog (Catalog.GetString ("Updating F-Spot Database"), ProgressDialog.CancelButtonType.None, 0, null);
				dialog.Message.Text = Catalog.GetString ("Please wait while your F-Spot gallery's database is updated. This may take some time.");
				dialog.Bar.Fraction = 0.0;
				dialog.Modal = false;
				dialog.SkipTaskbarHint = true;
				dialog.WindowPosition = WindowPosition.Center;
				dialog.ShowAll ();
				dialog.Present ();
				dialog.QueueDraw ();
			}

			db.BeginTransaction ();
			try {
				ArrayList keys = new ArrayList (updates.Keys);
				keys.Sort ();
				foreach (Version version in keys) {
					if (version <= current_version)
						continue;

					Pulse ();
					(updates[version] as Update).Execute (db, db_version);
				}

				db.CommitTransaction ();
			} catch (Exception e) {
				Console.WriteLine ("Rolling back database changes because of Exception");
				// There was an error, roll back the database
				db.RollbackTransaction ();

				// Pass the exception on, this is fatal
				throw e;
			}
			
			if (dialog != null)
				dialog.Destroy ();
			
			if (new Version(db_version.Value) == LatestVersion)
				Console.WriteLine ("Database updates completed successfully.");
		}
        private Instance createMetaItemInstance(AnalyzingContext analyzingContext, MetaItem item)
        {
            var metaDataObject = item.IsMultiple ? item.Data.ToArray() : item.Data.First();

            return(createInstance(analyzingContext, metaDataObject));
        }
Exemple #16
0
 public FrontController()
 {
     _bModel = new BuildRepository();
     _mModel = new MetaItem();
 }
			public void Execute (Db db, MetaItem db_version)
			{
				code ();
				
				Console.WriteLine ("Updated database from version {0} to {1}",
						db_version.Value,
						Version.ToString ());


				db_version.Value = Version.ToString ();
				db.Meta.Commit (db_version);
			}
Exemple #18
0
        private MetaItem CreateOperationMetaItem(string baseUri, ApiDescription description,
                                                 IServiceProvider serviceProvider)
        {
            var relativePath = Uri.UnescapeDataString(description.RelativePath ?? string.Empty);
            var url          = $"{baseUri}/{relativePath}";
            var operation    = new MetaOperation
            {
                auth        = ResolveOperationAuth(description),
                proxy       = new { },
                certificate = new { },
                method      = description.HttpMethod,
                description = new MetaDescription {
                    content = "", type = MediaTypeNames.Text.Markdown, version = null
                },
                header = new List <MetaParameter>
                {
                    new MetaParameter
                    {
                        disabled    = false,
                        description = "",                         /* new MetaDescription
                                                                   * {
                                                                   * content = "",
                                                                   * type = MediaTypeNames.Markdown,
                                                                   * version = null
                                                                   * },*/
                        key         = HeaderNames.ContentType,
                        value       = MediaTypeNames.Application.Json
                    }
                },
                body = default
            };

            operation.url = MetaUrl.FromRaw(url);

            foreach (var provider in _parameterProviders)
            {
                provider.Enrich(url, operation, serviceProvider);
            }

            var item = new MetaItem
            {
                id          = Guid.NewGuid(),
                name        = relativePath,
                description =
                    new MetaDescription {
                    content = "", type = MediaTypeNames.Text.Markdown, version = null
                },
                variable = new List <dynamic>(),
                @event   = new List <dynamic>(),
                request  = operation,
                response = new List <dynamic>(),
                protocolProfileBehavior = new { }
            };

            if (description.SupportedRequestFormats.Count > 0)
            {
                var bodyParameter = description.ParameterDescriptions.SingleOrDefault(
                    x => x.Source.IsFromRequest && x.Source.Id == "Body");

                //
                // Token Capture:
                if (item.request.method == "POST" && bodyParameter?.Type?.Name == "BearerTokenRequest")
                {
                    [email protected](new
                    {
                        listen = "test",
                        script = new
                        {
                            id   = "66a87d23-bc0e-432c-acee-cb48d3704947",
                            exec = new List <string>
                            {
                                "var data = JSON.parse(responseBody);\r",
                                "postman.setGlobalVariable(\"accessToken\", data.accessToken);"
                            },
                            type = "text/javascript"
                        }
                    });
                    item.request.body = new
                    {
                        mode = "raw",
                        raw  =
                            "{\r\n\t\"IdentityType\": \"Username\",\r\n\t\"Identity\": \"\",\r\n\t\"Password\": \"\"\r\n}"
                    };
                }

                //
                // Body Definition (roots only):
                if (bodyParameter != null && bodyParameter.Type != null &&
                    !typeof(IEnumerable).IsAssignableFrom(bodyParameter.Type))
                {
                    item.request.body = new
                    {
                        mode = "raw",
                        raw  = JsonConvert.SerializeObject(
                            FormatterServices.GetUninitializedObject(bodyParameter.Type))
                    }
                }
                ;
            }

            //
            // Bearer:
            if (item.request?.auth != null &&
                (item.request.auth.Equals("bearer", StringComparison.OrdinalIgnoreCase) ||
                 item.request.auth.Equals("platformbearer", StringComparison.OrdinalIgnoreCase)))
            {
                item.request.header.Add(new MetaParameter
                {
                    key         = "Authorization",
                    value       = "Bearer {{accessToken}}",
                    description = "Access Token",
                    type        = "text"
                });
            }

            return(item);
        }
 private static void AddGetter( MetaItem item )
 {
     AppendInFile( messageFile , @"// Getter of " + item.name.ToLower() + "_" + myNewLine , indent );
     AppendInFile( messageFile , item.type + " " + item.name+ "()" + myNewLine , indent );
     AppendInFile( messageFile , "{" + myNewLine , indent );
     indent++;
     AppendInFile( messageFile , "return " + item.name.ToLower() + "_;" + myNewLine , indent );
     indent--;
     AppendInFile( messageFile , "}" + myNewLine , indent );
     AppendInFile( messageFile , myNewLine , indent );
 }
 private static void AddSetter( MetaItem item )
 {
     AppendInFile( messageFile , @"// Setter of " + item.name.ToLower() + "_" + myNewLine , indent );
     AppendInFile( messageFile , "void " + item.name+ "( " + item.type + " value )" + myNewLine , indent );
     AppendInFile( messageFile , "{" + myNewLine , indent );
     indent++;
     AppendInFile( messageFile , item.name.ToLower() + "_ = value;" + myNewLine , indent );
     AppendInFile( messageFile , "raw_data_[ \"data\" ][ \"" + item.name + "\" ] = value;" + myNewLine , indent );
     indent--;
     AppendInFile( messageFile , "}" + myNewLine , indent );
     AppendInFile( messageFile , myNewLine , indent );
 }
 private static void FixStringType( MetaItem item )
 {
     if ( item.type.ToLower().Equals( "string" ) )
     {
         item.value = "\"" + item.value + "\"";
     }
 }
Exemple #22
0
 public MetaController()
 {
     _mModel = new MetaItem();
 }