Ejemplo n.º 1
0
        public bool authWithCurrentUser(string password, string uri)
        {
            //get auth token with current user
            request = new RequestEngine();

            string email = this.getEmail();
            string body  = "{\"email\":\"" + email + "\",\"password\":\"" + password + "\"}";


            RequestProperties headers = new RequestProperties();

            headers.setMethod("POST");
            headers.setEndpoint("/api/v/1/user/auth");
            headers.setUri(uri);
            headers.setBody(body);

            request.setHeaders(headers);
            Console.WriteLine("In Auth with current user");
            PlatformResponse <string> result = request.executePost();

            if (result.getError())
            {
                Util.logger("CBUserTask", "User call failed: " + result.getData(), true);
                ClearBlade.setInitError(true);
                Console.WriteLine("Some error in result");
                return(false);
            }
            else
            {
                JObject json = JObject.Parse((string)result.getData());
                setAuthToken((string)json["user_token"]);
                return(true);
            }
        }
Ejemplo n.º 2
0
        public bool logout(string uri)
        {
            request = new RequestEngine();
            Console.WriteLine("Req URI: " + uri);
            RequestProperties headers = new RequestProperties();

            headers.setMethod("POST");
            headers.setEndpoint("/api/v/1/user/logout");
            headers.setUri(uri);


            request.setHeaders(headers);

            PlatformResponse <string> result = request.execute();

            if (result.getError())
            {
                Util.logger("CBUserTask", "User call failed: " + result.getData(), true);
                ClearBlade.setInitError(true);
                return(false);
            }
            else
            {
                setAuthToken(null);
                Console.WriteLine("User Logged out");
                return(true);
            }
        }
