示例#1
0
        static void Main(string[] args)
        {
            ServicePointManager.DefaultConnectionLimit = 100;
            //DemoClient.Init(new RabbitMissionConfig("amqp://127.0.0.1", "http://localhost:9008/", serializerType: SerializerType.MessagePack), new Logger());
            DemoClient.Init("rabbit", new Logger());
            var j = 0;

            while (j < 10000)
            {
                j++;
                var list  = new List <Task>();
                var watch = new Stopwatch();
                watch.Start();
                for (var i = 0; i < 10000; i++)
                {
                    var request = new DemoRequest
                    {
                        OrderNo = i.ToString(),
                    };
                    list.Add(Task.Run(async() => await DemoClient.Instace.DemoInvoke(request)));
                }

                Task.WaitAll(list.ToArray());
                watch.Stop();
                Console.WriteLine($"第{j}次,1000条请求耗时:{watch.ElapsedMilliseconds}ms");

                Task.Delay(200).Wait();
            }

            Console.WriteLine("一万次请求完成,按回车退出!");
            Console.ReadLine();
            DemoClient.Stop();
        }
示例#2
0
        static void Main(string[] args)
        {
            //ServiceReference1.DemoServiceClient client = new ServiceReference1.DemoServiceClient();
            DemoRequest dr = new DemoRequest()
            {
                Foo = "A",
                Bar = "B"
            };


            //DemoResponse result = client.DoTheThing(dr);
            //Console.WriteLine($"{result.Baz}\t{result.Quux}");

            ChannelFactory <IDemoService> factory = new ChannelFactory <IDemoService>("test");
            IDemoService service = factory.CreateChannel();

            try
            {
                var result = service.DoTheThing(dr);
                Console.WriteLine($"{result.Baz}\t{result.Quux}");
            }
            catch (Exception)
            {
                throw;
            }



            Console.ReadLine();
        }
示例#3
0
 public override Task <DemoResponse> Demo(DemoRequest request, ServerCallContext context)
 {
     return(Task.FromResult(new DemoResponse
     {
         Id = 2
     }));
 }
示例#4
0
        static void Main(string[] args)
        {
            //DemoClient.Init(new RabbitMissionConfig("amqp://127.0.0.1", "http://localhost:9008/", serializerType: SerializerType.MessagePack), new Logger());
            DemoClient.Init("rabbit", new Logger());
            //ThreadPool.SetMaxThreads(24, 100);
            var j = 0;

            while (j < 10000)
            {
                j++;
                var list  = new List <Task>();
                var watch = new Stopwatch();
                watch.Start();
                for (var i = 0; i < 1000; i++)
                {
                    var request = new DemoRequest
                    {
                        OrderNo = i.ToString(),
                    };
                    //ThreadPool.QueueUserWorkItem(DoWork,request);
                    list.Add(Task.Factory.StartNew(async() => await DemoClient.Instace.DemoInvoke(request)));
                    //list.Add(DemoClient.Instace.DemoInvoke(request));
                }

                Task.WaitAll(list.ToArray());
                watch.Stop();
                Console.WriteLine($"第{j}次,1000条请求耗时:{watch.ElapsedMilliseconds}ms");

                Task.Delay(200).Wait();
            }

            Console.WriteLine("一万次请求完成,按回车退出!");
            Console.ReadLine();
            DemoClient.Stop();
        }
示例#5
0
 public DemoResponse GetDemo(DemoRequest request)
 {
     return(new DemoResponse()
     {
         Id = request.Id, Description = "a return model", Name = request.Name + " hello"
     });
 }
示例#6
0
        static void Main(string[] args)
        {
            var bus = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri("rabbitmq://192.168.17.129"), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });
            });

            bus.Start();

            var message = new DemoRequest
            {
                Id      = 1,
                Content = "MassTransit.RequestResponse.Demo",
            };

            var address        = new Uri("rabbitmq://192.168.17.129/rabbitmq.demo.masstransit.requestresponse");
            var requestTimeout = TimeSpan.FromSeconds(30);
            var client         = new MessageRequestClient <DemoRequest, DemoResponse>(bus, address, requestTimeout);
            var result         = client.Request(message).GetAwaiter().GetResult();

            Console.WriteLine($"Response message: Code={result.ResultCode}, RequestId={result.RequestId}");

            bus.Stop();

            Console.WriteLine(" Press [enter] to exit request console.");
            Console.ReadLine();
        }
        public object GetDemoName()
        {
            var req  = new DemoRequest();
            var resp = req.RunRequest();

            return(resp);
        }
示例#8
0
        public DemoResponse DoTheThing(DemoRequest request)
        {
            request.Bar += "-Proxied";
            IDemoService service = factory.CreateChannel();

            using (OperationContextScope scope = new OperationContextScope((IContextChannel)service))
            {
                WebOperationContext woc = WebOperationContext.Current;
                woc.OutgoingRequest.ContentType = "application/json; charset=utf-8";
                var result = service.DoTheThing(request);
                try
                {
                    return(result);
                }
                finally
                {
                    if (result is System.ServiceModel.ICommunicationObject client)
                    {
                        if (client.State == System.ServiceModel.CommunicationState.Faulted)
                        {
                            client.Abort();
                        }
                        else
                        {
                            client.Close();
                        }
                    }
                }
            }
        }
 public int GetOrder(DemoRequest request)
 {
     Container.Server.AsyncExecuteMission(request, Task.FromResult(new DemoResponse
     {
         Id   = request.OrderNo,
         Name = "demo"
     }));
     return(0);
 }
        public async Task <IActionResult> SendEvent()
        {
            var demoRequest = new DemoRequest()
            {
                Message = $"event sent on {DateTime.Now} in {this.GetType().Name} (Thread {Thread.CurrentThread.ManagedThreadId})"
            };

            _mediator.SendAsync(demoRequest);
            return(RedirectToAction("Index"));
        }
        public ActionResult Mailforsocioboard(DemoRequest demoReq)
        {
            string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\registrationmail.html";
            string html = System.IO.File.ReadAllText(path);

            html = html.Replace("[FirstName]", demoReq.firstName);
            html = html.Replace("[AccountType]", demoReq.demoPlanType.ToString());
            _emailSender.SendMail("", "", "*****@*****.**", "", "", "Customer requested for demo enterprise plan ", html, _appSettings.ZohoMailUserName, _appSettings.ZohoMailPassword);
            return(Ok("Mail Sent Successfully."));
        }
        public ResultData Post(DemoRequest request)
        {
            DateTime   start  = DateTime.Now;
            ResultData result = new ResultData();

            result.Data = this.Service.Add(request);
            DateTime end = DateTime.Now;

            result.RequestTime = string.Format("{0}-{1}={2}Milliseconds", end.ToString("yyyy-MM-dd HH:mm:ss.ffffff"), start.ToString("yyyy-MM-dd HH:mm:ss.ffffff"), (end - start).TotalMilliseconds);
            return(result);
        }
示例#13
0
        public object Any(DemoRequest demoRequest)
        {
            var header = Request.Headers[HeaderNames.CorrelationId];

            // Request.Items[HeaderNames.CorrelationId]

            $"Demo service received request with {header} value for {HeaderNames.CorrelationId} header".Print();

            return(new DemoResponse {
                Message = $"Internal request id = {header}"
            });
        }
示例#14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string serverurl = GetSiteRoot() + "/TopHandler.ashx";

            var client = new TopClient(serverurl, APPID, APPSECRET);

            var req = new DemoRequest();

            req.p1 = new DemoObject()
            {
                id = 10,
                name = "hello world!",
            };

            var rsp = client.Execute(req);

            System.Diagnostics.Debugger.Break();
        }
