Activity Stream
48,167 MEMBERS
61976 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 6 of 6

Hybrid View

litewarez My Work in C# 28th Jun 2010, 08:15 PM
iFlames looks cool lite good luck with it... 29th Jun 2010, 03:31 PM
DLow meh very sexy litewarez 29th Jun 2010, 03:36 PM
Hyperz Tips: -... 29th Jun 2010, 03:43 PM
-Im.z2ight- Nice job very basic C# coding... 29th Jun 2010, 05:29 PM
litewarez Thanks Hyperz, them notes are taken... 29th Jun 2010, 09:23 PM
Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com

    Default My Work in C#

    Well iv'e started working on some tools to help me manage computers easier at work and heres my code so far, im showing you so that you can become better

    What this script does is search local area networks for host-names filtered down by an id that is in each computer on our corporate network!

    This is not completed but thought I would share

    PHP Code: 
    /*use all System here*/
    using System;
    using System.Text.RegularExpressions;

    /*
     * using System.Text;
     * using System.Collections.Generic;
     * using System.Linq;
    */

    using System.Net;

    namespace 
    Serco.Main
    {
        class 
    Program
        
    {
            static 
    void Main(string[] args)
            {
                
    show_main_menu(true);
                
    string option show_main_menu();

                switch (
    option
                {
                    case 
    "1":
                        
    FindHostByAssetTag();
                    break;
                }
            }

            static 
    string show_main_menu(bool header false)
            {
                if (
    header == true)
                {
                    
    Console.Clear();
                    
    Console.Write("Network Toolbox (V1) - *** ICT Team - Developed by ********\n\n");
                    return 
    "";
                }

                
    //Show the menu options
                
    Console.WriteLine("1) Find Host via Asset Tag");
                
    Console.WriteLine("To exit type 'exit' or 'x'");
                
    Console.WriteLine("\n\n");
                
    Console.Write("Please enter an option:");
                
    string o Console.ReadLine().ToString();
                
                return 
    o;
            }

            
    /*
             * methods for each function!
             */
            
    static void FindHostByAssetTag(string error "")
            {
                
    show_main_menu(true);
                
    Console.WriteLine("Asset Tag Searcher\n");
                if (
    error != ""
                {
                    
    Console.WriteLine("Error: {0}\n",error);
                }
                
    Console.Write("Enter Asset Tag:");

                
    string assetTag Console.ReadLine().ToString();
                
    Regex AssetMatch = new Regex("0-9{6}");
                if (
    AssetMatch.Match(assetTag).Success == false
                {
                    
    FindHostByAssetTag("Asset tag failed validation, please use exactly six digits");
                    return;
                }

                
    /*lests start the search*/
                
    string localH Dns.GetHostName();
                
    //Console.WriteLine("Current Host:" + localH);
                
    Console.WriteLine("Searching...");

                
    /*
                 *  DNS Searching Now
                 */
                
    IPHostEntry localHostname Dns.GetHostEntry(Dns.GetHostName());
                foreach (
    IPAddress ip in localHostname.AddressList)
                {
                    
    IPHostEntry Address Dns.GetHostEntry(ip);
                    
    string current_host Address.HostName.ToString();
                    if (
    current_host.IndexOf(assetTag) > 0)
                    {
                        
    Console.WriteLine("\t" Address.HostName.ToString());
                    }
    //                Console.WriteLine(); //Brings back some hashes ??
                    /*
                     * here i want to search all hosts on teh network and match the "assetTag" with the string, if theres a match i want to print out a ip,hostname,etc
                     */
                
    }
                
    Console.Read();
            }
        }

    litewarez Reviewed by litewarez on . My Work in C# Well iv'e started working on some tools to help me manage computers easier at work and heres my code so far, im showing you so that you can become better What this script does is search local area networks for host-names filtered down by an id that is in each computer on our corporate network! This is not completed but thought I would share /*use all System here*/ using System; using System.Text.RegularExpressions; Rating: 5
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  2.   Sponsored Links

  3.     
    #2
    Member
    looks cool lite
    good luck with it

  4.     
    #3
    Banned
    Website's:
    KWWHunction.com
    meh

    very sexy litewarez

  5.     
    #4
    Respected Developer
    Tips:
    - FunctionNamesShouldLookLikeThis();
    - Namespaces should follow this naming: CompanyOrAuthor.ApplicationName.Etc
    - Don't use switch to check one value.
    - Using String.Empty instead of "" saves memory.

    Other than that good job .

  6.     
    #5
    Member
    Website's:
    FlowForums.com
    Nice job very basic C# coding though.

  7.     
    #6
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Thanks Hyperz, them notes are taken into consideration with gratitude .

    Just an update to show that i am increasing my complexity by using the Directories and understanding how to declare variables and class/ method types.

    PHP Code: 
    static void FindHostByAssetTag(string error "")
            {
                
    show_main_menu(true);
                
    Console.WriteLine("Asset Tag Searcher\n");
                if (
    error != ""
                {
                    
    Console.WriteLine("Error: {0}\n",error);
                }
                
    Console.Write("Enter Asset Tag or * for all: ");

                
    string assetTag Console.ReadLine().ToString();
                
    Regex AssetMatch = new Regex("[0-9]{6}|[*]{1}");
                if (
    AssetMatch.Match(assetTag).Success == false
                {
                    
    FindHostByAssetTag("Asset tag failed validation, please use exactly six digits");
                    return;
                }

                
    /*lests start the search*/
                
    string localH Dns.GetHostName();
                
    //Console.WriteLine("Current Host:" + localH);
                
    Console.WriteLine("Searching...");

                
    /*
                 *  DNS Searching Now
                 */
                
    IPHostEntry localHostname Dns.GetHostEntry(Dns.GetHostName());
                if (
    localHostname.AddressList.Length == 0
                {
                    
    FindHostByAssetTag("unable to detect any hosts at all. make sure a connection is active");
                    return;
                }
                
    int count 0;
                
    Dictionary<stringIPAddressstorage = new Dictionary<stringIPAddress>();

                foreach (
    IPAddress ip in localHostname.AddressList)
                {
                    
    IPHostEntry Address Dns.GetHostEntry(ip);
                    
    string current_host Address.HostName.ToString();
                    if (
    assetTag == "*" || current_host.IndexOf(assetTag) > 0)
                    {
                        
    count++;
                        
    storage.Add(count.ToString(),ip);//Store as string
                        
    Console.WriteLine("("+count+")\t" Address.HostName.ToString());
                    }
                }
                if (
    count == 0
                {
                    
    FindHostByAssetTag("Unable to find any hosts matching (" assetTag ")");
                    return;
                }

                
    //Show the menu select menu for the selected asset tag
                
    Console.WriteLine("Please select an ID for options: ");
                
    string selected Console.ReadLine();
                if (
    Int32.Parse(selected) > && storage.ContainsKey(selected))
                {
                    if (
    storage.ContainsKey(selected))
                    {
                        
    show_main_menu(true);
                        
    Console.WriteLine("options for item {0}"selected);
                        
    string option Console.ReadLine();
                    }
                }
                else 
                {
                    
    Console.WriteLine("item could not be found!");
                    
    Console.Read();
                }
            } 
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. mtn not work with wmn and mp4
    By ciaociao4 in forum Web Development Area
    Replies: 0
    Last Post: 14th Aug 2011, 10:20 PM
  2. Show your work station/work area
    By Hydrode in forum General Discussion
    Replies: 18
    Last Post: 27th Mar 2011, 10:30 PM
  3. Does Kloxo Takes Time To Make Domain Work And DNs Work?
    By soft2050 in forum Technical Help Desk Support
    Replies: 12
    Last Post: 15th Oct 2010, 12:01 PM
  4. Need some work done.
    By d0ped in forum Graphics Area
    Replies: 9
    Last Post: 17th Jul 2010, 06:45 AM
  5. Does OVH FTP really work?
    By lucy fox in forum Hosting Discussion
    Replies: 8
    Last Post: 13th Mar 2010, 05:03 AM
BE SOCIAL