Пример #1
0
		private void notifyme(
			string message_in,
			XS_templateType template_in,
			DBConnectionstrings dbConnectionStrings_in,
			Statistics statistics_in
		) {
			// ToDos: here!
//			cDBConnection _con = null;

			#region int _verifiedConditions = ...;
			int _verifiedConditions = 0;
			for (int c = 0; c < template_in.Conditions.ConditionCollection.Count; c++) {
				if (
					this.translate(
						template_in.Conditions.ConditionCollection[c].Eval, 
						message_in
					)
					==
					template_in.Conditions.ConditionCollection[c].To
				) _verifiedConditions++;
			}
			#endregion
			if (_verifiedConditions == template_in.Conditions.ConditionCollection.Count) {
				#region Hashtable _args = ...;
				Hashtable _args = new Hashtable(template_in.Arguments.ArgumentCollection.Count);
				for (int a = 0; a < template_in.Arguments.ArgumentCollection.Count; a++) {
					_args.Add(
						template_in.Arguments.ArgumentCollection[a].Name, 
						//System.Web.HttpUtility.UrlEncode(
							this.translateFully(
								template_in.Arguments.ArgumentCollection[a].Value, 
								message_in
							)
						//)
					);
				}
				#endregion
				for (int o = 0; o < template_in.Outputs.OutputCollection.Count; o++) {
					#region if (!dbConnectionStrings_in.Contains(DBServerTypes. ...)) continue;
					switch (template_in.Outputs.OutputCollection[o].Type) {
						#region case XS_OutputEnumeration.someDBServer_whatever: ... break;
#if PostgreSQL
						case XS_OutputEnumeration.PostgreSQL_Function: 
						case XS_OutputEnumeration.PostgreSQL_StoredProcedure: 
						case XS_OutputEnumeration.PostgreSQL_View: {
							if (!dbConnectionStrings_in.Contains_disableIfNot(DBServerTypes.PostgreSQL)) continue;
//							_con = (cDBConnection)connection_[DBServerTypes.PostgreSQL];
							break;
						}
#else
						case XS_OutputEnumeration.PostgreSQL_Function: 
						case XS_OutputEnumeration.PostgreSQL_StoredProcedure: 
						case XS_OutputEnumeration.PostgreSQL_View: {
							continue;
						}
#endif
#if MySQL
						case XS_OutputEnumeration.MySQL_Function: 
						case XS_OutputEnumeration.MySQL_StoredProcedure: 
						case XS_OutputEnumeration.MySQL_View: {
							if (!dbConnectionStrings_in.Contains_disableIfNot(DBServerTypes.MySQL)) continue;
//							_con = (cDBConnection)connection_[DBServerTypes.MySQL];
							break;
						}
#else
						case XS_OutputEnumeration.MySQL_Function: 
						case XS_OutputEnumeration.MySQL_StoredProcedure: 
						case XS_OutputEnumeration.MySQL_View: {
							continue;
						}
#endif
						case XS_OutputEnumeration.SQLServer_Function: 
						case XS_OutputEnumeration.SQLServer_StoredProcedure: 
						case XS_OutputEnumeration.SQLServer_View: {
							if (!dbConnectionStrings_in.Contains_disableIfNot(DBServerTypes.SQLServer)) continue;
//							_con = (cDBConnection)connection_[DBServerTypes.SQLServer];
							break;
						}
						#endregion
					}
					#endregion
					string _ouputTo = this.translateFully(
						template_in.Outputs.OutputCollection[o].To, 
						message_in
					);
//					#region bool _exists = ...;
bool _exists_aux = false;
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	dbConnectionStrings_in[d].exists_aux__ = false;
}
					switch (template_in.Outputs.OutputCollection[o].Type) {
						case XS_OutputEnumeration.File: {
							_exists_aux = (_ouputTo == DEVNULL) ? true : File.Exists(_ouputTo);
							break;
						}

						#region case XS_OutputEnumeration.someDBServer_whatever: ... break;
						case XS_OutputEnumeration.MySQL_Function: 
						case XS_OutputEnumeration.PostgreSQL_Function:
						case XS_OutputEnumeration.SQLServer_Function: {
//_exists = _con.SQLFunction_exists(_ouputTo);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;

	dbConnectionStrings_in[d].exists_aux__ 
		= dbConnectionStrings_in[d].Connection.SQLFunction_exists(_ouputTo);

	if (!_exists_aux && dbConnectionStrings_in[d].exists_aux__) _exists_aux = true;
}
							break;
						}

						case XS_OutputEnumeration.MySQL_StoredProcedure: 
						case XS_OutputEnumeration.PostgreSQL_StoredProcedure: 
						case XS_OutputEnumeration.SQLServer_StoredProcedure: {
//_exists = _con.SQLStoredProcedure_exists(_ouputTo);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;

	dbConnectionStrings_in[d].exists_aux__ 
		= dbConnectionStrings_in[d].Connection.SQLStoredProcedure_exists(_ouputTo);

	if (!_exists_aux && dbConnectionStrings_in[d].exists_aux__) _exists_aux = true;
}
							break;
						}
						case XS_OutputEnumeration.MySQL_View: 
						case XS_OutputEnumeration.PostgreSQL_View: 
						case XS_OutputEnumeration.SQLServer_View: {
//_exists = _con.SQLView_exists(_ouputTo);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;

	dbConnectionStrings_in[d].exists_aux__ 
		= dbConnectionStrings_in[d].Connection.SQLView_exists(_ouputTo);

	if (!_exists_aux && dbConnectionStrings_in[d].exists_aux__) _exists_aux = true;
}
							break;
						}
						#endregion

						default: {
							throw notifyme_Exception;
						}
					}
//					#endregion

					if (
						!_exists_aux 
						|| 
						(template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Replace)
						||
						(template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
					) {
						#region string _parsedOutput = ...;
						string _parsedOutput;
						if (template_in.ParserType == XS_ParserEnumeration.xslt) {
							System.Text.StringBuilder _stringbuilder = new System.Text.StringBuilder();
							StringWriter _stringwriter = new StringWriter(_stringbuilder, System.Globalization.CultureInfo.CurrentCulture);

							string _xmltemplatesfile
								= this.xmltemplatesdir_
								+ (this.xmltemplatesfileuri_.IsFile
									? Path.DirectorySeparatorChar.ToString() 
									: "/")
								+ template_in.Name;
							ParserXSLT.Parse(
//xmlmetadatafile_, 
this.metafiles_[
	Utilities.MetaFile_find(
		this.metafiles_, 
		message_in.Split('.')[1]
	)
].Path, 
								_xmltemplatesfile, 
								_args, 
								_stringwriter
							);

							_parsedOutput = _stringbuilder.ToString();
						} else {
							if (this.xmltemplatesfileuri_.IsFile) {
								switch (template_in.ParserType) {
									case XS_ParserEnumeration.aspx: {
										ParserASPX.Parse(
											this.xmltemplatesdir_, 
											template_in.Name, 
											_args, 
											out _parsedOutput
										);

										if (statistics_in != null) {
											statistics_in.Lines_Add(_parsedOutput);
											statistics_in.Bytes_Add(_parsedOutput);
										}

										break;
									}
									case XS_ParserEnumeration.none: {

if (template_in.Outputs.OutputCollection[o].Type == XS_OutputEnumeration.File) {
	_parsedOutput = null; // will be copied
} else {
	// needs to be read
	_parsedOutput = new StreamReader(
		Path.Combine(
			this.xmltemplatesdir_,
			template_in.Name
		)
	).ReadToEnd();
}

										break;
									}
									default: {
										// ToDos: here!
										throw new Exception("ToDos: here!");
									}
								}
							} else {
								switch (template_in.ParserType) {
									case XS_ParserEnumeration.aspx:
									case XS_ParserEnumeration.none: {
										_parsedOutput = OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL_ToString(
											this.xmltemplatesdir_ + "/" + template_in.Name, 
											_args
										);

										if (statistics_in != null) {
											statistics_in.Lines_Add(_parsedOutput);
											statistics_in.Bytes_Add(_parsedOutput);
										}

										break;
									}
									default: {
										// ToDos: here!
										throw new Exception("ToDos: here!");
									}
								}
							}
						}
						#endregion

						switch (template_in.Outputs.OutputCollection[o].Type) {
							case XS_OutputEnumeration.File: {
if (
	string.IsNullOrEmpty(_ouputTo)
	||
	(_ouputTo == DEVNULL)
	||
	(Directory.Exists(_ouputTo))
)
	break;

								#region Directory.CreateDirectory(_ouputTo);
								string _directory = System.IO.Path.GetDirectoryName(_ouputTo);
								if (!System.IO.Directory.Exists(_directory)) {
									System.IO.Directory.CreateDirectory(
										_directory
									);
								}
								#endregion
								if (
									(template_in.ParserType == XS_ParserEnumeration.none)
									&&
									(this.xmltemplatesfileuri_.IsFile)
								) {
//									#region File.Copy(...);
// ToDos: here!
if (
	(template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
)
	throw new Exception(string.Format(
		System.Globalization.CultureInfo.CurrentCulture, 
		"not implemented (at template: {0})", 
		template_in.Name
	));
									File.Copy(
										Path.Combine(
											this.xmltemplatesdir_, 
											template_in.Name
										), 
										_ouputTo, 
										true // (!_exists || template_in.Outputs.OutputCollection[o].Replace)
									);
//									#endregion
								} else {
									#region new StreamWriter(_ouputTo).Write(_parsedOutput);
									StreamWriter _writer = new StreamWriter(
										_ouputTo,
										(template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
									);
									_writer.Write(_parsedOutput);
									_writer.Close();
									#endregion
								}
								break;
							}
							#region case XS_OutputEnumeration.someDBServer_whatever: ... break;
							case XS_OutputEnumeration.MySQL_Function: 
							case XS_OutputEnumeration.MySQL_StoredProcedure: 
							case XS_OutputEnumeration.MySQL_View: 
							case XS_OutputEnumeration.PostgreSQL_Function: 
							case XS_OutputEnumeration.PostgreSQL_StoredProcedure: 
							case XS_OutputEnumeration.PostgreSQL_View: 
							case XS_OutputEnumeration.SQLServer_Function: 
							case XS_OutputEnumeration.SQLServer_StoredProcedure: 
							case XS_OutputEnumeration.SQLServer_View: {
								if (template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
									throw new Exception("can't handle append over a db function");

//								#region if (_exists_aux) connection_.Function_delete(_ouputTo);
								if (_exists_aux) {
									switch (template_in.Outputs.OutputCollection[o].Type) {
										case XS_OutputEnumeration.MySQL_Function:
										case XS_OutputEnumeration.SQLServer_Function: {
//_con.SQLFunction_delete(_ouputTo);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;

	switch (dbConnectionStrings_in[d].DBServerType) {
#if MySQL
		case DBServerTypes.MySQL:
#endif
		case DBServerTypes.SQLServer: {
			if (dbConnectionStrings_in[d].exists_aux__) 
				dbConnectionStrings_in[d].Connection.SQLFunction_delete(_ouputTo);
			break;
		}
	}
}
											break;
										}
										case XS_OutputEnumeration.MySQL_StoredProcedure: 
										case XS_OutputEnumeration.SQLServer_StoredProcedure: {
//_con.SQLStoredProcedure_delete(_ouputTo);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;

	switch (dbConnectionStrings_in[d].DBServerType) {
#if MySQL
		case DBServerTypes.MySQL:
#endif
		case DBServerTypes.SQLServer: {
			if (dbConnectionStrings_in[d].exists_aux__) 
				dbConnectionStrings_in[d].Connection.SQLStoredProcedure_delete(_ouputTo);
			break;
		}
	}
}
											break;
										}
										case XS_OutputEnumeration.MySQL_View: 
										case XS_OutputEnumeration.SQLServer_View: {
//_con.SQLView_delete(_ouputTo);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;

	switch (dbConnectionStrings_in[d].DBServerType) {
#if MySQL
		case DBServerTypes.MySQL:
#endif
		case DBServerTypes.SQLServer: {
			if (dbConnectionStrings_in[d].exists_aux__) 
				dbConnectionStrings_in[d].Connection.SQLView_delete(_ouputTo);
			break;
		}
	}
}
											break;
										}
										case XS_OutputEnumeration.PostgreSQL_Function: 
										case XS_OutputEnumeration.PostgreSQL_StoredProcedure: 
										case XS_OutputEnumeration.PostgreSQL_View: 
											// No Need! unlike SQL Server and MySQL,
											// PostgreSQL allows:
											// "CREATE OR REPLACE FUNCTION/VIEW" :)
											break;
										default: {
											break;
										}
									}
								}
//								#endregion
//_con.Execute_SQLQuery(_parsedOutput);
for (int d = 0; d < dbConnectionStrings_in.Count; d++) {
	if (!dbConnectionStrings_in[d].enabled_aux__) continue;
	try {
		dbConnectionStrings_in[d].Connection.Execute_SQLQuery(_parsedOutput);
	} catch (Exception _ex) {
		System.Text.StringBuilder _sb = new System.Text.StringBuilder();
		for (int a = 0; a < template_in.Arguments.ArgumentCollection.Count; a++) {
			_sb.Append(string.Format(
				System.Globalization.CultureInfo.CurrentCulture,
				"{0}:\n\t{1}\n\t{2}\n",
				template_in.Arguments.ArgumentCollection[a].Name,
				template_in.Arguments.ArgumentCollection[a].Value,
				_args[template_in.Arguments.ArgumentCollection[a].Name]
			));
		}

		throw new Exception(string.Format(
			System.Globalization.CultureInfo.CurrentCulture,
			"---\nTEMPLATE: {0}\n---\nARGUMENTS:\n\n{5}\n---\nDBServerType:\n\n{2}\n---\nQUERY:\n\n{1}\n---\nEXCEPTION:\n\n{3}\n---\nINNER-EXCEPTION:\n\n{4}\n---\n",
			template_in.Name,
			_parsedOutput, 
			dbConnectionStrings_in[d].DBServerType.ToString(), 
			_ex.Message,
			_ex.InnerException,
			_sb.ToString()
		));
	}
}
								break;
							}
							#endregion
							default: {
								throw notifyme_Exception;
							}
						}
					}
				}
			}
		}
Пример #2
0
        private void notifyme(
            string message_in,
            XS_templateType template_in,
            DBConnectionstrings dbConnectionStrings_in,
            Statistics statistics_in
            )
        {
            // ToDos: here!
//			cDBConnection _con = null;

            #region int _verifiedConditions = ...;
            int _verifiedConditions = 0;
            for (int c = 0; c < template_in.Conditions.ConditionCollection.Count; c++)
            {
                if (
                    this.translate(
                        template_in.Conditions.ConditionCollection[c].Eval,
                        message_in
                        )
                    ==
                    template_in.Conditions.ConditionCollection[c].To
                    )
                {
                    _verifiedConditions++;
                }
            }
            #endregion
            if (_verifiedConditions == template_in.Conditions.ConditionCollection.Count)
            {
                #region Hashtable _args = ...;
                Hashtable _args = new Hashtable(template_in.Arguments.ArgumentCollection.Count);
                for (int a = 0; a < template_in.Arguments.ArgumentCollection.Count; a++)
                {
                    _args.Add(
                        template_in.Arguments.ArgumentCollection[a].Name,
                        //System.Web.HttpUtility.UrlEncode(
                        this.translateFully(
                            template_in.Arguments.ArgumentCollection[a].Value,
                            message_in
                            )
                        //)
                        );
                }
                #endregion
                for (int o = 0; o < template_in.Outputs.OutputCollection.Count; o++)
                {
                    #region if (!dbConnectionStrings_in.Contains(DBServerTypes. ...)) continue;
                    switch (template_in.Outputs.OutputCollection[o].Type)
                    {
                        #region case XS_OutputEnumeration.someDBServer_whatever: ... break;
#if PostgreSQL
                    case XS_OutputEnumeration.PostgreSQL_Function:
                    case XS_OutputEnumeration.PostgreSQL_StoredProcedure:
                    case XS_OutputEnumeration.PostgreSQL_View: {
                        if (!dbConnectionStrings_in.Contains_disableIfNot(DBServerTypes.PostgreSQL))
                        {
                            continue;
                        }
//							_con = (cDBConnection)connection_[DBServerTypes.PostgreSQL];
                        break;
                    }
#else
                    case XS_OutputEnumeration.PostgreSQL_Function:
                    case XS_OutputEnumeration.PostgreSQL_StoredProcedure:
                    case XS_OutputEnumeration.PostgreSQL_View: {
                        continue;
                    }
#endif
#if MySQL
                    case XS_OutputEnumeration.MySQL_Function:
                    case XS_OutputEnumeration.MySQL_StoredProcedure:
                    case XS_OutputEnumeration.MySQL_View: {
                        if (!dbConnectionStrings_in.Contains_disableIfNot(DBServerTypes.MySQL))
                        {
                            continue;
                        }
//							_con = (cDBConnection)connection_[DBServerTypes.MySQL];
                        break;
                    }
#else
                    case XS_OutputEnumeration.MySQL_Function:
                    case XS_OutputEnumeration.MySQL_StoredProcedure:
                    case XS_OutputEnumeration.MySQL_View: {
                        continue;
                    }
#endif
                    case XS_OutputEnumeration.SQLServer_Function:
                    case XS_OutputEnumeration.SQLServer_StoredProcedure:
                    case XS_OutputEnumeration.SQLServer_View: {
                        if (!dbConnectionStrings_in.Contains_disableIfNot(DBServerTypes.SQLServer))
                        {
                            continue;
                        }
//							_con = (cDBConnection)connection_[DBServerTypes.SQLServer];
                        break;
                    }
                        #endregion
                    }
                    #endregion
                    string _ouputTo = this.translateFully(
                        template_in.Outputs.OutputCollection[o].To,
                        message_in
                        );
//					#region bool _exists = ...;
                    bool _exists_aux = false;
                    for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                    {
                        dbConnectionStrings_in[d].exists_aux__ = false;
                    }
                    switch (template_in.Outputs.OutputCollection[o].Type)
                    {
                    case XS_OutputEnumeration.File: {
                        _exists_aux = (_ouputTo == DEVNULL) ? true : File.Exists(_ouputTo);
                        break;
                    }

                        #region case XS_OutputEnumeration.someDBServer_whatever: ... break;
                    case XS_OutputEnumeration.MySQL_Function:
                    case XS_OutputEnumeration.PostgreSQL_Function:
                    case XS_OutputEnumeration.SQLServer_Function: {
//_exists = _con.SQLFunction_exists(_ouputTo);
                        for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                        {
                            if (!dbConnectionStrings_in[d].enabled_aux__)
                            {
                                continue;
                            }

                            dbConnectionStrings_in[d].exists_aux__
                                = dbConnectionStrings_in[d].Connection.SQLFunction_exists(_ouputTo);

                            if (!_exists_aux && dbConnectionStrings_in[d].exists_aux__)
                            {
                                _exists_aux = true;
                            }
                        }
                        break;
                    }

                    case XS_OutputEnumeration.MySQL_StoredProcedure:
                    case XS_OutputEnumeration.PostgreSQL_StoredProcedure:
                    case XS_OutputEnumeration.SQLServer_StoredProcedure: {
//_exists = _con.SQLStoredProcedure_exists(_ouputTo);
                        for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                        {
                            if (!dbConnectionStrings_in[d].enabled_aux__)
                            {
                                continue;
                            }

                            dbConnectionStrings_in[d].exists_aux__
                                = dbConnectionStrings_in[d].Connection.SQLStoredProcedure_exists(_ouputTo);

                            if (!_exists_aux && dbConnectionStrings_in[d].exists_aux__)
                            {
                                _exists_aux = true;
                            }
                        }
                        break;
                    }

                    case XS_OutputEnumeration.MySQL_View:
                    case XS_OutputEnumeration.PostgreSQL_View:
                    case XS_OutputEnumeration.SQLServer_View: {
//_exists = _con.SQLView_exists(_ouputTo);
                        for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                        {
                            if (!dbConnectionStrings_in[d].enabled_aux__)
                            {
                                continue;
                            }

                            dbConnectionStrings_in[d].exists_aux__
                                = dbConnectionStrings_in[d].Connection.SQLView_exists(_ouputTo);

                            if (!_exists_aux && dbConnectionStrings_in[d].exists_aux__)
                            {
                                _exists_aux = true;
                            }
                        }
                        break;
                    }
                        #endregion

                    default: {
                        throw notifyme_Exception;
                    }
                    }
//					#endregion

                    if (
                        !_exists_aux
                        ||
                        (template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Replace)
                        ||
                        (template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
                        )
                    {
                        #region string _parsedOutput = ...;
                        string _parsedOutput;
                        if (template_in.ParserType == XS_ParserEnumeration.xslt)
                        {
                            System.Text.StringBuilder _stringbuilder = new System.Text.StringBuilder();
                            StringWriter _stringwriter = new StringWriter(_stringbuilder, System.Globalization.CultureInfo.CurrentCulture);

                            string _xmltemplatesfile
                                = this.xmltemplatesdir_
                                  + (this.xmltemplatesfileuri_.IsFile
                                                                        ? Path.DirectorySeparatorChar.ToString()
                                                                        : "/")
                                  + template_in.Name;
                            ParserXSLT.Parse(
//xmlmetadatafile_,
                                this.metafiles_[
                                    Utilities.MetaFile_find(
                                        this.metafiles_,
                                        message_in.Split('.')[1]
                                        )
                                ].Path,
                                _xmltemplatesfile,
                                _args,
                                _stringwriter
                                );

                            _parsedOutput = _stringbuilder.ToString();
                        }
                        else
                        {
                            if (this.xmltemplatesfileuri_.IsFile)
                            {
                                switch (template_in.ParserType)
                                {
                                case XS_ParserEnumeration.aspx: {
                                    ParserASPX.Parse(
                                        this.xmltemplatesdir_,
                                        template_in.Name,
                                        _args,
                                        out _parsedOutput
                                        );

                                    if (statistics_in != null)
                                    {
                                        statistics_in.Lines_Add(_parsedOutput);
                                        statistics_in.Bytes_Add(_parsedOutput);
                                    }

                                    break;
                                }

                                case XS_ParserEnumeration.none: {
                                    if (template_in.Outputs.OutputCollection[o].Type == XS_OutputEnumeration.File)
                                    {
                                        _parsedOutput = null; // will be copied
                                    }
                                    else
                                    {
                                        // needs to be read
                                        _parsedOutput = new StreamReader(
                                            Path.Combine(
                                                this.xmltemplatesdir_,
                                                template_in.Name
                                                )
                                            ).ReadToEnd();
                                    }

                                    break;
                                }

                                default: {
                                    // ToDos: here!
                                    throw new Exception("ToDos: here!");
                                }
                                }
                            }
                            else
                            {
                                switch (template_in.ParserType)
                                {
                                case XS_ParserEnumeration.aspx:
                                case XS_ParserEnumeration.none: {
                                    _parsedOutput = OGen.Libraries.PresentationLayer.WebForms.Utilities.ReadURL_ToString(
                                        this.xmltemplatesdir_ + "/" + template_in.Name,
                                        _args
                                        );

                                    if (statistics_in != null)
                                    {
                                        statistics_in.Lines_Add(_parsedOutput);
                                        statistics_in.Bytes_Add(_parsedOutput);
                                    }

                                    break;
                                }

                                default: {
                                    // ToDos: here!
                                    throw new Exception("ToDos: here!");
                                }
                                }
                            }
                        }
                        #endregion

                        switch (template_in.Outputs.OutputCollection[o].Type)
                        {
                        case XS_OutputEnumeration.File: {
                            if (
                                string.IsNullOrEmpty(_ouputTo)
                                ||
                                (_ouputTo == DEVNULL)
                                ||
                                (Directory.Exists(_ouputTo))
                                )
                            {
                                break;
                            }

                            #region Directory.CreateDirectory(_ouputTo);
                            string _directory = System.IO.Path.GetDirectoryName(_ouputTo);
                            if (!System.IO.Directory.Exists(_directory))
                            {
                                System.IO.Directory.CreateDirectory(
                                    _directory
                                    );
                            }
                            #endregion
                            if (
                                (template_in.ParserType == XS_ParserEnumeration.none)
                                &&
                                (this.xmltemplatesfileuri_.IsFile)
                                )
                            {
//									#region File.Copy(...);
// ToDos: here!
                                if (
                                    (template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
                                    )
                                {
                                    throw new Exception(string.Format(
                                                            System.Globalization.CultureInfo.CurrentCulture,
                                                            "not implemented (at template: {0})",
                                                            template_in.Name
                                                            ));
                                }
                                File.Copy(
                                    Path.Combine(
                                        this.xmltemplatesdir_,
                                        template_in.Name
                                        ),
                                    _ouputTo,
                                    true                                             // (!_exists || template_in.Outputs.OutputCollection[o].Replace)
                                    );
//									#endregion
                            }
                            else
                            {
                                #region new StreamWriter(_ouputTo).Write(_parsedOutput);
                                StreamWriter _writer = new StreamWriter(
                                    _ouputTo,
                                    (template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
                                    );
                                _writer.Write(_parsedOutput);
                                _writer.Close();
                                #endregion
                            }
                            break;
                        }

                            #region case XS_OutputEnumeration.someDBServer_whatever: ... break;
                        case XS_OutputEnumeration.MySQL_Function:
                        case XS_OutputEnumeration.MySQL_StoredProcedure:
                        case XS_OutputEnumeration.MySQL_View:
                        case XS_OutputEnumeration.PostgreSQL_Function:
                        case XS_OutputEnumeration.PostgreSQL_StoredProcedure:
                        case XS_OutputEnumeration.PostgreSQL_View:
                        case XS_OutputEnumeration.SQLServer_Function:
                        case XS_OutputEnumeration.SQLServer_StoredProcedure:
                        case XS_OutputEnumeration.SQLServer_View: {
                            if (template_in.Outputs.OutputCollection[o].Mode == XS_OutputModeEnumeration.Append)
                            {
                                throw new Exception("can't handle append over a db function");
                            }

//								#region if (_exists_aux) connection_.Function_delete(_ouputTo);
                            if (_exists_aux)
                            {
                                switch (template_in.Outputs.OutputCollection[o].Type)
                                {
                                case XS_OutputEnumeration.MySQL_Function:
                                case XS_OutputEnumeration.SQLServer_Function: {
//_con.SQLFunction_delete(_ouputTo);
                                    for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                                    {
                                        if (!dbConnectionStrings_in[d].enabled_aux__)
                                        {
                                            continue;
                                        }

                                        switch (dbConnectionStrings_in[d].DBServerType)
                                        {
#if MySQL
                                        case DBServerTypes.MySQL:
#endif
                                        case DBServerTypes.SQLServer: {
                                            if (dbConnectionStrings_in[d].exists_aux__)
                                            {
                                                dbConnectionStrings_in[d].Connection.SQLFunction_delete(_ouputTo);
                                            }
                                            break;
                                        }
                                        }
                                    }
                                    break;
                                }

                                case XS_OutputEnumeration.MySQL_StoredProcedure:
                                case XS_OutputEnumeration.SQLServer_StoredProcedure: {
//_con.SQLStoredProcedure_delete(_ouputTo);
                                    for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                                    {
                                        if (!dbConnectionStrings_in[d].enabled_aux__)
                                        {
                                            continue;
                                        }

                                        switch (dbConnectionStrings_in[d].DBServerType)
                                        {
#if MySQL
                                        case DBServerTypes.MySQL:
#endif
                                        case DBServerTypes.SQLServer: {
                                            if (dbConnectionStrings_in[d].exists_aux__)
                                            {
                                                dbConnectionStrings_in[d].Connection.SQLStoredProcedure_delete(_ouputTo);
                                            }
                                            break;
                                        }
                                        }
                                    }
                                    break;
                                }

                                case XS_OutputEnumeration.MySQL_View:
                                case XS_OutputEnumeration.SQLServer_View: {
//_con.SQLView_delete(_ouputTo);
                                    for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                                    {
                                        if (!dbConnectionStrings_in[d].enabled_aux__)
                                        {
                                            continue;
                                        }

                                        switch (dbConnectionStrings_in[d].DBServerType)
                                        {
#if MySQL
                                        case DBServerTypes.MySQL:
#endif
                                        case DBServerTypes.SQLServer: {
                                            if (dbConnectionStrings_in[d].exists_aux__)
                                            {
                                                dbConnectionStrings_in[d].Connection.SQLView_delete(_ouputTo);
                                            }
                                            break;
                                        }
                                        }
                                    }
                                    break;
                                }

                                case XS_OutputEnumeration.PostgreSQL_Function:
                                case XS_OutputEnumeration.PostgreSQL_StoredProcedure:
                                case XS_OutputEnumeration.PostgreSQL_View:
                                    // No Need! unlike SQL Server and MySQL,
                                    // PostgreSQL allows:
                                    // "CREATE OR REPLACE FUNCTION/VIEW" :)
                                    break;

                                default: {
                                    break;
                                }
                                }
                            }
//								#endregion
//_con.Execute_SQLQuery(_parsedOutput);
                            for (int d = 0; d < dbConnectionStrings_in.Count; d++)
                            {
                                if (!dbConnectionStrings_in[d].enabled_aux__)
                                {
                                    continue;
                                }
                                try {
                                    dbConnectionStrings_in[d].Connection.Execute_SQLQuery(_parsedOutput);
                                } catch (Exception _ex) {
                                    System.Text.StringBuilder _sb = new System.Text.StringBuilder();
                                    for (int a = 0; a < template_in.Arguments.ArgumentCollection.Count; a++)
                                    {
                                        _sb.Append(string.Format(
                                                       System.Globalization.CultureInfo.CurrentCulture,
                                                       "{0}:\n\t{1}\n\t{2}\n",
                                                       template_in.Arguments.ArgumentCollection[a].Name,
                                                       template_in.Arguments.ArgumentCollection[a].Value,
                                                       _args[template_in.Arguments.ArgumentCollection[a].Name]
                                                       ));
                                    }

                                    throw new Exception(string.Format(
                                                            System.Globalization.CultureInfo.CurrentCulture,
                                                            "---\nTEMPLATE: {0}\n---\nARGUMENTS:\n\n{5}\n---\nDBServerType:\n\n{2}\n---\nQUERY:\n\n{1}\n---\nEXCEPTION:\n\n{3}\n---\nINNER-EXCEPTION:\n\n{4}\n---\n",
                                                            template_in.Name,
                                                            _parsedOutput,
                                                            dbConnectionStrings_in[d].DBServerType.ToString(),
                                                            _ex.Message,
                                                            _ex.InnerException,
                                                            _sb.ToString()
                                                            ));
                                }
                            }
                            break;
                        }

                            #endregion
                        default: {
                            throw notifyme_Exception;
                        }
                        }
                    }
                }
            }
        }