public void descricaoDesejo(long codigo)
        {
            JavaScriptSerializer js = new JavaScriptSerializer();
            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            HelloWorldData data = new HelloWorldData();
            //data.Message = "HelloWorld";
            


            Desejo desejo = new Desejo();
            desejo.IdDesejo = codigo;
            ArrayList alTemp = DataAccess.queryDesejo(desejo, null);
            if (alTemp.Count == 0)
            {
                //return "Nenhum desejo encontrado.";
                data.Message = "Nenhum desejo encontrado.";                
            }
            else
            {
                desejo = (Desejo)alTemp[0];
                //return desejo.DescricaoCurta;
                data.Message = desejo.DescricaoCurta;
            }
            Context.Response.Write(js.Serialize(data));
        }//descricaoDesejo()
    public void IsMethodExistsName(string serviceName, string methodName)
    {
        Context.Response.Clear();
        Context.Response.ContentType = "application/json";

        using (MySqlConnection connection = new MySqlConnection(connectionString))
        {
            string       queryString = "SELECT COUNT(1) FROM service inner join methods on service.id = methods.serviceid WHERE service.name = \'" + serviceName + "\' AND methods.methodname = \'" + methodName + "\';";
            MySqlCommand command     = new MySqlCommand(queryString, connection);
            try
            {
                command.Connection.Open();


                JavaScriptSerializer js = new JavaScriptSerializer();
                Context.Response.Clear();
                Context.Response.ContentType = "application/json";
                HelloWorldData data = new HelloWorldData();
                data.Message = Convert.ToInt32(command.ExecuteScalar()) == 1;
                Context.Response.Write(js.Serialize(data));
                return;
            }
            catch
            {
                return;
            }
        }
    }
Example #3
0
        private async void GetHelloWorldDataButtonOnClick(object sender, EventArgs eventArgs)
        {
            if (_getHelloTextEdit.Text == string.Empty)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                var alertDialog = builder.Create();
                alertDialog.SetTitle("Пустое поле");
                alertDialog.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                alertDialog.SetMessage("Поле не может быть пустым");
                alertDialog.SetButton("OK", (s, ev) =>
                {
                    _getHelloTextEdit.RequestFocus();
                });
                alertDialog.Show();
            }
            else
            {
                var data = new HelloWorldData {Name = _getHelloTextEdit.Text, SayHello = true};
                _getHelloWorldDataTextView.Text = "Waiting for WCF...";
                var taskResult = HelloWorldAgent.DoGetHelloAsync(data);
                 await taskResult;

                if (taskResult.IsCompleted)
                {
                    _getHelloWorldDataTextView.Text = taskResult.Result.Name;
                    _getHelloTextEdit.Text = string.Empty;
                }
            }

        }
Example #4
0
        private void GetHelloWorldDataButtonOnClick(object sender, EventArgs eventArgs)
        {
            HelloWorldData data = new HelloWorldData {
                Name = "Mr. Chad", SayHello = true
            };

            _getHelloWorldDataTextView.Text = "Waiting for WCF...";
            _client.GetHelloDataAsync(data);
        }
Example #5
0
        private void GetHelloWorldDataButtonTouchUpInside(object sender, EventArgs e)
        {
            getHelloWorldDataText.Text = "Waiting WCF...";
            HelloWorldData data = new HelloWorldData {
                Name = "Mr. Chad", SayHello = true
            };

            _client.GetHelloDataAsync(data);
        }
Example #6
0
        /// <summary>
        ///     Gets data from the web API
        /// </summary>
        /// <returns>A HelloWorldData model</returns>
        public HelloWorldData GetHelloWorldData()
        {
            HelloWorldData helloWorldData = null;

            // Set the URL for the request
            this.restClient.BaseUrl = this.uriService.GetUri(this.appSettings.Get(AppSettingsKeys.HelloWorldApiUrlKey));

            // Setup the request
            this.restRequest.Resource = "helloworld";
            this.restRequest.Method   = Method.GET;

            // Clear the request parameters
            this.restRequest.Parameters.Clear();

            // Execute the call and get the response
            var helloWorldDataResponse = this.restClient.Execute <HelloWorldData>(this.restRequest);

            // Check for data in the response
            if (helloWorldDataResponse != null)
            {
                // Check if any actual data was returned
                if (helloWorldDataResponse.Data != null)
                {
                    helloWorldData = helloWorldDataResponse.Data;
                }
                else
                {
                    var errorMessage = "Error in RestSharp, most likely in endpoint URL." + " Error message: "
                                       + helloWorldDataResponse.ErrorMessage + " HTTP Status Code: "
                                       + helloWorldDataResponse.StatusCode + " HTTP Status Description: "
                                       + helloWorldDataResponse.StatusDescription;

                    // Check for existing exception
                    if (helloWorldDataResponse.ErrorMessage != null && helloWorldDataResponse.ErrorException != null)
                    {
                        // Log an informative exception including the RestSharp exception
                        this.logger.Error(errorMessage, null, helloWorldDataResponse.ErrorException);
                    }
                    else
                    {
                        // Log an informative exception including the RestSharp content
                        this.logger.Error(errorMessage, null, new Exception(helloWorldDataResponse.Content));
                    }
                }
            }
            else
            {
                // Log the exception
                const string ErrorMessage =
                    "Did not get any response from the Hello World Web Api for the Method: GET /helloworlddata";

                this.logger.Error(ErrorMessage, null, new Exception(ErrorMessage));
            }

            return(helloWorldData);
        }
