Mike Askew 131 Veteran Poster Featured Poster

Think I am going mad here..

So I have a working website setup in IIS. This was all configured by a previous developer. We have a set of reports that you can browse to by going to localhost/Reports/ReportName, the underlying directory structure in IIS is actually Reports/Views/ReportName/index.cshtml. I have added a new report with the exact same setup as the others however when I navigate to the localhost/Reports/NewReportName URL I get a 404 and I am not quite sure what I am missing...

Mike Askew 131 Veteran Poster Featured Poster

Hmm still confused. Trying to avoid posting code.

I have

    <script type="text/javascript">
        function getPetDetails() {

        }
    </script>

Which is linked to the onupdate() of

<select name="availablePets" id="availablePets" size=10" onchange="getPetDetails()">

But not sure how it works from there still. May have to dumb it down for me, thought I could be clever!

Mike Askew 131 Veteran Poster Featured Poster

I was using a <select> with size=x to make it into a Listbox

I know you can bind the onchange event of that, so just had to figure out how I then link that event to the pageload and populate. Would the above code work in that situation also?

Mike Askew 131 Veteran Poster Featured Poster

So I currently have a listbox which dynamically generates its members from the database. It has name and id set to "availablePets".

When one of the items in the list is clicked I want to populate some other fields on the screen by quering the database for the rest of the data surrounding that one entry.

I am not sure how to link the onchange event to a javascript/jquery function that will in turn allow the page to fire off PHP again and populate the data? I gather that I will need to probably use jquery to do a ajax post to trigger the PHP?

Pointers in the right direction for resources on the topic would suit fine as this is uni work or some discussion around what logic is needed. I should be able to figure out the code.

Mike Askew 131 Veteran Poster Featured Poster

Hi All

We are having an issue where a WSDL is loading another WSDL into it when we call it. This call takes a while on the first call which normally causes failures across the application during testing. One option we are looking into is pre-caching the WSDL in IIS prior to the server becoming available in the load balancer.

Does anybody have any knowledge around how WSDL caching behaves in IIS?

Couple of questions I am trying to figure out:
1) How long does a WSDL stay cached for once it is first called
2) Does IIS cache the WSDLs by default?

Cheers

Mike

Mike Askew 131 Veteran Poster Featured Poster

Works fine for me in VS2013 Ultimate running .Net 4.5 console application.

I can access the matches variable and it contains fox as expected... odd.

Mike Askew 131 Veteran Poster Featured Poster

I like it!

But from a readability perspective in my opinion the for-loop is better. Can't skim read over the given extension example and know what it does too easily.

Mike Askew 131 Veteran Poster Featured Poster

No problem.

Is the restructure of the XML acceptable or did you need to keep it as it originally was? Hopefully it was as otherwise I am not sure it would be possible :)

If it is solved, please mark the question as solved :)

Mike Askew 131 Veteran Poster Featured Poster

Yeah misworded it slightly I believe eventually worked out what I was trying to do with a spot of googling.

Mike Askew 131 Veteran Poster Featured Poster

... but I can't for the life of me figure it out.

I have an object that comes from an application which has a Status property, and within that property is Name and Key. So I can do things like object.Status.Name = x.

I have created another of these objects within my site and currently the value of the status field is set to 0 by default. If I want to populate the Status field to at least get a specific value in the object.Status.Name field how would I go about it?

object.Status.Name = x doesn't seem to work and instead creates object.StatusName = x when run.

Thanks in advance

Mike

Mike Askew 131 Veteran Poster Featured Poster

This would mainly depend on which language you intend to use.

A programming language will be the main driver for most of the above tasks and therefore each language will have its own ways of doing them.

Mike Askew 131 Veteran Poster Featured Poster

I have achieved the above using XSL 1.0, however your XML file structures are not the best and so I have done it using a modified structure. Let me know if this causes any issues and I will see if it can be adapted.

New input file, this had to be modified to group together the name and language code of each entry, just having one line next to another is not queryable using xsl.