示例#15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string serverurl = GetSiteRoot() + "/TopHandler.ashx";

            var client = new TopClient(serverurl, APPID, APPSECRET);

            var req = new DemoRequest();

            req.p1 = new DemoObject()
            {
                id   = 10,
                name = "hello world!",
            };

            var rsp = client.Execute(req);

            System.Diagnostics.Debugger.Break();
        }
        public IActionResult DemoRequest(DemoRequest demoRequest)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DatabaseRepository  dbr     = new DatabaseRepository(_logger, _appEnv);
            IList <DemoRequest> lstUser = dbr.Find <DemoRequest>(t => t.emailId.Equals(demoRequest.emailId));

            if (lstUser != null && lstUser.Count() > 0)
            {
                return(BadRequest("EmailId Exist"));
            }
            int SavedStatus = dbr.Add <Domain.Socioboard.Models.DemoRequest>(demoRequest);

            if (SavedStatus == 1 && demoRequest != null)
            {
                try
                {
                    string path = _appEnv.WebRootPath + "\\views\\mailtemplates\\plan.html";
                    string html = System.IO.File.ReadAllText(path);
                    html = html.Replace("[FirstName]", demoRequest.firstName);
                    html = html.Replace("[AccountType]", demoRequest.demoPlanType.ToString());

                    //_emailSender.SendMail("", "", demoRequest.emailId, "", "", "You requested for Demo plan", html, _appSettings.ZohoMailUserName, _appSettings.ZohoMailPassword);
                    //Mailforsocioboard(demoRequest);
                    _emailSender.SendMailSendGrid(_appSettings.frommail, "", demoRequest.emailId, "", "", "You requested for Demo plan", html, _appSettings.SendgridUserName, _appSettings.SendGridPassword);
                    Mailforsocioboard(demoRequest);
                    return(Ok("Demo Requested Added"));
                    // return Ok("Mail Sent Successfully.");
                }
                catch (Exception ex)
                {
                    return(Ok("Issue while sending mail."));
                }
            }
            else
            {
                return(Ok("problem while saving,pls try after some time"));
            }
        }
        public IActionResult SendAgencyMail(DemoRequest demoRequest)
        {
            string ret    = string.Empty;
            string tomail = _appSettings.ZohoMailUserName;

            string subject = "Socioboard Agency";
            string Body    = "Name: " + demoRequest.firstName + "" + demoRequest.lastName + "</br>" + "Email: " + demoRequest.emailId + "</br>" + "Company: " + demoRequest.company + "</br>" + "Message: " + demoRequest.message + "</br>" + "Phone: " + demoRequest.phoneNumber + "</br>";

            try
            {
                ret = _emailSender.SendMail(tomail, "", tomail, "", "", subject, Body, _appSettings.ZohoMailUserName, _appSettings.ZohoMailPassword);
            }
            catch (Exception ex)
            {
                _logger.LogError("MailSender = > " + ex.StackTrace);
                _logger.LogError("MailSender = > " + ex.Message);
            }

            return(Ok());
        }
示例#18
0
        public DataTable SaveDemoDetails(DemoRequest b)
        {
            LogTraceWriter traceWriter = new LogTraceWriter();
            SqlConnection  conn        = new SqlConnection();
            DataTable      dt          = new DataTable();

            try
            {
                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "InsUpdDemoRequest";

                cmd.Connection = conn;

                SqlParameter i = new SqlParameter("@flag", SqlDbType.VarChar);
                i.Value = b.flag;
                cmd.Parameters.Add(i);

                SqlParameter ie = new SqlParameter("@Id", SqlDbType.Int);
                ie.Value = b.Id;
                cmd.Parameters.Add(ie);

                SqlParameter cm = new SqlParameter("@Email", SqlDbType.VarChar, 250);
                cm.Value = b.email;
                cmd.Parameters.Add(cm);

                SqlParameter bd = new SqlParameter("@MobileNumber", SqlDbType.VarChar, 50);
                bd.Value = b.mobile;
                cmd.Parameters.Add(bd);

                SqlParameter stat = new SqlParameter("@Status", SqlDbType.VarChar, 50);
                stat.Value = b.statusid;
                cmd.Parameters.Add(stat);

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);


                #region Demo
                string email = dt.Rows[0]["Email"].ToString();
                string dpwd  = dt.Rows[0]["DashboardPwd"].ToString();
                string cotp  = dt.Rows[0]["OtpCustomerApp"].ToString();
                string bname = dt.Rows[0]["BusinessAppUsername"].ToString();
                string botp  = dt.Rows[0]["OtpBusinessApp"].ToString();
                if (email != null)
                {
                    try
                    {
                        MailMessage mail        = new MailMessage();
                        string      emailserver = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();

                        string username    = System.Configuration.ConfigurationManager.AppSettings["username"].ToString();
                        string pwd         = System.Configuration.ConfigurationManager.AppSettings["password"].ToString();
                        string fromaddress = System.Configuration.ConfigurationManager.AppSettings["fromaddress"].ToString();
                        string port        = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();

                        SmtpClient SmtpServer = new SmtpClient(emailserver);

                        mail.From = new MailAddress(fromaddress);
                        mail.To.Add(b.email);
                        mail.Subject    = "PaySmart Demo Credentials";
                        mail.IsBodyHtml = true;

                        string samplemail = @"<div>
                                         <p>Hi,</p>
                                         <p>Thanks for requesting demo of PaySmart.</p>
                                        <p>We have set up a basic demo for your evaluation. The demo is setup for the city Hyderabad with currency INR, English as the language. One driver is automatically registered by us whose credentials we have mentioned below. You can go through the complete ride flow in the demo. If there are any issues, please refer to this <a href='http://196.27.119.221:53800/UI/DemoRequest.html'>Demo setup video</a> or feel free to connect with us by replying back to this email.</p>

                                              <p>Your PaySmart Demo credentials and links are here.</p>
                                              <p><a href='http://196.27.119.220:6688/Login.html'>Dashboard Link</a><br/>
                                              Username:  "******"<br/> 
                                              Password:"******"</p>

                                               <p>Customer App Link:<a href='http://196.27.119.221:53800/UI/CustomerApp.html'>Android , </a><a href='http://196.27.119.221:53800/UI/CustomerApp.html'>IOS</a><br/>
                                               You can login with any phone number in the customer app.<br/> 
                                               A 4 digit OTP will come as an SMS, please enter it.<br/>  
                                               Again, on the next screen you need to enter this six digit demo passcode : " + cotp + @"</p>

                                              <p>Driver App: <a href='http://196.27.119.221:53800/UI/DriverApp.html'>Android , </a><a href='http://196.27.119.221:53800/UI/DriverApp.html'>IOS</a><br/> 
                                               Driver Mobile Number: " + bname + @"<br/> 
                                               OTP: " + botp + @"</p>  
                                               <p>PaySmart</p>
                                           

                                                   </div>";

                        //                        string verifcodeMail = @"<table>
                        //                                                        <tr>
                        //                                                            <td>
                        //                                                                <h2>Thank you for signing up with PaySmart</h2>
                        //                                                                <table width=\""760\"" align=\""center\"">
                        //                                                                    <tbody style='background-color:#F0F8FF;'>
                        //                                                                        <tr>
                        //                                                                            <td style=\""font-family:'Zurich BT',Arial,Helvetica,sans-serif;font-size:15px;text-align:left;line-height:normal;background-color:#F0F8FF;\"" >
                        //<div style='padding:10px;border:#0000FF solid 2px;'>    <br /><br />

                        //                                                       Your Vehicle is Booked:<h3>" + eotp + @" </h3>

                        //                                                        If you didn't make this request, <a href='http://154.120.237.198:52800'>click here</a> to cancel.

                        //                                                                                <br/>
                        //                                                                                <br/>

                        //                                                                                Warm regards,<br>
                        //                                                                                PAYSMART Customer Service Team<br/><br />
                        //</div>
                        //                                                                            </td>
                        //                                                                        </tr>

                        //                                                                    </tbody>
                        //                                                                </table>
                        //                                                            </td>
                        //                                                        </tr>

                        //                                                    </table>";

                        mail.Body = samplemail;
                        //mail.Body = verifcodeMail;
                        //SmtpServer.Port = 465;
                        //SmtpServer.Port = 587;
                        SmtpServer.Port = Convert.ToInt32(port);
                        SmtpServer.UseDefaultCredentials = false;

                        SmtpServer.Credentials = new System.Net.NetworkCredential(username, pwd);
                        SmtpServer.EnableSsl   = true;
                        //SmtpServer.TargetName = "STARTTLS/smtp.gmail.com";
                        SmtpServer.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                        throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                    }
                }
                #endregion Demo
            }
            catch (Exception ex)
            {
                throw ex;
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);
        }
