Beispiel #1
0
        private void OnQueryUserPrivilege(object sender, PacketEventArgs e)
        {
            if (!Enabled && e.Handled)
            {
                return;
            }

            var     arg = e.Packet;
            dynamic res = new DynamicStructure();

            int userId = arg.userId;
            int zoneId = arg.zoneId;

            Log.Trace("QueryUserPrivilege userId = {0}, zoneId = {1}", userId, zoneId);

            /*
             * packet 507 QueryUserPrivilege_Re:
             * int userId;
             * byte[] auth;
             */

            res.userId = userId;
            res.auth   = Auth;

            Session.Send(507, res);
        }
Beispiel #2
0
        public FEMCalculator(TrainLoadInput trainLoadInput)
        {
            this.trainLoadInput  = trainLoadInput;
            this.elementBarIdMap = new Dictionary <IDynamicBeamElement, string>();

            var settings = this.trainLoadInput.TimeSettings.ToDynamicSolverSettings(dampingRatio);

            this.structure      = new DynamicStructure(settings);
            this.trainLoadInput = trainLoadInput;
        }
Beispiel #3
0
        private static void MultipleHyperCubesExamples(IApp theApp)
        {
            var theObject = CreateCustomObject(theApp);
            // Create two hypercubes with the same measure, but different dimensions.
            var salesPerMonthHc = new HyperCubeDef();

            AddInlineDimension(salesPerMonthHc, "Month");
            AddInlineMeasure(salesPerMonthHc, "Sum([Sales Amount])");
            var salesPerYearHc = new HyperCubeDef();

            AddInlineDimension(salesPerYearHc, "Year");
            AddInlineMeasure(salesPerYearHc, "Sum([Sales Amount])");

            // Add the hypercubes to containers. The containers are used to separate the two
            // qHyperCubeDef properties in the property tree of the object.
            var hcContainer0 = new DynamicStructure();

            hcContainer0.Set("qHyperCubeDef", salesPerMonthHc);
            var hcContainer1 = new DynamicStructure();

            hcContainer1.Set("qHyperCubeDef", salesPerYearHc);

            // Add containers to object.
            using (theObject.SuspendedLayout)
            {
                theObject.Properties.Set("container0", hcContainer0);
                theObject.Properties.Set("container1", hcContainer1);
            }

            // Print data for first hypercube
            PrintData("Sales per Month", theObject,
                      row => String.Format("Month: {0}, Sales: {1}", row[0].Text, row[1].Text),
                      // Path to hypercube 0. (Name of container property followed by hypercube property.)
                      "/container0/qHyperCubeDef");

            // Print data for second hypercube
            PrintData("Sales per Year", theObject,
                      row => String.Format("Year: {0}, Sales: {1}", row[0].Num, row[1].Text),
                      // Path to hypercube 1. (Name of container property followed by hypercube property.)
                      "/container1/qHyperCubeDef");

            // Get pager for cube in container 1:
            var thePager = theObject.GetAllHyperCubePagers().First(pager => pager.Path.Contains("container0"));

            // Get Last five rows for that hypercube:
            thePager.CurrentPages = new [] { new NxPage {
                                                 Width = 2, Height = 5
                                             } };
            var theLastFiveRows = thePager.GetLastPage().First();

            PrintPage("The last five rows of hypercube in container0:", theLastFiveRows,
                      row => String.Format("Month: {0}, Sales: {1}", row[0].Text, row[1].Text)
                      );
        }
Beispiel #4
0
        public virtual void Send(uint packetId, int connectionId, object argument, object result)
        {
            connectionId = (int)(((uint)connectionId) & 0x7FFFFFFF);

            dynamic d = new DynamicStructure();

            d.Id  = connectionId;
            d.Res = result;
            d.Arg = argument;
            Send(packetId, d);
        }
Beispiel #5
0
        private void OnMatrixPasswdArg(object sender, PacketEventArgs e)
        {
            if (Enabled)
            {
                var    arg       = e.Packet.Arg;
                int    id        = e.Packet.Id;
                byte[] account   = arg.Account;
                byte[] challenge = arg.Challenge;
                byte[] loginip   = arg.loginip;

                string login = Encoding.ASCII.GetString(account);

                Log.Debug("OnMatrixPasswdArg, ip = {2}, login = {0}, challenge = {1}",
                          login,
                          BitConverter.ToString(challenge),
                          Ext.GetIp(loginip));

                if (e.Handled)
                {
                    return;
                }

                dynamic res = new DynamicStructure();
                try
                {
                    Log.Trace("Auth with login: {0}", login);
                    int    uid;
                    string hashstr;
                    Session.Database.AcquireUserPassword(login, out uid, out hashstr);

                    var reshash = Convert.FromBase64String(hashstr);

                    res.retcode   = 0;
                    res.userId    = uid;
                    res.algorithm = 0;
                    res.response  = reshash;
                    res.matrix    = Ext.EmptyBytes;
                }
                catch (MySql.Data.MySqlClient.MySqlException ex)
                {
                    Log.Trace("Auth failure: {0}", ex.Message);

                    res.retcode   = 3;
                    res.userId    = 0;
                    res.algorithm = 0;
                    res.response  = Ext.EmptyBytes;
                    res.matrix    = Ext.EmptyBytes;
                }

                Session.Send(0x226, id, arg, res);
            }
        }