Example #7
0
    //      [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]

    public void HelloWorld()
    {
        JavaScriptSerializer js = new JavaScriptSerializer();

        Context.Response.Clear();
        Context.Response.ContentType = "application/json";
        HelloWorldData data = new HelloWorldData();

        data.Message = "HelloWorld";
        Context.Response.Write(js.Serialize(data));
    }
Example #8
0
    public static void CreateHelloWorld(this UnitFactory factory)
    {
        var requiredModuleGroup = WorldManager.Instance.Module
                                  .TagToModuleGroupType(GameConstant.HELLO_WORLD_GROUP_TYPE);
        var unit = factory.CreateUnit(requiredModuleGroup);

        var helloWorldData = new HelloWorldData();

        helloWorldData.helloWorld = "Hello World!";
        unit.AddData(helloWorldData);

        var unitData = unit.GetData <UnitData>();

        unitData.stateTypeProperty.Value = UnitStateType.Init;
    }
Example #9
0
        public static async Task<HelloWorldData> DoGetHelloAsync(HelloWorldData helloWorldData)
        {
            try
            {
           

                dynamic res = Task<HelloWorldData>.Factory.FromAsync(_client.BeginGetHelloData,
                    _client.EndGetHelloData, helloWorldData, null);
                await res;
                return res.Result;
            }
            catch (Exception)
            {
                
                throw;
            }
        }
Example #10
0
        static void Main(string[] args)
        {
            HelloWorldData newObject = new HelloWorldData("Hello World");

            //Method use to access property value
            Console.WriteLine(newObject.getName());

            //Direct access to public property
            Console.WriteLine(newObject.Name);



            //"delegate" keyword example
            //create delegate instances for multicast
            NumberChanger nc;
            NumberChanger nc1 = new NumberChanger(AddNum);
            NumberChanger nc2 = new NumberChanger(MultNum);

            nc  = nc1;
            nc += nc2;

            //calling the methods using the delegate objects
            nc1(25);
            Console.WriteLine("Value of Num: {0}", getNum());
            nc2(5);
            Console.WriteLine("Value of Num: {0}", getNum());

            //calling multicast
            nc(5);
            Console.WriteLine("Value of Num: {0}", getNum());



            //lambda expression
            NumberChanger ncAddWithLambda = (x) => { x += x; return(x); };

            Console.WriteLine("Value of ncAddWithLambda: {0}", ncAddWithLambda(10));


            //"using" keyword example
            Console.WriteLine(getContentFromFile(@"C:\Mufaddal\DotNetvsJAVA\Examples\TextDemo.txt"));



            Console.Read();
        }
Example #11
0
        private static void Main(string[] args)
        {
            using (HelloWorldServiceClient client = new HelloWorldServiceClient())
            {
                string result = client.SayHelloTo("Kilroy");
                Console.WriteLine(result);
                Debug.WriteLine(result);

                HelloWorldData data = new HelloWorldData
                {
                    SayHello = true,
                    Name     = "Mr. Chad"
                };
                HelloWorldData newData = client.GetHelloData(data);
                Console.WriteLine(newData.Name);
                Debug.WriteLine(newData.Name);

                Console.ReadKey();
            }
        }
