Author Topic: XML_ConsoleApplication_001  (Read 2514 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
XML_ConsoleApplication_001
« on: November 19, 2007, 06:53:05 AM »
Had a play tonight ..

DrivePath added:
Save as C:\ProjectStart.XML
Code: [Select]
<?xml version="1.0" encoding="utf-8" ?>
<ProjectList>
<LastProject>J1002</LastProject>
<Project>
    <ProjectID>1001</ProjectID>
    <ProjectNumber>J1001</ProjectNumber>
    <ProjectName>ALPHA</ProjectName>
    <ClientName>Us and Them</ClientName>   
    <JobServer> \\\\Screamer\Drive D\TestProjects</JobServer>     
    <JobSubstDrive>W:</JobSubstDrive>   
    <JobFolder> \J1001</JobFolder>
    <TSDFolder>\TSD</TSDFolder>   
     <StdConsSubstDrive>V:</StdConsSubstDrive>   
    <StdConsFolder>\V-Drive\V-Std</StdConsFolder>     
</Project>
<Project>
    <ProjectID>1002</ProjectID>
    <ProjectNumber>J1002</ProjectNumber>
    <ProjectName>BRAVO</ProjectName>
    <ClientName>Them and Co.</ClientName>
    <JobSubstDrive>W:</JobSubstDrive>
    <JobServer> \\\\Screamer\Drive D\TestProjects</JobServer>   
    <JobFolder> \J1002</JobFolder>
    <TSDFolder>\TSD</TSDFolder>   
    <StdConsSubstDrive>V:</StdConsSubstDrive>     
    <StdConsFolder>\V-Drive\V-Std</StdConsFolder>     
</Project>
<Project>
    <ProjectID>1003</ProjectID>
    <ProjectNumber>J1003</ProjectNumber>
    <ProjectName>CHARLIE</ProjectName>
    <ClientName>Bloggs and Assoc</ClientName>
     <JobSubstDrive>W:</JobSubstDrive>
    <JobServer> \\\\Screamer\Drive D\TestProjects</JobServer>   
    <JobFolder> \J1003</JobFolder>
    <TSDFolder>\TSD</TSDFolder>   
    <StdConsSubstDrive>V:</StdConsSubstDrive>
    <StdConsFolder>\V-Drive\V-Std</StdConsFolder>   
</Project>
</ProjectList>

Then run this ..
Note the projectNumbers are J1001, J1002, J1003 ..
Code: [Select]
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
//----------------------------------------------
// CodeHimBelonga kwb: 2007/11/19 21:40:04
//----------------------------------------------
namespace XML_ConsoleApplication_001
{
    class Program
    {
        static void Main(string[] args)
        {
            DataSet dsProjects = new DataSet();
            dsProjects.ReadXml(@"c:\ProjectStart.XML");

            DataView dvProject = new
                DataView(dsProjects.Tables["Project"]);
            dvProject.Sort = "ProjectNumber";

            Console.Write("\nEnter Project Number :");
            string input = Console.ReadLine();

            int rowIndex = dvProject.Find(input);
            if (rowIndex == -1)
            {
                // The ProjectNumber was not found in our data
                Console.WriteLine("\nProjectNumber {0} was not found.", input);
                Console.ReadKey();
                return;
            }
            //else proceed
            string ProjectID = dvProject[rowIndex]["ProjectID"].ToString();
            string ProjectNumber = dvProject[rowIndex]["ProjectNumber"].ToString();
            string ProjectName = dvProject[rowIndex]["ProjectName"].ToString();
            string ClientName = dvProject[rowIndex]["ClientName"].ToString();
            string JobServer = dvProject[rowIndex]["JobServer"].ToString();
            string JobSubstDrive = dvProject[rowIndex]["JobSubstDrive"].ToString();
            string JobFolder = dvProject[rowIndex]["JobFolder"].ToString();
            //
            Console.WriteLine("\nProjectID {0}"+
                    "\nProjectNumber : {1}"+                 
                    "\nProjectName : {2}"+
                    "\nClientName : {3}"+
                    "\nJobServer : {4}"+
                    "\nJobSubstDrive : {5}"+
                    "\nJobFolder : {6}",
                   rowIndex.ToString(),
                   ProjectNumber,
                   ProjectName,
                   ClientName,
                   JobServer,
                   JobSubstDrive,
                   JobFolder
               );
            //
            Console.Write("\nPress any key to proceed.");
            Console.ReadKey();           
         }
    }
}

Note, this is not meant to be in the least indicative of good code .. just posting what i'm learning :-)

.. and the obligatory piccy,
« Last Edit: November 19, 2007, 08:23:12 PM by Kerry Brown »
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

John Kaul (Se7en)

  • Administrator
  • Needs a day job
  • Posts: 9289
Re: XML_ConsoleApplication_001
« Reply #1 on: November 19, 2007, 09:32:10 AM »
Cool.

I can learn from this. Thank you Kerry.
“Common sense is not so common.” ~Voltaire

--> Donate to TheSwamp.org <--

CmdrDuh

  • Automatic Duh Generator
  • King Gator
  • Posts: 4039
Re: XML_ConsoleApplication_001
« Reply #2 on: November 19, 2007, 10:04:48 AM »
Very cool Kerry!
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: XML_ConsoleApplication_001
« Reply #3 on: November 19, 2007, 07:11:55 PM »
John, David ;
yep, this is fun ..
and you're most welcome.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

MickD

  • Gator
  • Posts: 3315
  • (x-in)->[process]->(y-out)
Re: XML_ConsoleApplication_001
« Reply #4 on: November 19, 2007, 07:18:02 PM »
That looks easy enough Kerry, very clean example and a very good starting point.

Gotta love text based documents :)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: XML_ConsoleApplication_001
« Reply #5 on: November 20, 2007, 01:39:40 AM »
Wheeeee .. in VS2008  Linq in Xml has some potential.
Time to hit the books I think .. :-)
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: XML_ConsoleApplication_001
« Reply #6 on: November 20, 2007, 02:00:18 AM »
I'm wetting myself ..