Beispiel #6
0
        public override IEnumerable <dynamic> Query(string name, params object[] args)
        {
            if (MySqlConnection.State != ConnectionState.Open)
            {
                Connect();
            }
            var index    = name.IndexOf('.');
            var baseName = name;

            if (index != -1)
            {
                baseName = name.Substring(0, index);
            }

            var query = Queries[baseName];

            using (var command = new MySqlCommand(query.Select(name), MySqlConnection))
            {
                command.CommandType = CommandType.Text;

                for (var i = 0; i < args.Length; i++)
                {
                    command.Parameters.Add(new MySqlParameter("argument" + i, args[i]));
                }

                using (var reader = command.ExecuteReader())
                {
                    var schema = reader.GetSchemaTable();
                    var rows   = new List <string>();
                    foreach (DataRow row in schema.Rows)
                    {
                        rows.Add(row.Field <string>("ColumnName"));
                    }
                    while (reader.Read())
                    {
                        var obj = new DynamicStructure();
                        foreach (var row in rows)
                        {
                            obj.Dictionary[row.ToLower()] = reader[row];
                        }
                        yield return(obj);
                    }
                }
            }
        }
Beispiel #7
0
        private void OnUserLogin(object sender, PacketEventArgs e)
        {
            int id  = e.Packet.id;
            var arg = e.Packet.arg;

            int userId = arg.userId;

            Log.Trace("Auth lock userId = {0}, check = {1}, interval = {2}", userId, CheckLock(userId), LockInterval);

            if (CheckLock(userId))
            {
                e.Handled = true;

                dynamic res = new DynamicStructure();
                res.retcode = Retcode;

                Session.Send(0x0F, id, arg, res);
            }
            else
            {
                UpdateLock(userId);
            }
        }
Beispiel #8
0
        private void OnUserLogout(object sender, PacketEventArgs e)
        {
            if (Enabled && !e.Handled)
            {
                var arg = e.Packet.Arg;
                var id  = e.Packet.Id;

                int userId   = arg.userId;
                int localSid = arg.Localsid;

                int zoneId    = Zone.ZoneId;
                int aid       = Zone.Aid;
                int overwrite = aid;

                Session.Database.RecordOffline(userId, aid, ref zoneId, ref localSid, ref overwrite);

                Log.Trace("UserLogout userId = {0}, localsid = {1}", userId, localSid);

                dynamic res = new DynamicStructure();
                res.retcode = 0;

                Session.Send(33, id, arg, res);
            }
        }
 public StorageList(DynamicStructure structure, in StorageOptions options, Stream dataStream)
Beispiel #10
0
        private void OnUserLogin(object sender, PacketEventArgs e)
        {
            if (Enabled && !e.Handled)
            {
                var arg = e.Packet.Arg;
                var id  = e.Packet.Id;

                int    userId     = arg.userId;
                int    localsid   = arg.localsid;
                int    blkickuser = arg.blkickuser;
                byte[] loginip    = arg.loginip;
                byte[] account    = arg.account;

                int zoneId = Zone.ZoneId;

                dynamic res = new DynamicStructure();
                try
                {
                    res.retcode        = 0;
                    res.remainplaytime = 0;
                    res.func           = 0;
                    res.funcparm       = 0;
                    res.blisgm         = 0;
                    res.freetimeleft   = 0;
                    res.freetimeend    = 0;
                    res.creatime       = 0;
                    res.adduppoint     = 0;
                    res.soldpoint      = 0;

                    int overwrite = blkickuser;
                    Session.Database.RecordOnline(userId, Zone.Aid, ref zoneId, ref localsid, ref overwrite);
                    if (zoneId != Zone.ZoneId || (blkickuser == 0 && localsid != arg.localsid))
                    {
                        Log.Warn("(zoneId != Zone.ZoneId || localsid != arg.localsid <=> {0} != {1} || {2} != {3}", zoneId, Zone.ZoneId, localsid, (int)arg.localsid);

                        res.retcode = 10;
                    }
                    else
                    {
                        DateTime creatime = Session.Database.Query("acquireUserCreatime.byUid", userId).First().CreaTime;

                        Log.Trace("OnUserLogin login={0}, uid={1}, ip={2}", Encoding.ASCII.GetString(account), userId, Ext.GetIp(loginip));

                        res.creatime = Ext.ToUnixTime(creatime);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    res.retcode = 0xff;

                    /*
                     *  if ((arrayOfObject[0] != null) && (arrayOfObject[1] != null) && (arrayOfObject[2] != null) && ((((Integer)arrayOfObject[0]).intValue() != i) || (((Integer)arrayOfObject[1]).intValue() != localUserLoginArg.localsid)))
                     * if (((Integer)arrayOfObject[2]).intValue() == 1)
                     * {
                     * KickoutUser localObject = (KickoutUser)Rpc.Create("KICKOUTUSER");
                     * localObject.userid = localUserLoginArg.userid;
                     * localObject.localsid = ((Integer)arrayOfObject[1]).intValue();
                     * localObject.cause = 32;
                     * GAuthServer.GetLog().info("Send Kickout userid=" + localObject.userid + " sid=" + localObject.localsid);
                     * Session localSession = GetSessionbyZoneid((Integer)arrayOfObject[0]);
                     * if (localSession != null)
                     * localGAuthServer.Send(localSession, localObject);
                     * else
                     * GAuthServer.GetLog().info("Error: kickout user " + localObject.userid + " failed.");
                     * }
                     * else
                     * {
                     * localUserLoginRes.retcode = 10;
                     * return;
                     * }
                     */
                }

                Session.Send(0x0f, id, arg, res);
                Log.Trace("0x0F sended, retcode = {0}", (int)res.retcode);
            }
        }