<XML>
  <Data>
    <Name>shades</Name>
    <Languagecode>555</Languagecode>
  </Data>
  <Data>
    <Name>test1</Name>
    <Languagecode>559</Languagecode>
  </Data>
  <Data>
    <Name>test2</Name>
    <Languagecode>557</Languagecode>
  </Data>
</XML>

The lookup file, same as above, needed to group the data.

<Languages>
  <Language code="555">
    <Name>hindi</Name>
  </Language>
  <Language code="556">
    <Name>tamil</Name>
  </Language>
  <Language code="558">
    <Name>telugu</Name>
  </Language>
  <Language code="559">
    <Name>malayalam</Name>
  </Language>
  <Language code="557">
    <Name>bengali</Name>
  </Language>
  <Language code="554">
    <Name>punjabi</Name>
  </Language>
</Languages>

and finally the XSL

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output omit-xml-declaration="yes" indent="yes"/>
  <xsl:strip-space elements="*"/>
  <xsl:variable name="lookupDoc" select="document('FULL_FILEPATH_HERE')" />

  <xsl:template match="*">
    <xsl:element name="XML">
      <xsl:apply-templates />
    </xsl:element>
  </xsl:template>

  <xsl:template match="Data">
    <xsl:element name="Data">
      <xsl:element name="Name">
        <xsl:value-of select="./Name/text()"/>
      </xsl:element>
      <xsl:call-template name="MakeSpanForCode">
        <xsl:with-param name="code" select="Languagecode/text()" />
      </xsl:call-template>
    </xsl:element>

  </xsl:template>

  <xsl:template name="MakeSpanForCode">
    <xsl:param name="code" />
    <xsl:element name="Languagecode">
      <xsl:value-of select="$lookupDoc/Languages/Language[@code = $code]/Name/text()" />
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

Produces the following

<XML>
  <Data>
    <Name>shades</Name>
    <Languagecode>hindi</Languagecode>
  </Data>
  <Data>
    <Name>test1</Name>
    <Languagecode>malayalam</Languagecode>
  </Data>
  <Data>
    <Name>test2</Name>
    <Languagecode>bengali</Languagecode>
  </Data>
</XML>
Mike Askew 131 Veteran Poster Featured Poster

Hi

Sorry for the delayed reply.

Is there the option to edit the layout of your Lookup file to start with? It could be improved in terms of how you structure it for clarity of querying.

Mike Askew 131 Veteran Poster Featured Poster

Where does server name come from in that file?

Mike Askew 131 Veteran Poster Featured Poster

I thought I had figured it out!

and then I realised they were grouped off att2.

It has been a couple of years since I have used XSLT in anger and can't remember how to do it off the top of my head now :(

Mike Askew 131 Veteran Poster Featured Poster

THE issue Prit, god people these days.

xD

Mike Askew 131 Veteran Poster Featured Poster

Okay to start with I will point you in the right direction for what you want to do and then if you have issues post them back and we will look at them.

Work is absolutely mad for me today and its already half 6 in the evening and don't think I will be out of here before 8pm so will reply when possible.

Anyway...

            // Greet the user.
            Console.WriteLine("\n\tWelcome to Vegas Dice Roller!");
            Console.WriteLine("\n\tLet's get started!");
            Console.WriteLine();
            // Start the loop for dice rolls, rolling two dice at a time

            // ##You will make a while loop here which just uses the value 'true' so it never ends

                // Generate the two values randomly (1 - 6, inclusive)

                // ##See this link http://stackoverflow.com/questions/2706500/how-to-generate-random-int-number
                // ##Store the numbers as parameters

                // Call the ShowDice method, sending the two values into it, so it can display the roll

                // ## Call ShowDice using the parameters made above. ie. ShowDice(paramNumOne, paramNumTwo)

                // Ask the user if he wants to roll again.

                // ##Write to the console like you have done at the start of program

                // If he answers anything other than "Y" or "N", ask him again.

                sResponse = Console.ReadLine().ToUpper();
                while ((sResponse != "Y") && (sResponse != "N"))
                {
                    Console.WriteLine("I'm sorry but I didn't understand your response.");
                    Console.Write("Would you like to roll again (Y or N)? ");
                    // Obtain user's response and store in the string variable
                    sResponse = Console.ReadLine().ToUpper(); // no change needed
                }

                // ##This …
