public void Generate(Table table,string inputDir, string outputDir)
 {
     var directoryInfo = new DirectoryInfo(inputDir);
     var client = new Client();
     //var originalSd = client.StartDelimiter;
     //var originalEd = client.EndingDelimiter;
     if(_CustomValue != null)
     {
         client.CustomValues = _CustomValue;
     }
     foreach(var fileInfo in directoryInfo.GetFiles())
     {
         client.StartDelimiter = "{";//originalSd;
         client.EndingDelimiter = "}";//originalEd;
         var sr = File.OpenText(fileInfo.FullName);
         var fileContent = sr.ReadToEnd();
         sr.Close();
         var codeGenerated = client.Parse(table,fileContent);
         client.StartDelimiter = String.Empty;
         client.EndingDelimiter = String.Empty;
         var filename = client.Parse(table,fileInfo.Name);
         try
         {
             var sw = new StreamWriter(outputDir + Path.DirectorySeparatorChar + filename);
             sw.Write(codeGenerated);
             sw.Flush();
             sw.Close();
         }
         catch (Exception e)
         {
             Debug.WriteLine(e);
         }
     }
     CompleteNotifier(new EventArgs());
 }
 public void TestFilenameGenerator()
 {
     Server.ConnectionString = @"SERVER=(local);DATABASE=;UID=sa;PWD=m14m14;";
     Server.ProviderType = DataProviderType.MSSQL;
     Server server = new Server();
     Client c = new Client();
     string sd = c.StartDelimiter;
     string ed = c.EndingDelimiter;
     c.StartDelimiter = String.Empty;
     c.EndingDelimiter = String.Empty;
     Console.WriteLine(c.Parse(server.Databases[0].Tables[0],"DATABASE.NAME_TABLE.NAMEForm.aspx"));
 }
        public void Generate(Table table,string inputDir, string outputDir)
        {
            DirectoryInfo directoryInfo = new DirectoryInfo(inputDir);
            Client client = new Client();
            //string originalSD = client.StartDelimiter;
            //string originalED = client.EndingDelimiter;
            if(_CustomValue != null)
            {
                client.CustomValues = _CustomValue;
            }
            foreach(FileInfo fileInfo in directoryInfo.GetFiles())
            {
                //client.StartDelimiter = originalSD;
                //client.EndingDelimiter = originalED;
                StreamReader sr = File.OpenText(fileInfo.FullName);
                string fileContent = sr.ReadToEnd();
                sr.Close();
                string codeGenerated = client.Parse(table,fileContent);

                //client.StartDelimiter = String.Empty;
                //client.EndingDelimiter = String.Empty;
                string dirname = client.Parse(table, directoryInfo.Name);
                string filename = client.Parse(table,fileInfo.Name);
                //change back Delimiters immediately (subsequent calls to Generate() fail if you don't do so)
                //client.StartDelimiter = originalSD;
                //client.EndingDelimiter = originalED;

                String fullDir = outputDir + Path.DirectorySeparatorChar + dirname;

                try
                {
                    //StreamWriter sw = new StreamWriter(outputDir + Path.DirectorySeparatorChar + filename);

                    if (Directory.Exists(fullDir) == false)
                    {
                        Directory.CreateDirectory(fullDir);
                    }

                    StreamWriter sw = new StreamWriter(fullDir + Path.DirectorySeparatorChar + filename);
                    sw.Write(codeGenerated);
                    sw.Flush();
                    sw.Close();
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e);
                }
            }
            //CompleteNotifier(new EventArgs());
        }
Beispiel #4
0
        private void GenerateCode()
		{
			try
			{
				if (_selectedTable == null) return;
				var cgenerator = new Client {CustomValues = _cvf.CustomValues};
			    _rf.ContentText = cgenerator.Parse(_selectedTable, _df.ContentText);
			}
			catch (DataTypeManagerException ex)
			{
				MessageBox.Show(this, ex.Message, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
			}
		}
		public void TestCustomValues()
		{
			Hashtable hs = new Hashtable();
			hs.Add("NAMESPACE","CodeGenerator.Bla");
			Client client = new Client();
			client.CustomValues = hs;
			Server.ConnectionString = ConnectionStringManager.Instance.GetConnectionStrings()[0];
			Server.ProviderType = DataProviderType.SqlClient;
			client.Parse(new Server().Databases[0].Tables[0],"{NAMESPACE}");
		}
		public void TestColumnsIfTypeClient()
		{
			Client client = new Client();
			string outputText = client.Parse(new Server().Databases[0].Tables[0],@"
{TABLE.COLUMNS}
{IF COLUMN.TYPE EQ 'int'}int _{COLUMN.NAME}{/IF}
{IF COLUMN.TYPE NE 'int'}string _{COLUMN.NAME}{/IF}
{/TABLE.COLUMNS}");
			System.Console.WriteLine(outputText);
		}
		public void TestColumnsPrimary()
		{
			Client client = new Client();
			string outputText = client.Parse(new Server().Databases[0].Tables[0],@"{TABLE.COLUMNS PRIMARY}{COLUMN.NAME}
{/TABLE.COLUMNS}");
			System.Console.WriteLine(outputText);
		}
 private void GenerateCode()
 {
     try
     {
         if (selectedTable == null) return;
         Client cgenerator = new Client();
         cgenerator.CustomValues = GetCustomValues();
         uiGeneratedCodeTextBox.Text = cgenerator.Parse(selectedTable, uiTemplateTextBox.Text);
     }
     catch (DataTypeManagerException ex)
     {
         MessageBox.Show(this, ex.Message, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }