Search Results

Search found 18677 results on 748 pages for 'current'.

Page 96/748 | < Previous Page | 92 93 94 95 96 97 98 99 100 101 102 103  | Next Page >

  • Kohana 3: How to find the active item in a dynamic menu

    - by Svish
    Maybe not the best explanation, but hear me out. Say I have the following in a config file called menu.php: // Default controller is 'home' and default action is 'index' return array( 'items' => array( 'Home' => '', 'News' => 'news', 'Resources' => 'resources', ), ); I now want to print this out as a menu, which is pretty simple: foreach(Kohana::config('menu.items') as $title => $uri) { echo '<li>' . HTML::anchor($uri, $title) . '</li>'; } However, I want to find the $uri that matches the current controller and action. And if the action is the default one or not. What I want to end up with is that menu item should have id="active-item" if it is the linking to the current controller, but the default action. And id="active-subitem if it is linking to the current controller and the action is not the default one. Hope that made sense... Anyone able to help me out here? Both in how to do this in Kohana 3 and also how it should be done in Kohana 3. I'm sure there are lots of ways, but yeah... any help is welcome :) Examples: domain.com -- Home should be active-item since it is the default controller domain.com/home -- Home should be active-item domain.com/home/index -- Home should be active-item since index is the default action domain.com/resources -- Resources should be active-item domain.com/resources/get/7 -- Resources should be active-subitem since get is not the default action

    Read the article

  • Using a custom MvcHttpHandler v2.0 Breaking change from 1.0 to 2.0 ?

    - by Myster
    Hi I have a site where part is webforms (Umbraco CMS) and part is MVC This is the HttpHandler to deal with the MVC functionality: public class Mvc : MvcHttpHandler { protected override void ProcessRequest(HttpContext httpContext) { httpContext.Trace.Write("Mvc.ashx", "Begin ProcessRequest"); string originalPath = httpContext.Request.Path; string newPath = httpContext.Request.QueryString["mvcRoute"]; if (string.IsNullOrEmpty(newPath)) newPath = "/"; httpContext.Trace.Write("Mvc.ashx", "newPath = "+newPath ); HttpContext.Current.RewritePath(newPath, false); base.ProcessRequest(HttpContext.Current); HttpContext.Current.RewritePath(originalPath, false); } } Full details of how this is implemented here This method works well in an MVC 1.0 website. However when I upgrade this site to MVC 2.0 following the steps in Microsoft's upgrade documentation; everything compiles, except at runtime I get this exception: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL: /mvc.ashx Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927 This resource and it's dependencies are found fine in MVC 1.0 but not in MVC 2.0, is there an extra dependency I'd need to add? Is there something I'm missing? Is there a change in the way MVC 2.0 works?

    Read the article

  • iPhone Development - CLLocationManager vs. MapKit

    - by Mustafa
    If i want to show userLocation on the map, and at the same time record the user's location, is it a good idea to add an observer to userLocation.location and record the locations, OR should i still use CLLocationManager for recording user location and use mapView.showUserLocation to show the user's current location (blue indicator)? I want to show the default blue indicator supported by the MapKit API. Also, here's a rough sample code: - (void)viewDidLoad { ... locationManager = [[CLLocationManager alloc] init]; locationManager.desiredAccuracy = kCLLocationAccuracyBest; locationManager.distanceFilter = DISTANCE_FILTER_VALUE; locationManager.delegate = self; [locationManager startUpdatingLocation]; myMapView.showUserLocation = YES; [myMapView addObserver:self forKeyPath:@"userLocation.location" options:0 context:nil]; ... } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { // Record the location information // ... } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"%s begins.", __FUNCTION__); // Make sure that the location returned has the desired accuracy if (newLocation.horizontalAccuracy <= manager.desiredAccuracy) return; // Record the location information // ... } Under the hood, i think MKMapView also uses CLLocationManager to get user's current location? So, will this create any problems because i believe both CLLocationManager and MapView will try to use same location services? Will there be any conflicts and lack of accurate/required or current data?

    Read the article

  • Rails test db doesn't persist record changes

    - by nathan.f77
    I've been trying to solve a problem for a few weeks now. I am running rspec tests for my Rails app, and they are working fine except for one error that I can't seem get my head around. I am using MySQL with the InnoDB engine. I have set config.use_transactional_fixtures = true in spec_helper.rb I load my test fixtures manually with the command rake spec:db:fixtures:load. The rspec test is being written for a BackgrounDRb worker, and it is testing that a record can have its state updated (through the state_machine gem). Here is my problem: I have a model called Listings. The rspec test calls the update_sold_items method within a file called listing_worker.rb. This method calls listing.sell for a particular record, which sets the listing record's 'state' column to 'sold'. So far, this is all working fine, but when the update_sold_items method finishes, my rspec test fails here: listing = Listing.find_by_listing_id(listing_id) listing.state.should == "sold" expected: "sold", got: "current" (using ==) I've been trying to track down why the state change is not persisting, but am pretty much lost. Here is the result of some debugging code that I placed in the update_sold_items method during the test: pp listing.state # => "current" listing.sell! listing.save! pp listing.state # => "sold" listing.reload pp listing.state # => "current" I cannot understand why it saves perfectly fine, but then reverts back to the original record whenever I call reload, or Listing.find etc. Thanks for reading this, and please ask any questions if I haven't given enough information. Thanks for your help, Nathan B P.S. I don't have a problem creating new records for other classes, and testing those records. It only seems to be a problem when I am updating records that already exist in the database.

    Read the article

  • WPF ToolTip Style with dynamic LayoutTransform

    - by NoOne
    I have an app that scales it's UI and I want to scale the ToolTips with it. I have tried doing this: <Style TargetType="{x:Type ToolTip}"> <Setter Property="LayoutTransform" Value="{DynamicResource scaleTransf}"/> ... </Style> ...where scaleTransf is a resource that I change via code: Application.Current.Resources["scaleTransf"] = new ScaleTransform(...); Most of the ToolTips do get scaled in size but some of them that are created by C# code don't get scaled. I've checked and it seems that I don't set their Style or LayoutTransform by code, so I don't really understand what is going wrong... Moreover, I have the impression that the above XAML code worked fine a few days ago. :( Is there sth I can do to make it work all the time without setting the LayoutTransform in code-behind? EDIT : The ToolTips that don't change scale are the ones that have become visible before. EDIT2 : Extra code: <ScaleTransform x:Key="scaleTransf" ScaleX="1" ScaleY="1"/> I have also tried this: Application.Current.Resources.Remove("scaleTransf"); Application.Current.Resources.Add("scaleTransf", new ScaleTransform(val, val)); EDIT3 : My attempt to solve this using a DependencyProperty: In MainWindow.xaml.cs : public static readonly DependencyProperty TransformToApplyProperty = DependencyProperty.Register("TransformToApply", typeof(Transform), typeof(MainWindow)); public Transform TransformToApply { get { return (Transform)this.GetValue(TransformToApplyProperty); } } Somewhere in MainWindow, in response to a user input: this.SetValue(TransformToApplyProperty, new ScaleTransform(val, val)); XAML Style: <Style TargetType="{x:Type ToolTip}"> <Setter Property="LayoutTransform" Value="{Binding TransformToApply, ElementName=MainWindow}"/> ... Using this code, not a single one of the ToolTips seem to scale accordingly.

    Read the article

  • GDB Not Skipping Functions without Debug Info

    - by Alan Lue
    I compiled GDB 7 on a Mac OS X Leopard system. When stepping through a C program, GDB fails to step through 'printf()' statements, which probably don't have associated debug information, and starts printing "Cannot find bounds of current function." Here's some output: $ /usr/local/bin/gdb try1 GNU gdb (GDB) 7.1 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-apple-darwin10". (gdb) list 1 #include <stdio.h> 2 static void display(int i, int *ptr); 3 4 int main(void) { 5 int x = 5; 6 int *xptr = &x; 7 printf("In main():\n"); 8 printf(" x is %d and is stored at %p.\n", x, &x); 9 printf(" xptr holds %p and points to %d.\n", xptr, *xptr); 10 display(x, xptr); (gdb) b 6 Breakpoint 1 at 0x1e8e: file try1.c, line 6. (gdb) r Starting program: /tmp/try1 Breakpoint 1, main () at try1.c:6 6 int *xptr = &x; (gdb) n 7 printf("In main():\n"); (gdb) n 0x0000300a in ?? () (gdb) n Cannot find bounds of current function (gdb) n Cannot find bounds of current function Any idea what's going on? Alan

    Read the article

  • How to fix IE ClearType + jQuery opacity problem in this script?

    - by Justine
    Hello, I'm having a rather common problem (or so it seems, after some googling around...) with IE messing both bold text AND transparent pngs while animating opacity using jQuery. You can view the sample here: http://dev.gentlecode.net/dotme/index-sample.html (only occurs in IE, obviously) I've seen some blog posts saying the fix is to remove the filter attribute but I'm not sure how to apply it to the script I'm using since I got it from a tutorial and am still learning jQuery... The script goes as follows: $('ul.nav').each(function() { var $links = $(this).find('a'), panelIds = $links.map(function() { return this.hash; }).get().join(","), $panels = $(panelIds), $panelWrapper = $panels.filter(':first').parent(), delay = 500; $panels.hide(); $links.click(function() { var $link = $(this), link = (this); if ($link.is('.current')) { return; } $links.removeClass('current'); $link.addClass('current'); $panels.animate({ opacity : 0 }, delay); $panelWrapper.animate({ height: 0 }, delay, function() { var height = $panels.hide().filter(link.hash).show().css('opacity', 1).outerHeight(); $panelWrapper.animate({ height: height }, delay); }); return false; }); var showtab = window.location.hash ? '[hash=' + window.location.hash + ']' : ':first'; $links.filter(showtab).click(); }); I would appreciate if someone could go over it and show me how to fix the opacity issue. Will the filter method also fix the trouble I'm having with transparent pngs having pixelated ugly borders like the bold type as well? Thanks in advance for all help!

    Read the article

  • Using ASP .NET Membership and Profile with MVC, how can I create a user and set it to HttpContext.Cu

    - by Jeremy Gruenwald
    I've read the other questions on the topic of MVC membership and profiles, but I'm missing something. I implemented a custom Profile object in code as described by Joel here: http://stackoverflow.com/questions/426609/asp-net-membership-how-to-assign-profile-values I can't get it to work when I'm creating a new user, however. When I do this: Membership.CreateUser(userName, password); Roles.AddUserToRole(userName, "MyRole"); the user is created and added to a role in the database, but HttpContext.Current.User is still empty, and Membership.GetUser() returns null, so this (from Joel's code) doesn't work: static public AccountProfile CurrentUser { get { return (AccountProfile) (ProfileBase.Create(Membership.GetUser().UserName)); } } AccountProfile.CurrentUser.FullName = "Snoopy"; I've tried calling Membership.GetUser(userName) and setting Profile properties that way, but the set properties remain empty, and calling AccountProfile.CurrentUser(userName).Save() doesn't put anything in the database. I've also tried indicating that the user is valid & logged in, by calling Membership.ValidateUser, FormsAuthentication.SetAuthCookie, etc., but the current user is still null or anonymous (depending on the state of my browser cookies). I have the feeling I'm missing some essential piece of understanding about how Membership, Authentication, and Profiles fit together. Do I have to do a round trip before the current User will be populated? Any advice would be much appreciated.

    Read the article

  • WPF Background Thread Invocation

    - by jeffn825
    Maybe I'm mis-remembering how Winforms works or I'm overcomplicating the hell out of this, but here's my problem. I have a WPF client app application that talks to a server over WCF. The current user may "log out" of the WPF client, which closes all open screens, leaves only the navigation pane, and minimizes the program window. When the user re-maximizes the program window, they are prompted to log in. Simple. But sometimes things happen on background threads - like every 5 minutes the client tries to make a WCF calls that refreshes some cached data. And what if the user is logged out when this 5 minute timer triggers? Well, then the user should be prompted to log back in...and this must of course happen on the UI thread. private static ISecurityContext securityContext; public static ISecurityContext SecurityContext { get { if (securityContext == null) { // Login method shows a window and prompts the user to log in Application.Current.Dispatcher.Invoke((Action)Login); } return securityContext; } } So far so good, right? But what happens when multiple threads hit this spot of code? Well, my first intuition was that since I'm syncrhonizing across the Application.Current.Dispatcher, I should be fine, and whichever thread hit first would be responsible for showing the login form and getting the user logged in... Not the case... Thread 1 will hit the code and call ShowDialog on the login form Thread 2 will also hit the code and will call Login as soon as Thread 1 has called ShowDialog, since calling ShowDialog unblocked Thread 1 (I believe because of the way the WPF message pump works) All I want is a synchronized way of getting the user logged back into the application...what am I missing here? Thanks in advance.

    Read the article

  • Auto load a specific link at various time intervals

    - by user228837
    Here's what I need to do. I'm using Google Chrome. I have page that auto-reloads every 5 seconds using a script: javascript: timeout=prompt("Set timeout [s]"); current=location.href; if(timeout>0) setTimeout('reload()',1000*timeout); else location.replace(current); function reload() { setTimeout('reload()',1000*timeout); fr4me='<frameset cols=\'*\'>\n<frame src=\''+current+'\'/>'; fr4me+='</frameset>'; with(document){write(fr4me);void(close())}; } I found that script by Googling. The reason why the page auto-reloads every 5 seconds is I'm waiting for a specific link or url to appear in the page. It appears at random times. Once I see the link I'm waiting for, I immediately click the link. That's fine. But I want more. What I want is the page will auto-reload and I want it to auto-detect the the link I'm waiting for. Once the script finds the link I'm waiting for, it automatically loads that link on a new tab or page. For example, I'm auto-reloading www.example.com. I'm waiting for a specific url "BUY NOW". When the page auto-reloads, it checks if there's a url "BUY NOW". If it sees one, it should automatically open that link. Thanks.

    Read the article

  • What is private bytes, virtual bytes, working set?

    - by Devil Jin
    I am using perfmon windows utility to debug memory leak in a process. Perfmon explaination: Working Set- Working Set is the current size, in bytes, of the Working Set of this process. The Working Set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the Working Set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from Working Sets. If they are needed they will then be soft-faulted back into the Working Set before leaving main memory. Virtual Bytes- Virtual Bytes is the current size, in bytes, of the virtual address space the process is using. Use of virtual address space does not necessarily imply corresponding use of either disk or main memory pages. Virtual space is finite, and the process can limit its ability to load libraries. Private Bytes- Private Bytes is the current size, in bytes, of memory that this process has allocated that cannot be shared with other processes. Q1. Is it the private byte should I measure to be sure if the process is having any leak as it does not involve any shared libraries and any leak if happening will be coming from the process itself? Q2. What is the total memory consumed by the process? Is it the Virtual byte size? or Is it the sum of Virtual Bytes and Working Set Q3. Is there any relation between private bytes, working set and virtual bytes. Q4. Any tool which gives a better idea memory information?

    Read the article

  • Front End Developer v/s PHP-MySQL Engineer

    - by user301943
    Hello, I want to decide which of this would be a more viable career option? I am ready to quit my current job and hence I am looking for new opportunity. Current job is maintainence and no more active development. My current role is of a PHP/MySQL Developer. I very well understand web-programming and am comfortable with RoR/Sinatra/Zend MVC/JQuery/JSON manipulation, etc. I understand MySQL InnoDB/MyISAM engine and how one differs from the other, etc. Basically, I could very well manage the deployment of a web-application end-to-end including configuration of Apache/Nginx servers, memcache,etc On the other hand, I am being offered a Sr.Front End Web developer that would require me to extensively write HTML/CSS crossbrowser/crossplatform compliant code. I very well understand XHTML/CSS/Box model etc. I would be working on Drupal for the management of websites. While I understand continuing to work on server-side technologies would always be a good career path, how would the role of Core front-end developer turn out to be? If I take this opportunity, will I eventually get a chance to focus onto UCD, HCI, Information Architect,etc. So are these kinda roles possible if I focus on front end development? No offenses to the Front end developers, just want to understand if this is something I want to gain a mastery over. I have 2 yrs of industry experience after graduating with a MS-Computer Science. Although, I have a CS degree, if I were to take uip serious front-end role; I could probably go back and take up some design/HCI/UI courses. Please advise.

    Read the article

  • XSLT 1.0 help with recursion logic

    - by DashaLuna
    Hello guys, I'm having troubles with the logic and would apprecite any help/tips. I have <Deposits> elements and <Receipts> elements. However there isn't any identification what receipt was paid toward what deposit. I am trying to update the <Deposits> elements with the following attributes: @DueAmont - the amount that is still due to pay @Status - whether it's paid, outstanding (partly paid) or due @ReceiptDate - the latest receipt's date that was paid towards this deposit Every deposit could be paid with one or more receipts. It also could happen, that 1 receipt could cover one or more deposits. For example. If there are 3 deposits: 500 100 450 That are paid with the following receipts: 200 100 250 I want to get the following info: Deposit 1 is fully paid (status=paid, dueAmount=0, receiptNum=3. Deposit 2 is partly paid (status=outstanding, dueAmount=50, receiptNum=3. Deposit 3 is not paid (status=due, dueAmount=450, receiptNum=NAN. I've added comments in the code explaining what I'm trying to do. I am staring at this code for the 3rd day now non stop - can't see what I'm doing wrong. Please could anyone help me with it? :) Thanks! Set up: $deposits - All the available deposits $receiptsAsc - All the available receipts sorted by their @ActionDate Code: <!-- Accumulate all the deposits with @Status, @DueAmount and @ReceiptDate attributes Provide all deposits, receipts and start with 1st receipt --> <xsl:variable name="depositsClassified"> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$deposits"/> <xsl:with-param name="receiptsAll" select="$receiptsAsc"/> <xsl:with-param name="receiptCount" select="'1'"/> </xsl:call-template> </xsl:variable> <!-- Recursive function to associate deposits' total amounts with overall receipts paid to determine whether a deposit is due, outstanding or paid. Also determine what's the due amount and latest receipt towards the deposit for each deposit --> <xsl:template name="classifyDeposits"> <xsl:param name="depositsAll"/> <xsl:param name="receiptsAll"/> <xsl:param name="receiptCount"/> <!-- If there are deposits to proceed --> <xsl:if test="$depositsAll"> <!-- Get the 1st deposit --> <xsl:variable name="deposit" select="$depositsAll[1]"/> <!-- Calculate the sum of all receipts up to and including currenly considered --> <xsl:variable name="receiptSum"> <xsl:choose> <xsl:when test="$receiptsAll"> <xsl:value-of select="sum($receiptsAll[position() &lt;= $receiptCount]/@ReceiptAmount)"/> </xsl:when> <xsl:otherwise>0</xsl:otherwise> </xsl:choose> </xsl:variable> <!-- Difference between deposit amount and sum of the receipts calculated above --> <xsl:variable name="diff" select="$deposit/@DepositTotalAmount - $receiptSum"/> <xsl:choose> <!-- Deposit isn't paid fully and there are more receipts/payments exist. So consider the same deposit, but take next receipt into calculation as well --> <xsl:when test="($diff &gt; 0) and ($receiptCount &lt; count($receiptsAll))"> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$depositsAll"/> <xsl:with-param name="receiptsAll" select="$receiptsAll"/> <xsl:with-param name="receiptCount" select="$receiptCount + 1"/> </xsl:call-template> </xsl:when> <!-- Deposit is paid or we ran out of receipts --> <xsl:otherwise> <!-- process the deposit. Determine its status and then update corresponding attributes --> <xsl:apply-templates select="$deposit" mode="defineDeposit"> <xsl:with-param name="diff" select="$diff"/> <xsl:with-param name="receiptNum" select="$receiptCount"/> </xsl:apply-templates> <!-- Recursively call the template with the rest of deposits excluding the first. Before hand update the @ReceiptsAmount. For the receipts before current it is now 0, for the current is what left in the $diff, and simply copy over receipts after current one. --> <xsl:variable name="receiptsUpdatedRTF"> <xsl:for-each select="$receiptsAll"> <xsl:choose> <!-- these receipts was fully accounted for the current deposit. Make them 0 --> <xsl:when test="position() &lt; $receiptCount"> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="ReceiptAmount">0</xsl:attribute> </xsl:copy> </xsl:when> <!-- this receipt was partly/fully(in case $diff=0) accounted for the current deposit. Make it whatever is in $diff --> <xsl:when test="position() = $receiptCount"> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="ReceiptAmount"> <xsl:value-of select="format-number($diff, '#.00;#.00')"/> </xsl:attribute> </xsl:copy> </xsl:when> <!-- these receipts weren't yet considered - copy them over --> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:variable> <xsl:variable name="receiptsUpdated" select="msxsl:node-set($receiptsUpdatedRTF)/Receipts"/> <!-- Recursive call for the next deposit. Starting counting receipts from the current one. --> <xsl:call-template name="classifyDeposits"> <xsl:with-param name="depositsAll" select="$deposits[position() != 1]"/> <xsl:with-param name="receiptsAll" select="$receiptsUpdated"/> <xsl:with-param name="receiptCount" select="$receiptCount"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> <!-- Determine deposit's status and due amount --> <xsl:template match="MultiDeposits" mode="defineDeposit"> <xsl:param name="diff"/> <xsl:param name="receiptNum"/> <xsl:choose> <xsl:when test="$diff &lt;= 0"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'paid'"/> <xsl:with-param name="dueAmount" select="'0'"/> <xsl:with-param name="receiptNum" select="$receiptNum"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$diff = ./@DepositTotalAmount"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'due'"/> <xsl:with-param name="dueAmount" select="$diff"/> </xsl:apply-templates> </xsl:when> <xsl:when test="$diff &lt; ./@DepositTotalAmount"> <xsl:apply-templates select="." mode="addAttrs"> <xsl:with-param name="status" select="'outstanding'"/> <xsl:with-param name="dueAmount" select="$diff"/> <xsl:with-param name="receiptNum" select="$receiptNum"/> </xsl:apply-templates> </xsl:when> <xsl:otherwise/> </xsl:choose> </xsl:template> <!-- Add new attributes (@Status, @DueAmount and @ReceiptDate) to the deposit element --> <xsl:template match="MultiDeposits" mode="addAttrs"> <xsl:param name="status"/> <xsl:param name="dueAmount"/> <xsl:param name="receiptNum" select="''"/> <xsl:copy> <xsl:copy-of select="./@*"/> <xsl:attribute name="Status"><xsl:value-of select="$status"/></xsl:attribute> <xsl:attribute name="DueAmount"><xsl:value-of select="$dueAmount"/></xsl:attribute> <xsl:if test="$receiptNum != ''"> <xsl:attribute name="ReceiptDate"> <xsl:value-of select="$receiptsAsc[position() = $receiptNum]/@ActionDate"/> </xsl:attribute> </xsl:if> <xsl:copy-of select="./*"/> </xsl:copy> </xsl:template>

    Read the article

  • problem with AddSort method

    - by netNewbi3
    Hi Could you let me know what the proboem is with sorting in this code? It doesn't work. My xml: CONTRACTS --CONTRACT ---SUPPLIER ---COMMODITIES ----COMMODITY -----COMODDITYNAME My code: Dim myString As StringBuilder = New StringBuilder(200) Dim xdoc As New XPathDocument("local_xml.xml") Dim nav As XPathNavigator = xdoc.CreateNavigator() Dim expr As XPathExpression expr = nav.Compile("/pf:CONTRACTS/pf:CONTRACT") Dim namespaceManager As XmlNamespaceManager = New XmlNamespaceManager(nav.NameTable) namespaceManager.AddNamespace("pf", "http://namespace.ac.uk/") expr.AddSort("pf:SUPPLIER", XmlSortOrder.Ascending, XmlCaseOrder.None, String.Empty, XmlDataType.Text) expr.SetContext(namespaceManager) Dim nodes As XPathNodeIterator = nav.Select(expr) If nodes.Count > 0 Then myString.AppendLine("<table width='96%' border='0' cellpadding='0' cellspacing='0' border='0' class='datatable1'>") myString.AppendLine("<th width='35%'>Name</th><th width='35%'>Commodity</th><th width='20%'>Supplier</a></th>") While nodes.MoveNext() Dim node As XPathNavigator = nodes.Current.SelectSingleNode("pf:NAME", namespaceManager) Dim supplier As XPathNavigator = nodes.Current.SelectSingleNode("pf:SUPPLIER", namespaceManager) Dim commodity As XPathNavigator = nodes.Current.SelectSingleNode("pf:COMMODITIES/pf:COMMODITY/pf:COMMODITYNAME", namespaceManager) Dim sChars As String = " " myString.AppendLine("<tr>") myString.AppendLine("<td>") myString.AppendLine(node.ToString()) myString.AppendLine("</td>") myString.AppendLine("<td>") myString.AppendLine(commodity.ToString()) myString.AppendLine("</td>") myString.AppendLine("<td>") myString.AppendLine(supplier.ToString()) myString.AppendLine("</td>") myString.AppendLine("</tr>") End While myString.AppendLine("</table>") Dim strOutput As String = myString.ToString() lblOutput.Text = strOutput Else lblOutput.Text = "No results for your search<br/>" End If

    Read the article

  • Why in this example (got from msdn), in GetEnumerator method , new PeopleEnum returns IEnumerator?

    - by odiseh
    Hi guys, Why in this example (got from msdn), in GetEnumerator method , PeopleEnum returns IEnumerator? public class Person { public Person(string fName, string lName) { this.firstName = fName; this.lastName = lName; } public string firstName; public string lastName; } public class People : IEnumerable { private Person[] _people; public People(Person[] pArray) { _people = new Person[pArray.Length]; for (int i = 0; i < pArray.Length; i++) { _people[i] = pArray[i]; } } //why??? IEnumerator IEnumerable.GetEnumerator() { return (IEnumerator) GetEnumerator(); } public PeopleEnum GetEnumerator() { return new PeopleEnum(_people); } } public class PeopleEnum : IEnumerator { public Person[] _people; // Enumerators are positioned before the first element // until the first MoveNext() call. int position = -1; public PeopleEnum(Person[] list) { _people = list; } public bool MoveNext() { position++; return (position < _people.Length); } public void Reset() { position = -1; } object IEnumerator.Current { get { return Current; } } public Person Current { get { try { return _people[position]; } catch (IndexOutOfRangeException) { throw new InvalidOperationException(); } } } }

    Read the article

  • get parent elements in xml with simplexml in php?

    - by fayer
    with $element->children() i cant get all the child elements of current element. but how can i get all the parent elements for current element with simplexml? lets say it looks like this: <entity id=1> <name>apple</name> <entities> <entity id=2> <name>mac</name> <entities> <entity id=3> <name>safari</name> </entity> </entities> </entity> </entities> </entity> if my current $element is id=3, i want to get the mac and apple entity ids. is this possible with simplexml cause i cant find any function allowing me to do this?

    Read the article

  • Why does IIS respond to a secure(SSL) page request with a 302 to its non-secure version?

    - by ISawrub
    I have SSL installed at the root of a server. I have a page whose code behind code is supposed to redirect after certain validation to a secure page. Here's the redirect code: switch (PageBase2.GetParameterValue("Environment")) //Retrieves App Setting named Environment from web.config { case "Server": strURL = @"https://" + HttpContext.Current.Request.Url.Authority + "/checkout/payment.aspx"; break; case "Local": strURL = @"http://" + HttpContext.Current.Request.Url.Authority + "/checkout/payment.aspx"; break; default: strURL = @"https://" + HttpContext.Current.Request.Url.Authority + "/checkout/payment.aspx"; break; } Response.Redirect(strURL, false); But the page that's been served by IIS is non-secure. I looked at the firebug console and it appears that the client does make a get request to https://server/checkout/payment.aspx but IIS responds with a 302 to http://server/checkout/payment.aspx Any clues, as to what could be causing it. I've even tried forcing SSL for the page, but it doesn't work I get 403.4 error. (SSL is required to view this resource.) And if i remove the redirection logic and code the payment page to redirect to its SSL version when the connection is not secure using Request.IsSecureConnection, i end up with an endless redirect loop, simply because IIS still won't serve the secure version without a 302. Any ideas?

    Read the article

  • Call long running operation in WSS feature OnActivated Event

    - by dirq
    More specifically - How do I reference SPContext in Web Service with [SoapDocumentMethod(OneWay=true)]? We are creating a feature that needs to run a job when a site is created. The job takes about 4 minutes to complete. So, we made a web service that we can call when the feature is activated. This works but we want it to run asynchronously now. We've found the SoapDocumentMethod's OneWay property and that would work awesomely but the SPContext is now NULL. We have our web services in the _vti_bin virtual directory so it's available in each Windows Sharepoint Services site. I was using the SPContext.Current.Web to get the site and perform the long running operation. I wanted to just fire and forget about it by returning a soap response right away and letting the process run. How can I get the current SPContext? I used to be able to do this in my web service: SPWeb mySite = SPContext.Current.Web; Can I get the same context when I have the [SoapDocumentMethod(OneWay=true)] attribute applied to my web service? Or must I recreate the SPWeb from the url? This is similar to this thread: http://stackoverflow.com/questions/340192/webservice-oneway-and-new-spsitemyurl Update: I've tried these two ways but they didn't work: SPWeb targetSite = SPControl.GetContextWeb(this.Context); SPWeb targetSite2 = SPContext.GetContext(this.Context).Web;

    Read the article

  • Preloading Winforms

    - by msarchet
    I am currently working on a project where we have a couple very control heavy user controls that are being used inside a MDI Controller. This is a Line of Business app and it is very data driven. The problem that we were facing was the aforementioned controls would load very very slowly, we dipped our toes into the waters of multi-threading for the control loading but that was not a solution for a plethora of reasons. Our solution to increasing the performance of the controls ended up being to 'pre-load' the forms onto a hidden window, create a stack of the existing forms, and pop off of the stack as the user requested a form. Now the current issue that I'm seeing that will arise as we push this 'fix' out to our testers, and the ultimately our users is this: Currently the 'hidden' window that contains the preloaded forms is visible in task manager, and can be shut down thus causing all of the controls to be lost. Then you have to create them on the fly losing the performance increase. Secondly, when the user uses up the stack we lose the performance increase (current solution to this is discussed below). For the first problem, is there a way to hide this window from task manager, perhaps by creating a parent form that encapsulates both the main form for the program and the hidden form? Our current solution to the second problem is to have an inactivity timer that when it fires checks the stacks for the forms, and loads a new form onto the stack if it isn't full. However this still has the potential of causing a hang in the UI while it creates the forms. A possible solutions for this would be to put 'used' forms back onto the stack, but I feel like there may be a better way.

    Read the article

  • detecting pauses in a spoken word audio file using pymad, pcm, vad, etc

    - by james
    First I am going to broadly state what I'm trying to do and ask for advice. Then I will explain my current approach and ask for answers to my current problems. Problem I have an MP3 file of a person speaking. I'd like to split it up into segments roughly corresponding to a sentence or phrase. (I'd do it manually, but we are talking hours of data.) If you have advice on how to do this programatically or for some existing utilities, I'd love to hear it. (I'm aware of voice activity detection and I've looked into it a bit, but I didn't see any freely available utilities.) Current Approach I thought the simplest thing would be to scan the MP3 at certain intervals and identify places where the average volume was below some threshold. Then I would use some existing utility to cut up the mp3 at those locations. I've been playing around with pymad and I believe that I've successfully extracted the PCM (pulse code modulation) data for each frame of the mp3. Now I am stuck because I can't really seem to wrap my head around how the PCM data translates to relative volume. I'm also aware of other complicating factors like multiple channels, big endian vs little, etc. Advice on how to map a group of pcm samples to relative volume would be key. Thanks!

    Read the article

  • Position an icon on the right in the middle of a list item

    - by Andy
    I have the following code which prints an img if the current page is selected. The issue i have is if the list item is a varied height i cant position it in the middle of the list item on the far right... <li><?php echo $child->link($child->title); ?><?php echo (url_start_with($child->url) ? '<img src="images/ico-arrow.png" class="pointer">': null); ?></li> how can i ammend the "TOP" so that it will position itself vertically no matter what the height using css #bf-fest-list li { margin:0; padding:5px 25px; position:relative; } #bf-fest-list li a:hover { color:#ec1c23; text-decoration:none; } #bf-fest-list li.current { background:#a0a1a4; padding:10px 25px; } #bf-fest-list li.current a { color:#FFF; } #bf-fest-list li .pointer { position:absolute; top:10px; left:233px; }

    Read the article

  • WCF Callback Faulted - what happens to the session?

    - by RemotecUk
    Just trying to get my head around what can happen when things go wrong with WCF. I have an implementation of my service contract declared with an InstanceContextMode of PerSession... [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)] The calls happen as follows: My client calls the server and calls GetServerUTC() to return the current UTC time of the server. This is a one way call and the server will call the client back when its ready (trivial in this instance to simply return the current time!) The server calls back to the client and for test purposes in the callback implementation on the client I throw an exception. This goes unhandled in the client (for test purposes) and the client crashes and closes down. On the server I handle the faulted event handler on the ICommunicationObject... obj.Faulted += new EventHandler(EventService_Faulted); Questions... Will this kill off the session for the current connection on the server. I presume I am free to do what I want in this method e.g. logging or something, but should I do anything specific here to terminate the session or will WCF handle this? From a best practise view point what should I do when the callback is faulted? Does it mean "something has happened in your client" and thats the end of that or is there something I a missing here? Additionally, are there any other faulted handlers I should be handling. Ive done a lot of reading on WCF and it seems sort of vague on what to do when something goes wrong. At present I am implementing a State Machine on my client which will manage the connection and determine if a user action can happen dependant on if a connection exists to the server - or is this overkill. Any tips would be really appreciated ;)

    Read the article

  • SoundManager / Jquery / Regular expression : Parse class name before certain character To Get SoundI

    - by j-man86
    So I am trying to access a jquery soundmanager variable from one script (wpaudio.js – from the wp-audio plugin) inside of another (init.js – my own javascript). I am creating an alternate pause/play button higher up on the page and need to resume the current soundID, which is contained as part of a class name in the DOM. Here is the code that creates that class name in wpaudio.js: function wpaButtonCheck() { if (!this.playState || this.paused) jQuery('#' + this.sID + '_play').attr('src', wpa_url + '/wpa_play.png'); else jQuery('#' + this.sID + '_play').attr('src', wpa_url + '/wpa_pause.png'); } Here is the output: where wpa0 would be the sID of the sound I need. My current script in init.js is: $('.mixesSidebar #currentSong .playBtn').toggle(function() { soundManager.pauseAll(); $(this).addClass('paused'); }, function() { soundManager.resumeAll(); $(this).removeClass('paused'); }); I need to change resumeAll to "resume(this.sID)", but I need to somehow store the sID onclick and call it in the above function. Alternately, I think a regular expression that could get the class name of the current play button and either parse the string up to the "_play" or use a trim function to get rid of "_play"– but I'm not sure how to do this. Thanks for your help!

    Read the article

  • Controlling ASP.NET output cache memory usage

    - by Josh Einstein
    I would like to use output caching with WCF Data Services and although there's nothing specifically built in to support caching, there is an OnStartProcessingRequest method that allows me to hook in and set the cacheability of the request using normal ASP.NET mechanisms. But I am worried about the worker process getting recycled due to excessive memory consumption if large responses are cached. Is there a way to specify an upper limit for the ASP.NET output cache so that if this limit is exceeded, items in the cache will be discarded? I've seen the caching configuration settings but I get the impression from the documentation that this is for explicit caching via the Cache object since there is a separate outputCacheSettings which has no memory-related attributes. Here's a code snippet from Scott Hanselman's post that shows how I'm setting the cacheability of the request. protected override void OnStartProcessingRequest(ProcessRequestArgs args) { base.OnStartProcessingRequest(args); //Cache for a minute based on querystring HttpContext context = HttpContext.Current; HttpCachePolicy c = HttpContext.Current.Response.Cache; c.SetCacheability(HttpCacheability.ServerAndPrivate); c.SetExpires(HttpContext.Current.Timestamp.AddSeconds(60)); c.VaryByHeaders["Accept"] = true; c.VaryByHeaders["Accept-Charset"] = true; c.VaryByHeaders["Accept-Encoding"] = true; c.VaryByParams["*"] = true; }

    Read the article

  • Rails - Logic for finding info from a :has_many :through needed!

    - by Jty.tan
    I have 3 relevant tables. User, Orders, and Viewables The idea is that each User has got many Orders, but at the same time, each User can View specific other Orders that belong to other Users. So Viewables has the attributes of user_id and order_id. Orders has a :has_many :Users, :through => :viewables Is it possible to do a find through an Order's view? So something like @viewable_orders = Orders.find(:all, :conditions = ["Viewable.user_id=?",1]) To get a list of Orders which are viewable by user_id=1. (This doesn't work, else I won't be asking. :( ) The idea being that I can do something like a sidebar where the current user (the logged-in one) can view a list of other people's orders that he can view. For example Three other Users who have some Orders that he can view should be eventually displayed like this: Jack (2) Basic Order (registry_id: 1) New Order (registry_id: 29) Amy (4) Short Order (registry_id: 12) Jill (5) Hardware Order (14) Pink Order (17) Software Order (76) (The number in brackets are the respective user_id or registry_id) So to find the list of all of the orders that the current user can find (assuming user_id of the current user is 1), would be found by doing @viewable_orders = Viewable.find(:all, :conditions => ["user_id=?", 1]) And that would give me the collection of the above 6 registries. Now, the easiest way to do this, is for me to just have a list of + Jill's Hardware Order + Jill's Pink Order + Amy's Short Order + etc But that gets ugly for long lists. Thanks!

    Read the article

< Previous Page | 92 93 94 95 96 97 98 99 100 101 102 103  | Next Page >