Beispiel #1
0
        protected override object OnExecute(CommandContext context)
        {
            if (context.Expression.Arguments == null || context.Expression.Arguments.Length == 0)
            {
                throw new CommandException("Missing command arguments.");
            }

            //获取地图客户端应用提供程序
            var provider = AlimapCommand.GetProvider(context.CommandNode);

            if (provider == null)
            {
                throw new CommandException("No found the alimap provider for the command.");
            }

            //获取指定的应用编号参数
            var appId = context.Expression.Options.GetValue <string>(APP_COMMAND_OPTION);

            //获取指定应用编号对应的地图客户端
            var client = provider.Get(appId) ??
                         throw new CommandException($"The alimap-client of the specified '{appId}' appId does not exist or is undefined.");

            var result = new string[context.Expression.Arguments.Length];

            for (int i = 0; i < context.Expression.Arguments.Length; i++)
            {
                result[i] = Utility.ExecuteTask(() => client.CreateTableAsync(context.Expression.Arguments[i]));
            }

            return(result);
        }
        protected override object OnExecute(CommandContext context)
        {
            if (context.Parameter == null)
            {
                throw new CommandException("Missing parameter of the command.");
            }

            //获取地图客户端应用提供程序
            var provider = AlimapCommand.GetProvider(context.CommandNode);

            if (provider == null)
            {
                throw new CommandException("No found the alimap provider for the command.");
            }

            //获取指定的应用编号参数
            var appId = context.Expression.Options.GetValue <string>(APP_COMMAND_OPTION);

            //获取指定应用编号对应的地图客户端
            var client = provider.Get(appId) ??
                         throw new CommandException($"The alimap-client of the specified '{appId}' appId does not exist or is undefined.");

            client.UpdateDataAsync(
                context.Expression.Options.GetValue <string>(TABLE_COMMAND_OPTION),
                context.Parameter as IDictionary <string, object>,
                context.Expression.Options.GetValue <string>(MAPPING_COMMAND_OPTION),
                context.Expression.Options.GetValue <CoordinateType>(COORDINATE_COMMAND_OPTION)).Wait(TimeSpan.FromSeconds(10));

            return(null);
        }
Beispiel #3
0
        protected override object OnExecute(CommandContext context)
        {
            if (context.Expression.Arguments == null || context.Expression.Arguments.Length == 0)
            {
                throw new CommandException("Missing command arguments.");
            }

            //获取地图客户端应用提供程序
            var provider = AlimapCommand.GetProvider(context.CommandNode);

            if (provider == null)
            {
                throw new CommandException("No found the alimap provider for the command.");
            }

            //获取指定的应用编号参数
            var appId = context.Expression.Options.GetValue <string>(APP_COMMAND_OPTION);

            //获取指定应用编号对应的地图客户端
            var client = provider.Get(appId) ??
                         throw new CommandException($"The alimap-client of the specified '{appId}' appId does not exist or is undefined.");

            if (context.Expression.Arguments.Length == 1)
            {
                ulong id;

                if (!ulong.TryParse(context.Expression.Arguments[0], out id))
                {
                    throw new CommandException(string.Format("Invalid '{0}' argument value, it must be a integer.", context.Expression.Arguments[0]));
                }

                return(Utility.ExecuteTask(() => client.GetAsync <IDictionary <string, object> >(
                                               context.Expression.Options.GetValue <string>(TABLE_COMMAND_OPTION), id)));
            }

            var result = new IDictionary <string, object> [context.Expression.Arguments.Length];

            for (int i = 0; i < context.Expression.Arguments.Length; i++)
            {
                ulong id;

                if (!ulong.TryParse(context.Expression.Arguments[i], out id))
                {
                    throw new CommandException(string.Format("Invalid '{0}' argument value, it must be a integer.", context.Expression.Arguments[i]));
                }

                result[i] = Utility.ExecuteTask(() => client.GetAsync <IDictionary <string, object> >(
                                                    context.Expression.Options.GetValue <string>(TABLE_COMMAND_OPTION), id));
            }

            return(result);
        }
        protected override object OnExecute(CommandContext context)
        {
            if (context.Expression.Arguments == null || context.Expression.Arguments.Length == 0)
            {
                throw new CommandException("Missing command arguments.");
            }

            //获取地图客户端应用提供程序
            var provider = AlimapCommand.GetProvider(context.CommandNode);

            if (provider == null)
            {
                throw new CommandException("No found the alimap provider for the command.");
            }

            //获取指定的应用编号参数
            var appId = context.Expression.Options.GetValue <string>(APP_COMMAND_OPTION);

            //获取指定应用编号对应的地图客户端
            var client = provider.Get(appId) ??
                         throw new CommandException($"The alimap-client of the specified '{appId}' appId does not exist or is undefined.");

            string mark;

            if (context.Expression.Arguments.Length == 1)
            {
                mark = context.Expression.Arguments[0];
            }
            else
            {
                mark = string.Join(",", context.Expression.Arguments);
            }

            return(Utility.ExecuteTask(() => client.DeleteDataAsync(
                                           context.Expression.Options.GetValue <string>(TABLE_COMMAND_OPTION), mark)));
        }