Example #12
0
        private static void Main(string[] args)
        {
            using (HelloWorldServiceClient client = new HelloWorldServiceClient())
            {
                string result = client.SayHelloTo("Kilroy");
                Console.WriteLine(result);
                Debug.WriteLine(result);

                HelloWorldData data = new HelloWorldData
                                          {
                                              SayHello = true,
                                              Name = "Mr. Chad"
                                          };
                HelloWorldData newData = client.GetHelloData(data);
                Console.WriteLine(newData.Name);
                Debug.WriteLine(newData.Name);

                Console.ReadKey();
            }
        }
        public void UnitTestHelloWorldConsoleAppRunNormalDataNullDataNullErrorException()
        {
            // Create return models for dependencies
            const string         WebApiIUrl        = "http://www.somesiteheretesting.com";
            var                  uri               = new Uri(WebApiIUrl);
            var                  mockParameters    = new Mock <List <Parameter> >();
            var                  mockRestResponse  = new Mock <IRestResponse <HelloWorldData> >();
            HelloWorldData       helloWorldData    = null;
            const string         ErrorMessage      = "Error Message";
            const HttpStatusCode StatusCode        = HttpStatusCode.InternalServerError;
            const string         StatusDescription = "Status Description";
            Exception            errorException    = null;
            const string         ProfileContent    = "Content here";

            var errorMessage = "Error in RestSharp, most likely in endpoint URL."
                               + " Error message: " + ErrorMessage
                               + " HTTP Status Code: " + StatusCode
                               + " HTTP Status Description: " + StatusDescription;

            // Set up dependencies
            this.appSettingsMock.Setup(m => m.Get(AppSettingsKeys.HelloWorldApiUrlKey)).Returns(WebApiIUrl);
            this.uriServiceMock.Setup(m => m.GetUri(WebApiIUrl)).Returns(uri);
            this.restRequestMock.Setup(m => m.Parameters).Returns(mockParameters.Object);
            this.restClientMock.Setup(m => m.Execute <HelloWorldData>(It.IsAny <IRestRequest>())).Returns(mockRestResponse.Object);
            mockRestResponse.Setup(m => m.Data).Returns(helloWorldData);
            mockRestResponse.Setup(m => m.ErrorMessage).Returns(ErrorMessage);
            mockRestResponse.Setup(m => m.StatusCode).Returns(StatusCode);
            mockRestResponse.Setup(m => m.StatusDescription).Returns(StatusDescription);
            mockRestResponse.Setup(m => m.ErrorException).Returns(errorException);
            mockRestResponse.Setup(m => m.Content).Returns(ProfileContent);

            // Call the method to test
            var response = this.helleHelloWorldWebService.GetHelloWorldData();

            // Check values
            Assert.IsNull(response);
            Assert.AreEqual(this.logMessageList.Count, 1);
            Assert.AreEqual(this.logMessageList[0], errorMessage);
            Assert.AreEqual(this.exceptionList.Count, 1);
            Assert.AreEqual(this.exceptionList[0].Message, ProfileContent);
        }
        async void GetHelloWorldDataButton_TouchUpInside(object sender, EventArgs e)
        {
            getHelloWorldDataText.Text = "Waiting for WCF...";
            var data = new HelloWorldData
            {
                Name     = "Mr. Chad",
                SayHello = true
            };

            HelloWorldData result;

            try
            {
                result = await _client.GetHelloDataAsync(data);

                getHelloWorldDataText.Text = result.Name;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public void DoubleCheckStreet2(string prefixText)
        {
            Street2 = prefixText;

            JavaScriptSerializer js = new JavaScriptSerializer();
            Context.Response.Clear();
            Context.Response.ContentType = "application/json";
            HelloWorldData hdata = new HelloWorldData();
            //string prefixText = "Лен";

            List<string> ajaxDataCollection = new List<string>();

            IgnoreBadCertificates();

            string sURL; string sParams;

            sURL = "get_addresses_like";

            string name = Uri.EscapeDataString(prefixText);

            sParams = "get_streets=true&get_points=false&get_houses=false&street=" + name;

            WebRequest wrGETURL;

            sURL = "https://188.17.142.18:8089/common_api/1.0/" + sURL;
            if (sParams.Length > 0) sURL = sURL + "?" + sParams;
            wrGETURL = WebRequest.Create(sURL);

            MD5 md5Hash = MD5.Create();
            string hash = GetMd5Hash(md5Hash, sParams + "9028165499");

            var data = Encoding.ASCII.GetBytes(sParams);

            wrGETURL.Headers.Add("Signature", GetMd5Hash(md5Hash, sParams + "9028165499"));

            Stream objStream;
            objStream = wrGETURL.GetResponse().GetResponseStream();

            StreamReader objReader = new StreamReader(objStream);

            string sLine = "";
            int i = 0;

            string response = "";
            while (sLine != null)
            {
                i++;
                sLine = objReader.ReadLine();
                if (sLine != null)
                    response = response + sLine;
            }

            var results = JsonConvert.DeserializeObject<dynamic>(response);

            var sdata = results.data.addresses;

            hdata.Message = "{result:N}";

            if (sdata != null)
                foreach (var item in sdata)
                {
                    hdata.Message = "{result:Y}";
                }
            //if (ajaxDataCollection.Count == 0) ajaxDataCollection.Add("Улица не найдена");

            //var dataz = new { Greeting = "Hello", Name = "CCCC" };

            string ccc = js.Serialize(hdata);

            Context.Response.Write(js.Serialize(hdata));

            // return js.Serialize(dataz);
        }