Click here to Skip to main content
15,886,199 members
Articles / Programming Languages / C#

AccountPlus

Rate me:
Please Sign up or sign in to vote.
4.47/5 (63 votes)
10 Sep 2009LGPL320 min read 240.1K   61.8K   209  
A Complete Account Management System
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using AccountPlus.Messaging;
using System.IO;

namespace AccountPlus.UI
{
    public partial class Diagnostic : AccountPlusBase
    {
        public Diagnostic()
        {
            InitializeComponent();
        }

        private void LoadData()
        {
            if (AccountPlus.Configurations.ApplicationConfiguration.TracingEnabled)
                lblTracingEnabled.Text = "Enable";
            else
            {
                lblTracingEnabled.Text = "Disable";
                rbnTrace.Enabled = false;
            }

            if (AccountPlus.Configurations.ApplicationConfiguration.LoggingEnabled)
                lblLoggingEnabled.Text = "Enable";
            else
                lblLoggingEnabled.Text = "Disable";
        }
  
        private void DisplayDignosisInfo()
        {
            lblImportMessage.Text = string.Empty;

            string[] files = null;
            string logTrace = string.Empty;
            if (rbnLog.Checked)
            {
                lblOptionSelected.Text = "Log file(s) : ";
                files = GetFiles(Environment.CurrentDirectory + @"\Diagnostics\Log\");
                logTrace = "log";
            }
            else
            {
                lblOptionSelected.Text = "Trace file(s) : ";
                files = GetFiles(Environment.CurrentDirectory + @"\Diagnostics\Trace\");
                logTrace = "trace";
            }

            if ((files != null))
            {
                lstFileDetails.Items.Clear();

                if (files.Length > 0)
                {
                    foreach (string file in files)
                        lstFileDetails.Items.Add(file);

                    lblFilesInfo.Text =  MessageManager.GetMessage("56",logTrace , files.Length.ToString());
                    btnExport.Enabled = true;
                }
                else
                {
                    lblFilesInfo.Text = MessageManager.GetMessage("56", logTrace, "0");
                    btnExport.Enabled = false;
                }
            }
            else
            {
                lblFilesInfo.Text = MessageManager.GetMessage("56", logTrace, "0");
                btnExport.Enabled = false;
            }
            
        }

        private string[] GetFiles(string path)
        {
            List<string> fileName = new List<string>();
            string[] files = null;
            if (Directory.Exists(path))
            {
                files = Directory.GetFiles(path);
                foreach (string file in files)                
                    fileName.Add(Path.GetFileName(file));
                
            }

            return fileName.ToArray();
        }
              
        private void OpenFile(string fileName)
        {
            if (System.IO.File.Exists(fileName))            
                Process.Start(fileName);
        }

       

        private void ImportFiles(string importLocation)
        {
            try
            {
                string fromPath = string.Empty;
                if (rbnLog.Checked)
                    fromPath = Environment.CurrentDirectory + @"\Diagnostics\Log\";                
                else
                    fromPath = Environment.CurrentDirectory + @"\Diagnostics\Trace\";                

                if (Directory.Exists(fromPath))
                {
                    string[] files = Directory.GetFiles(fromPath);
                    string fileName = string.Empty;
                    if ((files != null))
                    {
                        foreach (string filePath in files)
                        {
                            fileName = Path.GetFileName(filePath);
                            File.Copy(filePath, importLocation + "\\" + fileName, true);
                        }
                        lblImportMessage.Text = MessageManager.GetMessage("57");
                    }
                }
                else
                    lblImportMessage.Text = MessageManager.GetMessage("58");
            }
            catch (Exception ex)
            {
                lblImportMessage.Text = MessageManager.GetMessage("59");
                throw ex;
            }
        }

        private void btnExport_Click(object sender, EventArgs e)
        {
            if (lstFileDetails.Items.Count == 0)
            {
                lblImportMessage.Text = MessageManager.GetMessage("58");
                return;
            }

            lblImportMessage.Text = string.Empty;
            FolderBrowserDialog folderBrowse = new FolderBrowserDialog();

            if (folderBrowse.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string path = folderBrowse.SelectedPath;

                if (string.IsNullOrEmpty(path))
                    lblImportMessage.Text = MessageManager.GetMessage("60");
                else                
                    ImportFiles(path);                
            }            
        }

        private void lstFileDetails_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            lblImportMessage.Text = string.Empty;
            if (lstFileDetails.Items.Count == 0) return;

            string selectedFile = string.Empty;
            if ((lstFileDetails.SelectedItem != null))
            {
                selectedFile = lstFileDetails.SelectedItem.ToString();
                if (rbnLog.Checked)
                    OpenFile(Environment.CurrentDirectory + @"\Diagnostics\Log\" + selectedFile);                
                else
                    OpenFile(Environment.CurrentDirectory + @"\Diagnostics\Trace\" + selectedFile);                
                
            }
        }

        private void Diagnostic_Load(object sender, EventArgs e)
        {
            base.SetBGColor(this);
            LoadData();
            DisplayDignosisInfo();
        }

        private void rbnLog_CheckedChanged(object sender, EventArgs e)
        {
            DisplayDignosisInfo();
        }

        private void rbnTrace_CheckedChanged(object sender, EventArgs e)
        {
            DisplayDignosisInfo();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

     

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Founder Aspirea Technologies Pvt Ltd
India India
• 8 years of experience in IT Industry as a Developer.
• Experience of End-To-End Software Development and Implementation (Entire SDLC i.e Software Development Life Cycle)
• Real time Exposure to Banking, Finance and Energy industry.
• Expertise in distributed application architecture as well as web based applications using Microsoft.NET platform.
• Expertise in database design, SQL programming and SQL performance tuning.
• Expertise in Web Services and WCF Services.
• Experience of Rich Internet Application using Adobe Flex.
• Experience in migration of legacy application to latest technology, migration of VB application to .NET.
• Knowledge of OOPS and Design Concepts.
• Expertise in Agile/ Scrum software development processes.

Specialties
• Languages\ Technologies-
.NET Framework 1.1/2.0/3.0/3.5, C#.NET, VB.NET, ASP.NET, VB6, AJAX, ASP.NET, Adobe Flex 3.0, Web Services, Windows Communication Foundation (WCF), LINQ, SQL Server, Oracle, MySql, MS Access, HTML, XML, JavaScript, C# Script, CSS and XSLT.

• Methodology/ Concepts-
OOPS, Data Structures, Design Concepts and Agile/ Scrum Software Development

Comments and Discussions