[/too much information]

A piccy is enough !
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6963
  • AKA Daniel
Re: XML_ConsoleApplication_001
« Reply #7 on: November 20, 2007, 04:09:51 AM »
I'm wetting myself ..

Well, off to buy cleaning supplies  :lol:

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: XML_ConsoleApplication_001
« Reply #8 on: November 20, 2007, 04:33:30 AM »
I'm really going to enjoy this Dan ..
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: XML_ConsoleApplication_001
« Reply #9 on: November 20, 2007, 07:28:04 AM »
This looks like something we were discussing not so long ago Kerry...good to see you're making progress with it.

Cheers,
Glenn.
Me

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: XML_ConsoleApplication_001
« Reply #10 on: November 20, 2007, 08:16:39 AM »
This looks like something we were discussing not so long ago Kerry...good to see you're making progress with it.

Cheers,
Glenn.

Hi Glenn,
yep, this is the start of the beast.

Has your body clock adjusted to Greenwich Mean Time yet ?
« Last Edit: November 20, 2007, 08:18:29 AM by Kerry Brown »
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

joseguia

  • Guest
Re: XML_ConsoleApplication_001
« Reply #11 on: November 20, 2007, 09:19:48 AM »
WOW, .. no way for me to bookmark this topic so I guess I'll reply so I can find it again later.

Thanks for the SAMPLE

TR

  • Guest
Re: XML_ConsoleApplication_001
« Reply #12 on: November 20, 2007, 11:17:32 PM »
The beauty of DataSets is their ability to:

1) Hold a collection of DataTables
2) Read and Write XML data.
3) The ability to connect them to a DataGridView

I am in the process of working on a BOM program using all 3 features listed above. The nicest feature is I can write the DataSets XML to an XRecord in the drawing, which then can be loaded every time my BOM program is initiated.

I can provide code if needed when I get back on my windows laptop but unfortunately for most I do all my coding in BOO so SharpDevelop's translator would be needed.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: XML_ConsoleApplication_001
« Reply #13 on: November 22, 2007, 06:29:52 AM »
Has your body clock adjusted to Greenwich Mean Time yet ?

Yep - all's good Kerry. Will speak to you soon.

Cheers,
Glenn.
Me