Beispiel #5
0
        protected override object OnExecute(CommandContext context)
        {
            //获取地图客户端应用提供程序
            var provider = AlimapCommand.GetProvider(context.CommandNode);

            if (provider == null)
            {
                throw new CommandException("No found the alimap provider for the command.");
            }

            //获取指定的应用编号参数
            var appId = context.Expression.Options.GetValue <string>(COMMAND_APP_OPTION);

            //获取指定应用编号对应的地图客户端
            var client = provider.Get(appId) ??
                         throw new CommandException($"The alimap-client of the specified '{appId}' appId does not exist or is undefined.");

            if (context.Expression.Options.Contains(COMMAND_CENTER_OPTION))
            {
                var parts = context.Expression.Options.GetValue <string>(COMMAND_CENTER_OPTION).Split(',', ';', '|');

                if (parts.Length != 2)
                {
                    throw new CommandOptionException(COMMAND_CENTER_OPTION, "Invalid format of the center point.");
                }

                if (!decimal.TryParse(parts[0], out var longitude))
                {
                    throw new CommandOptionException(COMMAND_CENTER_OPTION, "Invalid longitude value of the center point.");
                }

                if (!decimal.TryParse(parts[1], out var latitude))
                {
                    throw new CommandOptionException(COMMAND_CENTER_OPTION, "Invalid latitude value of the center point.");
                }

                return(Utility.ExecuteTask(() => client.SearchAsync <IDictionary <string, object> >(
                                               context.Expression.Options.GetValue <string>(COMMAND_TABLE_OPTION),
                                               longitude, latitude,
                                               context.Expression.Options.GetValue <int>(COMMAND_RADIUS_OPTION),
                                               context.Expression.Arguments.Length > 0 ? context.Expression.Arguments[0] : string.Empty,
                                               context.Expression.Arguments.Length > 1 ? context.Expression.Arguments[1] : string.Empty,
                                               context.Expression.Options.GetValue <int>(COMMAND_PAGEINDEX_OPTION),
                                               context.Expression.Options.GetValue <int>(COMMAND_PAGESIZE_OPTION))));
            }
            else if (context.Expression.Options.Contains(COMMAND_POLYGON_OPTION))
            {
                return(Utility.ExecuteTask(() => client.SearchAsync <IDictionary <string, object> >(
                                               context.Expression.Options.GetValue <string>(COMMAND_TABLE_OPTION),
                                               context.Expression.Options.GetValue <string>(COMMAND_POLYGON_OPTION),
                                               context.Expression.Arguments.Length > 0 ? context.Expression.Arguments[0] : string.Empty,
                                               context.Expression.Arguments.Length > 1 ? context.Expression.Arguments[1] : string.Empty,
                                               context.Expression.Options.GetValue <int>(COMMAND_PAGEINDEX_OPTION),
                                               context.Expression.Options.GetValue <int>(COMMAND_PAGESIZE_OPTION))));
            }
            else
            {
                return(Utility.ExecuteTask(() => client.SearchAsync <IDictionary <string, object> >(
                                               context.Expression.Options.GetValue <string>(COMMAND_TABLE_OPTION),
                                               context.Expression.Arguments.Length > 0 ? context.Expression.Arguments[0] : string.Empty,
                                               context.Expression.Options.GetValue <int>(COMMAND_PAGEINDEX_OPTION),
                                               context.Expression.Options.GetValue <int>(COMMAND_PAGESIZE_OPTION))));
            }
        }