Ejemplo n.º 3
0
        public bool authWithAnonUser(string uri, int timeout)
        {
            request = new RequestEngine();
            Console.WriteLine("Req URI: " + uri);
            RequestProperties headers = new RequestProperties();

            headers.setMethod("POST");
            headers.setEndpoint("/api/v/1/user/anon");
            headers.setUri(uri);
            headers.setTimeout(timeout);

            request.setHeaders(headers);

            PlatformResponse <string> result = request.execute();

            if (result.getError())
            {
                Util.logger("CBUserTask", "User call failed: " + result.getData(), true);
                ClearBlade.setInitError(true);
                return(false);
            }
            else
            {
                JObject json = JObject.Parse((string)result.getData());
                setAuthToken((string)json["user_token"]);
                return(true);
            }
        }
        /// <summary>
        /// Execute the request
        /// </summary>
        /// <param name="id">Id of the Platform to retreive.</param>
        /// <returns></returns>
        public PlatformResponse Execute(int id)
        {
            CheckInputValidity(id);
            Log.Information("Retrieving Platform by Id: [{Id}]...", id);

            var platformResponse = new PlatformResponse();

            try
            {
                var platform = Repository.SingleOrDefault(p => p.Id == id);
                if (platform == null)
                {
                    var exception = new Exception($"Could not find Platform with Id: [{id}].");
                    HandleErrors(platformResponse, exception, 404);
                }
                else
                {
                    platformResponse.Platform   = platform;
                    platformResponse.StatusCode = 200;
                    Log.Information("Retrieved [{NewName}] for Id: [{Id}].", platformResponse.Platform.Name, id);
                }
            }
            catch (Exception exception)
            {
                Log.Error("Failed to get Platforms List. [{Message}].", exception.Message);
                HandleErrors(platformResponse, exception);
            }
            return(platformResponse);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Execute the request based on the input properties.
        /// </summary>
        /// <param name="input">Inputs required to update a Platform.</param>
        /// <returns></returns>
        public PlatformResponse Execute(UpdatePlatformNameInput input)
        {
            var platformResponse = new PlatformResponse();

            try
            {
                CheckInputValidity(input);
                Log.Information("Updating name Platform with Id: [{Id}] to [{NewName}]...", input.Id, input.NewName);
                var platformToUpdate = Repository.SingleOrDefault(p => p.Id == input.Id);
                if (platformToUpdate == null)
                {
                    var exception = new Exception($"Failed to find platform with Id: [{input.Id}].");
                    Log.Error(exception, EXCEPTION_MESSAGE_TEMPLATE, exception.Message);
                    HandleErrors(platformResponse, exception, 404);
                }
                else
                {
                    var previousName = platformToUpdate.Name;
                    platformToUpdate.Name = input.NewName;
                    var updatedPlatform = Repository.Update(platformToUpdate);

                    platformResponse.Platform   = updatedPlatform;
                    platformResponse.StatusCode = 200;

                    Log.Information("Updated Platform from [{PreviousName}] to [{NewName}].", previousName, input.NewName);
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to update Platform.");
                HandleErrors(platformResponse, exception);
            }
            return(platformResponse);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Executes the request asynchronously.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <PlatformResponse> ExecuteAsync(int id)
        {
            Log.Information("Retrieving Platform by Id: [{Id}]...", id);

            CheckInputValidity(id);

            var platformResponse = new PlatformResponse();

            try
            {
                var platform = await Repository.SingleOrDefaultAsync(p => p.Id == id);

                if (platform == null)
                {
                    var exception = new Exception($"Could not find Platform with Id: [{id}].");
                    Log.Error(exception, EXCEPTION_MESSAGE_TEMPLATE, exception.Message);
                    HandleErrors(platformResponse, exception, 404);
                }
                else
                {
                    platformResponse.Platform   = platform;
                    platformResponse.StatusCode = 200;
                    Log.Information("Retrieved [{NewName}] for Id: [{Id}].", platformResponse.Platform.Name, id);
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to get Platform with Id: [{Id}].", id);
                HandleErrors(platformResponse, exception);
            }
            return(platformResponse);
        }
Ejemplo n.º 7
0
        public bool executeCode(string serviceName, string parameters)
        {
            request = new RequestEngine();
            Console.WriteLine("Service Name: " + serviceName);
            RequestProperties headers = new RequestProperties();

            headers.setMethod("POST");
            string endpoint = "/api/v/1/code/" + Util.getSystemKey() + "/" + this.serviceName + "";

            headers.setEndpoint(endpoint);
            headers.setBody(parameters);

            request.setHeaders(headers);

            PlatformResponse <string> result = request.executePost();

            if (result.getError())
            {
                Util.logger("CBUserTask", "User call failed: " + result.getData(), true);
                return(false);
            }
            else
            {
                Console.WriteLine((string)result.getData());

                return(true);
            }
        }
        /// <summary>
        /// Executes the request asynchronously based on input properties..
        /// </summary>
        /// <param name="input">Required input properties to create a Platform.</param>
        /// <returns></returns>
        public async Task <PlatformResponse> ExecuteAsync(CreatePlatformInput input)
        {
            var platformResponse = new PlatformResponse();

            try
            {
                Log.Information("Creating Platform [{Name}]...", input?.Name);
                var platformToCreate = Mapper.Map <CreatePlatformInput, Domain.Platform.Entities.Platform>(input);
                var createdPlatform  = await Repository.CreateAsync(platformToCreate);

                if (createdPlatform == null)
                {
                    var exception = new Exception($"Failed to create Platform [{platformToCreate.Name}].");
                    Log.Error(exception, EXCEPTION_MESSAGE_TEMPLATE, exception.Message);
                    HandleErrors(platformResponse, exception);
                }
                else
                {
                    platformResponse.Platform   = createdPlatform;
                    platformResponse.StatusCode = 200;

                    Log.Information("Created Platform [{Name}]", platformResponse.Platform.Name);
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to create Platform [{Name}].", input?.Name);
                HandleErrors(platformResponse, exception);
            }
            return(platformResponse);
        }
        /// <summary>
        /// Execute the Request
        /// </summary>
        /// <param name="id">Id of the Platform to delete.</param>
        /// <returns></returns>
        public PlatformResponse Execute(int id)
        {
            var platformResponse = new PlatformResponse();

            try
            {
                Log.Information("Deleting Platform with Id: [{Id}]...", id);
                CheckInputValidity(id);

                var platform = Repository.SingleOrDefault(p => p.Id == id);
                if (platform == null)
                {
                    var exception = new Exception($"Platform not found for Id: [{id}]");
                    Log.Error(exception, EXCEPTION_MESSAGE_TEMPLATE, exception.Message);
                    HandleErrors(platformResponse, exception, 404);
                }
                else
                {
                    platformResponse.Platform   = platform;
                    platformResponse.StatusCode = 200;

                    Log.Information("Retrieved Platform [{NewName}] for Id: [{Id}].", platform.Name, platform.Id);
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to get Platform with Id: [{Id}]", id);
                HandleErrors(platformResponse, exception);
            }
            return(platformResponse);
        }
Ejemplo n.º 10
0
        public async Task GetByIdAsyncWhenInvalidIdReturnsPlatformNotFoundResponse()
        {
            // Arrange
            var mockUnitOfWork         = GetDefaultUnitOfWorkRepositoryInstance();
            var mockPlatformRepository = GetDefaultPlatformRepositoryInstance();
            var PlatformId             = 1;

            mockPlatformRepository.Setup(r => r.FindById(PlatformId)).Returns(Task.FromResult <Platform>(null));
            var service = new PlatformService(mockPlatformRepository.Object, mockUnitOfWork.Object);

            // Act
            PlatformResponse result = await service.GetByIdAsync(PlatformId);

            var message = result.Message;

            // Assert
            message.Should().Be("Platform not found");
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Execute the Request based on the input propreties.
        /// </summary>
        /// <param name="input">Input properties required to create a Platform.</param>
        /// <returns></returns>
        public PlatformResponse Execute(CreatePlatformInput input)
        {
            var platformResponse = new PlatformResponse();

            try
            {
                Log.Information("Creating Platform [{Name}]...", input?.Name);
                var platformToCreate = Mapper.Map <CreatePlatformInput, Domain.Platform.Entities.Platform>(input);
                var createdPlatform  = Repository.Create(platformToCreate);

                platformResponse.Platform   = createdPlatform;
                platformResponse.StatusCode = 200;

                Log.Information("Created Platform [{Name}]", createdPlatform.Name);
            }
            catch (Exception exception)
            {
                Log.Error(exception, "Failed to create Platform [{Name}]", input?.Name);
                HandleErrors(platformResponse, exception);
            }
            return(platformResponse);
        }
Ejemplo n.º 12
0
        public async Task CreatePlatformAsync_ExpectedResult_VerifiesCall()
        {
            // Arrange
            var platformRequest = new PlatformRequest();
            var expectedResult  = new PlatformResponse();
            var urlSuffix       = UrlProvider.PlatformUrlSuffix;

            _mockAuthorizedRequestsHandler
            .Setup(m => m.PostOrExceptionAsync <PlatformResponse>(urlSuffix, It.IsAny <StringContent>()))
            .ReturnsAsync(expectedResult)
            .Verifiable();
            var sut = CreateSut();

            // Act
            var result = await sut.CreatePlatformAsync(platformRequest);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expectedResult, result);
            _mockAuthorizedRequestsHandler
            .Verify(m => m.PostOrExceptionAsync <PlatformResponse>(urlSuffix, It.IsAny <StringContent>()), Times.Once);
        }
        public async Task CreatePlatformAsync_ExpectedResponse_VerifiesCall()
        {
            // Arrange
            var platformRequest             = new PlatformRequest();
            var expectedResult              = new PlatformResponse();
            var mockPlatformRequestsHandler = new Mock <IPlatformRequestsHandler>();

            mockPlatformRequestsHandler
            .Setup(m => m.CreatePlatformAsync(platformRequest))
            .ReturnsAsync(expectedResult)
            .Verifiable();

            var sut = new TikkieClient(mockPlatformRequestsHandler.Object, Mock.Of <IUserRequestsHandler>(), Mock.Of <IPaymentRequestsHandler>());

            // Act
            var result = await sut.CreatePlatformAsync(platformRequest);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(expectedResult, result);
            mockPlatformRequestsHandler
            .Verify(m => m.CreatePlatformAsync(platformRequest), Times.Once);
        }
Ejemplo n.º 14
0
 public Task InvokeAsync(HttpContext context, OpenRepository repository)
 {
     if (context.Request.Path.Value.StartsWith("/open/"))
     {
         var res = new PlatformResponse();
         if (!context.Request.Query.ContainsKey("appid"))
         {
             return(JsonAsync(context, res.RenderFailure("APP ID error"), 404));
         }
         var appid = context.Request.Query["appid"];
         if (string.IsNullOrWhiteSpace(appid))
         {
             return(JsonAsync(context, res.RenderFailure("APP ID error"), 404));
         }
         var model = repository.GetByAppId(appid);
         if (model == null)
         {
             return(JsonAsync(context, res.RenderFailure("APP ID error"), 404));
         }
         if (!model.VerifyRule(context.Request.Path.Value))
         {
             return(JsonAsync(context, res.RenderFailure("The URL you requested was disabled"), 404));
         }
         if (!model.VerifyRest(context))
         {
             return(JsonAsync(context, res.RenderFailure("sign or encrypt error"), 404));
         }
         res.Platform = model;
         context.Items.Add(RESPONSE_KEY, res);
     }
     else
     {
         context.Items.Add(RESPONSE_KEY, new JsonResponse());
     }
     return(_next.Invoke(context));
 }
Ejemplo n.º 15
0
        public async Task <IPlatformResponse <T> > Request <T>(ApiEndpoint endpoint, string relativePath, CancellationToken cancellationToken, IProgress <ISDKProgress> progress = null, HttpMethod method = null, string body = null, byte[] rawData = null, string contentType = "application/json", IDictionary <string, string> headers = null)
        {
            var monitor = _container.Resolve <IProgressMonitor>();

            if (progress != null)
            {
                monitor.Progress = progress;
                monitor.Start();
            }
            monitor.Report("Initializing Http Request", 0);

            var _method = HttpMethod.Get;

            if (method != null)
            {
                _method = method;
            }

            var platformResponse = new PlatformResponse <T>
            {
                Success = false
            };

            if (headers != null && headers.Count > 0)
            {
                if (headers.ContainsKey("Authorization"))
                {
                    var h = headers["Authorization"];
                    if (h.IndexOf(" ", StringComparison.Ordinal) > 0)
                    {
                        var type  = h.Substring(0, h.IndexOf(" ", StringComparison.Ordinal)).Trim();
                        var token = h.Substring(h.IndexOf(" ", StringComparison.Ordinal)).Trim();
                        AuthorizationType           = type;
                        Authorization.MojioApiToken = token;
                        headers.Remove("Authorization");
                    }
                }
            }

            HttpClient client;

            switch (endpoint)
            {
            case ApiEndpoint.Accounts:
                client = AccountsClient(contentType);
                break;

            case ApiEndpoint.Images:
                client = ImagesClient(contentType);
                break;

            case ApiEndpoint.Push:
                client = PushClient(contentType);
                break;

            default:
                client = ApiClient(contentType);
                break;
            }

            var request = new HttpRequestMessage(_method, relativePath);

            monitor.Report("Setting HttpContent Body", 0.1);

            if (!string.IsNullOrEmpty(body))
            {
                Debug.WriteLine($"Request Content:{body}");
                request.Content = new StringContent(body, Encoding.UTF8, contentType);
            }

            monitor.Report("Set HttpContent Body", 0.2);

            if (rawData != null)
            {
                monitor.Report("Creating MultiPart Form Content", 0.2);

                var requestContent = new MultipartFormDataContent(); //"Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture));

                var imageContent = new ByteArrayContent(rawData);
                var fileName     = "image.png";
                var type         = "image/png";

                if (headers != null && headers.Count > 0)
                {
                    type     = (from x in headers where x.Key == "Content-Type" select x.Value).FirstOrDefault();
                    fileName = (from x in headers where x.Key == "Filename" select x.Value).FirstOrDefault();
                    if (!string.IsNullOrEmpty(type))
                    {
                        headers.Remove("Content-Type");
                    }
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        headers.Remove("Filename");
                    }
                }

                imageContent.Headers.ContentDisposition          = ContentDispositionHeaderValue.Parse("form-data");
                imageContent.Headers.ContentDisposition.Name     = "\"file\"";
                imageContent.Headers.ContentDisposition.FileName = fileName;
                imageContent.Headers.ContentDisposition.Size     = rawData.Length;
                imageContent.Headers.ContentType = MediaTypeHeaderValue.Parse(type);

                requestContent.Add(imageContent);
                request.Content = requestContent;

                monitor.Report("Created MultiPart Form Content", 0.3);
            }
            monitor.Report("Adding Headers", 0.4);

            if (headers != null && headers.Count > 0)
            {
                foreach (var h in headers)
                {
                    request.Headers.Add(h.Key, h.Value);
                }
            }
            request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip"));
            request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("deflate"));

            if (DisableSessionAffinity)
            {
                request.Headers.Add("Arr-Disable-Session-Affinity", "True");
            }

            monitor.Report("Added Headers", 0.4);

            if (cancellationToken.IsCancellationRequested)
            {
                platformResponse.WasCancelled = true;
                monitor.Report("Operation Cancelled", 0.5);
                return(platformResponse);
            }
            monitor.Report("Sending Http Request", 0.6);
            var requestSw = new Stopwatch();

            requestSw.Start();
            Debug.WriteLine($"Pre-flight request URL: {request.RequestUri}");

            using (var sendResult = await client.SendAsync(request, cancellationToken))
            {
                platformResponse.RequestDurationMS = requestSw.ElapsedMilliseconds;
                monitor.Report("Received Response from Http Request", 0.7);
                requestSw.Stop();

                platformResponse.Url = sendResult.RequestMessage.RequestUri.ToString();
                Debug.WriteLine($"Post-flight request URL: {platformResponse.Url}");
                platformResponse.Timestamp      = DateTimeOffset.UtcNow;
                platformResponse.HttpStatusCode = sendResult.StatusCode;
                Debug.WriteLine($"Status Code: {platformResponse.HttpStatusCode}");

                try
                {
                    var cookie = (from h in sendResult.Headers where h.Key == "Set-Cookie" select h.Value.FirstOrDefault()).FirstOrDefault();
                    if (cookie != null)
                    {
                        platformResponse.ARRAffinityInstance = (from c in cookie.Split(';') where c.StartsWith("") select c.Split('=').LastOrDefault()).FirstOrDefault();
                    }
                }
                catch (Exception)
                {
                }

                if (sendResult.IsSuccessStatusCode)
                {
                    monitor.Report("Received Successful StatusCode", 0.8);
                    if (cancellationToken.IsCancellationRequested)
                    {
                        platformResponse.WasCancelled = true;
                        monitor.Report("Operation Cancelled", 0.9);
                        return(platformResponse);
                    }

                    monitor.Report("Reading data from Response", 0.9);
                    var json = await sendResult.Content.ReadAsStringAsync();

                    monitor.Report("Deserializing data", 0.95);
                    try
                    {
                        platformResponse.Response = _serializer.Deserialize <T>(json);
                        if (platformResponse.Response != null)
                        {
                            platformResponse.Success = true;
                        }
                    }
                    catch (Exception e)
                    {
                        _log.Error(e, "Invalid response from the server. Received:{0}, expected:{1}.  Will continue.", json, typeof(T));
                    }

                    if (typeof(T) == typeof(IAuthorization))
                    {
                        monitor.Report("Setting internal auth token", 0.99);
                        Authorization.MojioApiToken = (platformResponse.Response as IAuthorization).AccessToken;
                        _container.RegisterInstance(Authorization, "Session");
                    }
                }
                else
                {
                    monitor.Report("Received Unsuccessful StatusCode", 0.8);

                    platformResponse.Success      = false;
                    platformResponse.ErrorCode    = sendResult.StatusCode.ToString();
                    platformResponse.ErrorMessage = sendResult.ReasonPhrase;

                    monitor.Report("Reading data from Response", 0.9);
                    var content = await sendResult.Content.ReadAsStringAsync();

                    Debug.WriteLine(content);
                    Debug.WriteLine(_serializer.SerializeToString(request));

                    if (!string.IsNullOrEmpty(content))
                    {
                        try
                        {
                            monitor.Report("Deserializing data", 0.95);
                            dynamic result = _serializer.Deserialize(content);
                            if (result != null)
                            {
                                if (result.Message != null)
                                {
                                    platformResponse.ErrorMessage = platformResponse.ErrorMessage + ", " + result.Message;
                                }
                                else
                                {
                                    platformResponse.ErrorMessage = platformResponse.ErrorMessage + ", " + content;
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            monitor.Report("Finished", 1);

            monitor.Stop();

            return(platformResponse);
        }
Ejemplo n.º 16
0
        public async static void init()
        {
            try
            {
                Mac = GetMACAddress();

                #region Platforms

                var dataEntity = LiteDBHelper.Load <DataModel>().FirstOrDefault() ?? new DataModel()
                {
                    Id = 1, ScrapGuid = "", ScrapEmail = ""
                };
                //var burl = await GetGame("¤", 1, false, dataEntity.ScrapGuid);
                //BaseUrls = burl.BaseUrls;

                var tmp = await LiteDBHelper.LoadAsync <PlatformResponse>();

                platforms = tmp.FirstOrDefault()?.data.Platforms.Select(p => p) ?? null;
                platforms = null;
                Dictionary <int, List <string> > extensions;
                extensions = await Task.Run(() => JsonHandler.DownloadSerializedJsonData <EmuExtensionsEntity>("http://timeonline.se/RGHandler/EmulatorSupportList.json").Extensions.ToDictionary(em => em.id, em => em.extensoins));

                if (platforms == null)
                {
                    PlatformResponse p = null;
                    var headers        = new Dictionary <string, string>();

                    headers.Add("secret", RGHSettings.ProgGuid);
                    headers.Add("version", RGHSettings.Version);
                    await Task.Run(() => p = JsonHandler.DownloadSerializedJsonData <PlatformResponse>(PlatformApiPath, headers));

                    if (p != null)
                    {
                        await Task.Run(() =>
                        {
                            platforms = p.data?.Platforms;/*?.Select(i => i.Value);*/

                            foreach (var pl in platforms)
                            {
                                pl.Extensions = extensions.ContainsKey(pl.Id) && !extensions[pl.Id].Any(s => s == "?") ? extensions[pl.Id] : new List <string>();
                                var icon      = pl.Icon;
                                var url       = PlatformImagePath + icon;
                                if (LiteDBHelper.FileExists("platform/images", icon))
                                {
                                    continue;
                                }
                                using (WebClient client = new WebClient())
                                {
                                    byte[] data = client.DownloadData(url);
                                    using (MemoryStream mem = new MemoryStream(data))
                                    {
                                        LiteDBHelper.SaveFile("platform/images", icon, mem);
                                    }
                                }
                            }
                        });

                        LiteDBHelper.Save(p);
                    }
                }
                else
                {
                    foreach (var pl in platforms)
                    {
                        pl.Extensions = extensions.ContainsKey(pl.Id) && !extensions[pl.Id].Any(s => s == "?") ? extensions[pl.Id] : new List <string>();
                    }
                }

                foreach (var pl in platforms)
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        LiteDBHelper.LoadFile("platform/images", pl.Icon, mem);
                        PlatformModels.Add(new PlatformModel(pl, LoadImage(mem)));
                    }
                }

                #endregion Platforms
            }
            catch (Exception ex)
            {
                ErrorHandler.Error(ex);
                throw;
            }
        }
Ejemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // HttpRequest를 이용하여 PlatformRequest 생성
        PlatformRequest req = new PlatformRequest(Request.InputStream);

        // 데이터 수신
        req.ReceiveData();

        // 수신받은 데이터 획득
        PlatformData reqData    = req.GetData();
        VariableList reqVarList = reqData.GetVariableList();

        // 부서명 획득
        string name = reqVarList.GetString("name");

        // 송신할 데이터 생성
        PlatformData resData    = new PlatformData();
        VariableList resVarList = resData.GetVariableList();

        // 부서별 인원을 저장할 DataSet 생성
        DataSet employees = new DataSet("employees");

        // DataSet에 열(column) 추가
        employees.AddColumn(new ColumnHeader("name", DataTypes.STRING, 8));
        employees.AddColumn(new ColumnHeader("jobTitle", DataTypes.STRING));
        employees.AddColumn(new ColumnHeader("number", DataTypes.INT));
        employees.AddColumn(new ColumnHeader("manager", DataTypes.BOOLEAN));

        // 부서별 인원 데이터 추가
        if ("R&D Center".Equals(name))
        {
            // 행(row) 추가
            int row = employees.NewRow();
            // 추가된 행(row)의 데이터 설정
            employees.Set(row, "name", "John Jones");
            employees.Set(row, "jobTitle", "developer");
            employees.Set(row, "number", 1234);
            employees.Set(row, "manager", false);
            // ...
            // 정상 수행
            resData.AddDataSet(employees);
            resVarList.Add("ERROR_CODE", 200);
        }
        else if ("Quality Assurance".Equals(name))
        {
            // 행(row) 추가
            int row = employees.NewRow();
            // 추가된 행(row)의 데이터 설정
            employees.Set(row, "name", "Tom Glover");
            employees.Set(row, "jobTitle", "manager");
            employees.Set(row, "number", 9876);
            employees.Set(row, "manager", true);
            // ...
            // 정상 수행
            resData.AddDataSet(employees);
            resVarList.Add("ERROR_CODE", 200);
        }
        else
        {
            // 오류 발생
            resVarList.Add("ERROR_CODE", 500);
        }
        // HttpServletResponse를 이용하여 PlatformResponse 생성
        PlatformResponse res = new PlatformResponse(Response.OutputStream);

        res.SetData(resData);
        // 데이터 송신
        res.SendData();
    }