public void ClientSendToServer() { const string hostName = "127.0.0.1"; const ushort port = 8888; var clientHost = new EService(); var serverHost = new EService(hostName, port); var serverThread = new Thread(() => serverHost.Start()); var clientThread = new Thread(() => clientHost.Start()); serverThread.Start(); clientThread.Start(); var barrier = new Barrier(2); // 往server host线程增加事件,accept serverHost.Events += () => ServerEvent(serverHost, barrier); barrier.SignalAndWait(); // 往client host线程增加事件,client线程连接server clientHost.Events += () => ClientEvent(clientHost, hostName, port); serverThread.Join(); clientThread.Join(); }
/// <summary> /// Email sent to oganization users (or site admins) for access (HPCDS-22) /// </summary> /// <param name="user"></param> /// <returns></returns> private async Task <bool> SendApprovedEmail(ApplicationUser user) { bool isSentToAdmins = false; var roleIds = DataProviderAuth.GetAppRolesFor(new List <string>(new string[] { UserRoles.PendingAccess }), false).Select(s => s.Id); string DestinationEmails = string.Join("; ", user.Organization .Users .Where(w => w.LockoutEndDateUtc == null && w.EmailConfirmed && w.Roles.Any(a => roleIds.Contains(a.RoleId))) // HPCDS-22 TODO: specify a better way of IDentify'n active users .Select(s => s.Email).ToList()); if (String.IsNullOrWhiteSpace(DestinationEmails)) { var adminUsers = DataProviderAuth.GetAdminUsers(); DestinationEmails = string.Join("; ", adminUsers.Select(s => s.Email).ToList()); isSentToAdmins = true; } var emailMsg = new PgrmIdentityMessage() { Destination = DestinationEmails, Subject = isSentToAdmins ? EmailRes.RegistrationApprovalReqForAdminSubjectFormat : EmailRes.RegistrationApprovalReqForOrgUsersSubjectFormat, Body = String.Format(isSentToAdmins ? EmailRes.RegistrationApprovalReqForAdminBodyFormat : EmailRes.RegistrationApprovalReqForOrgUsersBodyFormat //"email: {0} organization name: {1} urlControllerAction: {2} token: {3}" , user.Email, user?.Organization.OrganizationName ?? "ERROR-NO Organization Name", "URL-TODO: (HPCDS-25)", "TOKEN-APPROVE-USER"), }; await EService.SendAsync(emailMsg); #if DEBUG TempData["DebugMessage"] = emailMsg.ToStringEmail(); #endif return(true); }
public int generalRecieveData(int type) { int temp = 0; if (server == null) { server = new EService(); } ; string courseid = Global.getCourseID().ToString(); string classid = Global.getClassID().ToString(); string lessonid = Global.getLessonID().ToString(); server.HandonOver("-1", ""); if (type == 0) { temp = server.SingleProjectiveInPPT(courseid, classid, lessonid); } else if (type == 1) { temp = server.ProjectiveInPPT(courseid, classid, lessonid); } else if (type == 2) { temp = server.JudgeProjectiveInPPT(courseid, classid, lessonid); } return(temp); }
public Service Create(int invoiceId, Service service) { EService eService = EService(service); eService.InvoiceId = invoiceId; eService = _iDService.Create(eService); return Service(eService); }
private Application(Guid user, EService service, int sortingOffice) { User = user; Service = service; DateSubmitted = DateTime.Now; CityId = sortingOffice; }
public async Task <Guid> BillAsync(EService service, Guid user, string reference) { var transaction = new Transaction(user); transaction.NameSearchPaymentDescription(reference); transaction.Debit(await GetPriceAsync(service)); if (await CanGetServiceAsync(service, user)) { var balance = await _paymentsContext.Balances.SingleAsync(b => b.User.Equals(user)); var originalBalance = balance.Amount; if (transaction.DebitAmount != null) { var newBalance = originalBalance - transaction.DebitAmount.Value; balance.UpDateAmount(_paymentsContext, originalBalance, newBalance); } try { await _paymentsContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { // TODO LOG instance of concurrency conflict here return(await BillAsync(service, user, reference)); } _paymentsContext.Add(transaction); await _paymentsContext.SaveChangesAsync(); return(transaction.TransactionId); } throw new Exception("Insufficient funds"); }
public ActionResult Update(EService model) { using (var db = new MyDbDataContext()) { if (ModelState.IsValid) { try { Service service = db.Services.FirstOrDefault(b => b.ID == model.ID); if (service != null) { service.Title = model.Title; service.MenuID = model.MenuID; service.Alias = model.Alias; service.Image = model.Image; service.Description = model.Description; service.Content = model.Content; service.MetaTitle = string.IsNullOrEmpty(model.MetaTitle) ? model.Title : model.MetaTitle; service.MetaDescription = string.IsNullOrEmpty(model.MetaDescription) ? model.Title : model.MetaDescription; service.Status = model.Status; service.Home = model.Home; db.SubmitChanges(); //xóa gallery cho phòng db.ServiceGalleries.DeleteAllOnSubmit( db.ServiceGalleries.Where(a => a.ServiceID == service.ID).ToList()); //Thêm hình ảnh cho phòng if (model.EGalleryITems != null) { foreach (EGalleryITem itemGallery in model.EGalleryITems) { var serviceGallery = new ServiceGallery { ImageLarge = itemGallery.Image, ImageSmall = ReturnSmallImage.GetImageSmall(itemGallery.Image), ServiceID = service.ID, }; db.ServiceGalleries.InsertOnSubmit(serviceGallery); } db.SubmitChanges(); } TempData["Messages"] = "Sửa dịch vụ thành công"; return(RedirectToAction("Index")); } } catch (Exception exception) { ViewBag.Messages = "Error: " + exception.Message; LoadData(); return(View(model)); } } LoadData(); return(View(model)); } }
public ActionResult Create() { ViewBag.Title = "Thêm dịch vụ"; var eService = new EService(); LoadData(); return(View(eService)); }
private void HideForm(object sender, EventArgs e) { //this.WindowState = FormWindowState.Minimized; //fParent.Dispose(); //fParent = null; //this.Dispose(); //this.Close(); EService.LessonOver(); }
private async Task <double> GetPriceAsync(EService service) { var price = await _paymentsContext.PriceItems.SingleOrDefaultAsync(p => p.Service.Equals(service)); if (price == null) { throw new Exception("Not a billable service"); } return(price.Price); }
///<summary>Launches the eServices Setup window defaulted to the tab of the eService passed in.</summary> public FormEServicesSetup(EService setTab = EService.SignupPortal) { InitializeComponent(); Lan.F(this); switch (setTab) { case EService.ListenerService: tabControl.SelectTab(tabEConnector); break; case EService.MobileOld: tabControl.SelectTab(tabMobileSynch); break; case EService.MobileNew: tabControl.SelectTab(tabMobileWeb); break; case EService.WebSched: tabControl.SelectTab(tabWebSched); break; case EService.SmsService: tabControl.SelectTab(tabTexting); break; case EService.eConfirmRemind: tabControl.SelectTab(tabECR); break; case EService.eMisc: tabControl.SelectTab(tabMisc); break; case EService.PatientPortal: tabControl.SelectTab(tabPatientPortal); break; case EService.WebSchedNewPat: tabControl.SelectTab(tabWebSched); tabControlWebSched.SelectTab(tabWebSchedNewPatAppts); break; case EService.EClipboard: tabControl.SelectTab(tabEClipboard); break; case EService.SignupPortal: default: tabControl.SelectTab(tabSignup); break; } }
/// <summary> /// 事件上传----老师打开PPT /// </summary> /// <param name="filename"></param> public static void uploadFileopenEvent(string filename) { ////异步同步到云服务 string filepath = EService.getFilepath(filename); string fileopen_data = ""; string md5 = Util.GetFileMD5(filepath); fileopen_data += "filename=" + filename; fileopen_data += "&filepath=" + filepath; fileopen_data += "&md5=" + md5; doPostAsync("fileopen", fileopen_data); return; }
private Service Service(EService eService) { Service returnService = new Service { ServiceId = eService.ServiceId, Quantity = eService.Quantity, Rate = eService.Rate, InvoiceId = eService.InvoiceId, TypeOfServiceId = eService.TypeOfServiceId, Comments = eService.Comments }; return returnService; }
/// <summary> /// 事件上传----老师打开PPT /// </summary> /// <param name="filename"></param> public static void uploadFilecloseEvent(string filename) { ////异步同步到云服务 string filepath = EService.getFilepath(filename); string hdtype = filepath.Split('#')[0].ToLower(); string path = filepath.Split('#')[1]; string data = "filename=" + filename; data += "&drivertype=" + hdtype; data += "&filepath=" + System.Web.HttpUtility.UrlEncode(path, Encoding.UTF8); doPostAsync("fileclose", data); return; }
private EService EService(Service service) { EService returnEService = new EService { ServiceId = service.ServiceId, Quantity = service.Quantity, Rate = service.Rate, InvoiceId = service.InvoiceId, TypeOfServiceId = service.TypeOfServiceId, Comments = service.Comments }; return returnEService; }
private EService EService(Service service) { EService returnEService = new EService { ServiceId = service.ServiceId, Description = service.Description, Quantity = service.Quantity, Rate = service.Rate, InvoiceId = service.InvoiceId, TypeOfServiceId = service.TypeOfServiceId, Comments = service.Comments }; return(returnEService); }
private Service Service(EService eService) { Service returnService = new Service { ServiceId = eService.ServiceId, Description = eService.Description, Quantity = eService.Quantity, Rate = eService.Rate, InvoiceId = eService.InvoiceId, TypeOfServiceId = eService.TypeOfServiceId, Comments = eService.Comments }; return(returnService); }
private void Form1_Load(object sender, EventArgs e) { try { EService service = new EService(); m_Host = new ServiceHost(service); m_Host.Open(); m_HttpdComet = new Httpd(); thread_comet = new Thread(m_HttpdComet.run); thread_comet.Start(); ////////////////////////////////////////////////////////////// // 系统管理 发现IP地址变更后自动重启服务 ////////////////////////////////////////////////////////////// thread_Manage = new Thread(delegate() { string ip1 = GetInternalIPList(); while (true) { string ip2 = GetInternalIPList(); if (ip1 != ip2) { Log.Info("ip1=" + ip1 + ". ip2=" + ip2); ip1 = ip2; restartHttpd(); } Thread.Sleep(8000); } }); thread_Manage.Start(); ////////////////////////////////////////////////////////////// // 系统管理 发现IP地址变更后自动重启服务 ////////////////////////////////////////////////////////////// thread_DeviceStatusCheck = new Thread(Thread_CheckDeviceStatus); thread_DeviceStatusCheck.Start(); } catch (Exception ex) { Log.Error(ex.Message); MessageBox.Show("小助手启动异常,请联系管理员", "Warning!!!"); } }
public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model) { if (ModelState.IsValid) { var user = await UserManager.FindByNameAsync(model.Email); var emailMsg = new PgrmIdentityMessage { Destination = user?.Email ?? model.Email }; if (user == null) { // Don't reveal that the user does not exist or is not confirmed EmailSetupForNotRegisterdUser(emailMsg); await EService.SendAsync(emailMsg); } else if (!(await UserManager.IsEmailConfirmedAsync(user.Id))) { string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); EmailSetupForNotVerifiedUser(emailMsg, user.Id, code); await UserManager.SendEmailAsync(user.Id, emailMsg.Subject, emailMsg.Body); } else { //For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link string code = await UserManager.GenerateUserTokenAsync("CanAnswerSecQuestions", user.Id); EmailSetupForRegisterdUser(emailMsg, code, "VerifyUser"); await UserManager.SendEmailAsync(user.Id, emailMsg.Subject, emailMsg.Body); } #if DEBUG TempData["DebugMessage"] = emailMsg.ToStringEmail(); #endif return(RedirectToAction("ForgotPasswordConfirmation", "Account")); } // If we got this far, something failed, redisplay form return(View(model)); }
private static async void ServerEvent(EService service, Barrier barrier) { barrier.SignalAndWait(); bool isRunning = true; while (isRunning) { Log.Debug("start accept"); var eSocket = new ESocket(service); await eSocket.AcceptAsync(); eSocket.Disconnect += ev => { isRunning = false; service.Stop(); }; Echo(eSocket); } }
public int recieveData(string answer, string type) { int temp = 0; if (server == null) { server = new EService(); } ; string courseid = Global.getCourseID().ToString(); string classid = Global.getClassID().ToString(); string lessonid = Global.getLessonID().ToString(); server.HandonOver("-1", ""); server.SingleProjectiveInPPT(courseid, classid, lessonid); server.SetAnswer(answer); return(temp); }
/// <summary> /// 异步拷贝到本地sourcefile目录下 /// </summary> public void AsnycCopy() { DriveInfo[] drives = DriveInfo.GetDrives(); string hd = sourcePath.Substring(0, 1); string hdtype = ""; foreach (DriveInfo dri in drives) { string _name = dri.Name.Substring(0, 1); if (_name == hd) { hdtype = dri.DriveType.ToString(); break; } } string dir = Application.StartupPath + "\\sourcefile\\"; string filename = sourceFilename; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string pathSrc = sourcePath + "\\" + sourceFilename; string ext = Path.GetExtension(pathSrc); //if (ext == ".ppt" || ext == ".pptx" || ext == ".doc" || ext == ".docx" || ext == ".jpg" || ext == ".jpeg" || ext == ".bmp" || ext == ".png" || ext == ".gif") //{ // FileOper.CopyFile(pathSrc, dir + filename, true); //} EService.selectFile(sourceFilename, pathSrc, false); if (filename.IndexOf("ppt") > 0 || filename.IndexOf("PPT") > 0) { bExporting = true; MyPPT.exportImg(sourcePath + "\\" + sourceFilename); bExporting = false; } }
private static async void ClientEvent(EService service, string hostName, ushort port) { var eSocket = new ESocket(service); await eSocket.ConnectAsync(hostName, port); var stopWatch = new Stopwatch(); stopWatch.Start(); for (int i = 0; i < pingPangCount; ++i) { eSocket.WriteAsync("0123456789".ToByteArray()); var bytes = await eSocket.ReadAsync(); CollectionAssert.AreEqual("9876543210".ToByteArray(), bytes); } stopWatch.Stop(); Log.Debug("time: {0}", stopWatch.ElapsedMilliseconds); await eSocket.DisconnectAsync(); service.Stop(); }
///<summary>Launches the eServices Setup window defaulted to the tab of the eService passed in.</summary> public FormEServicesSetup(EService setTab) { InitializeComponent(); Lan.F(this); switch(setTab) { case EService.ListenerService: tabControl.SelectTab(tabListenerService); break; case EService.MobileOld: tabControl.SelectTab(tabMobileOld); break; case EService.MobileNew: tabControl.SelectTab(tabMobileNew); break; case EService.WebSched: tabControl.SelectTab(tabWebSched); break; case EService.PatientPortal: default: tabControl.SelectTab(tabPatientPortal); break; } }
//点击选择老师 public void pictureBox_SelectTeacher_Click(object sender, EventArgs e) { //http://172.18.201.3:8989/user.do?action=login&courseid=12&callback=angular.callbacks._8 PictureBox box = (PictureBox)sender; string name = box.Name; int courseid = int.Parse(name); foreach (User u in Global.g_TeacherArray) { if (u.courseid == courseid) { Dictionary <String, String> pList = new Dictionary <String, String>(); pList.Add("courseid", "" + courseid); Httpd.handleLogin(pList, ""); //TODO:WQ 开始上课 EService.ShowSelectTeacher(false, 1); //调用控制栏 Form1.ShowController(true); } } }
public ActionResult Update(int id) { using (var db = new MyDbDataContext()) { Service service = db.Services.FirstOrDefault(a => a.ID == id); if (service == null) { TempData["Messages"] = "Dịch vụ không tồn tại"; return(RedirectToAction("Index")); } ViewBag.Title = "Sửa dịch vụ"; var eService = new EService { ID = service.ID, MenuID = service.MenuID, Title = service.Title, Alias = service.Alias, Image = service.Image, Index = service.Index, Description = service.Description, Content = service.Content, MetaTitle = service.MetaTitle, MetaDescription = service.MetaDescription, Status = service.Status, Home = service.Home }; //lấy danh sách hình ảnh eService.EGalleryITems = db.ServiceGalleries.Where(a => a.ServiceID == service.ID).Select(a => new EGalleryITem { Image = a.ImageLarge }).ToList(); LoadData(); return(View(eService)); } }
private void pictureBox2_Click(object sender, EventArgs e) { //TODO:WQ 开始上课 EService.ShowSelectTeacher(true, 1); this.Hide(); }
private void ReadFilePath(string diskPath, int field, bool bNotify = false) { currentdir = diskPath; if (diskPath.LastIndexOf("\\") == diskPath.Length - 1) { diskPath = diskPath.Substring(0, diskPath.Length - 1); } ArrayList autoAddedFileList = new ArrayList(); ArrayList al = Disk.MergrObj(diskPath.Replace("\r\n", "")); btnList = new ArrayList(); if (field == 1) { Button backBtn = CreateBackBtn(); btnList.Add(backBtn); } bool bAutoSync = false; string[] szType = { "ppt", "pptx", "doc", "docx", "pdf", "mp3", "wma", "wmv", "mp4", "swf" }; ArrayList filelist0 = Disk.getFilelist(diskPath.Replace("\r\n", ""), szType); if (filelist0.Count <= 5) { bAutoSync = true; } else { Httpd.pushFilelistTips("U盘课件文件超过5个!\r\n请手动选择课件文件,并使用鼠标\"右键\"选择\"添加到如e小助手\""); } bAutoSync = false; for (int k = 0; k < al.Count; k++) { string value = al[k].ToString(); Button btn = new Button(); btn.Size = new System.Drawing.Size(70, 70); btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255); btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(153, 209, 255); btn.FlatAppearance.BorderSize = 0; btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255); btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255); btn.TextAlign = ContentAlignment.BottomCenter; btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove); btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown); btn.AllowDrop = true; if (value.Split('|')[0].ToString() == "0") { btn.BackgroundImage = global::RueHelper.Properties.Resources.wenjianjia; btn.Name = "0|" + diskPath + "|" + value.Split('|')[2].ToString(); } else { string filename = value.Split('|')[2].ToString(); string extName = filename.Substring(filename.LastIndexOf(".") + 1, (filename.Length - filename.LastIndexOf(".") - 1)); btn.BackgroundImage = FileICON(extName);//load if (btn.BackgroundImage == null) { continue; } btn.Name = "1|" + diskPath + "|" + value.Split('|')[2].ToString(); if (filename.StartsWith("~$")) { continue; } if (field == 0 && bAutoSync) { //仅仅在插上U盘时自动加载 string _filepath = diskPath + "\\" + filename; autoAddedFileList.Add(_filepath); continue; } } this.label6.Text = diskPath + "\\" + value.Split('|')[2].ToString(); btn.Text = value.Split('|')[1].ToString(); string tooltipStr = value.Split('|')[2].ToString() + "\r\n类型:" + value.Split('|')[3].ToString() + "\r\n修改日期:" + value.Split('|')[5].ToString() + "\r\n大小:" + value.Split('|')[4].ToString() + ""; this.toolTip1.SetToolTip(btn, tooltipStr); addButtonlist_Left(btn); } try { for (int i = 0; i < autoAddedFileList.Count; i++) { string _path = (string)autoAddedFileList.ToArray()[i]; string _name = Path.GetFileName(_path); EService.selectFile(_name, _path); this.AddFile(_path, false); } }catch (Exception e1) { ;// } Thread thread = new Thread(delegate() { if (autoAddedFileList.Count == 0) { return; } bExporting = true; try { string title = Global.getSchoolname() + " - " + Global.getClassname() + ""; if (bNotify) { if (fNotify == null) { fNotify = new FormNotify(title, "\r\n 课件导入中,请稍后!", 30); } this.Invoke(new System.EventHandler(this.showForm), new object[] { fNotify, null }); fNotify.InvokeUpdate(title, "\r\n 课件导入中,请稍后!"); } for (int i = 0; i < autoAddedFileList.Count; i++) { string filepathSrc = (string)autoAddedFileList.ToArray()[i]; Log.Info("copy ppt......0:" + filepathSrc); string _fname = Path.GetFileName(filepathSrc); if (_fname.IndexOf("ppt") > 0 || _fname.IndexOf("PPT") > 0) { Log.Info("copy ppt......3"); MyPPT.exportImg(filepathSrc); Log.Info("copy ppt......4"); } Log.Info("copy ppt......5"); } bExporting = false; if (bNotify && fNotify != null) { fNotify.InvokeUpdate(title, "\r\n 课件导入完毕!"); Thread.Sleep(5000); fNotify.InvokeClose(); fNotify = null; } }catch (Exception e1) { Log.Error("Err!!! " + e1.Message); bExporting = false; try { if (fNotify != null) { fNotify.InvokeClose(); fNotify = null; } } catch (Exception e2) { Log.Error("Err!!! " + e2.Message); } } }); thread.Start(); RefreshControls(); }
public async Task <bool> CanGetServiceAsync(EService service, Guid user) { return(await GetBalanceAsync(user) - await GetPriceAsync(service) >= 0); }
public void LessonOver() { EService.ShowSelectTeacher(true, 2); }
/// <summary>根据服务类型,获取相对应的服务 /// </summary> /// <param name="serviceType">服务类型</param> /// <returns>服务</returns> public IServiceCollection GetDbService(EService serviceType) => (serviceType switch