public DataRelation (string relationName, DataColumn[] parentColumns, DataColumn[] childColumns, bool createConstraints) { this.extendedProperties = new PropertyCollection(); if (relationName == null) relationName = string.Empty; this.relationName = relationName; if (parentColumns == null) throw new ArgumentNullException (); this.parentColumns = parentColumns; if (childColumns == null) throw new ArgumentNullException (); this.childColumns = childColumns; this.createConstraints = createConstraints; if (parentColumns.Length != childColumns.Length) throw new ArgumentException ("ParentColumns and ChildColumns should be the same length"); DataTable parentTable = parentColumns[0].Table; DataTable childTable = childColumns[0].Table; if (parentTable.DataSet != childTable.DataSet) throw new InvalidConstraintException (); foreach (DataColumn column in parentColumns) if (column.Table != parentTable) throw new InvalidConstraintException (); foreach (DataColumn column in childColumns) if (column.Table != childTable) throw new InvalidConstraintException (); for (int i=0; i<ChildColumns.Length; i++) if (!( parentColumns[i].DataType.Equals( childColumns[i].DataType))) throw new InvalidConstraintException(); }
internal static void AddExtendedProperties(PropertyCollection props, XmlElement node, Type type) { if(props != null) { foreach(DictionaryEntry entry in props) { String s, v; if (entry.Key is INullable) { s = (String) SqlConvert.ChangeTypeForXML(entry.Key, typeof(string)); } else { s = (String) Convert.ToString(entry.Key, CultureInfo.InvariantCulture); } if (entry.Value is INullable) { v = (String) SqlConvert.ChangeTypeForXML(entry.Value, typeof(string)); } else if (entry.Value is System.Numerics.BigInteger) { v = (string)BigIntegerStorage.ConvertFromBigInteger((System.Numerics.BigInteger)entry.Value, typeof(string), CultureInfo.InvariantCulture); } else { v = (String) Convert.ToString(entry.Value, CultureInfo.InvariantCulture); } if (type == typeof(DataRelation)) { s = Keywords.MSD_REL_PREFIX + s; } else if (type == typeof(ForeignKeyConstraint)) { s = Keywords.MSD_FK_PREFIX + s; } node.SetAttribute(XmlConvert.EncodeLocalName(s), Keywords.MSPROPNS, v); } } }
/// <summary> /// Constructor /// </summary> /// <param name="dest">Destination of the message</param> /// <param name="src">Source of the message</param> /// <param name="buf">Byte buffer of payload associated with the message</param> public Message(Address dest, Address src, byte[] buf) { dest_addr = dest; src_addr = src; this.buf = buf; headers = new PropertyCollection(); }
public override object Clone() { // override Clone so that returned object is an // instance of PropertyCollection instead of Hashtable PropertyCollection clone = new PropertyCollection(); foreach (DictionaryEntry pair in this) { clone.Add(pair.Key, pair.Value); } return clone; }
public void AttachProperties_PropertyCollectionWithMishmatchingSchemaTypes_ThrowsArgumentException() { var prophandler = DummyFactory.GetPropertyHandler(); var propertyList = DummyFactory.GetPropertyList(12); var schema = DummyFactory.GetSchema<int>("property", 12); var attachedProperties = new PropertyCollection(propertyList, schema); Assert.Throws<ArgumentException>(() => prophandler.AttachProperties(attachedProperties)); }
public DataSet (string name) { dataSetName = name; tableCollection = new DataTableCollection (this); relationCollection = new DataRelationCollection.DataSetRelationCollection (this); properties = new PropertyCollection (); this.prefix = String.Empty; this.Locale = CultureInfo.CurrentCulture; }
public static void AppendExtendedProperties(DataTable dtObj, PropertyCollection props, bool withClear) { if (withClear) dtObj.ExtendedProperties.Clear(); try { foreach (DictionaryEntry item in props) { dtObj.ExtendedProperties.Add(item.Key, item.Value); } } catch { } }
public Field(int fieldId, string column, int typeId, string typeName, int panelId, PropertyCollection attr = null, PropertyCollection rules = null) { this.fieldId = fieldId; this.column = column; this.typeName = typeName; this.panelId = panelId; this.typeId = typeId; this.attr = attr==null?new PropertyCollection():attr; this.rules = rules==null?new PropertyCollection():rules; value = null; errMsg = ""; }
/// <summary> /// Constructor /// </summary> /// <param name="dest">Destination of the message</param> /// <param name="src">Source of the message</param> /// <param name="obj">Serialisable payload OR array of <c>Message</c>s</param> public Message(Address dest, Address src, Object obj) { dest_addr = dest; src_addr = src; headers = new PropertyCollection(); if(obj!=null) { if(obj is Array) setMessageArray((Array)obj); else if(obj.GetType().IsSerializable) setObject(obj); else throw new Exception("Message can only contain an Array of messages or a ISerializable object"); } }
// holder (if != null) in attr["holder"] public Panel(string tableName, int panelId, int typeId, string typeName, List<IPanel> children, List<IField> fields, List<IControl> controls, List<string> PKColNames, DataRow PK = null, PropertyCollection viewAttr = null, PropertyCollection controlAttr = null, IPanel parent = null) { this.tableName = tableName; this.viewAttr = viewAttr == null ? new PropertyCollection() : viewAttr; this.controlAttr = controlAttr==null?new PropertyCollection():controlAttr; this.panelId = panelId; this.children = children; this.fields = fields; this.controls = controls; this.PKColNames = PKColNames; this.PK = PK; this.typeId = typeId; this.typeName = typeName; this.parent = parent; if (this.controls == null) this.controls = new List<IControl>(); if (this.fields == null) this.fields = new List<IField>(); if (this.controlAttr == null) this.controlAttr = new PropertyCollection(); if (this.viewAttr == null) this.viewAttr = new PropertyCollection(); if (this.PKColNames == null) this.PKColNames = new List<string>(); }
//Does the DS or ANY object in it have ExtendedProperties? private static bool _PropsNotEmpty(PropertyCollection props) { return props != null && props.Count != 0; }
/// <summary> /// Sets the properties specified in the configuration string /// </summary> /// <param name="props">Properties to set</param> /// <returns>False if properties were specified that are not know, otherwise true</returns> public override bool setProperties(PropertyCollection props) { if(props.Contains("shun")) { shun = Convert.ToBoolean(props["shun"]); props.Remove("shun"); } if(props.Contains("print_local_addr")) { print_local_addr = Convert.ToBoolean(props["print_local_addr"]); props.Remove("print_local_addr"); } if(props.Contains("join_timeout")) { join_timeout = Convert.ToInt64(props["join_timeout"]); props.Remove("join_timeout"); } if(props.Contains("join_retry_timeout")) { join_retry_timeout = Convert.ToInt64(props["join_retry_timeout"]); props.Remove("join_retry_timeout"); } if(props.Contains("leave_timeout")) // time to wait until coord responds to LEAVE req. { leave_timeout = Convert.ToInt64(props["leave_timeout"]); props.Remove("leave_timeout"); } if(props.Contains("digest_timeout")) // time to wait for GET_DIGEST_OK from PBCAST { digest_timeout = Convert.ToInt64(props["digest_timeout"]); props.Remove("digest_timeout"); } if(props.Contains("disable_initial_coord")) // time to wait for GET_DIGEST_OK from PBCAST { disable_initial_coord = Convert.ToBoolean(props["disable_initial_coord"]); props.Remove("disable_initial_coord"); } if(props.Count > 0) { return false; } return true; }
public DataSet (string dataSetName) { this.dataSetName = dataSetName; tableCollection = new DataTableCollection (this); relationCollection = new DataRelationCollection.DataSetRelationCollection (this); properties = new PropertyCollection (); prefix = String.Empty; }
/// <summary> /// Removes and sets all generic properties of a Protocol, then passes remainder of properties on to implementation /// </summary> /// <param name="properties">Collection of properties</param> /// <returns>False if properties were specified that are not know, otherwise true</returns> public bool setPropertiesInternal(PropertyCollection properties) { this.props = properties; if(props.Contains("down_thread")) { down_thread = Convert.ToBoolean(props["down_thread"]); props.Remove("down_thread"); } if(props.Contains("up_thread")) { up_thread = Convert.ToBoolean(props["up_thread"]); props.Remove("up_thread"); } return setProperties(props); }
public static NpgsqlCommand BuildDynamicUpdateCommand(tgDataRequest request, tgEntitySavePacket packet) { string where = String.Empty; string conncur = String.Empty; string scomma = String.Empty; string defaults = String.Empty; string defaultsComma = String.Empty; string and = String.Empty; string sql = "UPDATE " + CreateFullName(request) + " SET "; PropertyCollection props = new PropertyCollection(); NpgsqlParameter p = null; Dictionary<string, NpgsqlParameter> types = Cache.GetParameters(request); NpgsqlCommand cmd = new NpgsqlCommand(); if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value; tgColumnMetadataCollection cols = request.Columns; foreach (tgColumnMetadata col in cols) { bool isModified = packet.ModifiedColumns == null ? false : packet.ModifiedColumns.Contains(col.Name); if (isModified && (!col.IsAutoIncrement && !col.IsConcurrency && !col.IsEntitySpacesConcurrency)) { p = cmd.Parameters.Add(CloneParameter(types[col.Name])); object value = packet.CurrentValues[col.Name]; p.Value = value != null ? value : DBNull.Value; sql += scomma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; scomma = ", "; } else if (col.IsAutoIncrement) { // Nothing to do but leave this here } else if (col.IsConcurrency) { p = CloneParameter(types[col.Name]); p.SourceVersion = DataRowVersion.Original; p.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(p); conncur += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; } else if (col.IsEntitySpacesConcurrency) { p = CloneParameter(types[col.Name]); p.Value = packet.OriginalValues[col.Name]; p.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(p); sql += scomma; sql += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName + " + 1"; conncur += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; defaults += defaultsComma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; defaultsComma = ","; } else if (col.IsComputed) { // Do nothing but leave this here } else if (cols.IsSpecialColumn(col)) { // Do nothing but leave this here } else if (col.HasDefault) { // defaults += defaultsComma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; // defaultsComma = ","; } if (col.IsInPrimaryKey) { p = CloneParameter(types[col.Name]); p.Value = packet.OriginalValues[col.Name]; cmd.Parameters.Add(p); where += and + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; and = " AND "; } } #region Special Column Logic if (cols.DateModified != null && cols.DateModified.IsServerSide) { p = CloneParameter(types[cols.DateModified.ColumnName]); p.Direction = ParameterDirection.Output; cmd.Parameters.Add(p); sql += scomma + Delimiters.ColumnOpen + cols.DateModified.ColumnName + Delimiters.ColumnClose + " = " + request.ProviderMetadata["DateModified.ServerSideText"]; scomma = ", "; defaults += defaultsComma + cols.DateModified.ColumnName; defaultsComma = ","; } if (cols.ModifiedBy != null && cols.ModifiedBy.IsServerSide) { p = CloneParameter(types[cols.ModifiedBy.ColumnName]); p.Direction = ParameterDirection.Output; cmd.Parameters.Add(p); sql += scomma + Delimiters.ColumnOpen + cols.ModifiedBy.ColumnName + Delimiters.ColumnClose + " = " + request.ProviderMetadata["ModifiedBy.ServerSideText"]; scomma = ", "; defaults += defaultsComma + cols.ModifiedBy.ColumnName; defaultsComma = ","; tgColumnMetadata col = request.Columns[cols.ModifiedBy.ColumnName]; if (col.CharacterMaxLength > 0) { p.Size = (int)col.CharacterMaxLength; } } #endregion sql += " WHERE " + where + ""; if (conncur.Length > 0) { sql += " AND " + conncur; } if (defaults.Length > 0) { sql += "; SELECT " + defaults + " FROM " + CreateFullName(request) + " WHERE (" + where + ")"; } cmd.CommandText = sql; cmd.CommandType = CommandType.Text; return cmd; }
internal void SetExtendedProperties(PropertyCollection properties) { _properties = properties; }
public static SqlCeCommand BuildDynamicInsertCommand(tgDataRequest request, tgEntitySavePacket packet) { string sql = String.Empty; string defaults = String.Empty; string into = String.Empty; string values = String.Empty; string comma = String.Empty; string defaultComma = String.Empty; string where = String.Empty; string whereComma = String.Empty; PropertyCollection props = new PropertyCollection(); SqlCeParameter p = null; Dictionary<string, SqlCeParameter> types = Cache.GetParameters(request); SqlCeCommand cmd = new SqlCeCommand(); if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value; tgColumnMetadataCollection cols = request.Columns; foreach (tgColumnMetadata col in cols) { bool isModified = packet.ModifiedColumns == null ? false : packet.ModifiedColumns.Contains(col.Name); if (isModified && (!col.IsAutoIncrement && !col.IsConcurrency && !col.IsTiraggoConcurrency)) { p = cmd.Parameters.Add(CloneParameter(types[col.Name])); into += comma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; values += comma + p.ParameterName; comma = ", "; } else if (col.IsAutoIncrement) { props["AutoInc"] = col.Name; props["Source"] = request.ProviderMetadata.Source; } else if (col.IsConcurrency) { props["Timestamp"] = col.Name; props["Source"] = request.ProviderMetadata.Source; } else if (col.IsTiraggoConcurrency) { props["EntitySpacesConcurrency"] = col.Name; into += comma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; values += comma + "1"; comma = ", "; p = CloneParameter(types[col.Name]); p.Value = 1; cmd.Parameters.Add(p); } else if (col.IsComputed) { // Do nothing but leave this here } else if (cols.IsSpecialColumn(col)) { // Do nothing but leave this here } else if (col.HasDefault) { into += comma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; values += comma + "DEFAULT"; comma = ","; defaults += defaultComma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; defaultComma = ","; } if (col.IsInPrimaryKey) { where += whereComma + col.Name; whereComma = ","; } } #region Special Columns if (cols.DateAdded != null && cols.DateAdded.IsServerSide) { into += comma + Delimiters.ColumnOpen + cols.DateAdded.ColumnName + Delimiters.ColumnClose; values += comma + request.ProviderMetadata["DateAdded.ServerSideText"]; comma = ", "; defaults += defaultComma + Delimiters.ColumnOpen + cols.DateAdded.ColumnName + Delimiters.ColumnClose; defaultComma = ","; } if (cols.DateModified != null && cols.DateModified.IsServerSide) { into += comma + Delimiters.ColumnOpen + cols.DateModified.ColumnName + Delimiters.ColumnClose; values += comma + request.ProviderMetadata["DateModified.ServerSideText"]; comma = ", "; defaults += defaultComma + Delimiters.ColumnOpen + cols.DateModified.ColumnName + Delimiters.ColumnClose; defaultComma = ","; } if (cols.AddedBy != null && cols.AddedBy.IsServerSide) { into += comma + Delimiters.ColumnOpen + cols.AddedBy.ColumnName + Delimiters.ColumnClose; values += comma + request.ProviderMetadata["AddedBy.ServerSideText"]; comma = ", "; defaults += defaultComma + Delimiters.ColumnOpen + cols.AddedBy.ColumnName + Delimiters.ColumnClose; defaultComma = ","; } if (cols.ModifiedBy != null && cols.ModifiedBy.IsServerSide) { into += comma + Delimiters.ColumnOpen + cols.ModifiedBy.ColumnName + Delimiters.ColumnClose; values += comma + request.ProviderMetadata["ModifiedBy.ServerSideText"]; comma = ", "; defaults += defaultComma + Delimiters.ColumnOpen + cols.ModifiedBy.ColumnName + Delimiters.ColumnClose; defaultComma = ","; } #endregion if (defaults.Length > 0) { comma = String.Empty; props["Defaults"] = defaults; props["Where"] = where; } sql += " INSERT INTO " + CreateFullName(request); if (into.Length == 0) { foreach (tgColumnMetadata col in request.Columns) { if (!col.IsAutoIncrement && !col.IsComputed && !col.IsConcurrency) { into += comma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; values += comma + "DEFAULT"; comma = ","; } } } if (into.Length != 0) { sql += "(" + into + ") VALUES (" + values + ")"; } request.Properties = props; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; return cmd; }
private List<Field> PanelFields(int idPanel) { DataTable tbl = fetchAll("SELECT * FROM fields JOIN field_types USING(id_field) WHERE id_panel = ", idPanel); List<Field> res = new List<Field>(); foreach(DataRow row in tbl.Rows){ int typeId = (int) row["id_type"]; int fieldId = (int)row["id_field"]; PropertyCollection properties = new PropertyCollection(); PropertyCollection rules = new PropertyCollection(); PropertyCollection controlOptions = new PropertyCollection(); DataTable propsTab = fetchAll("SELECT name, val, concerns FROM fields_meta WHERE id_field = ", fieldId); foreach(DataRow propRow in propsTab.Rows) switch((string)propRow["concerns"]){ case "view": properties.Add(propRow["name"], propRow["val"]); break; case "validation": rules.Add(propRow["name"], propRow["val"]); break; case "controls": controlOptions.Add(propRow["name"], propRow["val"]); break; default: throw new Exception("Cannot handle metadata about " + propRow["concerns"].ToString() + " (yet)."); } properties.Add("caption", row["caption"] as string); string typeName = row["type_name"] as string; if(!controlOptions.ContainsKey("isFK") && !controlOptions.ContainsKey("isM2NMapping")){ res.Add(new Field(fieldId, (string)row["column_name"], typeId, (string)row["type_name"], idPanel, properties, rules)); continue; // just a standard field } // FK or M2NMapping string myTable = fetchSingle("SELECT table_name FORM panels WHERE id_panel = ", idPanel) as string; string myColumn = row["column_name"] as string; string refTable = controlOptions[CC.FIELD_REF_TABLE] as string; string refColumn = controlOptions[CC.FIELD_REF_COLUMN] as string; string displayColumn = controlOptions[CC.FIELD_DISPLAY_COLUMN] as string; if(controlOptions.ContainsKey("isFK")){ // foreign key FKMySql fk = new FKMySql(myTable, myColumn, refTable, refColumn, displayColumn); res.Add(new FKField(fieldId, myColumn, typeId, typeName, idPanel, fk, properties, rules)); } // M2NMapping string mapTable = controlOptions[CC.FIELD_MAP_TABLE] as string; string mapMyColumn = controlOptions[CC.FIELD_MAP_MY_COLUMN] as string; string mapRefColumn = controlOptions[CC.FIELD_REF_COLUMN] as string; M2NMappingMySql mapping = new M2NMappingMySql(myTable, myColumn, refTable, refColumn, mapTable, displayColumn, mapMyColumn, mapRefColumn); res.Add(new M2NMappingField(fieldId, myColumn, typeId, typeName, idPanel, mapping, properties, rules)); } return res; }
internal static void AddExtendedProperties(PropertyCollection props, XmlElement node) { AddExtendedProperties(props, node, null); }
/* METHODS */ private double ShowBills(DateTime fromDay, DateTime toDay) { Dictionary<string, object> items = DataWorkBill.LoadRangeBills(fromDay, toDay, AppConfig.Path_Bills, AppConfig.APP_SubUnit); DataTable currentBill = new DataTable(); PropertyCollection props = new PropertyCollection(); Dictionary<string, object> billInfo = new Dictionary<string, object>(); double generalSuma = 0.0; //this.billFileList.Clear(); listGrid.Rows.Clear(); foreach (KeyValuePair<string, object> billEntry in items) { currentBill = (DataTable)((object[])billEntry.Value)[0]; props = (PropertyCollection)((object[])billEntry.Value)[1]; billInfo = ((Dictionary<string, object>)props[CoreConst.BILL]); //this.billFileList.Add(billInfo[CoreConst.OID].ToString(), billEntry.Key); if (props[CoreConst.ORDER_NO] == null) continue; listGrid.Rows.Add( new object[] { billInfo[CoreConst.OID], billEntry.Key, false, billInfo[CoreConst.BILL_NO], billInfo[CoreConst.DATETIME], billInfo[CoreConst.COMMENT], (double)props[mdcore.Common.CoreConst.ORDER_SUMA], bool.Parse(billInfo[CoreConst.IS_LOCKED].ToString()), props[CoreConst.ORDER_NO] } ); generalSuma += (double)props[mdcore.Common.CoreConst.ORDER_SUMA]; /*if (props.ContainsKey(CoreConst.ORDER_NO) && props[CoreConst.ORDER_NO] != null && props[CoreConst.ORDER_NO].ToString() != string.Empty) { Font extFont = listGrid.Font; listGrid.Rows[listGrid.Rows.Count - 1].DefaultCellStyle.Font = new Font(extFont, FontStyle.Strikeout); }*/ } this.label_orderInfo_General.Text = string.Format("Всього {0} запис(ів) на суму {1:0.00}{2}", listGrid.RowCount, generalSuma, "грн"); return generalSuma; }
// DeSerialize dataset properties private void DeserializeDataSetProperties(SerializationInfo info, StreamingContext context) { //DataSet basic properties dataSetName = info.GetString("DataSet.DataSetName"); namespaceURI = info.GetString("DataSet.Namespace"); _datasetPrefix = info.GetString("DataSet.Prefix"); //DataSet runtime properties _caseSensitive = info.GetBoolean("DataSet.CaseSensitive"); int lcid = (int)info.GetValue("DataSet.LocaleLCID", typeof(int)); _culture = new CultureInfo(lcid); _cultureUserSet = true; enforceConstraints = info.GetBoolean("DataSet.EnforceConstraints"); //ExtendedProperties extendedProperties = (PropertyCollection)info.GetValue("DataSet.ExtendedProperties", typeof(PropertyCollection)); }
protected Constraint() { dataSet = null; _properties = new PropertyCollection(); }
public static SqlCeCommand BuildDynamicUpdateCommand(tgDataRequest request, tgEntitySavePacket packet) { string where = String.Empty; string scomma = String.Empty; string wcomma = String.Empty; string defaults = String.Empty; string defaultsWhere = String.Empty; string defaultsComma = String.Empty; string defaultsWhereComma = String.Empty; string sql = "UPDATE " + CreateFullName(request) + " SET "; PropertyCollection props = new PropertyCollection(); SqlCeParameter p = null; Dictionary<string, SqlCeParameter> types = Cache.GetParameters(request); SqlCeCommand cmd = new SqlCeCommand(); if (request.CommandTimeout != null) cmd.CommandTimeout = request.CommandTimeout.Value; tgColumnMetadataCollection cols = request.Columns; foreach (tgColumnMetadata col in cols) { bool isModified = packet.ModifiedColumns == null ? false : packet.ModifiedColumns.Contains(col.Name); if (isModified && (!col.IsAutoIncrement && !col.IsConcurrency && !col.IsTiraggoConcurrency)) { p = cmd.Parameters.Add(CloneParameter(types[col.Name])); sql += scomma; sql += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; scomma = ", "; } else if (col.IsAutoIncrement) { // Nothing to do but leave this here } else if (col.IsConcurrency) { p = CloneParameter(types[col.Name]); p.SourceVersion = DataRowVersion.Original; cmd.Parameters.Add(p); where += wcomma; where += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; wcomma = " AND "; } else if (col.IsTiraggoConcurrency) { props["EntitySpacesConcurrency"] = col.Name; p = CloneParameter(types[col.Name]); p.SourceVersion = DataRowVersion.Original; cmd.Parameters.Add(p); sql += scomma; sql += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " + 1"; scomma = ", "; where += wcomma; where += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; wcomma = " AND "; } else if (col.IsComputed) { // Do nothing but leave this here } else if (cols.IsSpecialColumn(col)) { // Do nothing but leave this here } else if (col.HasDefault) { // defaults += defaultsComma + Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose; // defaultsComma = ","; } if (col.IsInPrimaryKey) { p = CloneParameter(types[col.Name]); p.SourceVersion = DataRowVersion.Original; cmd.Parameters.Add(p); where += wcomma; where += Delimiters.ColumnOpen + col.Name + Delimiters.ColumnClose + " = " + p.ParameterName; wcomma = " AND "; defaultsWhere += defaultsWhereComma + col.Name; defaultsWhereComma = ","; } } #region Special Columns if (cols.DateModified != null && cols.DateModified.IsServerSide) { sql += scomma; sql += Delimiters.ColumnOpen + cols.DateModified.ColumnName + Delimiters.ColumnClose + " = " + request.ProviderMetadata["DateModified.ServerSideText"]; scomma = ", "; defaults += defaultsComma + Delimiters.ColumnOpen + cols.DateModified.ColumnName + Delimiters.ColumnClose; defaultsComma = ","; } if (cols.ModifiedBy != null && cols.ModifiedBy.IsServerSide) { sql += scomma; sql += Delimiters.ColumnOpen + cols.ModifiedBy.ColumnName + Delimiters.ColumnClose + " = " + request.ProviderMetadata["ModifiedBy.ServerSideText"]; scomma = ", "; defaults += defaultsComma + Delimiters.ColumnOpen + cols.ModifiedBy.ColumnName + Delimiters.ColumnClose; defaultsComma = ","; } #endregion if (defaults.Length > 0) { props["Defaults"] = defaults; props["Where"] = defaultsWhere; } sql += " WHERE (" + where + ")"; request.Properties = props; cmd.CommandText = sql; cmd.CommandType = CommandType.Text; return cmd; }
private void DeserializeDataSetProperties(SerializationInfo info, StreamingContext context) { this.dataSetName = info.GetString("DataSet.DataSetName"); this.namespaceURI = info.GetString("DataSet.Namespace"); this._datasetPrefix = info.GetString("DataSet.Prefix"); this._caseSensitive = info.GetBoolean("DataSet.CaseSensitive"); int culture = (int) info.GetValue("DataSet.LocaleLCID", typeof(int)); this._culture = new CultureInfo(culture); this._cultureUserSet = true; this.enforceConstraints = info.GetBoolean("DataSet.EnforceConstraints"); this.extendedProperties = (PropertyCollection) info.GetValue("DataSet.ExtendedProperties", typeof(PropertyCollection)); }
/// <summary> /// Initializes a new instance of the DataTable class with no arguments. /// </summary> public DataTable () { dataSet = null; _columnCollection = new DataColumnCollection(this); _constraintCollection = new ConstraintCollection(this); _extendedProperties = new PropertyCollection(); _tableName = ""; _nameSpace = null; _caseSensitive = false; //default value _displayExpression = null; _primaryKeyConstraint = null; _site = null; _rows = new DataRowCollection (this); _indexes = new ArrayList(); _recordCache = new RecordCache(this); //LAMESPEC: spec says 25 impl does 50 _minimumCapacity = 50; _childRelations = new DataRelationCollection.DataTableRelationCollection (this); _parentRelations = new DataRelationCollection.DataTableRelationCollection (this); }
private static bool _PropsNotEmpty(PropertyCollection props) { return ((props != null) && (props.Count != 0)); }
private double LoadDayBills(DateTime selectedDay) { Dictionary<string, object> items = DataWorkBill.LoadDayBills(selectedDay, ConfigManager.Instance.CommonConfiguration.Path_Bills, ConfigManager.Instance.CommonConfiguration.APP_SubUnit); DataTable currentBill = new DataTable(); PropertyCollection props = new PropertyCollection(); Dictionary<string, object> billInfo = new Dictionary<string, object>(); double generalSuma = 0.0; try { foreach (KeyValuePair<string, object> billEntry in items) { currentBill = (DataTable)((object[])billEntry.Value)[0]; props = (PropertyCollection)((object[])billEntry.Value)[1]; billInfo = ((Dictionary<string, object>)props[CoreConst.BILL]); this.billFileList.Add(billInfo[CoreConst.OID].ToString(), billEntry.Key); listGrid.Rows.Add( new object[] { billInfo[CoreConst.OID], billInfo[CoreConst.BILL_NO], billInfo[CoreConst.DATETIME], (billInfo[CoreConst.COMMENT] != null)?billInfo[CoreConst.COMMENT].ToString().Replace("%20", " "):"", (double)props[CoreConst.ORDER_REAL_SUMA], bool.Parse(billInfo[CoreConst.IS_LOCKED].ToString()), props[CoreConst.ORDER_NO], (billInfo.ContainsKey(CoreConst.DATETIME_LOCK)?billInfo[CoreConst.DATETIME_LOCK]:"-") } ); generalSuma += (double)props[CoreConst.ORDER_REAL_SUMA]; if (props.ContainsKey(CoreConst.ORDER_NO) && props[CoreConst.ORDER_NO] != null && props[CoreConst.ORDER_NO].ToString() != string.Empty) { Font extFont = listGrid.Font; listGrid.Rows[listGrid.Rows.Count - 1].DefaultCellStyle.Font = new Font(extFont, FontStyle.Strikeout); } else listGrid.Rows[listGrid.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightPink; } } catch { } /* string item = string.Empty; bills = Directory.GetFiles(ConfigManager.Instance.CommonConfiguration.Path_Bills, string.Format("{0:X2}_N*_{1}.bill", ConfigManager.Instance.CommonConfiguration.APP_SubUnit, selectedDay.ToString("ddMMyy"))); Array.Sort(bills); double billListSuma = 0.0; double billSuma = 0.0; object[] billEntry = new object[2]; PropertyCollection props = new PropertyCollection(); Dictionary<string, object> billInfo = new Dictionary<string, object>(); object orderNo = new object(); for (int i = 0; i < bills.Length; i++, item = string.Empty) { try { stream = new FileStream(bills[i], FileMode.Open, FileAccess.Read, FileShare.Read); billEntry = (object[])binF.Deserialize(stream); //dTBill = (DataTable)binF.Deserialize(stream); dTBill = (DataTable)billEntry[0]; props = (PropertyCollection)billEntry[1]; billInfo = ((Dictionary<string, object>)props[CoreConst.BILL]); stream.Close(); stream.Dispose(); //Adding item billFileList.Add(billInfo[CoreConst.OID].ToString(), bills[i]); billSuma = (double)props[CoreConst.ORDER_SUMA]; orderNo = props[CoreConst.ORDER_NO]; // hide special flags //if (orderNo != null && (string.Compare(orderNo.ToString(), "null") == 0 || string.Compare(orderNo.ToString(), "k") == 0)) // orderNo = string.Empty; listGrid.Rows.Add( new object[] { billInfo[CoreConst.OID], billInfo[CoreConst.BILL_NO], billInfo[CoreConst.DATETIME], billInfo[CoreConst.COMMENT], billSuma, bool.Parse(billInfo[CoreConst.IS_LOCKED].ToString()), orderNo } ); billListSuma += billSuma; if (props.ContainsKey(CoreConst.ORDER_NO) && props[CoreConst.ORDER_NO] != null && props[CoreConst.ORDER_NO].ToString() != string.Empty) { Font extFont = listGrid.Font; listGrid.Rows[listGrid.Rows.Count - 1].DefaultCellStyle.Font = new Font(extFont, FontStyle.Strikeout); } } catch (Exception ex) { CoreLib.WriteLog(ex, "LoadDayBills(DateTime selectedDay); Unable to load bill file: " + bills[i]); } }*/ return generalSuma; }
internal static void AddExtendedProperties(PropertyCollection props, XmlElement node, Type type) { if (props != null) { foreach (DictionaryEntry entry in props) { string str; string str2; if (entry.Key is INullable) { str = (string) SqlConvert.ChangeTypeForXML(entry.Key, typeof(string)); } else { str = Convert.ToString(entry.Key, CultureInfo.InvariantCulture); } if (entry.Value is INullable) { str2 = (string) SqlConvert.ChangeTypeForXML(entry.Value, typeof(string)); } else if (entry.Value is BigInteger) { str2 = (string) BigIntegerStorage.ConvertFromBigInteger((BigInteger) entry.Value, typeof(string), CultureInfo.InvariantCulture); } else { str2 = Convert.ToString(entry.Value, CultureInfo.InvariantCulture); } if (type == typeof(DataRelation)) { str = "rel_" + str; } else if (type == typeof(ForeignKeyConstraint)) { str = "fk_" + str; } node.SetAttribute(XmlConvert.EncodeLocalName(str), "urn:schemas-microsoft-com:xml-msprop", str2); } } }
/// <summary> /// Sets the properties specified in the configuration string /// </summary> /// <param name="props">Properties to set</param> /// <returns>False if properties were specified that are not know, otherwise true</returns> public virtual bool setProperties(PropertyCollection props) { if (props.Count > 0) return false; return true; }
/// <summary> /// Retrieves the user-defined sounds from the registry /// </summary> private PropertyCollection GetUserDefinedSounds() { string rootKey = "AppEvents\\Schemes\\Apps\\.Default"; PropertyCollection coll = new PropertyCollection(); try { // open root key key1 = Registry.CurrentUser.OpenSubKey(rootKey, false); // go through each subkey foreach (string subKey in key1.GetSubKeyNames()) { // open subkey key2 = key1.OpenSubKey(subKey + "\\.Current", false); // get filename, if any if (key2 != null) if (key2.GetValue(null).ToString().Length > 0) coll.Add(subKey, key2.GetValue(null).ToString()); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Yikes!", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // close keys key1.Close(); key2.Close(); } return coll; }
// Deserialize all the Columns internal void DeserializeTableSchema(SerializationInfo info, StreamingContext context, bool isSingleTable) { //DataTable basic properties tableName = info.GetString("DataTable.TableName"); tableNamespace = info.GetString("DataTable.Namespace"); tablePrefix = info.GetString("DataTable.Prefix"); bool caseSensitive = info.GetBoolean("DataTable.CaseSensitive"); SetCaseSensitiveValue(caseSensitive, true, false); _caseSensitiveUserSet = !info.GetBoolean("DataTable.caseSensitiveAmbient"); int lcid = (int)info.GetValue("DataTable.LocaleLCID", typeof(int)); CultureInfo culture = new CultureInfo(lcid); SetLocaleValue(culture, true, false); _cultureUserSet = true; MinimumCapacity = info.GetInt32("DataTable.MinimumCapacity"); //DisplayExpression = info.GetString("DataTable.DisplayExpression"); //DataTable state internal properties fNestedInDataset = (bool) info.GetBoolean("DataTable.NestedInDataSet"); string tName = info.GetString("DataTable.TypeName"); typeName = new XmlQualifiedName(tName); repeatableElement = info.GetBoolean("DataTable.RepeatableElement"); //ExtendedProperties extendedProperties = (PropertyCollection) info.GetValue("DataTable.ExtendedProperties", typeof(PropertyCollection)); //Columns int colCount = info.GetInt32("DataTable.Columns.Count"); string [] expressions = new string[colCount]; Debug.Assert(Columns.Count == 0, "There is column in Table"); IFormatProvider formatProvider = CultureInfo.InvariantCulture; for (int i = 0; i < colCount; i++) { DataColumn dc = new DataColumn(); //DataColumn public state properties dc.ColumnName = info.GetString(String.Format(formatProvider, "DataTable.DataColumn_{0}.ColumnName", i)); dc._columnUri = info.GetString(String.Format(formatProvider, "DataTable.DataColumn_{0}.Namespace", i)); dc.Prefix = info.GetString(String.Format(formatProvider, "DataTable.DataColumn_{0}.Prefix", i)); dc.DataType = (Type) info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.DataType", i), typeof(Type)); dc.XmlDataType = (string) info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.XmlDataType", i), typeof(string)); dc.SimpleType = (SimpleType) info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.SimpleType", i), typeof(SimpleType)); dc.ColumnMapping = (MappingType) info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.ColumnMapping", i), typeof(MappingType)); dc.DateTimeMode = (DataSetDateTime) info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.DateTimeMode", i), typeof(DataSetDateTime)); dc.AllowDBNull = info.GetBoolean(String.Format(formatProvider, "DataTable.DataColumn_{0}.AllowDBNull", i)); dc.AutoIncrement = info.GetBoolean(String.Format(formatProvider, "DataTable.DataColumn_{0}.AutoIncrement", i)); dc.AutoIncrementStep = info.GetInt64(String.Format(formatProvider, "DataTable.DataColumn_{0}.AutoIncrementStep", i)); dc.AutoIncrementSeed = info.GetInt64(String.Format(formatProvider, "DataTable.DataColumn_{0}.AutoIncrementSeed", i)); dc.Caption = info.GetString(String.Format(formatProvider, "DataTable.DataColumn_{0}.Caption", i)); dc.DefaultValue = info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.DefaultValue", i), typeof(object)); dc.ReadOnly = info.GetBoolean(String.Format(formatProvider, "DataTable.DataColumn_{0}.ReadOnly", i)); dc.MaxLength= info.GetInt32(String.Format(formatProvider, "DataTable.DataColumn_{0}.MaxLength", i)); //DataColumn internal state properties dc.AutoIncrementCurrent = info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.AutoIncrementCurrent", i), typeof(object)); //Expression if (isSingleTable) { expressions[i] = info.GetString(String.Format(formatProvider, "DataTable.DataColumn_{0}.Expression", i)); } //ExtendedProperties dc.extendedProperties = (PropertyCollection) info.GetValue(String.Format(formatProvider, "DataTable.DataColumn_{0}.ExtendedProperties", i), typeof(PropertyCollection)); Columns.Add(dc); } if (isSingleTable) { for(int i = 0; i < colCount; i++) { if (expressions[i] != null) { Columns[i].Expression = expressions[i]; } } } //Constraints if (isSingleTable) { DeserializeConstraints(info, context, /*table index */ 0, /* serialize all constraints */false);// since single table, send table index as 0, meanwhile passing // false for 'allConstraints' means, handle all the constraint related to the table } }
private void PopulateDropDown() { // fill our PropertyCollection object events = GetUserDefinedSounds(); // disable if no sound events if (events.Keys.Count == 0) cbUserSound.Enabled = false; else { foreach (string key in events.Keys) { cbUserSound.Items.Add(key); } } }