Mike Askew 131 Veteran Poster Featured Poster

Using command prompt or a winform?

Mike Askew 131 Veteran Poster Featured Poster

Untitled84

Sorry didnt make myself clear, the code runs all the way to the end.

Mike Askew 131 Veteran Poster Featured Poster

Oo sounds interesting, shall have a look at it!

Mike Askew 131 Veteran Poster Featured Poster

There is only one station on the London Underground that does not have any letters from the Word Mackerel in it. I'll give you a few hours to find it....

Took me 15 mins and a bit of C# :)

Mike Askew 131 Veteran Poster Featured Poster

So me and a colleague at work are trying to decide upon a mini-project to do, simply to see how differently we would code it.

Has anyone got a good resource for such ideas, or even have some themselves, that are semi-challenging and do-able in about a day?

Cheers,

Mike Askew 131 Veteran Poster Featured Poster

@happygeek, apologies I only read this thread after sending you the PM :)

Mike Askew 131 Veteran Poster Featured Poster

Anyone who has ever read parts or all of the Bible or Quran should have known that 2:6-7 means. I'm flabbergasted.

I know what they mean and I have no association to religon whatsoever...

I now question what these people actually know when they argue points.

Been following this thread out of interest and because Reverend Jim is providing interesting points and probably the best in the thread, in my opinion of course.

Mike Askew 131 Veteran Poster Featured Poster
  • What database are you using?

  • What's the table name?

  • What's the ID column name?

Mike Askew 131 Veteran Poster Featured Poster

The provided code runs fine on my computer, can we see the actual?

Mike Askew 131 Veteran Poster Featured Poster

Oh sugar didnt notice that, /palm.

Was just pinging through related articles lol.

Mike Askew 131 Veteran Poster Featured Poster

Updated code taking into account new requirement.

        static void Main(string[] args)
        {
            string sourcePath = @"E:\Source\";
            string targetPath = @"E:\Destination\";

            StreamReader strmReader = new StreamReader(sourcePath + "videoID.txt");

            string videoIDs = strmReader.ReadToEnd();

            videoIDs = Regex.Replace(videoIDs, "\\r\\n", ",");

            string[] individualVidIDs = videoIDs.Split(',');
            string[] tempArray = Directory.GetFiles(sourcePath);
            List<string> filesInFolder = new List<string>();
            foreach (string fileName in tempArray)
            {
                filesInFolder.Add(fileName);
            }
            filesInFolder.Remove(sourcePath + "videoID.txt");

            foreach (string videoID in individualVidIDs)
            {
                Console.WriteLine("VideoID = {0}", videoID);
                Console.WriteLine();

                foreach (string fileName in filesInFolder)
                {
                    if (fileName.Substring(fileName.LastIndexOf('\\') + 1, 3) == videoID)
                    {
                        Console.WriteLine("Video {0} has been found.", fileName.Substring(fileName.LastIndexOf('\\') + 1));

                        string destFile = targetPath + "\\" + (fileName.Substring(fileName.LastIndexOf('\\') + 1));
                        System.IO.File.Copy(fileName, destFile, true);
                        Console.WriteLine();
                    }
                    else
                    {
                        Console.WriteLine("Video {0} does not match VideoID!", fileName.Substring(fileName.LastIndexOf('\\') + 1));
                        Console.WriteLine();
                    }
                }
            }

            Console.ReadLine();
        }
Mike Askew 131 Veteran Poster Featured Poster

Wonderful to hear :)

Mike Askew 131 Veteran Poster Featured Poster