Mike Askew 131 Veteran Poster Featured Poster

Yeap you can put together a small application to do what you want.

Maybe the following link may help you: http://www.codeproject.com/Articles/4826/XML-File-Parsing-in-VB-NET

I personally have not used VB.Net for 4 or so years so slightly less useful there, I am a C# developer. They are very similar though so should be possible.

Mike Askew 131 Veteran Poster Featured Poster

You have posted a large block of code. What is your actual issue? Most on the forum don't have the time to try and guess the issue themselves.

Mike Askew 131 Veteran Poster Featured Poster

Do you have the skills to put together a small application in any language to take the file and create what you want from it?

Else if it is only 5-10 lines copy and pasting where needed isn't too difficult.

Mike Askew 131 Veteran Poster Featured Poster

Ok shall give it a go, seem to have found another way to do it that has the border but no close button etc.

For the moment I am settling for that due to deadlines and I need to finalise some functionality first. I will revisit this if I get time and let you know the outcome.

Mike Askew 131 Veteran Poster Featured Poster

Can you point me in the direction of some form of guidance in how to do that Prit? Not done before in terms of modifying a RadWindow template

Mike Askew 131 Veteran Poster Featured Poster

So I am currently working with custom silverlight extensions for a SAP application.

The extension kicks off a an async WCF request and waits for the response.

During which time I try the following:

                    waitWindow = new RadWindow();
                    waitWindow.WindowStartupLocation = Telerik.Windows.Controls.WindowStartupLocation.CenterScreen;
                    waitWindow.BorderThickness = new Thickness(0);
                    waitWindow.Content = new View.WaitWindowTest();
                    waitWindow.ShowDialog();

Where View.WaitWindowTest is a UserControl with the standard C# constructor behind it:

<UserControl
    x:Class="censored.View.WaitWindowTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
    mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="50">

    <Grid x:Name="LayoutRoot">

        <Grid.Resources>
            <Style x:Key="BorderlessWindowStyle" TargetType="telerikNavigation:RadWindow">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="telerikNavigation:RadWindow">
                            <Border BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="{TemplateBinding Background}">
                                <ContentPresenter Margin="{TemplateBinding Padding}"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <telerikNavigation:RadWindow x:Name="Window1" Style="{StaticResource BorderlessWindowStyle}" Width="300" Height="50" Padding="50,15,0,0" >
            <TextBlock FontSize="15">Processing, please wait...</TextBlock>
        </telerikNavigation:RadWindow>
    </Grid>
</UserControl>

However when I run the above code I get the following error:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)
Timestamp: Tue, 28 Oct 2014 12:47:13 UTC


Message: Unhandled Error in Silverlight 3 Application: RadWindow control needs to be displayed using its Show or ShowDialog method and shouldn't be added to the layout.
Line: 1
Char: 1
Code: 0
URI: http://localhost/censored/Silverlight.js


Message: Unhandled Error in Silverlight Application 
Code: 4004    
Category: ManagedRuntimeError       
Message: System.InvalidOperationException: RadWindow control needs to be displayed using its Show or ShowDialog method and shouldn't be added to the layout.
   at Telerik.Windows.Controls.RadWindow.OnApplyTemplate()
   at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr …
Mike Askew 131 Veteran Poster Featured Poster

Not entirely sure of another way to do it really apart from if /t works.

Work has got stupidly busy for me so dont have time to look into it in the forseeable future

Mike Askew 131 Veteran Poster Featured Poster

Where do you want the tab?

Do you have an example of the before and after?

Mike Askew 131 Veteran Poster Featured Poster

What is the value of Book.TxtFileNameat present?

Just need to make sure it is a filepath ie C:\Desktop\nBook.txt and it should be fine to save as a .txt file

Mike Askew 131 Veteran Poster Featured Poster

Thanks, I will look into this more on Monday :)

Mike Askew 131 Veteran Poster Featured Poster

window.open(weburlhere)

