Search Results

Search found 13135 results on 526 pages for 'actor model'.

Page 102/526 | < Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >

  • Design patterns for Caching Images in a MVC?

    - by Onema
    Hi, I'm designing an image cache system that will be used in an MVC CMS. The main purpose of the image cacher is to modify images: scale, crop, etc and cache them in the client site. I have created an image cache Model and Mapper that interact with the Database, to keep track of the images and know what kind of actions have been applied to them (scale, crop, etc). In addition to the Model and Mapper I have created a ImageCacher Class that is used by the API to manage the Model and image creation based on arguments passed by the client site, this class creates the images and generates the links to the images for the View. A coworker argued that I need to include the functionality of this last Class inside the Model, as the bulk of the logic should go in the model. I respectfully disagree with him since I feel the model's responsibility is to deal with the information about the images cached at the database level, and the responsibility of the ImageCacher Class is to create the url/image that we will be caching (keeping the single responsibility principle). In addition to this I believe that a model should not have Presentation-related features, like creating or showing images. Does anyone have any insight on this? is there a particular design pattern that would make this division of tasks clear and and the image cacher reusable? Should I add all the logic in the Model? Thank you.

    Read the article

  • mvc design in a card game

    - by Hong
    I'm trying to make a card game. some classes I have are: CardModel, CardView; DeckModel, DeckView. The deck model has a list of card model, According to MVC, if I want to send a card to a deck, I can add the card model to the deck model, and the card view will be added to the deck view by a event handler. So I have a addCard(CardModel m) in the DeckModel class, but if I want to send a event to add the card view of that model to the deck view, I only know let the model has a reference to view. So the question is: If the card model and deck model have to have a reference to their view classes to do it? If not, how to do it better? Update, the code: public class DeckModel { private ArrayList<CardModel> cards; private ArrayList<EventHandler> actionEventHandlerList; public void addCard(CardModel card){ cards.add(card); //processEvent(event x); //must I pass a event that contain card view here? } CardModel getCards(int index){ return cards.get(index); } public synchronized void addEventHandler(EventHandler l){ if(actionEventHandlerList == null) actionEventHandlerList = new ArrayList<EventHandler>(); if(!actionEventHandlerList.contains(l)) actionEventHandlerList.add(l); } public synchronized void removeEventHandler(EventHandler l){ if(actionEventHandlerList!= null && actionEventHandlerList.contains(l)) actionEventHandlerList.remove(l); } private void processEvent(Event e){ ArrayList list; synchronized(this){ if(actionEventHandlerList!= null) list = (ArrayList)actionEventHandlerList.clone(); else return; } for(int i=0; i<actionEventHandlerList.size(); ++i){ actionEventHandlerList.get(i).handle(e); } } }

    Read the article

  • how can I code a recursive query in an Entity Framework model?

    - by Greg
    Hi, I have a model which includes NODES, and RELATIONSHIPS (that tie the nodes together, via a parent_node, child_node arrangement). Q1 - Is there any way in EF / Linq-to-entities to perform a query on nodes (e.g. context.Nodes..) to find say "all parents" or "or children" in the graph? Q2 - If there's not in Linq-to-entities, is there any other way to do this other than writing a method that manually goes through and doing it? Q3 - If manual is the only way to do it, should I be concerned about the number of database hits that will be going out to the database as the method keeps recursing through the data? Or more specifically, is there any EF caching type feature that might assist here in ensuring the method is performance from a "number of database hits" point of view? thanks thanks

    Read the article

  • MSB3422 Failed to retrieve VC project information through the VC project engine object model. MSB342

    - by Scott Langham
    I'm getting the following errors from MSBuild while trying to build a solution: C:\dev\MySln.sln : warning MSB3422: Failed to retrieve VC project information through the VC project engine object model. Unable to determine default tool for the specified file configuration. C:\dev\MySln.sln : warning MSB3425: Could not resolve VC project reference "C:\dev\MyProj.vcproj". Have you got any ideas on what's causing this? I've seen other postings about similar, but different errors such as when the MSB3422 error has a different message and shows "Illegal characters in path.", but I haven't seen any useful information about how to solve the error I'm getting where it says "Unable to determine default tool for the specified file configuration.". Thanks. I found this, but it doesn't really help: http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/b470f111-9321-4b43-8bd1-7fcf67c2d402

    Read the article

  • Extending User object in Django: User model inheritance or use UserProfile?

    - by Chris
    To extend the User object with custom fields, the Django docs recommend using UserProfiles. However, according to this answer to a question about this from a year or so back: extending django.contrib.auth.models.User also works better now -- ever since the refactoring of Django's inheritance code in the models API. And articles such as this lay out how to extend the User model with custom fields, together with the advantages (retrieving properties directly from the user object, rather than through the .get_profile()). So I was wondering whether there is any consensus on this issue, or reasons to use one or the other. Or even what the Django team currently think?

    Read the article

  • MVVM- How would I go about propagating settings between my main view-model (and other view-models) a

    - by Justin
    I am building a settings dialog for my application and right now all of the settings correspond with settings on the main view-model, but as I add more view's and view-models some may not. I need to know what the best practice is for loading the current settings into the settings dialog and then saving the settings to thier corresponding view-models if the user clicks okay. I will not be using the Properties.Settings.Default system to store settings since I want my application to be as portable as possible and this would store user scoped settings in the directory: C:\Users\ username \Local Settings\Application Data\ ApplicationName Instead of in my application's directory. In case it makes any difference I am using the MVVM Light Toolkit by Laurent Bugnion.

    Read the article

  • Create unordered list tree menu from data stored in an table with the adjacency list model...php

    - by Ronedog
    I need to create a tree menu of "nth" subcategories. I settled on using the adjacency list model for my table structure, because I won't be updating this table very much and this seemed the easiest to implement for my use. I want to style the output using "ul" and "li" tags...I already have a css and jquery solution to do the styling. My problem comes from pulling the data out of the database and using a recursive function via PHP to build the list ... the list is a concatenated string that gets parsed to build the tree. I'm really having a hard time getting the closing "ul" and "li" tags to line up just where they need to be. Is this the best way to do this? Are there other better ways using arrays or something like that to do this? Any examples you can point me to of "best practices" for building a list like this will be appreciated. Thanks.

    Read the article

  • How does the Licenses.licx based .Net component licensing model work?

    - by Gishu
    I've encountered multiple third part .Net component-vendors use a licensing scheme. On an evaluation copy, the components show up with a nag-screen or watermark or some such indicator. On a licensed machine, a Licenses.licx is created - with what appears to be just the assembly full name/identifiers. This file has to be included when the client assembly is built. How does this model work? Both from component-vendors' and users' perspective. What is the .licx file used for? Should it be checked in? We've had a number of issues with the wrong/right .licx file being checked in and what not

    Read the article

  • How should I model the database for this problem? And which ORM can handle it?

    - by Kristof Claes
    I need to build some sort of a custom CMS for a client of ours. These are some of the functional requirements: Must be able to manage the list of Pages in the site Each Page can contain a number of ColumnGroups A ColumnGroup is nothing more than a list of Columns in a certain ColumnGroupLayout. For example: "one column taking up the entire width of the page", "two columns each taking up half of the width", ... Each Column can contain a number ContentBlocks Examples of a ContentBlock are: TextBlock, NewsBlock, PictureBlock, ... ContentBlocks can be given a certain sorting within a Column A ContentBlock can be put in different Columns so that content can be reused without having to be duplicated. My first quick draft of how this could look like in C# code (we're using ASP.NET 4.0 to develop the CMS) can be found at the bottom of my question. One of the technical requirements is that it must be as easy as possible to add new types of ContentBlocks to the CMS. So I would like model everything as flexible as possible. Unfortunately, I'm already stuck at trying to figure out how the database should look like. One of the problems I'm having has to do with sorting different types of ContentBlocks in a Column. I guess each type of ContentBlock (like TextBlock, NewsBlock, PictureBlock, ...) should have it's own table in the database because each has it's own different fields. A TextBlock might only have a field called Text whereas a NewsBlock might have fields for the Text, the Summary, the PublicationDate, ... Since one Column can have ContentBlocks located in different tables, I guess I'll have to create a many-to-many association for each type of ContentBlock. For example: ColumnTextBlocks, ColumnNewsBlocks and ColumnPictureBlocks. The problem I have with this setup is the sorting of the different ContentBlocks in a column. This could be something like this: TextBlock NewsBlock TextBlock TextBlock PictureBlock Where do I store the sorting number? If I store them in the associaton tables, I'll have to update a lot of tables when changing the sorting order of ContentBlocks in a Column. Is this a good approach to the problem? Basically, my question is: What is the best way to model this keeping in mind that it should be easy to add new types of ContentBlocks? My next question is: What ORM can deal with that kind of modeling? To be honest, we are ORM-virgins at work. I have been reading a bit about Linq-to-SQL and NHibernate, but we have no experience with them. Because of the IList in the Column class (see code below) I think we can rule out Linq-to-SQL, right? Can NHibernate handle the mapping of data from many different tables to one IList? Also keep in mind that this is just a very small portion of the domain. Other parts are Users belonging to a certain UserGroup having certain Permissions on Pages, ColumnGroups, Columns and ContentBlocks. The code (just a quick first draft): public class Page { public int PageID { get; set; } public string Title { get; set; } public string Description { get; set; } public string Keywords { get; set; } public IList<ColumnGroup> ColumnGroups { get; set; } } public class ColumnGroup { public enum ColumnGroupLayout { OneColumn, HalfHalf, NarrowWide, WideNarrow } public int ColumnGroupID { get; set; } public ColumnGroupLayout Layout { get; set; } public IList<Column> Columns { get; set; } } public class Column { public int ColumnID { get; set; } public IList<IContentBlock> ContentBlocks { get; set; } } public interface IContentBlock { string GetSummary(); } public class TextBlock : IContentBlock { public string GetSummary() { return "I am a piece of text."; } } public class NewsBlock : IContentBlock { public string GetSummary() { return "I am a news item."; } }

    Read the article

  • How do I create a controller and action without a model?

    - by Angela
    I have several models: Email Letter Call All three belong to a model Campaign. And a Campaign has_many Contacts I envision being able to see a schedule for Today by going to domain/schedule/today What I'd like it to do would be to show all the Events (Email, Letter, Call) that have to happen today for each campaign. I tried the following, but have some challenges in putting it into a controller versus into a View. There are many emails in campaign. Email.days is the number of days from the contact.start_date that an email should be sent to the Contact. ScheduleController < def index campaigns.each do |campaign| #goes through each campaign for contacts in campaign.contacts Email.find(:all).reject { |email| email.contact.start_date + email.days <= Date.now } end end end

    Read the article

  • How do I correctly model data in SQL-based databases that have some columns in common, but also have

    - by Brandon Weiss
    For instance, let's say I have a User model. Users have things like logins, passwords, e-mail addresses, avatars, etc. But there are two types of Users that will be using this site, let's say Parents and Businesses. I need to store some different information for the Parents (e.g. childrens' names, domestic partner, salaries, etc.) than for the Businesses (e.g. industry, number of employees, etc.), but also some of it is the same, like logins and passwords. How do I correctly structure this in a SQL-based database? Thanks!

    Read the article

  • Do you know of a free .Net component for visual flow model graph design and editing?

    - by Ivan
    An app (C#4, WinForms, Entity Framework, SQL Server 2008) of mine maintains a graph of interconnected objects, each having some simple member fields and a set of many directed (in and out) one-to-one links to other objects. I'd like to offer a user an ability to view and edit this graph visually some way, creating and removing connections, modifying objects attributes values and introducing/dropping objects. I suppose there has to be a framework (at list a primitive kind of) for this as visual model design tools are pretty common to meet. Do you know one?

    Read the article

  • R: ggplot2, how to get the parameters from a plotted linear model smoother?

    - by John
    I have a data.frame with 3 time series in it, shown below. When I plot them with a smoother time series, I want to be able to get the parameters of the linear model that I plot, but I can't see how to do that? > data day od series_id 1 1 0.10 A1 2 3 1.00 A1 3 5 0.50 A1 4 7 0.70 A1 5 1 1.70 B1 6 3 1.60 B1 7 5 1.75 B1 8 7 1.70 B1 9 1 2.10 C1 10 3 2.30 C1 11 5 2.50 C1 12 7 2.70 C1 data = data.frame (day = c(1,3,5,7,1,3,5,7,1,3,5,7), od = c(0.1,1.0,0.5,0.7 ,1.7,1.6,1.75,1.7 ,2.1,2.3,2.5,2.7), series_id = c("A1", "A1", "A1","A1", "B1", "B1","B1", "B1", "C1","C1", "C1", "C1")) r <- ggplot(data = data, aes(x = day, y = od)) r + stat_smooth(aes(group = series_id, color = series_id),method="lm")

    Read the article

  • How to render the properties of the view model's base class first when using ViewData.ModelMetadata.

    - by Martin R-L
    When I use the ViewData.ModelMetadata.Properties in order to loop the properties (with an additional Where(modelMetadata => modelMetadata.ShowForEdit && !ViewData.TemplateInfo.Visited(modelMetadata))), and thereby create a generic edit view, the properties of the view model's base class are rendered last. Is it possible to use a clever OrderBy() or is there another way to first get the properties of the base class, and then the sub class'? Reverse won't do the trick since the ordering of each class' properties is perfectly fine. A workaround would of course be composition + delegation, but since we don't have mixins, it's too un-DRY IMHO, why I seek a better solution if possible.

    Read the article

  • Limit JavaScript and CSS files on ASP.NET MVC 2 Master Page based on Model and View content

    - by Zack Peterson
    I want to include certain .js and .css files only on pages that need them. For example, my EditorTemplate DateTime.ascx needs files anytimec.js and anytimec.css. That template is applied whenever I use either the EditorFor or EditorForModel helper methods in a view for a model with a DateTime type value. I've put this condition into the <head> section of my master page. It checks for a DateTime type property in the ModelMetadata. <% if (this.ViewData.ModelMetadata.Properties.Any(p => p.ModelType == typeof(DateTime))) { %> <link href="../../Content/anytimec.css" rel="stylesheet" type="text/css" /> <script src="../../Scripts/anytimec.js" type="text/javascript"></script> <% } %> This has two problems: Fails if I have nested child models of type DateTime Unnecessarily triggered by views without EditorFor or EditorForModel methods (example: DisplayForModel) How can I improve this technique?

    Read the article

  • CakePHP: Same model, set up per form validation rules?

    - by mwaterous
    I have a single model in CakePHP that has multiple forms on different pages of the site that I would like to validate differently even where the field name is the same - I have discovered that you can set 'on' to create|update which has been a handy discovery but I am wondering if there is any other way of explicitly declaring rules based on the form that was submitted? Just to rephrase for clarity, form a and form b contain fields of the same name, but if form a is submitted the fields in question should be validated differently than if they were submitted from form b. Possible?

    Read the article

  • ruby on rails: How do I access variable data in a url parameter passed to a model?

    - by bandhunt
    I have a variable called "account_type" passed from a rails form and need to access the value in the corresponding model. I can check if :account_type exists as a symbol, but where does the stored data come into play? Is there something I need to do in the controller? This code gives an undefined method 'account_type' error. validates_format_of :name, :with => /^[a-z0-9_]+$/i, :on => :create if account_type == 2 If I use a symbol then it doesn't give an error, but a symbol will never equal 2 validates_format_of :name, :with => /^[a-z0-9_]+$/i, :on => :create if :account_type == 2 It's confusing that you can validate the format of a symbol (like :name above) when :name only seems to be a reference with nothing stored in it. Thanks!

    Read the article

  • How to register a model in django-tagging anywhere not in the applications?

    - by culebrón
    Is it possible to register a model in django-tagging not in tagging app, nor in my app? The standard way is to edit apps/myapp/models.py this way: from apps import tagging tagging.register(MyModel) I want to keep both applications without changes, for example, to be able to pull new versions and just replace them. So I tried putting this into project settings.py, in the end, but of course this fails. from apps.myapp.models import MyModel from apps import tagging tagging.register(MyModel) (This fails when importing MyModel.) Any other way?

    Read the article

  • [Django] How to find out whether a model's column is a foreign key?

    - by codethief
    I'm dynamically storing information in the database depending on the request: // table, id and column are provided by the request table_obj = getattr(models, table) record = table_obj.objects.get(pk=id) setattr(record, column, request.POST['value']) The problem is that request.POST['value'] sometimes contains a foreign record's primary key (i.e. an integer) whereas Django expects the column's value to be an object of type ForeignModel: Cannot assign "u'122'": "ModelA.b" must be a "ModelB" instance. Now, is there an elegant way to dynamically check whether b is a column containing foreign keys and what model these keys are linked to? (So that I can load the foreign record by it's primary key and assign it to ModelA?) Or doesn't Django provide information like this to the programmer so I really have to get my hands dirty and use isinstance() on the foreign-key column?

    Read the article

  • How Do I insert Data in a table From the Model MVC?

    - by user54197
    I have data coming into my Model, how do I setup to insert the data in a table? public string Name { get; set; } public string Address { get; set; } public string City { get; set; } public string State { get; set; } public string Zip { get; set; } public Info() { using (SqlConnection connect = new SqlConnection(connections)) { string query = "Insert Into Personnel_Data (Name, StreetAddress, City, State, Zip, HomePhone, WorkPhone)" + "Values('" + Name + "','" + Address + "','" + City + "','" + State + "','" + Zip + "','" + ContactHPhone + "','" + ContactWPhone + "')"; SqlCommand command = new SqlCommand(query, connect); connect.Open(); command.ExecuteNonQuery(); } } The Name, Address, City, and so on is null when the query is being run. How do I set this up?

    Read the article

  • When saving to a model, created and modified aren't automatically populated by CakePHP. Using SQL Se

    - by bakerjr
    Hi when saving to a model, my created and modified fields aren't automatically populated by CakePHP. It was automatically populated when I was using MySQL but now it isn't. I'm not using NOW() back when I was still using MySQL. Why is it? Also when a field's value is not set 'NULL' (with quotes) is inserted causing errors because SQL Server says I can't insert a string to a field of type smallint/date etc. How do I fix this? Thanks in advance!

    Read the article

  • Building a wiki like data model in rails question.

    - by lillq
    I have a data model in which I would like to have an item that has a description that can be edited. I would like to also keep track of all edits to the item. I am running into issues with my current strategy, which is: class Item < ActiveRecord::Base has_one :current_edit, :class_name => "Edit", :foreign_key => "current_edit_id" has_many :edits end class Edit < ActiveRecord::Base belongs_to :item end Can the Item have multiple associations to the same class like this? I was thinking that I should switch to keeping track of the edit version in the Edit object and then just sorting the has_many relationship base on this version.

    Read the article

  • Ruby on Rails: How best to escape a string in a model?

    - by williamjones
    I want my application to sanitize html on input rather than on display, so that the fields saved into the database are sanitized. I've been doing this with strip_tags, and it was working great. However, this has the downside that it means the user can't input anything that's bracketed with < and . How can I tell Rails in the model to securely escape tags before saving them to the database? I'd like to not have to call h on the sanitized fields again before using them in the views.

    Read the article

  • Ruby on Rails: Simple way to select all records of a nested model?

    - by Josh Pinter
    Just curious, I spent an embarrassing amount of time trying to get an array of all the records in a nested model. I just want to make sure there is not a better way. Here is the setup: I have three models that are nested under each other (Facilities Tags Inspections), producing code like this for routes.rb: map.resources :facilities do |facilities| facilities.resources :tags, :has_many => :inspections end I wanted to get all of the inspections for a facility and here is what my code ended up being: def facility_inspections @facility = Facility.find(params[:facility_id]) @inspections = [] @facility.tags.each do |tag| tag.inspections.each do |inspection| @inspections << inspection end end end It works but is this the best way to do this - I think it's cumbersome. Thanks in advance. Josh

    Read the article

  • Does retrieving an object from Doctrine2 cause __construct() of the model class to run?

    - by jiewmeng
    When I retrieve an object say by $em->find('Application\Models\User', 1); or other methods like DQL, findBy*() cause the __construct() of the model class to run? I am having a problem where I set variables there like reference to EntityManager and I find that its not set. I tried putting a die() in __construct() and it doesn't halt the application. Can I say that if I want to set other properties/fields like EntityManager $em I have to do it some other way? Perhaps something like protected function getEm() { if (!isset($this->em)) { $this->em = \Zend_Registry::get('em'); } return $this->em; }

    Read the article

< Previous Page | 98 99 100 101 102 103 104 105 106 107 108 109  | Next Page >