I did it using the following:

            string sourcePath = @"E:\Source";
            string targetPath = @"E:\Destination";

            StreamReader strmReader = new StreamReader(@"E:\Source\videoID.txt");

            string videoIDs = strmReader.ReadToEnd();

            videoIDs = Regex.Replace(videoIDs, "\\r\\n", ",");

            string[] individualVidIDs = videoIDs.Split(',');

            foreach (string videoID in individualVidIDs)
            {
                Console.WriteLine("Checking if video {0} exists...", videoID);
                string tempFilePath = sourcePath + "\\" + videoID + ".txt";
                if (File.Exists(tempFilePath))
                {
                    Console.WriteLine("Video {0} has been found...", videoID);

                    string fileName = System.IO.Path.GetFileName(tempFilePath);
                    string destFile = System.IO.Path.Combine(targetPath, fileName);
                    System.IO.File.Copy(tempFilePath, destFile, true);
                    Console.WriteLine();
                }
                else
                {
                    Console.WriteLine("Video {0} has NOT been found!", videoID);
                    Console.WriteLine();
                }
            }

This assumes that the videoID file is literally seperated by new lines and doesnt have like a comma etc.

Else the RegEx wouldnt be needed to remove the newline escape codes.

I used files like this to test: 10001.txt

Mike Askew 131 Veteran Poster Featured Poster

I suggest you re-think your post giving far more information and showing what you've done so far, also what issues you have, and what you need help with.

Nobody is going to write you one from scratch, especially when showing little to no effort on your behalf.

Mike Askew 131 Veteran Poster Featured Poster

datetimepicker2.value=DateTimePicker1.Value.AddDays(comboBox1.SelectedValue)

I believe the .SelectedValue would need to be converted from string to int first for that line to work?

Mike Askew 131 Veteran Poster Featured Poster

Move your methods for checking files etc to the splashScreen_Shown event.

This is run once the form appears on screen

EDIT:-

The reason all the checks are currently done before the splashscreen appears are because it is in the splashScreen_Load event which will fire before the form is visible as it loads everything required etc. Thought I'd just mention that for clarification purposes

Mike Askew 131 Veteran Poster Featured Poster

After a recent occurance this suggestion arises from me.

After writing a fair amount of text I managed to clip the back button on my mouse and thus lose everything written.

It would be quite convienient to have an 'Are you sure you wish to leave the page?' confirmation when you have text in either a forum response or PM. As this would stop the accidentle deletion of such post's content.

Not sure on the complexity of implementation as my web dev skills are pathetic :(

Mike Askew 131 Veteran Poster Featured Poster

I presume CSS can do this as it looks like a web application, however my CSS is awful.

Doing it with CSS would probably also require the rest to be done in it also which could just cause more problems.

Someone more experienced in web development can probably elaborate further.

EDIT: Whats it even meant to be aligned to etc? Its really unclear.

Mike Askew 131 Veteran Poster Featured Poster

Going on naming patterns and activity from the real time feed queenbaby will be the next to be removed or to watch.

Mike Askew 131 Veteran Poster Featured Poster

My first question is what causes the requirement for it to be a Laptop?

Gaming and Laptops in general don't mix very well, especially in terms of budgetting and also future proofing, you can't upgrade a laptop in the same way you can pretty much reconfigure a desktop rig every year or so.

The only real laptops for gaming as mentioned above are from Alienware and other high end manufacturers but all of these pack a nasty price tag, especially Alienware. Even then these 'laptops' are classed as desktop replacements and weight a rediculous amount for being called laptops.

Again as mentioned above, the Razer Blade, is marketed as the only true gaming laptop, and has a price tag to accompany that claim, however it does actually seem like a laptop in terms of weight and portability.

Back to the point in hand, you will most likely struggle to find a laptop with that budget to run newer games as they are slowly becoming more demanding as technologies progress.

It all depends on whether you need it to be a Laptop and couldnt get a desktop instead?

Mike Askew 131 Veteran Poster Featured Poster

I believe the intention is the last ID would be retrieved from the database and id set to that.

Mike Askew 131 Veteran Poster Featured Poster

Ah fair enough then, also skimmed over the 12. id++; on my first read through. :)

Mike Askew 131 Veteran Poster Featured Poster

@superjj

So where does id value come from? Looks like you add a blank value there.

Declared at the top and then used while blank if we assume no code isnt written there.

