protected string[] reflectPKNames(Type dat) { List <string> pkList = new List <string>(); foreach (FieldInfo fi in dat.GetFields()) { if (fi.GetCustomAttributes(typeof(PrimaryKey), true).Length > 0) { object[] ca = fi.GetCustomAttributes(typeof(JoinKey), true); if (ca.Length > 0) { JoinKey jk = (JoinKey)ca[0]; pkList.Add(jk.tableA + "." + fi.Name); continue; } ca = fi.GetCustomAttributes(typeof(DBAlias), true); if (ca.Length > 0) { DBAlias a = (DBAlias)ca[0]; pkList.Add(a.alias); continue; } pkList.Add(fi.Name); } } return(pkList.ToArray()); }
protected virtual string reflectSelectFields(Type dat) { string values = ""; System.Reflection.FieldInfo[] fieldInfo = dat.GetFields(); foreach (System.Reflection.FieldInfo fi in fieldInfo) { object[] ca = fi.GetCustomAttributes(typeof(JoinKey), true); if (ca.Length > 0) { JoinKey jk = (JoinKey)ca[0]; values += jk.tableA + "."; } ca = fi.GetCustomAttributes(typeof(DBAlias), true); if (ca.Length > 0) { DBAlias a = (DBAlias)ca[0]; values += a.alias + ", "; } else { values += fi.Name + ", "; } } values = values.Substring(0, values.Length - 2); return(values); }
/// <summary> /// Saves this process to a file /// </summary> /// <param name="file">The file to save this process to</param> /// <param name="name">The name of the process</param> public override void Save(string file, string name) { FdoJoinTaskDefinition join = new FdoJoinTaskDefinition(); join.name = name; join.Left = new FdoJoinSource(); join.Right = new FdoJoinSource(); join.Target = new FdoJoinTarget(); join.JoinSettings = new FdoJoinSettings(); join.Left.Class = _options.Left.ClassName; join.Left.ConnectionString = _options.Left.Connection.ConnectionString; join.Left.FeatureSchema = _options.Left.SchemaName; join.Left.Prefix = _options.LeftPrefix; join.Left.PropertyList = new List <string>(_options.LeftProperties).ToArray(); join.Left.Provider = _options.Left.Connection.Provider; join.Left.Filter = _options.LeftFilter; join.Right.Class = _options.Right.ClassName; join.Right.ConnectionString = _options.Right.Connection.ConnectionString; join.Right.FeatureSchema = _options.Right.SchemaName; join.Right.Prefix = _options.RightPrefix; join.Right.PropertyList = new List <string>(_options.RightProperties).ToArray(); join.Right.Provider = _options.Right.Connection.Provider; join.Right.Filter = _options.RightFilter; join.Target.Class = _options.Target.ClassName; join.Target.ConnectionString = _options.Target.Connection.ConnectionString; join.Target.FeatureSchema = _options.Target.SchemaName; join.Target.Provider = _options.Target.Connection.Provider; join.JoinSettings.DesignatedGeometry = new FdoDesignatedGeometry(); if (!string.IsNullOrEmpty(_options.GeometryProperty)) { join.JoinSettings.DesignatedGeometry.Property = _options.GeometryProperty; join.JoinSettings.DesignatedGeometry.Side = _options.Side; } join.JoinSettings.JoinType = (JoinType)Enum.Parse(typeof(JoinType), _options.JoinType.ToString()); List <JoinKey> keys = new List <JoinKey>(); foreach (string key in _options.JoinPairs.Keys) { JoinKey k = new JoinKey(); k.left = key; k.right = _options.JoinPairs[key]; keys.Add(k); } join.JoinSettings.JoinKeys = keys.ToArray(); XmlSerializer serializer = new XmlSerializer(typeof(FdoJoinTaskDefinition)); using (StreamWriter writer = new StreamWriter(file, false)) { serializer.Serialize(writer, join); } }
/// <summary> /// Saves the join options to xml /// </summary> /// <param name="opts">The opts.</param> /// <param name="name">The name.</param> /// <param name="file">The file.</param> public void ToXml(FdoJoinOptions opts, string name, string file) { FdoJoinTaskDefinition jdef = new FdoJoinTaskDefinition(); jdef.name = name; jdef.JoinSettings = new FdoJoinSettings(); if (!string.IsNullOrEmpty(opts.GeometryProperty)) { jdef.JoinSettings.DesignatedGeometry = new FdoDesignatedGeometry(); jdef.JoinSettings.DesignatedGeometry.Property = opts.GeometryProperty; jdef.JoinSettings.DesignatedGeometry.Side = opts.Side; } List <JoinKey> keys = new List <JoinKey>(); foreach (string left in opts.JoinPairs.Keys) { JoinKey key = new JoinKey(); key.left = left; key.right = opts.JoinPairs[left]; keys.Add(key); } jdef.JoinSettings.JoinKeys = keys.ToArray(); jdef.Left = new FdoJoinSource(); jdef.Left.Class = opts.Left.ClassName; jdef.Left.ConnectionString = opts.Left.Connection.ConnectionString; jdef.Left.FeatureSchema = opts.Left.SchemaName; jdef.Left.Prefix = opts.LeftPrefix; jdef.Left.PropertyList = new List <string>(opts.LeftProperties).ToArray(); jdef.Left.Provider = opts.Left.Connection.Provider; jdef.Right = new FdoJoinSource(); jdef.Right.Class = opts.Right.ClassName; jdef.Right.ConnectionString = opts.Right.Connection.ConnectionString; jdef.Right.FeatureSchema = opts.Right.SchemaName; jdef.Right.Prefix = opts.RightPrefix; jdef.Right.PropertyList = new List <string>(opts.RightProperties).ToArray(); jdef.Right.Provider = opts.Right.Connection.Provider; jdef.Target = new FdoJoinTarget(); jdef.Target.Class = opts.Target.ClassName; jdef.Target.ConnectionString = opts.Target.Connection.ConnectionString; jdef.Target.FeatureSchema = opts.Target.SchemaName; jdef.Target.Provider = opts.Target.Connection.Provider; using (XmlTextWriter writer = new XmlTextWriter(file, Encoding.UTF8)) { writer.Formatting = Formatting.Indented; writer.Indentation = 4; XmlSerializer ser = new XmlSerializer(typeof(FdoJoinTaskDefinition)); ser.Serialize(writer, jdef); } }
protected override string reflectSelectFields(Type dat) { string values = ""; System.Reflection.FieldInfo[] fieldInfo = dat.GetFields(); foreach (System.Reflection.FieldInfo fi in fieldInfo) { object[] ca = fi.GetCustomAttributes(typeof(JoinKey), true); if (ca.Length > 0) { JoinKey jk = (JoinKey)ca[0]; values += jk.tableA + "."; } ca = fi.GetCustomAttributes(typeof(DBAlias), true); if (ca.Length > 0) { DBAlias a = (DBAlias)ca[0]; values += a.alias + ", "; } else { #if USE_GMT_HACK if (fi.FieldType.ToString().Contains("System.DateTime")) { values += "date_gmt(" + fi.Name + ") as " + fi.Name + ", "; } else #endif { values += fi.Name + ", "; } } } values = values.Substring(0, values.Length - 2); return(values); }
protected string reflectJoinStatement(Type dat) { string joinString = ""; FieldInfo[] fieldInfo = dat.GetFields(); foreach (FieldInfo fi in fieldInfo) { object[] objLst = fi.GetCustomAttributes(typeof(JoinKey), true); if (objLst.Length > 0) { JoinKey jk = (JoinKey)objLst[0]; joinString += jk.tableA + "." + fi.Name + " = " + jk.tableB + "." + fi.Name + " AND "; } } if (joinString != "") { joinString = joinString.Substring(0, joinString.Length - 5); } return(joinString); }
public PlayerConnection(BasePlayer player, ISocketChannel channel) { _serializer = new BinarySerializer(); _deserializer = new BinaryDeserializer(); _player = player; _channel = channel; _messageProtocol = ProtocolType.Auto; _player.IPAddress = IPAddress.Parse(_channel.RemoteEndPoint.ToString()); _deserializer.OnDeserializedMessage += (message) => { if (!_connected) { if (message.Type == "join") { // find the game from the decrypted joinKey. var joinKey = JoinKey.Decode(message.GetString(0)); if (joinKey != null) { var game = _player.Host.Games.FirstOrDefault(g => g.RoomType == joinKey.ServerType); if (game != null) { _connected = true; game.RoomId = joinKey.RoomId; _player.ConnectUserId = joinKey.ConnectUserId; _player.Game = game; _player.Game.UserJoined(_player); this.Send(new Message("playerio.joinresult", true)); return; } } this.Send(new Message("playerio.joinresult", false)); _channel.Close(); } return; } _player.Game.GotMessage(_player, message); }; _channel.Closed += (s, e) => { _connected = false; if (_player.Game != null) { _player.Game.Disconnect(player); } }; _channel.BytesReceived += (s, bytes) => { switch (_messageProtocol) { case ProtocolType.Auto: switch (bytes[0]) { case 0: _messageProtocol = ProtocolType.Binary; break; } if (bytes.Length > 1) { _deserializer.AddBytes(bytes.Skip(1).ToArray()); } break; case ProtocolType.Binary: _deserializer.AddBytes(bytes); break; } }; }