Form1.cs :  » Content-Management-Systems-CMS » JMDCMS » JMDCMS.Win » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Content Management Systems CMS » JMDCMS 
JMDCMS » JMDCMS.Win » Form1.cs
/*
  Copyright (C) 2007  Ajay Handa - jmdcms.com 
  This program is free software; 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  License for more details.
  Some rights reserved. Please read License.txt for details.
  Removing above copyright message is a violation of license terms.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;



namespace JMDCMS.Win{
    public partial class Form1 : Form
    {
        

        public Form1()
        {
            InitializeComponent();
        }

        #region Database Build Script

        private void btnBuild_Click(object sender, EventArgs e)
        {
            txtLog.Text = "";
            txtScript.Text = "";
            AppendLog("Checking Directory Structure....");
            if (CheckStructure())
            {

                txtScript.Text += Environment.NewLine + "/*## TABLES SCRIPT ##*/" +Environment.NewLine;
                txtScript.Text += GetScript(txtPath.Text + "\\SQL2005\\DDL\\Table",".TBL");

                txtScript.Text += Environment.NewLine + "/*## VIEWS SCRIPT ##*/" + Environment.NewLine;
                txtScript.Text += GetScript(txtPath.Text + "\\SQL2005\\DDL\\View", ".VW");

                txtScript.Text += Environment.NewLine + "/*## FUNCTIONS SCRIPT ##*/" + Environment.NewLine;
                txtScript.Text += GetScript(txtPath.Text + "\\SQL2005\\DDL\\Function", ".FN");

                txtScript.Text += Environment.NewLine + "/*## STORED PROCEDURES SCRIPT ##*/" + Environment.NewLine;
                txtScript.Text += GetScript(txtPath.Text + "\\SQL2005\\DDL\\SP", ".SP");


            }
            else
            {
                MessageBox.Show("Directory structure is not correct. Please check LOG for details.");
            }
        }
        private bool CheckStructure()
        {
            bool ReturnValue = false;
            ReturnValue = CheckDirectory(txtPath.Text);
            if ( ReturnValue == true )
            {
                ReturnValue = CheckDirectory(txtPath.Text+"\\SQL2005");
            }
            if (ReturnValue == true)
            {
                ReturnValue = CheckDirectory(txtPath.Text + "\\SQL2005\\DDL");
            }
            if (ReturnValue == true)
            {
                ReturnValue = CheckDirectory(txtPath.Text + "\\SQL2005\\DDL\\Function");
            }
            if (ReturnValue == true)
            {
                ReturnValue = CheckDirectory(txtPath.Text + "\\SQL2005\\DDL\\SP");
            }
            if (ReturnValue == true)
            {
                ReturnValue = CheckDirectory(txtPath.Text + "\\SQL2005\\DDL\\Table");
            }
            if (ReturnValue == true)
            {
                ReturnValue = CheckDirectory(txtPath.Text + "\\SQL2005\\DDL\\View");
            }
            return ReturnValue;
        }
        private bool CheckDirectory(string DirPath)
        {
            if (Directory.Exists(DirPath))
            {
                return true;
            }
            else
            {
                AppendLog(string.Format("Failed: Directory {0} does not exists.", DirPath));
                return false;
            }
        }
        private void AppendLog(string LogText)
        {
            txtLog.Text += LogText + Environment.NewLine;
        }

        public static void GetAllDirFilesRecurse(string dir)
        {
            DirectoryInfo mainDir = new DirectoryInfo(dir);
            FileSystemInfo[] items = mainDir.GetFileSystemInfos();
            foreach (FileSystemInfo item in items)
            {
                if (item is DirectoryInfo)
                {
                    Console.WriteLine("DIRECTORY: " + ((DirectoryInfo)item).FullName);
                    GetAllDirFilesRecurse(((DirectoryInfo)item).FullName);
                }
                if (item is FileInfo)
                {
                    Console.WriteLine("FILE: " + ((FileInfo)item).FullName);
                }
                else
                {
                    Console.WriteLine("Unknown");
                }
            }
        }
        public static string GetScript(string dir, string Ext)
        {
            StringBuilder sb = new StringBuilder();
            DirectoryInfo mainDir = new DirectoryInfo(dir);
            FileSystemInfo[] items = mainDir.GetFileSystemInfos();
            foreach (FileSystemInfo item in items)
            {
                if (item is FileInfo)
                {
                    FileInfo fileInfo = item as FileInfo;
                    if (fileInfo.Extension.ToUpper().CompareTo(Ext.ToUpper()) == 0)
                        sb.Append(ReadText(((FileInfo)item).FullName));
                }
            }
            return sb.ToString();
        }
        public static string ReadText(string ScriptFileName)
        {
            if (!File.Exists(ScriptFileName))
            {
                throw (new FileNotFoundException(
                  "logfile cannot be read since it does not exist.", ScriptFileName));
            }
            string contents = "" + Environment.NewLine + Environment.NewLine;

            using (FileStream fileStream = new FileStream(ScriptFileName,
                        FileMode.Open,
                        FileAccess.Read,
                        FileShare.None))
            {
                using (StreamReader streamReader = new StreamReader(fileStream))
                {
                    contents += streamReader.ReadToEnd();
                }
            }
            return contents;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            /*
                        dgResults.Columns.Clear();
                        dgResults.Columns.Add("clickCommissionField", "ClickCommission");

                        dgResults.Columns.Add("clickCommissionField", "ClickCommission");
                        dgResults.Columns.Add("creativeHeightField", "creativeHeightField");
                        dgResults.Columns.Add("creativeWidthField", "creativeWidthField");
                        dgResults.Columns.Add("leadCommissionField", "leadCommissionField");
                        dgResults.Columns.Add("linkCodeHTMLField", "linkCodeHTMLField");

                        dgResults.Rows.Clear();

                        List<LinkData> Items = cjws.GetLinks(tvCategories.SelectedNode.Text,
                            txtFrom.Text, txtTo.Text);
                        foreach (LinkData linkData in Items)
                        {
                            dgResults.Rows.Add(new string[] 
                                { 
                                    linkData.clickCommission,
                                    linkData.creativeHeight,
                                    linkData.creativeWidth,
                                    linkData.leadCommission,
                                    linkData.linkCodeHTML
                                });
                        }

            


                        private string cidField;
        
                    private string clickCommissionField;
        
                    private string creativeHeightField;
        
                    private string creativeWidthField;
        
                    private string leadCommissionField;
        
                    private string linkCodeHTMLField;
        
                    private string linkCodeJavascriptField;
        
                    private string linkDescriptionField;
        
                    private string linkDestinationField;
        
                    private string linkIdField;
        
                    private string linkNameField;
        
                    private string linkTypeField;
        
                    private string nameField;
        
                    private string networkRankField;
        
                    private string performanceIncentivesField;
        
                    private string relationshipStatusField;
        
                    private string saleCommissionField;
        
                    private string sevenDayEPCField;
        
                    private string threeMonthEPCField;
            */

            //ListViewItem lvi = new ListViewItem(Items.ToArray(),-1);
        }

        #endregion

        

        private void tvCategories_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            //cjws.GetLinks(e.Node.Text, 0, 500);
        }

        private void tsbProducts_Click(object sender, EventArgs e)
        {
 
/*
            private int advertiserIdField;
        
        private string advertiserNameField;
        
        private string clickUrlField;
        
        private string currencyField;
        
        private string descriptionField;
        
        private string imageUrlField;
        
        private string nameField;
        
        private double priceField;
        
        private string skuField;
        
        private string upcField;

            dgResults.Columns.Clear();
            dgResults.Columns.Add("advertiserIdField", "advertiserIdField");
            dgResults.Columns.Add("advertiserNameField", "advertiserNameField");
            dgResults.Columns.Add("clickUrlField", "clickUrlField");
            dgResults.Columns.Add("descriptionField", "descriptionField");
            dgResults.Columns.Add("skuField", "skuField");

            dgResults.Rows.Clear();

            List<ProductData> Items = cjws.SearchProduct();

            foreach (ProductData linkData in Items)
            {
                dgResults.Rows.Add(new string[] 
                    { 
                        linkData.advertiserId.ToString(),
                        linkData.advertiserName,
                        linkData.clickUrl,
                        linkData.description,
                        linkData.sku
                    });
            }

*/     
  }
        
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.