Mike Askew 131 Veteran Poster Featured Poster

Right so,

<xs:attribute name="lang" type="xs:string"/>

Would create an xml attribute looking like this:

<RandomNode lang=""></RandomNode>

Which is perfectly acceptable if we want to create a blank attribute. What your referring to would be used when we wish to apply a value to that attribute and in that case it goes like you state.

<xs:attribute name="lang" type="xs:string"/>ValueHere</s:attribute>

Would create:

<RandomNode lang="ValueHere"></RandomNode>

Basically using the /> is shorthand for the whole node being written out, or thats how I view it.

Not entirely sure why we would need to stay away from using such formats?

Mike Askew 131 Veteran Poster Featured Poster

Do you have an example?

Are the characters required by the document?

Mike Askew 131 Veteran Poster Featured Poster

I would generally just right-click, outlining, toggle all outlining and then open up the main one and voila you have classes collasped.

I am using VS2010 but i assume it'll be similar.

Mike Askew 131 Veteran Poster Featured Poster

Understandable replies, case closed.

Mike Askew 131 Veteran Poster Featured Poster

Fair enough :) Guess we shall see Dani's response on the thread about such signatures

Mike Askew 131 Veteran Poster Featured Poster

@deceptikon, I know exactly what you mean about trawling through seperating flashy images from posts I've seen such issue before.

Admittedly as you said, that would be the issue, that and the possible abuse of such ability (no clue how strong the moderation team is in terms of numbers to fight such things :D)

It was a question destined to pop up eventually :p

---

A solution to the trawling through posts seperating sigs from images could plausibly be solved by an option in user config to turn on/off display of such imagery in signatures. So if your not interested in seeing them you wouldnt.

Thats just an opinion on how to deal with it though :)

Mike Askew 131 Veteran Poster Featured Poster

How exactly do you wish to manipulate the data?

You can manipulate the xml in the XmlDocument from .loadxml using XSLT.

Shown in: http://stackoverflow.com/questions/2548613/c-sharp-how-to-perform-a-live-xslt-transformation-on-an-in-memory-object

Im presuming you would use XSLT to manipulate the XML considering that is what XSLT is designed for?

Mike Askew 131 Veteran Poster Featured Poster

The below XSLT works regardless of node occurance.

Credit to nonnb on StackOverflow.
Route to solution if interested: http://stackoverflow.com/questions/11537036/xslt-select-specific-nodes-below-current

XSLT
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

  <xsl:template match="Process">
    <xsl:element name="Process">
      <xsl:for-each select ="name">
        <xsl:element name ="Process_Info">
          <xsl:copy-of select ="."/>
          <xsl:variable name="firstSib" select="local-name(following-sibling::*[1])" />
          <xsl:variable name="secondSib" select="local-name(following-sibling::*[2])" />
          <xsl:if test ="($firstSib='duration') or ($firstSib='time')">
            <xsl:copy-of select="following-sibling::*[1]"/>
          </xsl:if>
          <xsl:if test ="($secondSib='duration') or ($secondSib='time')">
            <xsl:copy-of select="following-sibling::*[2]"/>
          </xsl:if>
        </xsl:element>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>
Mike Askew 131 Veteran Poster Featured Poster

Indeed, your point did make me realise I still need to set an avatar haha xD

Mike Askew 131 Veteran Poster Featured Poster
Mike Askew 131 Veteran Poster Featured Poster

Plausible workaround, but if I wanted to have an avatar and a flair ;)?

Mike Askew 131 Veteran Poster Featured Poster

I'm well aware this is most likely going for an instant shoot-down.

Currently we can only get the four line signature.

It would be nice to allow small HTML imaging.

For example I'd like to include my StackOverflow flair :)

<a href="http://stackoverflow.com/users/1220965/mike">
<img src="http://stackoverflow.com/users/flair/1220965.png" width="208" height="58" alt="profile for Mike at Stack Overflow, Q&amp;A for professional and enthusiast programmers" title="profile for Mike at Stack Overflow, Q&amp;A for professional and enthusiast programmers">
</a>