I won't have a web url to open, simply raw html that I wish to view.

Mike Askew 131 Veteran Poster Featured Poster

So I am currently working in ASP.Net and a bit stuck.

I obtain the full html that I wish to render into the tab from a WSDL request and then need to find a way to load a new tab in the browser and display that information.

I have currently only found

string script = " <script type=\"text/javascript\">  window.open('http://www.codeproject.com/Questions/532873/Howplustopluscodeplustoplusopenplusnewplustabplusi');   </script> ";
            //  this.Page.ClientScript.RegisterStartupScript(typeof(Page), "alert", script);
            ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", script, false);

On the web however this loads a pre-defined page and not HTML I wish to define. Is there a way to do this?

Mike Askew 131 Veteran Poster Featured Poster

Yup you were right prit. Must be a defaulting behaviour though as I didn't add it

Mike Askew 131 Veteran Poster Featured Poster

Has there been a change behind the scenes to how the posting rank is calculated, or have I just reverted to being a Junior Poster with 900+ posts for no reason?

As know there are people at hjgher ranks with less posts.

Mike Askew 131 Veteran Poster Featured Poster

Asked a colleague and fellow student yesterday what the solution to such questions would be, apparently we are just expected to identify the least efficient part of the formula given based off the ordering of BigO.

For example:

T(n) = 45n^2 + 3n/1000 + 18(log n) would be O(N^2)

Quite simple it seems compared to the solutions offered above, I am very grateful that is the case!

Mike Askew 131 Veteran Poster Featured Poster

Didn't make sense probably because I haven't covered such things in lectures.

The exam question wanted the Time Complexity of the above formulas, guessing its a lot simpler than proving they are right and just identifying that they could be linear time for example or something?

At which point I always thought you just found the worse bit of the Algorithm, in the case of:

T(n) = 10000^40 (??)
T(n) = 45n^2 + 3n/1000 + 18(log n) (Quadratic?)

Mike Askew 131 Veteran Poster Featured Poster

