public async Task sendmessage(int from_userid, int?to_userid, string message, string messagetextpure) { string thisdatetime = DateTime.Now.ToPersianDate() + " " + DateTime.Now.ToString("HH:mm:ss"); string status = ""; string url = ""; if (message.Contains("www.") || message.Contains(".com") || message.Contains(".org") || message.Contains(".net") || message.Contains(".ir")) { if (message.Contains("http://") || message.Contains("https://")) { url = message; message = "<a href='" + url + "'>" + message + "</a>"; } else { url = "//" + message; message = "<a href='" + url + "'>" + message + "</a>"; } } var from_user = db.tbl_signalrUsers.Where(a => a.userid == from_userid).SingleOrDefault(); int branch = from_user.user.branches_id.HasValue ? from_user.user.branches_id.Value : 0; if (to_userid == null) { status = "public"; tbl_signalRmsg msg = new tbl_signalRmsg { from_userid = from_userid, msg_text = message, msg_textpure = messagetextpure, datetime_send = DateTime.Now, visibleforall = true, visibletofrom = true, visibletoto = true }; db.tbl_signalRmsg.Add(msg); db.SaveChanges(); await Clients.All.SendAsync("addNewMessage", msg.id, from_userid, from_user.username, message, thisdatetime, status, branch, messagetextpure); } else { status = "single"; var to_user = db.tbl_signalrUsers.Where(a => a.userid == to_userid.Value).SingleOrDefault(); tbl_signalRmsg msg = new tbl_signalRmsg { from_userid = from_userid, to_userid = to_userid, msg_text = message, msg_textpure = messagetextpure, datetime_send = DateTime.Now, visibleforall = true, visibletofrom = true, visibletoto = true }; db.tbl_signalRmsg.Add(msg); db.SaveChanges(); if (to_user.connectionId != null) { await Clients.Client(to_user.connectionId).SendAsync("addNewMessage", msg.id, from_userid, from_user.username, message, thisdatetime, status, branch, messagetextpure); } if (to_user.connectionId != from_user.connectionId) { await Clients.Client(from_user.connectionId).SendAsync("addNewMessage", msg.id, from_userid, from_user.username, message, thisdatetime, status, branch, messagetextpure); } } }
public ActionResult orderexporttopdf(int orderid) { //StimulsoftLicenseHelper.Activate(); //Stimulsoft.Base.StiActivator // step 2: set license key //var lic = "6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHlNHxonFYHbpjDx+27slnZs5ftj9P0vr+YW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D6vPzSJ9TQjgWtrbANDmjpHzK2YiTnvbUKf9FibYLmtl0iJ3WUhzO1R03jDUJSvF030BPxGWUt5UMTSpaImLTboUbWbCkLnkDXPyxT9xZORjgWTQzVYNUmCXW2qEtzOyVbB+m16KzWvFf69QI1zMEo/N6a1JzT7499RnmqkuqPyBESnVvAaG7Qfz8jff5tK6ml+BTsCRX4MsHV/Sh100Tv4Kt3raiWKyBG6L2UVbKvtaFnGSYPJzNSY6ndlrxWC65VSSbeXxR6AzKVjLw9sgJLh9i6IQ5d5cUfEFzFKNWvCPDiEERKPpG2Vj4yR3HoayBrgpRqgaLAq1/V//hlWT/dcRIevJGjDgbZGv2E1KOiB4Llj/HX0HAO7cCZrtM57hf5jMnqGDvkYSOOHTPqMPv9QbLdBX+5RnHoa8xtXPp1vVPbJXZHJ/f9rVOnGCqjtR6pWAGDYOOZkXZ02y0zjow0go2JuCZnzYZw37U12hcrb2gxPAlmy/SQerFJXaySRLSXu0QW1pfw=="; //StiLicense.Key = lic; var order = db.tbl_order.ToList().Where(a => a.id == orderid).Select(g => new { id = g.id.ToString(), username = g.user.username, sodoordate = g.sodoor_date.ToPersianDate(), sodoortime = g.sodoor_date.ToShortTimeString(), fullname = g.orderfor.Fname + " " + g.orderfor.Lname, cellphone = g.orderfor.cell, frombranch = g.from_branch.branch_name, tobranch = g.to_branch.branch_name, sharh = g.sharh, done = (g.done == false ? "نزد " + g.to_branch.branch_name : "تحویل شده"), address = g.orderfor.address, frombranch_address = g.from_branch.Address, tobranch_address = g.to_branch.Address }); var orderitems = db.tbl_orderdetails.Where(a => a.order_id == orderid).ToList().Select(g => new { productid = g.product_id.ToString(), Catgname = g.product_.category.categoryname, productname = g.product_.category.categoryname + "| " + g.product_.name + "| " + g.product_.codename + "| " + g.product_.dimension, weight = g.product_.weight.ToString() + "kg", number = g.number.ToString(), totalweight = (g.product_.weight.HasValue ? (g.product_.weight.Value * g.number).ToString() : ""), desc = g.description }); int branch = db.tbl_order.Where(a => a.id == orderid).SingleOrDefault().from_branchid; StiReport report = new StiReport(); string webroot = _hostingEnvironment.WebRootPath; string myroot = "/Content/reports/Reportorder.mrt"; string targetroot = webroot + myroot; //report.Load(Path.Combine(_hostingEnvironment.WebRootPath, "/Content/reports/Reportorder.mrt")); report.Load(targetroot); //report.Load(Path.Combine(_hostingEnvironment.WebRootPath, "/Content/reports/Reportorder.mrt")); report.RegData("orderinfo", order); report.RegData("orderitems", orderitems); report.Render(); MemoryStream stream = new MemoryStream(); StiPdfExportService pdfexport = new StiPdfExportService(); StiPdfExportSettings st = new StiPdfExportSettings(); pdfexport.ExportPdf(report, stream, st); stream.Position = 0; byte[] b = stream.ToArray(); tbl_filestosend t = new tbl_filestosend(); t.caption = "حواله " + order.SingleOrDefault().id; t.filecontent = b; t.uploaddatetime = DateTime.Now; t.imagename = "order" + order.SingleOrDefault().id + ".pdf"; t.user_id = int.Parse(User.Claims.FirstOrDefault().Value); t.filecontent = b; db.tbl_filestosend.Add(t); db.SaveChanges(); // //var context = GlobalHost.ConnectionManager.GetHubContext<chatHub>(); string msgframe = ""; msgframe += "<p class='msgtext'>حواله " + orderid + " جهت آقای " + order.SingleOrDefault().fullname + "</p>"; msgframe += "<a target='_blank' class='btn btn-success' href='/admin/DownLoadFile/" + t.id + "'>دانلود فایل</a>"; string mymsgpure = $"حواله {orderid} جهت آقای {order.SingleOrDefault().fullname}"; string thisdatetime = order.SingleOrDefault().sodoordate + " " + order.SingleOrDefault().sodoortime; tbl_signalRmsg msg = new tbl_signalRmsg { from_userid = int.Parse(User.Claims.FirstOrDefault().Value), msg_text = msgframe, datetime_send = DateTime.Now, visibleforall = true, visibletofrom = true, visibletoto = true, msg_textpure = mymsgpure }; db.tbl_signalRmsg.Add(msg); db.SaveChanges(); _hub.Clients.All.SendAsync("addNewMessage", msg.id, User.Claims.FirstOrDefault().Value, User.Identity.Name, msgframe, thisdatetime, "public", branch); return(Json(true)); }