What are the for/against's for such implementation on the site? Assuming database related or the content that the less mature individuals would put in the signatures.

Mike Askew 131 Veteran Poster Featured Poster

Have just tested, at present it will not work.

Looking for a solution to the issue it causes.

Mike Askew 131 Veteran Poster Featured Poster

Been a while since I played with forms but if exceptions are occuring I believe they do not get thrown in form_load and instead are suppressed. It might be worth assigning the code to a button press or to a function called from form_load to see if any exceptions occur.

Someone correct me if im wrong.

Mike Askew 131 Veteran Poster Featured Poster

The XSLT works by storing all the XML within <Process> root node allowing access to it within the <name> for-each selects.

Within each for-each we get the position() of the <name> and then copy in the <time> and <duration> with the same positions.

XSLT
<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

  <xsl:variable name ="varProcess" select ="Process"/>

  <xsl:template match="Process">
    <xsl:element name="Process">
      <xsl:for-each select ="name">
        <xsl:variable name ="varPosition" select ="position()"/>
        <xsl:element name ="Process_Info">
          <xsl:copy-of select ="."/>
          <xsl:copy-of select="$varProcess/duration[$varPosition]"/>
          <xsl:copy-of select="$varProcess/time[$varPosition]"/>
        </xsl:element>
      </xsl:for-each>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
INPUT
<Process>
  <name>Pro1</name>
  <duration>Dur1</duration>
  <time>Time1</time>
  <name>Pro2</name>
  <duration>Dur2</duration>
  <time>Time2</time>
  <name>Pro3</name>
  <duration>Dur3</duration>
  <time>Time3</time>
  <name>Pro4</name>
  <duration>Dur4</duration>
  <time>Time4</time>
  <name>Pro5</name>
  <duration>Dur5</duration>
  <time>Time5</time>
</Process>
OUTPUT
<Process>
  <Process_Info>
    <name>Pro1</name>
    <duration>Dur1</duration>
    <time>Time1</time>
  </Process_Info>
  <Process_Info>
    <name>Pro2</name>
    <duration>Dur2</duration>
    <time>Time2</time>
  </Process_Info>
  <Process_Info>
    <name>Pro3</name>
    <duration>Dur3</duration>
    <time>Time3</time>
  </Process_Info>
  <Process_Info>
    <name>Pro4</name>
    <duration>Dur4</duration>
    <time>Time4</time>
  </Process_Info>
  <Process_Info>
    <name>Pro5</name>
    <duration>Dur5</duration>
    <time>Time5</time>
  </Process_Info>
</Process>
Mike Askew 131 Veteran Poster Featured Poster

Is it safe to assume that every <name> node will have a corresponding <duration> and <time> node?

Mike Askew 131 Veteran Poster Featured Poster

Could use an XMLDocument to store the data from string?

http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml.aspx

The above method hopefully should do it.

Mike Askew 131 Veteran Poster Featured Poster

edit: Just noticed someone had raised this from the grave -.- still below might be useful to some

Forgive me for doing so without request but I thought I'd give you a pointer @jonifen as I used to make this mistake myself too until someone said.

You are using XSLT like a programatical language which it is not.

Therefore we can remove all of the for-each loops in your stylesheet and instead use templates for the specific items we are looping.

The template will match if it exists and do the code specified. If the node occurs more than once, the template will match all occurances individually, depending on how you select them.

See below for a re-written version of what you used, still produces same output (to the extent I could test, had to remove your class calls and used a dud instead).

