Daily Archives

Articles indexed Saturday May 22 2010

Page 16/81 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • Asynchronous Sockets - Handling false socket.AcceptAsync values

    - by David
    The Socket class has a method .AcceptAsync which either returns true or false. I'd thought the false return value was an error condition, but in the samples Microsoft provide for Async sockets they call the callback function synchronously after checking for failure, as shown here: public void StartAccept(SocketAsyncEventArgs acceptEventArg) { if (acceptEventArg == null) { acceptEventArg = new SocketAsyncEventArgs(); acceptEventArg.Completed += new EventHandler<SocketAsyncEventArgs>(AcceptEventArg_Completed); } else { // socket must be cleared since the context object is being reused acceptEventArg.AcceptSocket = null; } m_maxNumberAcceptedClients.WaitOne(); bool willRaiseEvent = listenSocket.AcceptAsync(acceptEventArg); if (!willRaiseEvent) { ProcessAccept(acceptEventArg); } } /// <summary> /// This method is the callback method associated with Socket.AcceptAsync operations and is invoked /// when an accept operation is complete /// </summary> void AcceptEventArg_Completed(object sender, SocketAsyncEventArgs e) { ProcessAccept(e); } Why do they do this? It defeats the purpose of asynchronous sockets and stops the method from returning.

    Read the article

  • Detect if any USB drive is detected or not using WinForm Application in Visual C#

    - by Pavan Kumar
    I want to do the following things in my application 1) I want to display whether any USB drive is inserted or not in my application to prompt the user to insert a USB drive. I just want to notify the user if any USB dirve is inserted else prompt him to insert one using a label or something (i want to avoid messagebox as it will keep appearing whenever a device is inserted or removed. It will be irritating for the end user) in my Visual C# WinForm Application. If any USB drive is present display "USB drive detected" in the label. The user may add one or more USB sticks but the status will remain same. When there is none then the status of the label will change to "No USB drives found.Please insert a USB drive". 2) When one or more USB drive is added the volume name with the drive letter for example "James(F:)" is added to the Combobox list. The combobox list also needs to remove the entry for the USB drive added in the list automatically when it is removed . So when there is no USB the list should be empty and the label will again prompt user to insert a USB stick or drive.

    Read the article

  • Where are the function address literals in c++?

    - by academicRobot
    First of all, maybe literals is not the right term for this concept, but its the closest I could think of (not literals in the sense of functions as first class citizens). <UPDATE> After some reading with help from answer by Chris Dodd, what I'm looking for is literal function addresses as template parameters. Chris' answer indicates how to do this for standard functions, but how can the addresses of member functions be used as template parameters? Since the standard prohibits non-static member function addresses as template parameters (c++03 14.3.2.3), I suspect the work around is quite complicated. Any ideas for a workaround? Below the original form of the question is left as is for context. </UPDATE> The idea is that when you make a conventional function call, it compiles to something like this: callq <immediate address> But if you make a function call using a function pointer, it compiles to something like this: mov <memory location>,%rax callq *%rax Which is all well and good. However, what if I'm writing a template library that requires a callback of some sort with a specified argument list and the user of the library is expected to know what function they want to call at compile time? Then I would like to write my template to accept a function literal as a template parameter. So, similar to template <int int_literal> struct my_template {...};` I'd like to write template <func_literal_t func_literal> struct my_template {...}; and have calls to func_literal within my_template compile to callq <immediate address>. Is there a facility in C++ for this, or a work around to achieve the same effect? If not, why not (e.g. some cataclysmic side effects)? How about C++0x or another language? Solutions that are not portable are fine. Solutions that include the use of member function pointers would be ideal. I'm not particularly interested in being told "You are a <socially unacceptable term for a person of low IQ>, just use function pointers/functors." This is a curiosity based question, and it seems that it might be useful in some (albeit limited) applications. It seems like this should be possible since function names are just placeholders for a (relative) memory address, so why not allow more liberal use (e.g. aliasing) of this placeholder. p.s. I use function pointers and functions objects all the the time and they are great. But this post got me thinking about the don't pay for what you don't use principle in relation to function calls, and it seems like forcing the use of function pointers or similar facility when the function is known at compile time is a violation of this principle, though a small one. Edit The intent of this question is not to implement delegates, rather to identify a pattern that will embed a conventional function call, (in immediate mode) directly into third party code, possibly a template.

    Read the article

  • Stick with MFC or go to .Net

    - by Jon Drnek
    We have a largish MFC app that is our main product. This app is being actively developed and there are no plans to stop development. I am new to windows development, but I get the impression that MFC is dead and all the new growth and enhancements are in .net. Is this view accurate? What criteria should we consider when deciding if we should convert this application to .net. Here I'm asking why. I have asked the how question here

    Read the article

  • how to implement unitofwork pattern when using subsonic 2.1(Repository pattern) ?

    - by ROHITH
    I am using subsonic repository pattern(2.1) for asp.net mvc application.In my application,there are many repositories like categoryRepository,Blogrepository etc.Inside each of this repository i am calling subsonic's DB.Select().From()...ExecuteReader() and then loading domain objects from those reader. In the controller action i make multiple calls from these repositories for e.g. List<IBlog> blogs=_blogRepository.GetHottestBlogs(); List<ICategory> categories=_categoryRepository.GetAll(); do i have to implement any unitofwork pattern for this ?.My doubt is that how subsonic performs each operation DB.Update/Insert/Select .Is a TransactionScope is enough for batch update or do i have to use SharedDbConnectionScope to get better performance?

    Read the article

  • struts2-json-plugin not retrieving json data from action class for Struts-JQuery-Plugin grid

    - by thebravedave
    Hello, Im having an issue getting json working with the struts-jquery-plugin-2.1.0 I have included the struts2-json-plugin-2.1.8.1 in my classpath as well. Im sure that I have my struts-jquery-plugin configured correctly because the grid loads, but doesnt load the data its supposed to get from the action class that has been json'ized. The documentation with the json plugin and the struts-jquery plugin leaves ALOT of gaps that I cant even find with examples/tutorials, so I come to the community at stackoverflow. My action class has a property called gridModel thats a List with a basic POJO called Customer. Customer is a pojo with one property, id. I have a factory that supplies the populated List to the actions List property which i mentioned called gridModel. Heres how i set up my struts.xml file: <constant name="struts.devMode" value="true"/> <constant name="struts.objectFactory" value="guice"/> <package name="org.webhop.ywdc" namespace="/" extends="struts-default,json-default"> <result-types> <result-type name="json" class="com.googlecode.jsonplugin.JSONResult"> </result-type> </result-types> <action name="login" class="org.webhop.ywdc.LoginAction" > <result type="json"></result> <result name="success" type="dispatcher">/pages/uiTags/Success.jsp</result> <result name="error" type="redirect">/pages/uiTags/Login.jsp</result> <interceptor-ref name="cookie"> <param name="cookiesName">JSESSIONID</param> </interceptor-ref> </action> <action name="logout" class="org.webhop.ywdc.LogoutAction" > <result name="success" type="redirect">/pages/uiTags/Login.jsp</result> </action> </package> In the struts.xml file i set the and in my action i listed in the action configuration. Heres my jsp page that the action loads: <%@ taglib prefix="s" uri="/struts-tags" % <%@ taglib prefix="sj" uri="/struts-jquery-tags"% <%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags"% <%@ page language="java" contentType="text/html" import="java.util.*"% Welcome, you have logged in! <s:url id="remoteurl" action="login"/> <sjg:grid id="gridtable" caption="Customer Examples" dataType="json" href="%{remoteurl}" pager="false" gridModel="gridModel" > <sjg:gridColumn name="id" key="true" index="id" title="ID" formatter="integer" sortable="false"/> </sjg:grid> Welcome, you have logged in. <br /> <b>Session Time: </b><%=new Date(session.getLastAccessedTime())%> <h2>Password:<s:property value="password"/></h2> <h2>userId:<s:property value="userId"/></h2> <br /> <a href="<%= request.getContextPath() %>/logout.action">Logout</a><br /><br /> ID: <s:property value="id"/> session id: <s:property value="JSESSIONID"/> </body> Im not really sure how to tell what json the json plugin is creating from the action class. If i did know how i could tell if it wasnt formed properly. As far as I know if I specificy in my action configuration in struts.xml, that the grid, which is set to read json and knows to look for "gridModel" will then automatically load the json to the grid, but its not. Heres my action class: public class LoginAction extends ActionSupport { public String JSESSIONID; public int id; private String userId; private String password; public Members member; public List<Customer> gridModel; public String execute() { Cookie cookie = new Cookie("ywdcsid", password); cookie.setMaxAge(3600); HttpServletResponse response = ServletActionContext.getResponse(); response.addCookie(cookie); HttpServletRequest request = ServletActionContext.getRequest(); Cookie[] ckey = request.getCookies(); for(Cookie c: ckey) { System.out.println(c.getName() + "/cookie_name + " + c.getValue() + "/cookie_value"); } Map requestParameters = ActionContext.getContext().getParameters();//getParameters(); String[] testString = (String[])requestParameters.get("password"); String passwordString = testString[0]; String[] usernameArray = (String[])requestParameters.get("userId"); String usernameString = usernameArray[0]; Injector injector = Guice.createInjector(new GuiceModule()); HibernateConnection connection = injector.getInstance(HibernateConnection.class); AuthenticationServices currentService = injector.getInstance(AuthenticationServices.class); currentService.setConnection(connection); currentService.setInjector(injector); member = currentService.getMemberByUsernamePassword(usernameString, passwordString); userId = member.getUsername(); password = member.getPassword(); CustomerFactory customerFactory = new CustomerFactory(); gridModel = customerFactory.getCustomers(); if(member == null) { return ERROR; } else { id = member.getId(); Map session = ActionContext.getContext().getSession(); session.put(usernameString, member); return SUCCESS; } } public String logout() throws Exception { Map session = ActionContext.getContext().getSession(); session.remove("logged-in"); return SUCCESS; } public List<Customer> getGridModel() { return gridModel; } public void setGridModel(List<Customer> gridModel) { this.gridModel = gridModel; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getJSESSIONID() { return JSESSIONID; } public void setJSESSIONID(String jsessionid) { JSESSIONID = jsessionid; } } Please help me with this problem. You will make my week, as this is a major bottleneck for me :( thanks so much, thebravedave

    Read the article

  • customize keyboard in hackintosh

    - by user36912
    i have Mac OS SL installed on intel machine. My shortcut keys for Home, End, Copy, Paste and Undo are not working. How can i customize keyboard so that i can get Copy by Ctrl+C, Paster by Ctrl+V, Undo by Ctrl+Z and so on..

    Read the article

  • Why are mercurial subrepos behaving as unversioned files in eclipse

    - by noam
    I am trying to use the subrepo feature of mercurial, using the mercurial eclipse plugin . I created and added the .hgsub file in the root repo, put all the mappings of the sub repos in it, and committed + pushed. Then, I pulled the root repo in eclipse, using import-mercurial. Now I see that all the subrepos appear as though they are unversioned (no "orange cylinder" icon next to their corresponding folders in the eclipse file explorer). Furthermore, when I right click on one of the subrepos, I don't get all the hg commands in the "team" menu as I usually get, with root projects - no "pull", "push" etc. Also, when I made a change to a file in a subrepo, and then "committed" the root project, it told me there were no changes found.

    Read the article

  • apply style to range of text with javascript in uiwebview

    - by drawnonward
    I am displaying some simple styled text as html in a UIWebView on iPhone. It is basically a series of paragraphs with the occasional strong or emphasized phrase. At runtime I need to apply styles to ranges of text. There are a few similar scenarios, one of which is highlighting search results. If the user has searched for "something" I would like to change the background color behind occurrences of the word, then later restore the original background. Is it possible to apply styles to ranges of text using javascript? A key part of this is also being able to unset the styles. There seem to be two likely paths to follow. One would be modifying some html in Objective-C and passing it through javascript as the new innerHTML of some container. The other would be to use javascript to directly manipulate DOM nodes. I could manipulate html, but that sounds tedious in Objective-C so I would rather manipulate the DOM if that is a reasonable approach. I am not that familiar with javascript and DOM so I do not know if it is a reasonable approach. I wrote some routines to translate between text ranges and node ranges with offsets. So if I start with text range 100-200 and that starts in one paragraph and ends in a third, I can get the text nodes and the offsets within the nodes that represent the given text range. I just need a way to split a text node at an offset in the text. Currently I just apply styles to the paragraphs containing the text range. A few notes: straight javascript please, no external frameworks like jquery. the changes never need to be written to disk. the changes should be undoable or at least removable. the styles to apply already exist in a css file. it needs to work in iPhone 3.0 and forward. all the source files are shipped with the app. please be verbose. Thanks for any suggestions.

    Read the article

  • displayed value - in-place-editor

    - by Ben
    So I put in in-place editing for one of my models. One of the attributes is PRICE. I used the to_currency method to format the value before it is displayed. The problem I'm having is that with the in-place editor, I just can't figure out how to set a custom display value. I'm trying to get the price to display as $20.00 until it is clicked, but the in place editor displays 20.0..

    Read the article

  • Finding rank of the student -Sql Compact

    - by Jankhana
    I have a table like this : Name Mar1 Mar2 Mar3 Total xxx 80 80 80 240 yyy 60 70 50 180 aaa 85 65 75 225 I wanted to find the rank of the student based on total. I using SQL Compact 3.5 . As we have rank() function in sql server do we have something with which we can find the students rank??? When I used "select Total,rank() over (order by total desc) i1 from stmarks " it's giving error as " Major Error 0x80040E14, Minor Error 25501 select Total,rank() over (order by total desc) i1 from stmarks There was an error parsing the query. [ Token line number = 1,Token line offset = 21,Token in error = over ] " Do Sql Compact support rank() over or is there any another way???

    Read the article

  • What is the best way pre filter user access for sqlalchemy queries?

    - by steve
    I have been looking at the sqlalchemy recipes on their wiki, but don't know which one is best to implement what I am trying to do. Every row on in my tables have an user_id associated with it. Right now, for every query, I queried by the id of the user that's currently logged in, then query by the criteria I am interested in. My concern is that the developers might forget to add this filter to the query (a huge security risk). Therefore, I would like to set a global filter based on the current user's admin rights to filter what the logged in user could see. Appreciate your help. Thanks.

    Read the article

  • Reporting system for organization. Architecture advise required

    - by Andrew Florko
    We have several legacy & 3'd-party systems in organization that use several RDBMS vendors (& more specific data storages). Cross-system data reporting (as well as extra-reports that are not implemented in 3'd-party systems) is required with charts and population of templates (winword, excel). Reporting system is visioned as intranet web-site with custom user access to reports. We expect ~50 reports per day. Would you suggest to use BizTalk or any other integration software if commercial-department doesn't plan to buy anything expensive. Would you suggest to create centralized data storage for reporting that is populated regularly or rely on on-demand services that providers always up-to-request data. Thank you in advance!

    Read the article

  • References/walkthroughs for maintaining database schemas with Visual Studio 2010?

    - by user206356
    I have Visual Studio 2010 Beta 2 and SQL Server 2008 installed. I'm working with a populated database and want to modify various column types. SQL Server Management Studio requires me to drop tables to do this, and get pretty finicky given my moderate level of knowledge of SQL Server. However, I heard the new database project type supports changing the database schema to the desired format and it will handle creating and running all the scripts to implement the changes. I've created a VS2010 database project using the existing database as the source, but so far haven't had much luck figuring out the appropriate method to make the changes without getting an error. As a result, I'm looking for any reference info I can find on using VS2010's capabilities in this area. Any suggestions?

    Read the article

  • Making sure an 'int' is bound on sqlite

    - by iphone_developer
    I have a method called like this... -(void)dbUpdate:(int)forId { Which contains this sqlite to bind and update a database. sqlite3_bind_int(UPDATE_ACCOUNT, 3, forId); When I run the query, it doesn't give me an error, but it doesn't update the database either. If I change this line of code... sqlite3_bind_int(UPDATE_ACCOUNT, 3, forId); manually, to... sqlite3_bind_int(UPDATE_ACCOUNT, 3, 6); the query runs 100% fine, as expected. Changing the variable to an actual integer proves to me that the variable 'forId' isn't being passed or bound to the query properly. What am I doing wrong? How is the best way to pass an Integer (and make sure it is an Integer) into an sqlite bind? Cheers,

    Read the article

  • are fixtures loaded when using the sql dump to create a test database

    - by Josh Moore
    Because of some non standard table creation options I am forced to use the sql dump instead of the standard schema.rb (i.e. I have uncommented this line in the environment.rb config.active_record.schema_format = :sql). I have noticed that when I use the sql dump that my fixtures do not seem to be loaded into the database. Some data is loaded into it but, I am not sure where it is coming from. Is this normal? and if it is normal can anybody tell me where this other data is coming from?

    Read the article

  • how to upload zip/rar files in codeigniter

    - by hwd
    how to upload zip/rar files in codeigniter itried like this $config['allowed_types'] = 'application/x-zip|application/x-zip-compressed|application/octet-stream|application/x-compress|application/x-compressed|multipart/x-zip'; but not working . please help me.................

    Read the article

  • Why does this asp.net mvc unit test fail?

    - by Brian McCord
    I have this unit test: [TestMethod] public void Delete_Post_Passes_With_State_4() { //Arrange ViewResult result = stateController.Delete( 4 ) as ViewResult; var model = (State)result.ViewData.Model; //Act RedirectToRouteResult redirectResult = stateController.Delete( model ) as RedirectToRouteResult; var newresult = stateController.Delete( 4 ) as ViewResult; var newmodel = (State)newresult.ViewData.Model; //Assert Assert.AreEqual( redirectResult.RouteValues["action"], "Index" ); Assert.IsNull( newmodel ); } Here are the two controller actions that handle deleting: // // GET: /State/Delete/5 public ActionResult Delete(int id) { var x = _stateService.GetById( id ); return View(x); } // // POST: /State/Delete/5 [HttpPost] public ActionResult Delete(State model) { try { if( model == null ) { return View( model ); } _stateService.Delete( model ); return RedirectToAction("Index"); } catch { return View( model ); } } What I can't figure out is why this test fails. I have verified that the record actually gets deleted from the list. If I set a break point in the Delete method on the line: var x = _stateService.GetById( id ); The GetById does indeed return a null just as it should, but when it gets back to the newresult variable in the test, the ViewData.Model is the deleted model. What am I doing wrong?

    Read the article

  • Populate Android Database From CSV file?

    - by MoMo
    Is it possible to take a csv file stored in the res/raw resource directory and use it to populate a table in the sqlite3 database? My thought was that, if there was a way to do a bulk import for the entire file into the table then that would be cleaner and faster than iterating over each line in the file and executing individual insert statements... I've found that there is a sqlite import command that allows this: http://stackoverflow.com/questions/1045910/how-can-i-import-load-a-sql-or-csv-file-into-sqlite ...but I'm having trouble applying those statements in my Android application. My first thought was to try something like the following...but no luck: db.execSQL("CREATE TABLE " + TABLE_NAME + "(id INTEGER PRIMARY KEY, name TEXT)"); db.execSQL(".mode csv"); db.execSQL(".import res/raw/MyFile.csv " + TABLE_NAME); Is this possible? Should I be trying a different approach to populate my database? Thanks for you answers!

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >