public override void Process() { Commands.GetView cmd; try { cmd = new Commands.GetView(_uri); } catch (Exception e) { Logger.Storage.Error("An exception occurred while creating the GetView command.", e); throw; } cmd.OnComplete += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection, Commands.ReplyBase reply) { View = ((Commands.GetViewReply)reply).View; TriggerOnComplete(reply); }; cmd.OnError += delegate(Commands.Base sender, Http.Client client, string message, Exception exception) { TriggerOnError(message, exception); }; cmd.OnProgress += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection, Tcp.DirectionType direction, int packetSize, decimal sendPercentComplete, decimal receivePercentComplete) { TriggerOnProgress(direction, packetSize, sendPercentComplete, receivePercentComplete); }; cmd.OnTimeout += delegate(Commands.Base sender, Http.Client client, Http.HttpConnection connection) { TriggerOnTimeout(); }; cmd.Execute(_sendTimeout, _receiveTimeout, _sendBufferSize, _receiveBufferSize); }
protected override void ParseResponse() { switch (_response.StatusLine.StatusCode) { case 200: Logger.Storage.Debug("Received a successful response from CouchDB."); ResponseMessage = _200; string s = StringifyResponseStream(); try { View = new Model.View(s); } catch (System.Exception e) { Logger.Storage.Error(s, e); throw; } Ok = true; Logger.Storage.Debug("GetViewReply loaded."); break; case 400: Logger.Storage.Debug("Received a failure response from CouchDB: " + _404); ResponseMessage = _404; Ok = false; Logger.Storage.Debug("GetViewReply loaded."); break; default: Logger.Storage.Error("GetViewReply received an unknown response code: " + _response.StatusLine.StatusCode.ToString()); Ok = false; throw new UnsupportedException("The response code " + _response.StatusLine.StatusCode.ToString() + " is not supported."); } }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.ProjectHelper.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : (int)columnRow["CHARACTER_MAXIMUM_LENGTH"], false, columnRow.IsNull("IsIdentity") ? false : (int)columnRow["IsIdentity"] == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], columnRow.IsNull("IsComputed") ? false : (int)columnRow["IsComputed"] == 1); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return(view); }
private Model.View GetNewView(Microsoft.SqlServer.Management.Smo.View smoView) { Model.View view = new Model.View(smoView.Name, Script.GetSingluar(smoView.Name), false); // Columns int ordinalPosition = 0; List<Microsoft.SqlServer.Management.Smo.Column> smoColumns = new List<Microsoft.SqlServer.Management.Smo.Column>(); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoView.Columns) { smoColumns.Add(smoColumn); } smoColumns.Sort(new SortComparer<Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) { continue; } Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingluar(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, false, smoColumn.Identity, smoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return view; }
private Model.View GetNewView(SQLDMO.View dmoView) { Model.View view = new Model.View(dmoView.Name, Script.GetSingluar(dmoView.Name), false); // Columns int ordinalPosition = 0; List<SQLDMO.Column> dmoColumns = new List<SQLDMO.Column>(); SQLDMO.SQLObjectList sqlObjectList = dmoView.ListColumns(); foreach (SQLDMO.Column dmoColumn in sqlObjectList) { dmoColumns.Add(dmoColumn); } dmoColumns.Sort(new SortComparer<SQLDMO.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (SQLDMO.Column dmoColumn in dmoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + dmoColumn.PhysicalDatatype.ToLower() + "'") >= 0) { continue; } Column column = new Column(dmoColumn.Name, Script.GetSingluar(dmoColumn.Name), false, dmoColumn.Name, view, ordinalPosition, dmoColumn.AllowNulls, dmoColumn.PhysicalDatatype, dmoColumn.Length, false, dmoColumn.Identity, dmoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return view; }
private Model.View GetNewView(SQLDMO.View dmoView) { Model.View view = new Model.View(dmoView.Name, Script.GetSingluar(dmoView.Name), false); // Columns int ordinalPosition = 0; List <SQLDMO.Column> dmoColumns = new List <SQLDMO.Column>(); SQLDMO.SQLObjectList sqlObjectList = dmoView.ListColumns(); foreach (SQLDMO.Column dmoColumn in sqlObjectList) { dmoColumns.Add(dmoColumn); } dmoColumns.Sort(new SortComparer <SQLDMO.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (SQLDMO.Column dmoColumn in dmoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + dmoColumn.PhysicalDatatype.ToLower() + "'") >= 0) { continue; } Column column = new Column(dmoColumn.Name, Script.GetSingluar(dmoColumn.Name), false, dmoColumn.Name, view, ordinalPosition, dmoColumn.AllowNulls, dmoColumn.PhysicalDatatype, dmoColumn.Length, false, dmoColumn.Identity, dmoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return(view); }
public List <Security.User> Transition(Model.View view) { List <Security.User> users = new List <Security.User>(); User transitionUser; Model.Document doc; JArray rows; int totalRows; try { totalRows = view["total_rows"].Value <int>(); if (totalRows <= 0) { return(users); } rows = (JArray)view["rows"]; for (int i = 0; i < rows.Count; i++) { transitionUser = new User(); doc = new Model.Document(rows[i]["key"]); users.Add(transitionUser.Transition(doc)); } } catch (Exception e) { Logger.Storage.Error("An exception occurred while attempting to parse users.", e); throw; } return(users); }
private Model.View GetNewView(Microsoft.SqlServer.Management.Smo.View smoView) { Model.View view = new Model.View(smoView.Name, Script.GetSingluar(smoView.Name), false); // Columns int ordinalPosition = 0; List <Microsoft.SqlServer.Management.Smo.Column> smoColumns = new List <Microsoft.SqlServer.Management.Smo.Column>(); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoView.Columns) { smoColumns.Add(smoColumn); } smoColumns.Sort(new SortComparer <Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) { if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) { continue; } Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingluar(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, false, smoColumn.Identity, smoColumn.Default, true); view.AddColumn(column); ordinalPosition++; } return(view); }
public Model.View[] GetViews() { List <Model.View> views = new List <Model.View>(); foreach (SQLDMO.View dmoView in Database.Views) { Model.View view = GetNewView(dmoView); views.Add(view); } return((Model.View[])views.ToArray()); }
private Model.View GetNewView(string viewName) { Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { bool isReadOnly = false; if (!columnRow.IsNull("IsIdentity") && (int)columnRow["IsIdentity"] == 1) { isReadOnly = true; } else if (!columnRow.IsNull("IsComputed") && (int)columnRow["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)columnRow["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(columnRow["CHARACTER_MAXIMUM_LENGTH"]), false, columnRow.IsNull("IsIdentity") ? false : Convert.ToInt32(columnRow["IsIdentity"]) == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], isReadOnly, columnRow.IsNull("IsComputed") ? false : Convert.ToInt32(columnRow["IsComputed"]) == 1, columnRow.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(columnRow["NUMERIC_PRECISION"]), columnRow.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(columnRow["NUMERIC_SCALE"])); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return(view); }
public Model.View[] GetViews() { List <Model.View> views = new List <Model.View>(); foreach (Microsoft.SqlServer.Management.Smo.View smoView in Database.Views) { if (!smoView.IsSystemObject) { Model.View view = GetNewView(smoView); views.Add(view); } } return((Model.View[])views.ToArray()); }
public static Model.View GetView(IList <Model.View> views, Model.View viewToFind, bool throwException) { foreach (Model.View view in views) { if (view.Name == viewToFind.Name && view.Schema == viewToFind.Schema) { return(view); } } if (throwException) { throw new Exception(string.Format("Cannot find view {0}.{1}", viewToFind.Schema, viewToFind.Name)); } return(null); }
public Model.View[] GetViews() { const string sql = @" SELECT TABLE_NAME, TABLE_SCHEMA FROM INFORMATION_SCHEMA.VIEWS ORDER BY TABLE_NAME"; List <string> viewNames = new List <string>(); //OleDbDataReader oleDbDataReader = null; System.Data.SqlClient.SqlDataReader sqlDataReader = null; try { sqlDataReader = RunQuerySQL(sql); while (sqlDataReader.Read()) { viewNames.Add(sqlDataReader["TABLE_NAME"].ToString() + "|" + sqlDataReader["TABLE_SCHEMA"].ToString()); } } finally { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } } List <Model.View> views = new List <Model.View>(); foreach (string viewNameEx in viewNames) { string viewName = viewNameEx.Split('|')[0]; string schema = viewNameEx.Split('|')[1]; Model.View view = GetNewView(viewName); view.Schema = schema; views.Add(view); } return(views.ToArray()); }
public List <Security.Group> Transition(Model.View view) { List <Security.Group> groups = new List <Security.Group>(); Group transitionGroup; Model.Document doc; JArray rows; int totalRows; try { totalRows = view["total_rows"].Value <int>(); if (totalRows <= 0) { return(groups); } rows = (JArray)view["rows"]; for (int i = 0; i < rows.Count; i++) { transitionGroup = new Group(); JObject obj = (JObject)rows[i]; JObject a = (JObject)obj["key"]; doc = new Model.Document(rows[i]["key"]); groups.Add(transitionGroup.Transition(doc)); } } catch (Exception e) { Logger.Storage.Error("An exception occurred while attempting to parse the view.", e); throw; } return(groups); }
public Model.View[] GetViews() { List <Model.View> views = new List <Model.View>(); string sql = string.Format(@"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS V ORDER BY V.TABLE_NAME", DatabaseName); System.Data.SqlClient.SqlDataReader dr = null; try { dr = RunQuerySqlClient(sql); System.Collections.ArrayList arrTableNames = new System.Collections.ArrayList(); while (dr.Read()) { arrTableNames.Add((string)dr["TABLE_NAME"]); } dr.Close(); for (int i = 0; i < arrTableNames.Count; i++) { Model.View view = GetNewView((string)arrTableNames[i]); views.Add(view); } } finally { if (dr != null) { dr.Close(); } } return((Model.View[])views.ToArray()); }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.ProjectHelper.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : (int)columnRow["CHARACTER_MAXIMUM_LENGTH"], false, columnRow.IsNull("IsIdentity") ? false : (int)columnRow["IsIdentity"] == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], columnRow.IsNull("IsComputed") ? false : (int)columnRow["IsComputed"] == 1); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return view; }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_dtColumns = null; Model.View view = new Model.View(viewName, false); // Columns DataRow[] columnRows = DtColumns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow row in columnRows) { bool isReadOnly = false; if (!row.IsNull("IsIdentity") && (int)row["IsIdentity"] == 1) { isReadOnly = true; } else if (!row.IsNull("IsComputed") && (int)row["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)row["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } // Check whether we have added this column before. Columns are repeated if they are both a PRIMARY_KEY and a FOREIGN_KEY ArchAngel.Providers.Database.Model.Column column = new ArchAngel.Providers.Database.Model.Column( (string)row["COLUMN_NAME"], false, view, (int)row["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)row["IS_NULLABLE"], "YES", false), (string)row["DATA_TYPE"], row.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]), (int)row["InPrimaryKey"] == 1, row.IsNull("IsIdentity") ? false : Convert.ToInt32(row["IsIdentity"]) == 1, row.IsNull("COLUMN_DEFAULT") ? "" : (string)row["COLUMN_DEFAULT"], isReadOnly, row.IsNull("IsComputed") ? false : Convert.ToInt32(row["IsComputed"]) == 1, row.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(row["NUMERIC_PRECISION"]), row.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(row["NUMERIC_SCALE"])); view.AddColumn(column); } //smoColumns.Sort(new SortComparer<Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); //foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) //{ // if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) // { // continue; // } // Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingular(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, // false, smoColumn.Identity, smoColumn.Default, true); // view.AddColumn(column); // ordinalPosition++; //} return view; }
private Model.View GetNewView(string viewName) { Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_columns = null; Model.View view = new Model.View(viewName, false); #region Columns DataRow[] columnRows = Columns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow columnRow in columnRows) { bool isReadOnly = false; if (!columnRow.IsNull("IsIdentity") && (int)columnRow["IsIdentity"] == 1) { isReadOnly = true; } else if (!columnRow.IsNull("IsComputed") && (int)columnRow["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)columnRow["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } Column column = new Column( (string)columnRow["COLUMN_NAME"], false, view, (int)columnRow["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)columnRow["IS_NULLABLE"], "YES", false), (string)columnRow["DATA_TYPE"], columnRow.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(columnRow["CHARACTER_MAXIMUM_LENGTH"]), false, columnRow.IsNull("IsIdentity") ? false : Convert.ToInt32(columnRow["IsIdentity"]) == 1, columnRow.IsNull("COLUMN_DEFAULT") ? "" : (string)columnRow["COLUMN_DEFAULT"], isReadOnly, columnRow.IsNull("IsComputed") ? false : Convert.ToInt32(columnRow["IsComputed"]) == 1, columnRow.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(columnRow["NUMERIC_PRECISION"]), columnRow.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(columnRow["NUMERIC_SCALE"])); if (IsSupported(column)) { view.AddColumn(column); } } #endregion return view; }
public static Model.View GetView(IList <Model.View> views, Model.View viewToFind) { return(GetView(views, viewToFind, true)); }
private Model.View GetNewView(string viewName) { ArchAngel.Interfaces.Events.RaiseObjectBeingProcessedEvent(viewName, "View"); //_dtColumns = null; Model.View view = new Model.View(viewName, false); // Columns DataRow[] columnRows = DtColumns.Select(string.Format("TABLE_NAME = '{0}'", viewName)); foreach (DataRow row in columnRows) { bool isReadOnly = false; if (!row.IsNull("IsIdentity") && (int)row["IsIdentity"] == 1) { isReadOnly = true; } else if (!row.IsNull("IsComputed") && (int)row["IsComputed"] == 1) { isReadOnly = true; } else if (Slyce.Common.Utility.StringsAreEqual((string)row["DATA_TYPE"], "timestamp", false)) { isReadOnly = true; } // Check whether we have added this column before. Columns are repeated if they are both a PRIMARY_KEY and a FOREIGN_KEY ArchAngel.Providers.Database.Model.Column column = new ArchAngel.Providers.Database.Model.Column( (string)row["COLUMN_NAME"], false, view, (int)row["ORDINAL_POSITION"], Slyce.Common.Utility.StringsAreEqual((string)row["IS_NULLABLE"], "YES", false), (string)row["DATA_TYPE"], row.IsNull("CHARACTER_MAXIMUM_LENGTH") ? 0 : Convert.ToInt32(row["CHARACTER_MAXIMUM_LENGTH"]), (int)row["InPrimaryKey"] == 1, row.IsNull("IsIdentity") ? false : Convert.ToInt32(row["IsIdentity"]) == 1, row.IsNull("COLUMN_DEFAULT") ? "" : (string)row["COLUMN_DEFAULT"], isReadOnly, row.IsNull("IsComputed") ? false : Convert.ToInt32(row["IsComputed"]) == 1, row.IsNull("NUMERIC_PRECISION") ? 0 : Convert.ToInt32(row["NUMERIC_PRECISION"]), row.IsNull("NUMERIC_SCALE") ? 0 : Convert.ToInt32(row["NUMERIC_SCALE"])); view.AddColumn(column); } //smoColumns.Sort(new SortComparer<Microsoft.SqlServer.Management.Smo.Column>("ID", System.ComponentModel.ListSortDirection.Ascending)); //foreach (Microsoft.SqlServer.Management.Smo.Column smoColumn in smoColumns) //{ // if (UnsupportedDataTypes.ToLower().IndexOf("'" + smoColumn.DataType.Name.ToLower() + "'") >= 0) // { // continue; // } // Model.Column column = new Model.Column(smoColumn.Name, Script.GetSingular(smoColumn.Name), false, smoColumn.Name, view, ordinalPosition, smoColumn.Nullable, smoColumn.DataType.Name, smoColumn.DataType.MaximumLength, // false, smoColumn.Identity, smoColumn.Default, true); // view.AddColumn(column); // ordinalPosition++; //} return(view); }