<xsl:stylesheet version="1.0" 
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:myObj="urn:addressfinder">
  <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>

  <xsl:template match="RootNode">
    <RootNode>
      <xsl:apply-templates/>
    </RootNode>
  </xsl:template>

  <xsl:template match="Person">
    <xsl:element name ="Person">
      <xsl:copy-of select="@ID"/>
      <xsl:copy-of select="@Name"/>
      <xsl:copy-of select="@Dept"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <xsl:template match ="Address">
    <xsl:element name="Address">
      <xsl:copy-of select="@Number"/>
      <xsl:copy-of select="@PostCode"/>
      <xsl:choose>
        <xsl:when test="StreetName">
          <xsl:copy-of select="@StreetName"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="StreetName">
            <xsl:value-of select="myObj:getStreetName(PostCode)"/>
          </xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:copy-of select="@Country"/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
Mike Askew 131 Veteran Poster Featured Poster

Figured I may as well do with the catalog names, its easy to remove them.

The following XSLT style sheet:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                exclude-result-prefixes="xsl">

  <xsl:output indent="yes" omit-xml-declaration ="yes" method="xml"/>
  <xsl:strip-space elements="*"/>

  <!-- Remove this template to get rid of the <html> tags -->
  <xsl:template match="catalogs">
    <xsl:element name="html">
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="catalogs/catalog">
      <!-- My way of getting the catalog name to show, feel free to use a different one -->
      <xsl:element name="div">
        <xsl:value-of select ="@name"/>
      </xsl:element>
      <xsl:element name="table">
        <xsl:element name="tr">
          <!-- Add/Remove lines here as required to change the amount of column headers -->
          <xsl:element name="th">TITLE</xsl:element>
          <xsl:element name="th">AUTHOR</xsl:element>
          <xsl:element name="th">COMPANY</xsl:element>
          <xsl:element name="th">COUNTRY</xsl:element>
        </xsl:element>
        <xsl:apply-templates/>
      </xsl:element>
  </xsl:template>

  <xsl:template match="catalogs/catalog/book">
    <xsl:element name="tr">
      <xsl:element name="td">
        <xsl:value-of select="title"/>
      </xsl:element>
      <xsl:element name="td">
        <xsl:value-of select="author"/>
      </xsl:element>
      <xsl:element name="td">
        <xsl:value-of select="company"/>
      </xsl:element>
      <xsl:element name="td">
        <xsl:value-of select="country"/>
      </xsl:element>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
With input:
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Edited by XMLSpy® -->
<?xml-stylesheet type="text/html" href="j.html"?>
<catalogs>
  <catalog name="infibeam">
    <book>
      <title>cnds</title>
      <author>balagurusamy</author>
      <company>zseries</company>
      <country>america</country>
      <price>
        <mrp_price>150</mrp_price>
        <discount>15%</discount>
      </price>
    </book>
    <book>
      <title>java</title>
      <author>chandrasekhar</author>
      <company>qlines</company>
      <country>england</country>
      <price>
        <mrp_price>15</mrp_price>
        <discount>5%</discount>
      </price>
    </book>
    <book>
      <title>oracle</title>
      <author>somasekhar</author>
      <company>MAster</company>
      <country>australia</country>
      <price>
        <mrp_price>15</mrp_price>
        <discount>5%</discount>
      </price>
    </book>
  </catalog>
  <catalog name="flipcart">
    <book>
      <title>C.N</title>
      <author>varma</author>
      <company>Vseries</company>
      <country>india</country>
      <price>
        <mrp_price>150</mrp_price>
        <discount>15%</discount>
      </price>
    </book>
    <book>
      <title>C.G</title>
      <author>Eswar</author>
      <company>kseries</company>
      <country>india</country>
      <price>
        <mrp_price>200</mrp_price>
        <discount>10%</discount>
      </price>
    </book>
  </catalog>
