private void SysTrayShowCommands(object sender, EventArgs e) { if (!AssistantHelper.IsWindowOpen <CommandManagement>()) { var commandManagement = new CommandManagement(); commandManagement.Show(); } else { MessageBox.Show(Properties.Resources.FormIsAlreadyOpen, Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information); } }
private void SysTrayAddCommand(object sender, EventArgs e) { if (!AssistantHelper.IsWindowOpen <AddNewCommand>()) { var addNewCommand = new AddNewCommand(_assistantService); addNewCommand.Show(); } else { MessageBox.Show(Properties.Resources.FormIsAlreadyOpen, Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information); } }
private void SysTrayShowConfig(object sender, EventArgs e) { if (!AssistantHelper.IsWindowOpen <ClassicAssistant.Configuration>()) { var configuration = new ClassicAssistant.Configuration(); configuration.Show(); } else { MessageBox.Show(Properties.Resources.FormIsAlreadyOpen, Properties.Resources.Information, MessageBoxButton.OK, MessageBoxImage.Information); } }
public void DefaultSpeechRecognized(object sender, SpeechRecognizedEventArgs e) { recognizedCommand = AssistantHelper.GetRecognizedCommand(commands.Command, e.Result.Text); if (recognizedCommand.CommandText == Properties.Resources.AddNewCommand) { if (!AssistantHelper.IsWindowOpen <AddNewCommand>()) { var addNewCommand = new AddNewCommand(_assistantService); addNewCommand.Show(); Sara.SpeakAsync(recognizedCommand.Answer); } else { Sara.SpeakAsync(Properties.Resources.FormIsAlreadyOpen); } } else if (recognizedCommand.CommandText == Properties.Resources.ShowCommands) { if (!AssistantHelper.IsWindowOpen <CommandManagement>()) { var commandManagement = new CommandManagement(); commandManagement.Show(); Sara.SpeakAsync(recognizedCommand.Answer); } else { Sara.SpeakAsync(Properties.Resources.FormIsAlreadyOpen); } } else if (recognizedCommand.CommandText == Properties.Resources.TimeForBreak) { Sara.SpeakAsync(recognizedCommand.Answer); CancelRecognize(); contextMenu.MenuItems[0].Enabled = true; contextMenu.MenuItems[1].Enabled = false; } else if (recognizedCommand.NeedsConfirmation) { Sara.SpeakAsync(Properties.Resources.ConfirmOperation); StopRecognize(); recognizer = new SpeechRecognitionEngine(); _speechRecognizerService.CreateNewSynthesizer(commands.Command.Where(x => x.IsConfimation).Select(x => x.CommandText).ToArray(), recognizer, Sara, listener, ConfirmationSpeechRecognized, RecognizerSpeechRecognized, ListenerSpeechRecognize); } else { _speechRecognizerService.ExecuteRecognizedAction(Sara, recognizedCommand); } }
public override bool TakeAction() { helperList = AssistantHelper.UserHelperList(ContextUser); return(true); }
private async Task CheckTheFile(OrderModel model) { _logger.LogInformation("Worker running CheckTheFile at: {time} : {fileInProcess}", DateTimeOffset.Now, model.JsonHelperSerializeObject()); try { //string chormaKey = "ffmpeg -i" + fullPath + " -filter_complex '[1:v]colorkey=0x00FF00:0.3:0.2[ckout];[0:v][ckout]overlay[out]' -map '[out]' " + fullPathNew; //string result = Assistant.Execute("C:\\ffmpeg\\bin\\ffmpeg.exe", chormaKey); var FileName = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.FileName; var CommandOptimaze = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.CommandOptimaze; var CommandConvertWebm = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.CommandConvertWebm; var BinPath = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.BinPath; if (string.IsNullOrEmpty(CommandOptimaze)) { _logger.LogInformation("Ffmpeg.CommandOptimaze Is Null"); } if (string.IsNullOrEmpty(CommandConvertWebm)) { _logger.LogInformation("Ffmpeg.CommandConvertWebm Is Null"); } if (string.IsNullOrEmpty(BinPath)) { _logger.LogInformation("Ffmpeg.BinPath Is Null"); } if (string.IsNullOrEmpty(FileName)) { _logger.LogInformation("Ffmpeg.FileName Is Null"); } if (System.IO.File.Exists(model.OutputFileName)) { System.IO.File.Delete(model.OutputFileName); } if (System.IO.File.Exists(model.OutputFileName + ".error")) { System.IO.File.Delete(model.OutputFileName + ".error"); } var ass = new AssistantHelper(); string cmdCommandOptimaze = string.Format(CommandOptimaze, CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + model.InputFileName, CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + changeFileOptimaizeName(model.InputFileName)); string cmdCommandConvertWebm = string.Format(CommandConvertWebm, CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + changeFileOptimaizeName(model.InputFileName), CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + model.OutputFileName); string result = ass.Execute(FileName, BinPath, cmdCommandOptimaze); result = ass.Execute(FileName, BinPath, cmdCommandConvertWebm); var fileOutInfo = new System.IO.FileInfo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + model.OutputFileName); if (fileOutInfo.Exists) { _logger.LogInformation("نام فایل ارسالی در سیستم at: {time} : {file}", DateTimeOffset.Now, CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + model.OutputFileName); // model.OutputFileSize = fileOutInfo.Length; TextWriter twm = new StreamWriter(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + AssistantHelper.ChangeFileExtention(model.InputFileName, "order"), true); twm.WriteLine(model.JsonHelperSerializeObject()); twm.Close(); twm.Dispose(); // var f = new FileInfo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInProcess + "\\" + model.OutputFileName); f.MoveTo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + model.OutputFileName); return; } _logger.LogInformation("برروز خطا در ساخت فایل at: {time} : {file}", DateTimeOffset.Now, model.JsonHelperSerializeObject()); TextWriter tw = new StreamWriter(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + model.OutputFileName + ".error", true); tw.WriteLine("Error:برروز خطا در ساخت فایل" + result); tw.Close(); tw.Dispose(); } catch (Exception ex) { _logger.LogInformation("برروز خطا در ساخت فایل at: {time} : {error}", DateTimeOffset.Now, JsonConvert.SerializeObject(ex.Message)); TextWriter tw = new StreamWriter(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + model.OutputFileName + ".error", true); tw.WriteLine("Error:" + JsonConvert.SerializeObject(ex.Message)); tw.Close(); tw.Dispose(); } }
public IActionResult Compelete() { var webRootPath = _environment.WebRootPath; var uploadTempPath = Path.Combine(webRootPath, "Temp", Convert.ToString(Assistant.getHeaderValue(Request, "UploadId"))); if (Directory.Exists(uploadTempPath)) { var Id = Guid.NewGuid().ToString(); var newId = Guid.NewGuid().ToString(); var Extension = Assistant.getHeaderValue(Request, "FileExt"); var ExtensionOut = ".webm"; var uploadFolderPath = Path.Combine(webRootPath, "videos"); Directory.CreateDirectory(uploadFolderPath); var fullPath = Path.Combine(uploadFolderPath, Id + Extension); var fullPathNew = Path.Combine(uploadFolderPath, newId + ExtensionOut); string[] inputFilePaths = Directory.GetFiles(uploadTempPath); if (inputFilePaths.Length != 0 && inputFilePaths.Length <= Convert.ToInt32(Assistant.getHeaderValue(Request, "TotalPartNumber"))) { using (FileStream filestream = new FileStream(fullPath, FileMode.OpenOrCreate)) { for (int i = 1; i <= Convert.ToInt32(Assistant.getHeaderValue(Request, "TotalPartNumber")); i++) { using (var inputStream = System.IO.File.OpenRead(uploadTempPath + "\\" + i + ".bmp")) { inputStream.CopyTo(filestream); } } Directory.Delete(uploadTempPath, true); filestream.Flush(); } try { if (CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.Status) { #region MicroService var fileInfo = new FileInfo(fullPath); fileInfo.MoveTo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInput + "\\" + fileInfo.Name); var orderModel = new OrderModel() { InputFileName = fileInfo.Name, OutputFileName = AssistantHelper.ChangeFileExtention(fileInfo.Name, ExtensionOut), InputFileSize = fileInfo.Length }; TextWriter tw = new StreamWriter(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInput + "\\" + AssistantHelper.ChangeFileExtention(fileInfo.Name, "order"), true); tw.WriteLine(orderModel.JsonHelperSerializeObject()); tw.Close(); tw.Dispose(); var findOutFile = false; var findOutFileError = ""; while (!findOutFile) { Task.Delay(1000); var fileInfoOut = new FileInfo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + orderModel.OutputFileName); if (fileInfoOut.Exists && !fileInfoOut.IsReadOnly) { findOutFile = true; fileInfoOut.MoveTo(fullPathNew); } var fileInfoOutError = new FileInfo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + orderModel.OutputFileName + ".error"); if (fileInfoOutError.Exists && !fileInfoOutError.IsReadOnly) { findOutFile = true; findOutFileError = System.IO.File.ReadAllText(fileInfoOutError.FullName);; } } if (System.IO.File.Exists(fullPathNew)) { return(Ok(new Response() { IsSuccess = true, Message = "Download File Name", Data = newId + ExtensionOut })); } return(Ok(new Response() { IsSuccess = false, Message = "Error On Convert File", Data = findOutFileError })); #endregion MicroService } else { #region Normal var FileName = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.FileName; var CommandConvertWebm = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.CommandConvertWebm; var CommandOptimaze = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.CommandOptimaze; var BinPath = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.BinPath; if (string.IsNullOrEmpty(CommandOptimaze)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.CommandOptimaze Is Null" })); } if (string.IsNullOrEmpty(CommandConvertWebm)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.CommandConvertWebm Is Null" })); } if (string.IsNullOrEmpty(BinPath)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.BinPath Is Null" })); } if (string.IsNullOrEmpty(FileName)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.FileName Is Null" })); } var ass = new AssistantHelper(); //string CmdommandOptimaze = string.Format(CommandOptimaze, fullPath, fullPath); //string result = ass.Execute(FileName, BinPath, CmdommandOptimaze); string CmdCommandConvertWebm = string.Format(CommandConvertWebm, fullPath, fullPathNew); string result = ass.Execute(FileName, BinPath, CmdCommandConvertWebm); if (System.IO.File.Exists(fullPathNew)) { return(Ok(new Response() { IsSuccess = true, Message = "Download File Name", Data = newId + ExtensionOut })); } return(Ok(new Response() { IsSuccess = false, Message = "Error On Convert File", Data = result })); #endregion Normal } } catch (Exception ex) { return(Ok(new Response() { IsSuccess = false, Message = JsonConvert.SerializeObject(ex.Message) })); } } else { List <int> numbres = new List <int>(); for (int i = 1; i <= Convert.ToInt32(Assistant.getHeaderValue(Request, "TotalPartNumber")); i++) { if (!System.IO.File.Exists(Path.Combine(uploadTempPath, Convert.ToString(i)))) { numbres.Add(i); } } Response response = new Response() { IsSuccess = false, Message = "تکه فایل های خراب در آپلود", Data = numbres }; return(Ok(response)); } } else { return(BadRequest("شناسه آپلود اشتباه است")); } }
public void Process(string funcCode, NotifyResult notifyResult) { //通讯信息 var recvResult = notifyResult.DataResult; switch (funcCode) { case "1301": { //接收业务数据 Req_1301 req_1301 = notifyResult.ReqData as Req_1301; //处理业务 //MemberInfoDataAccess.AddOrUpdateMemberInfo(req_1301); //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1301"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "1315": //出入金账户维护【1315】 { Req_1315 req_1315 = notifyResult.ReqData as Req_1315; //处理业务 //记录签约后返回来的子账户和出入金账号 后续用到 //MemberInfoDataAccess.AddOrUpdateMemberInfo(req_1315); //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1315"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "1303": //会员签解约维护【1303】 { //接收业务数据 Req_1303 req_1303 = notifyResult.ReqData as Req_1303; //处理业务 //MemberInfoDataAccess.AddOrUpdateMemberInfo(req_1303); //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1303"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "1310": //入金(银行发起)【1310】 { Req_1310 req_1310 = notifyResult.ReqData as Req_1310; //处理业务 //.... //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1310"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "1312": //出金(银行发起)【1312】 { Req_1312 req_1312 = notifyResult.ReqData as Req_1312; //处理业务 //.... //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1312"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "1019": //查交易网端会员管理账户余额 { Req_1019 req_1019 = notifyResult.ReqData as Req_1019; //处理业务 //.... //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1019"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "1326": //银行复核通知 { Req_1326 req_1326 = notifyResult.ReqData as Req_1326; //处理业务 //.... //构造返回结果 string serialNumber = AssistantHelper.GetOrderId(6, "yyyyMMddHHmmss", ""); notifyResult.RspData.ThirdLogNo = serialNumber; notifyResult.RspData.Reserve = "1326"; notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "FILE04": //ERP文件上传、下载结果通知 { Req_FILE04 req_FILE04 = notifyResult.ReqData as Req_FILE04; //处理业务 跨行快付的业务 //.... notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; case "F002": //银行通知 明细报表生成通知接口 { Req_F002 req_F002 = notifyResult.ReqData as Req_F002; //记录日志 notifyResult.RspStatus.Code = "000000"; notifyResult.RspStatus.Msg = "交易成功"; } break; default: break; } }
public WebBotController() { _assistantHelper = new AssistantHelper(); }
public IActionResult Default() { var webRootPath = _environment.WebRootPath; var defaultFilePath = Path.Combine(webRootPath, "Temp", "default.mp4"); if (!System.IO.File.Exists(defaultFilePath)) { return(BadRequest("فایل پیش فرض یافت نشد")); } var Extension = ".mp4"; var ExtensionOut = ".webm"; var Id = Guid.NewGuid().ToString(); var fullPath = Path.Combine(webRootPath, "Videos", Id + Extension); System.IO.File.Copy(defaultFilePath, fullPath); var newId = Guid.NewGuid().ToString(); var uploadFolderPath = Path.Combine(webRootPath, "videos"); var fullPathNew = Path.Combine(uploadFolderPath, newId + ExtensionOut); try { if (CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.Status) { #region MicroService var fileInfo = new FileInfo(fullPath); fileInfo.MoveTo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInput + "\\" + fileInfo.Name); var orderModel = new OrderModel() { InputFileName = fileInfo.Name, OutputFileName = AssistantHelper.ChangeFileExtention(fileInfo.Name, "webm"), InputFileSize = fileInfo.Length }; TextWriter tw = new StreamWriter(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderInput + "\\" + AssistantHelper.ChangeFileExtention(fileInfo.Name, "order"), true); tw.WriteLine(orderModel.JsonHelperSerializeObject()); tw.Close(); tw.Dispose(); var findOutFile = false; var findOutFileError = ""; while (!findOutFile) { Task.Delay(1000); var fileInfoOut = new FileInfo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + orderModel.OutputFileName); if (fileInfoOut.Exists && !fileInfoOut.IsReadOnly) { findOutFile = true; fileInfoOut.MoveTo(fullPathNew); } var fileInfoOutError = new FileInfo(CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.MicroServiceFile.ShareFolderOutput + "\\" + orderModel.OutputFileName + ".error"); if (fileInfoOutError.Exists && !fileInfoOutError.IsReadOnly) { findOutFile = true; findOutFileError = System.IO.File.ReadAllText(fileInfoOutError.FullName);; } } if (System.IO.File.Exists(fullPathNew)) { return(Ok(new Response() { IsSuccess = true, Message = "نام فایل ارسالی در سیستم", Data = newId + ExtensionOut })); } return(Ok(new Response() { IsSuccess = false, Message = "برروز خطا در ساخت فایل", Data = findOutFileError })); #endregion MicroService } else { #region Normal var FileName = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.FileName; var CommandOptimaze = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.CommandOptimaze; var CommandConvertWebm = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.CommandConvertWebm; var BinPath = CoreIocConfig.IocConfig.GetCmsConfiguration().AppSettings.Ffmpeg.BinPath; if (string.IsNullOrEmpty(CommandOptimaze)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.CommandOptimaze Is Null" })); } if (string.IsNullOrEmpty(CommandConvertWebm)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.CommandConvertWebm Is Null" })); } if (string.IsNullOrEmpty(BinPath)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.BinPath Is Null" })); } if (string.IsNullOrEmpty(FileName)) { return(Ok(new Response() { IsSuccess = false, Message = "Ffmpeg.FileName Is Null" })); } var ass = new AssistantHelper(); //string CmdommandOptimaze = string.Format(CommandOptimaze, fullPath, fullPath); //string result = ass.Execute(FileName, BinPath, CmdommandOptimaze); string CmdCommandConvertWebm = string.Format(CommandConvertWebm, fullPath, fullPathNew); string result = ass.Execute(FileName, BinPath, CmdCommandConvertWebm); if (System.IO.File.Exists(fullPathNew)) { return(Ok(new Response() { IsSuccess = true, Message = "نام فایل ارسالی در سیستم", Data = newId + ExtensionOut })); } return(Ok(new Response() { IsSuccess = false, Message = "برروز خطا در ساخت فایل", Data = result })); #endregion Normal } } catch (Exception ex) { return(Ok(new Response() { IsSuccess = false, Message = JsonConvert.SerializeObject(ex.Message) })); } }