示例#19
0
 public Response Add(DemoRequest item)
 {
     return(new Response {
         Message = "成功" + DateTime.Now.Ticks.ToString(), Sucess = true
     });
 }
        public DataTable SaveDemoRequest(DemoRequest b)
        {
            LogTraceWriter traceWriter = new LogTraceWriter();
            SqlConnection  conn        = new SqlConnection();
            DataTable      dt          = new DataTable();

            try
            {
                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "InsUpdDelDemoRequest";

                cmd.Connection = conn;

                SqlParameter i = new SqlParameter("@flag", SqlDbType.VarChar);
                i.Value = b.flag;
                cmd.Parameters.Add(i);

                SqlParameter ie = new SqlParameter("@Id", SqlDbType.Int);
                ie.Value = b.Id;
                cmd.Parameters.Add(ie);

                SqlParameter co = new SqlParameter("@BusinessName", SqlDbType.VarChar, 250);
                co.Value = b.Businessname;
                cmd.Parameters.Add(co);

                SqlParameter cm = new SqlParameter("@Email", SqlDbType.VarChar, 250);
                cm.Value = b.email;
                cmd.Parameters.Add(cm);

                SqlParameter bd = new SqlParameter("@MobileNumber", SqlDbType.VarChar, 50);
                bd.Value = b.mobile;
                cmd.Parameters.Add(bd);

                SqlParameter bt = new SqlParameter("@LoginNo", SqlDbType.VarChar, 50);
                bt.Value = b.LoginNo;
                cmd.Parameters.Add(bt);

                SqlParameter dd = new SqlParameter("@CountryId", SqlDbType.Int);
                dd.Value = b.countryid;
                cmd.Parameters.Add(dd);

                SqlParameter dt1 = new SqlParameter("@Reviewed", SqlDbType.VarChar, 50);
                dt1.Value = b.Reviewed;
                cmd.Parameters.Add(dt1);

                SqlParameter q1 = new SqlParameter("@Notification", SqlDbType.VarChar, 50);
                q1.Value = b.notification;
                cmd.Parameters.Add(q1);

                SqlParameter ss = new SqlParameter("@statusid", SqlDbType.Int);
                ss.Value = b.statusid;
                cmd.Parameters.Add(ss);

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);


                #region Mobile OTP
                string eotp = dt.Rows[0]["BusinessName"].ToString();
                if (eotp != null)
                {
                    try
                    {
                        MailMessage mail        = new MailMessage();
                        string      emailserver = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();

                        string username    = System.Configuration.ConfigurationManager.AppSettings["username"].ToString();
                        string pwd         = System.Configuration.ConfigurationManager.AppSettings["password"].ToString();
                        string fromaddress = System.Configuration.ConfigurationManager.AppSettings["fromaddress"].ToString();
                        string port        = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();

                        SmtpClient SmtpServer = new SmtpClient(emailserver);

                        mail.From = new MailAddress(fromaddress);
                        mail.To.Add(b.email);
                        mail.Subject    = "Thank you for signing up with PaySmart";
                        mail.IsBodyHtml = true;

                        string samplemail = @"<div>
                                         <p>Hi,</p>
                                         <p>Thanks for showing your interest in PaySmart. Our sales representative will connect with you shortly with demo credentials and links.</p>
                                        <p>If you need a demo of our product you can sign up on this link to get immediate access to it. <a href='http://196.27.119.221:53800/UI/DemoRequest.html'>Demo Link</a></p>
                                            <p>Thanks,<br/>PaySmart</p>
                                           

                                                   </div>";

//                        string verifcodeMail = @"<table>
//                                                        <tr>
//                                                            <td>
//                                                                <h2>Thank you for signing up with PaySmart</h2>
//                                                                <table width=\""760\"" align=\""center\"">
//                                                                    <tbody style='background-color:#F0F8FF;'>
//                                                                        <tr>
//                                                                            <td style=\""font-family:'Zurich BT',Arial,Helvetica,sans-serif;font-size:15px;text-align:left;line-height:normal;background-color:#F0F8FF;\"" >
//<div style='padding:10px;border:#0000FF solid 2px;'>    <br /><br />

//                                                       Your Vehicle is Booked:<h3>" + eotp + @" </h3>

//                                                        If you didn't make this request, <a href='http://154.120.237.198:52800'>click here</a> to cancel.

//                                                                                <br/>
//                                                                                <br/>

//                                                                                Warm regards,<br>
//                                                                                PAYSMART Customer Service Team<br/><br />
//</div>
//                                                                            </td>
//                                                                        </tr>

//                                                                    </tbody>
//                                                                </table>
//                                                            </td>
//                                                        </tr>

//                                                    </table>";

                        mail.Body = samplemail;
                        //mail.Body = verifcodeMail;
                        //SmtpServer.Port = 465;
                        //SmtpServer.Port = 587;
                        SmtpServer.Port = Convert.ToInt32(port);
                        SmtpServer.UseDefaultCredentials = false;

                        SmtpServer.Credentials = new System.Net.NetworkCredential(username, pwd);
                        SmtpServer.EnableSsl   = true;
                        //SmtpServer.TargetName = "STARTTLS/smtp.gmail.com";
                        SmtpServer.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        //throw ex;
                        throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                    }
                }
                #endregion Mobile OTP
            }
            catch (Exception ex)
            {
                throw ex;
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);
        }
        public DemoResponse ObtenerEstudiante(DemoRequest request)
        {
            DemoResponse response = IStudentService.ObtenerEstudiante(this.IJsonManager.CreateBinaryData(request)).Result;

            return(response);
        }
        public ListStudentDTO ActualizarEstudiante(DemoRequest oDemoRequest)
        {
            ListStudentDTO lista = IStudentService.ActualizarEstudiante(this.IJsonManager.CreateBinaryData(oDemoRequest)).Result;

            return(lista);
        }
 public string Post([FromBody] DemoRequest demoRequest)
 {
     return(demoRequest.Id);
 }
 public object Any(DemoRequest demoRequest) => new DemoResponse
 {
     Message = "Response from Demo Service"
 };
 public Response Add(DemoRequest request)
 {
     return(this.Client.Add(request));
 }
 public override Task <Response> Add(DemoRequest request, ServerCallContext context)
 {
     return(Task.FromResult(new Response {
         Message = "成功" + context.Host + DateTime.Now.Ticks.ToString(), Sucess = true
     }));
 }