</catalogs>
Produces:
<html>
  <div>infibeam</div>
  <table>
    <tr>
      <th>TITLE</th>
      <th>AUTHOR</th>
      <th>COMPANY</th>
      <th>COUNTRY</th>
    </tr>
    <tr>
      <td>cnds</td>
      <td>balagurusamy</td>
      <td>zseries</td>
      <td>america</td>
    </tr>
    <tr>
      <td>java</td>
      <td>chandrasekhar</td>
      <td>qlines</td>
      <td>england</td>
    </tr>
    <tr>
      <td>oracle</td>
      <td>somasekhar</td>
      <td>MAster</td>
      <td>australia</td>
    </tr>
  </table>
  <div>flipcart</div>
  <table>
    <tr>
      <th>TITLE</th>
      <th>AUTHOR</th>
      <th>COMPANY</th>
      <th>COUNTRY</th> …
Mike Askew 131 Veteran Poster Featured Poster

infibeam
TITLE AUTHOR COMPANY COUNTRY
cnds balagurusamy zseries america
java chandrasekhar qlines england
oracle somasekhar MAster australia

flipcart

TITLE AUTHOR COMPANY COUNTRY
C.N varma Vseries india
C.G Eswara kseries india

Are the infibeam and flipcart required in the output as they dont look like they fit into the tables you've drawn?

If they do, please clarify your tables further, possibly graphically or manually produce the HTML table code you require and it can then be replicated automatically.

I will assume they do not need to be in the tables and just the data is required until you respond.

Mike Askew 131 Veteran Poster Featured Poster

@samsylvertertty, It is posted in the correct place for XML to HTML, this is a use for XSLT.

Writing it currently.

Mike Askew 131 Veteran Poster Featured Poster

Mmm how odd, would be worth getting this post moved to the Mobile Dev forums I think as its more Android related than XML.

Mike Askew 131 Veteran Poster Featured Poster

The XML itself is fine and all well formed if you check it with online validators. Im not aware of the android specifics myself.

Element Type "SlidingDrawer" must be followed by either atribute specifications ">" , or , "/>"

One would guess that 'SlidingDrawer' cant have attributes and that it is expecting either ">" (creating a tag which can have child elements placed within), or "/>" closing the tag?

Error parsing XML: not well formed (invalid token)

Looks fine to me..

What is giving the errors, Ie. what IDE etc? and Does the book provide such XML that should work and if so are there any difference between the two?

Mike Askew 131 Veteran Poster Featured Poster

XML is mainly used for moving data between one platform and another.

It can definately be used for the chart, if you look at the link I posted it shows a rough XML structure which you could use similarly.

Then would just be a matter of creating something to read the data and interpret it using chart tools for example the graph tools with C# etc in visual studio.

Mike Askew 131 Veteran Poster Featured Poster

What do you intend to use the XML for? Holding the data for rows etc?

I.E: http://www.maani.us/xml_charts/index.php?menu=Tutorial&submenu=Chart_Data

Mike Askew 131 Veteran Poster Featured Poster

@MadTogger,

Updated the code if your interested.

        string[] topFoldersFound = Directory.GetDirectories(@"C:\");
        string DropboxPath = "null";

        foreach (string topFolder in topFoldersFound)
        {
            try
            {
                if (topFolder.Contains("Users") | topFolder.Contains("Documents and Settings"))
                {
                    string[] folderFound = Directory.GetDirectories(topFolder, Environment.UserName);

                    if (folderFound.Length > 0)
                    {
                        string[] subFoldersFound = Directory.GetDirectories(folderFound[0]);

                        foreach (string subFolder in subFoldersFound)
                        {
                            if (subFolder.Contains("Dropbox"))
                                DropboxPath = subFolder;
                        }
                    }

                }
            }
            catch (UnauthorizedAccessException ex) { }
        }

The reasons behind this being I figured if the computer has multiple user accounts and the user running the program is say second on the list and the first also had dropbox installed it would take their path, same for users after my target one.

The new code also allows it to work on either OS without difficulty and also removes the middle tier of looping by using a search pattern of the user's username while looking in either the Documents and Settings folder or the Users folder.

Mike Askew 131 Veteran Poster Featured Poster

Wow thats really useful cheers skata.

In this case it is not applicable as im looking at the folder heirachy one up from 'My Documents' but will definately remember that one for the future.