コード例 #1
0
        //public void TestConnection()
        //{

        //    logger.warning("Enter TestConnection Method");
        //    try
        //    {
        //        client = new CoreClient();
        //        TestConnectionRequest request = new TestConnectionRequest();
        //        TestConnectionResponse response;
        //        response = client.TestConnection(request);
        //        Console.WriteLine("Testing Connection Result : " + response.TestConnectionResult);
        //        logger.warning("Exit TestConnection Method");
        //        Console.ReadLine();

        //    }
        //    catch (FaultException<ConsoleTest.CoreService.Bug> Fex)
        //    {
        //        logger.error("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
        //        logger.error("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
        //        Console.ReadLine();
        //    }
        //    finally
        //    {
        //        if (null != client)
        //        {
        //            client.Close();
        //        }
        //    }

        //}


        public void SaveUser()
        {
            logger.warning("Enter TestConnection Method");
            try
            {
                WebClient client = new WebClient();
                client.Headers["Content-type"] = "application/json";
                ConsoleTest.Models.userItem item = new ConsoleTest.Models.userItem();
                item.userName    = "******";
                item.userAddress = "scdscscsdac";
                item.email       = "*****@*****.**";
                item.date        = DateTime.Now;

                MemoryStream stream = new MemoryStream();
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ConsoleTest.Models.userItem));
                serializer.WriteObject(stream, item);
                byte[] data = client.UploadData("http://127.0.0.1/Core.svc/SaveUser", "POST", stream.ToArray());
                stream     = new MemoryStream(data);
                serializer = new DataContractJsonSerializer(typeof(int));
                int result = (int)serializer.ReadObject(stream);
                Console.WriteLine("Save User Result : " + result);
                logger.warning("Exit TestConnection Method");
                Console.ReadLine();
            }
            catch (FaultException <ConsoleTest.CoreService.Bug> Fex)
            {
                logger.error("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
                logger.error("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
                Console.ReadLine();
            }
            finally
            {
                if (null != client)
                {
                    client.Close();
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: harjoben/socialCopsDev
        //public void TestConnection()
        //{
        //    logger.warning("Enter TestConnection Method");
        //    try
        //    {
        //        client = new CoreClient();
        //        TestConnectionRequest request = new TestConnectionRequest();
        //        TestConnectionResponse response;
        //        response = client.TestConnection(request);
        //        Console.WriteLine("Testing Connection Result : " + response.TestConnectionResult);
        //        logger.warning("Exit TestConnection Method");
        //        Console.ReadLine();
        //    }
        //    catch (FaultException<ConsoleTest.CoreService.Bug> Fex)
        //    {
        //        logger.error("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
        //        logger.error("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
        //        Console.ReadLine();
        //    }
        //    finally
        //    {
        //        if (null != client)
        //        {
        //            client.Close();
        //        }
        //    }
        //}
        public void SaveUser()
        {
            logger.warning("Enter TestConnection Method");
            try
            {
                WebClient client = new WebClient();
                client.Headers["Content-type"] = "application/json";
                ConsoleTest.Models.userItem item = new ConsoleTest.Models.userItem();
                item.userName = "******";
                item.userAddress = "scdscscsdac";
                item.email = "*****@*****.**";
                item.date = DateTime.Now;

                MemoryStream stream = new MemoryStream();
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(ConsoleTest.Models.userItem));
                serializer.WriteObject(stream, item);
                byte[] data = client.UploadData("http://127.0.0.1/Core.svc/SaveUser", "POST", stream.ToArray());
                stream = new MemoryStream(data);
                serializer = new DataContractJsonSerializer(typeof(int));
                int result = (int)serializer.ReadObject(stream);
                Console.WriteLine("Save User Result : " + result);
                logger.warning("Exit TestConnection Method");
                Console.ReadLine();
            }
            catch (FaultException<ConsoleTest.CoreService.Bug> Fex)
            {
                logger.error("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
                logger.error("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
                Console.ReadLine();
            }
            finally
            {
                if (null != client)
                {
                    client.Close();
                }
            }
        }
コード例 #3
0
        public userItem GetCopy()
        {
            userItem copy = (userItem)this.MemberwiseClone();

            return(copy);
        }