The example made no sense to me :(

Mike Askew 131 Veteran Poster Featured Poster

Doing some revision for a university exam being sat at the end of the week. Got my head around most of the BigO stuff I think apart from calculating the BigO equations like the below.

T(n) = 1000040
T(n) = 45n^2 + 3n/1000 + 18(log n)

Could anyone explain the logic behind how would come to an answer for these?

Mike Askew 131 Veteran Poster Featured Poster

The issue turned out to be my misunderstanding of how joins work with .Net and LINQ.

The duplicate rows were the rows joined to the original table. To remove them I had to implement a custom IEqualityComparer to provide to the .Distinct() call.

I can pad out the explanation a bit if anyone needs it.

Mike Askew 131 Veteran Poster Featured Poster
IQueryable<CustomObject> obj = (from table in db.TableName
                                                        orderby table.ObjectId descending
                                                        select
                                                            new CustomObject
                                                            {
                                                                 //Properties mapped here
                                                            }).Skip((pageNumber - 1) * pageSize).Take(pageSize);

The above is a stripped down version of the query I am running. It is missing about 10 joins and then just the bulk mapping of the object, which I have stripped out for confidentiality.

When run:
- pageNumber = 1
- pageSize = 500

table.ObjectId is a PK and so assumable to be unique

The query returns 500 objects into the IQueryable object, however instead of these 500 entries being unique I appear to get about 19 rows from the database duplicated across the 500 rows.

Is there an obvious reason as to why as I cannot find anything on Google regarding it.

Results in the object fit the following kind of pattern:

DBRow1
DBRow1
DBRow1
DBRow1
DBRow1
DBRow1
DBRow1
DBRow1
DBRow1
DBRow1
DBRow2
DBRow2
DBRow2
DBRow2
DBRow2
DBRow2
DBRow2
DBRow2
DBRow2
DBRow3
etc..

Mike Askew 131 Veteran Poster Featured Poster

Weather any better over there?

Mike Askew 131 Veteran Poster Featured Poster

Hehe, where did you move too?

Mike Askew 131 Veteran Poster Featured Poster

You sir are a genious, I did misread which encoding it was using, UTF-8 being correct.

Running with my machine default char-set works fine.

Mike Askew 131 Veteran Poster Featured Poster

Looking at this I may have to catch and manually convert them?

Mike Askew 131 Veteran Poster Featured Poster

Quite rare to see me post in the Java forum but have been picking it up as part of a long-distance university course I am doing.

I am currently trying to read in an ASCII coded .txt file and output it but am seeing some funny characters showing up.

The content is loaded using

        BufferedReader inputReader;

        System.out.println("Loading book...");

        try {
            inputReader = new BufferedReader(new InputStreamReader(new FileInputStream(fileToRead), "ASCII"));

Which I then split on the new page character into book "pages".

When I come to print these out to console using

        try {
            PrintStream output = new PrintStream(System.out, true, "ASCII");

            for (String theWord : words) {

                output.println(theWord);
            }
        }

This: Sorrow came—a gentle sorrow—but not at all in the shape of any disagreeable
Comes as: Sorrow came???a gentle sorrow???but not at all in the shape of any disagreeable

NOTE: The dash is an em-dash

Mike Askew 131 Veteran Poster Featured Poster

C# is actually mentioned third line from the end.

This post was written at a time where we were seeing alot of people in the C# forum asking questions along these lines. It is one of the more useful overarching posts on the forum.

If you look at some of the other sub-forums you can also find posts unique to them that could cover more than one language.

Mike Askew 131 Veteran Poster Featured Poster

Will do, thanks

Mike Askew 131 Veteran Poster Featured Poster

Other half's laptop just trying to clean it up a bit as very slow.

Do these logs look okay? Have deleted all the stuff flagged up in the malware scans but they just seemed to be some social search engine rubbish.

Any pointers appreciated in advance,

Mike

Mike Askew 131 Veteran Poster Featured Poster

Yeah I think it is something to do with how the serialize works. Not sure though.

Glad it's sorted.

Mike Askew 131 Veteran Poster Featured Poster

You're right!

I also now see this behaviour if I shorten the text contained in one of the variables.

The solution I used was the following (line 21):

    public class Temp
    {
        public string Name;
        public string HotKey;
        public string Timer;
        public string Message;
    }

    class Program
    {
        static void Main(string[] args)
        {
            Temp TempClass = new Temp();
            string FilePath = @"D:\Users\MASKEW\Desktop\Test.xml";

            TempClass.Name = "Na";
            TempClass.HotKey = "Hot";
            TempClass.Timer = "Timer";
            TempClass.Message = "Message";

            File.Delete(FilePath);
            XmlSerializer writer = new XmlSerializer(typeof(Temp));
            using (FileStream file = File.OpenWrite(FilePath))
            {
                writer.Serialize(file, TempClass);
            }
        }
    }

This deletes the file and then re-creates it meaning there is no data corruption from the previous entries.

Mike Askew 131 Veteran Poster Featured Poster

Can't seem to replicate your issue using the following test code:

    public class Temp
    {
        public string Name;
        public string HotKey;
        public string Timer;
        public string Message;
    }

    class Program
    {
        static void Main(string[] args)
        {
            Temp TempClass = new Temp();
            string FilePath = @"D:\Users\MASKEW\Desktop\Test.xml";

            TempClass.Name = "Name";
            TempClass.HotKey = "HotKey";
            TempClass.Timer = "Timer";
            TempClass.Message = "Message";

            XmlSerializer writer = new XmlSerializer(typeof(Temp));
            using (FileStream file = File.OpenWrite(FilePath))
            {
                writer.Serialize(file, TempClass);
            }
        }
    }

Any changes to the above to improve its accuracy?

Mike Askew 131 Veteran Poster Featured Poster

What code have you got so far for this?

What is the data etc?

Mike Askew 131 Veteran Poster Featured Poster

As JorgeM said, the class needs instantiating first.

You could also make the method static and then it would function how you are trying to do at present.

Static methods do not require class instantiation in order to be used.

    public static int compute(int a,int b)
    {
        return a*b;
    }

and

    int answer = Automobile.compute(2,3);