public WebDavFileManager(bool IsAdmin) { salesAudioUri = ConfigManager.AppSettings["SalesAudioUri"]; webDavLicense = XmlDecode(ConfigManager.AppSettings["WebDavLicense"]); string[] usernamePassword = ConfigManager.AppSettings["WebDavUsernamePassword"].Split('|'); WebDavUserName = usernamePassword[0]; WebDavPassword = usernamePassword[1]; CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); commonData.CreateFolder(commonData.ApplicationFolderPath + "\\tmpwav"); commonData.CreateFolder(commonData.ApplicationFolderPath + "\\cachewav"); commonData.CreateFolder(commonData.ApplicationFolderPath + "\\errorconversion"); }
public WebDavFileManager() { salesAudioUri = ConfigManager.AppSettings["SalesAudioUri"]; webDavLicense = XmlDecode(ConfigManager.AppSettings["WebDavLicense"]); string[] usernamePassword = ConfigManager.AppSettings["WebDavUsernamePassword"].Split('|'); WebDavUserName = usernamePassword[0]; WebDavPassword = usernamePassword[1]; backWorkerUploader = new BackgroundWorker(); backWorkerAudioConverter = new BackgroundWorker(); backWorkerCheckWebDavConnection = new BackgroundWorker(); backWorkerAudioConverter.WorkerSupportsCancellation = true; backWorkerUploader.WorkerSupportsCancellation = true; backWorkerCheckWebDavConnection.WorkerSupportsCancellation = true; //backWorkerUploader.DoWork += new DoWorkEventHandler(backWorkerUploader_DoWork); //backWorkerAudioConverter.DoWork += new DoWorkEventHandler(backWorkerAudioConverter_DoWork); //backWorkerCheckWebDavConnection.DoWork += new DoWorkEventHandler(backWorkerCheckWebDavConnection_DoWork); CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); commonData.CreateFolder(commonData.ApplicationFolderPath + "\\tmpwav"); commonData.CreateFolder(commonData.ApplicationFolderPath + "\\cachewav"); commonData.CreateFolder(commonData.ApplicationFolderPath + "\\errorconversion"); }
public static string DownloadedAudioFile(Guid audioID) { string audioPath = string.Empty; try { var objDbModel = new BrightPlatformEntities(UserSession.EntityConnection); var followup = objDbModel.event_followup_log.Where(param => param.audio_id == audioID).FirstOrDefault(); string salesAudioUri = ConfigurationManager.AppSettings["SalesAudioUri"]; string webDavLicense = XmlDecode(ConfigurationManager.AppSettings["WebDavLicense"]); string[] usernamePassword = ConfigurationManager.AppSettings["WebDavUsernamePassword"].Split('|'); string WebDavUserName = usernamePassword[0]; string WebDavPassword = usernamePassword[1]; string audioUrl = String.Format("{0}/{1}/{2}/{3}/{4}_.mp3", salesAudioUri, followup.date_created.Value.Year, followup.date_created.Value.Month, followup.date_created.Value.Day, audioID); var commonData = new CommonApplicationData("BrightVision", "BrightSales", true); return BrightSalesFacade.FileUpload.AudioToCacheFolder(audioUrl); //var session = new WebDavSession(webDavLicense); //session.Credentials = new NetworkCredential(WebDavUserName, WebDavPassword); //IFolder folder = session.OpenFolder(new Uri(salesAudioUri)); //IResource resource = session.OpenResource(audioUrl); //resource.TimeOut = 36000000; // 10 hours //using (Stream webStream = resource.GetReadStream()) //{ // int bufSize = 1048576; // 1Mb // byte[] buffer = new byte[bufSize]; // int bytesRead = 0; // audioPath = String.Format("{0}\\cachewav\\{1}", commonData.ApplicationFolderPath, resource.DisplayName); // using (FileStream fileStream = File.OpenWrite(audioPath)) // { // while ((bytesRead = webStream.Read(buffer, 0, bufSize)) > 0) // fileStream.Write(buffer, 0, bytesRead); // } //} } catch(Exception e) { // MessageBox.Show("There is a problem connecting to the file server. please contact administrator. Error" +e.Message, "Cannot download audio file", MessageBoxButtons.OK, MessageBoxIcon.Error); } return audioPath; }
/// <summary> /// Occurs when the phone call state has changed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void call_CallStateChanged1(object sender, VoIPEventArgs<CallState> e) { this.InvokeGUIThread(() => { if (e.Item == CallState.Ringing) { m_TimeStart = DateTime.Now.TimeOfDay; m_StartTimeOutCounter = true; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Ring); } else if (e.Item == CallState.InCall) { try { m_StartTimeOutCounter = false; mixer = new AudioMixerMediaHandler(); mixerMic = new AudioMixerMediaHandler(); mixerReceiver = new AudioMixerMediaHandler(); AudioId = Guid.NewGuid(); CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); if (m_UserMicrophone != null) m_UserMicrophone.Start(); if (m_UserSpeaker != null) m_UserSpeaker.Start(); connector.Connect(m_UserMicrophone, mediaSender); connector.Connect(mediaReceiver, m_UserSpeaker); m_MediaUtility.Stop(); //m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); mediaSender.AttachToCall(call); mediaReceiver.AttachToCall(call); #region combine mic and receiver in record string fileName = String.Format(@"{0}\\tmpwav\\{1}_.wav", commonData.ApplicationFolderPath, AudioId); recorder = new WaveStreamRecorder(fileName); recorder.Stopped += new EventHandler<EventArgs>(recorder_Stopped); connector.Connect(m_UserMicrophone, mixer); connector.Connect(mediaReceiver, mixer); connector.Connect(mixer, recorder); #endregion #region record mic fileName = String.Format(@"{0}\\tmpwav\\{1}_mic.wav", commonData.ApplicationFolderPath, AudioId); recorderMic = new WaveStreamRecorder(fileName); recorderMic.Stopped += new EventHandler<EventArgs>(recorder_Stopped1); connector.Connect(m_UserMicrophone, mixerMic); connector.Connect(mixerMic, recorderMic); #endregion #region record receiver fileName = String.Format(@"{0}\\tmpwav\\{1}_receiver.wav", commonData.ApplicationFolderPath, AudioId); recorderReceiver = new WaveStreamRecorder(fileName); recorderReceiver.Stopped += new EventHandler<EventArgs>(recorder_Stopped2); connector.Connect(mediaReceiver, mixerReceiver); connector.Connect(mixerReceiver, recorderReceiver); #endregion recorder.StartStreaming(); //recorder.IsStreaming = true; recorderReceiver.StartStreaming(); //recorderReceiver.IsStreaming = true; recorderMic.StartStreaming(); //recorderMic.IsStreaming = true; } catch(Ozeki.Common.Exceptions.MediaException me) { if (CallState_Changed != null) { CallState_Changed(this, new CallStateChangedArgs() { PhoneCallState = CallState.Rejected }); } if (call != null) call.HangUp(); //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); MessageBox.Show("Your mic or speaker is not working. Please change your mic or speaker in the Phone Settings.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (e.Item == CallState.Completed) { try { if (m_UserMicrophone != null) m_UserMicrophone.Stop(); if (m_UserSpeaker != null) m_UserSpeaker.Stop(); connector.Disconnect(m_UserMicrophone, mediaSender); connector.Disconnect(mediaReceiver, m_UserSpeaker); if (recorder != null) { recorder.StopStreaming(); //recorder.IsStreaming = false; } if (recorderMic != null) { recorderMic.StopStreaming(); //recorderMic.IsStreaming = false; } if (recorderReceiver != null) { recorderReceiver.StopStreaming(); //recorderReceiver.IsStreaming = false; } connector.Disconnect(m_UserMicrophone, mixer); connector.Disconnect(mediaReceiver, mixer); connector.Disconnect(mixer, recorder); connector.Disconnect(m_UserSpeaker, mixerMic); connector.Disconnect(mixerMic, recorderMic); connector.Disconnect(mixerMic, recorderMic); connector.Disconnect(mixerReceiver, recorderReceiver); mediaSender.Detach(); mediaReceiver.Detach(); if (m_RingTimeOut) return; //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); //call.HangUp(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); recorder.Dispose(); mixer.Dispose(); recorder = null; mixer = null; recorderMic.Dispose(); mixerMic.Dispose(); recorderMic = null; mixerMic = null; mixerReceiver.Dispose(); recorderReceiver.Dispose(); mixerReceiver = null; recorderReceiver = null; WaitUntilTheRecordEndProcess(); } catch { //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; } } else if (e.Item == CallState.Cancelled) { if (m_RingTimeOut) return; m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Rejected) { m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Busy || e.Item == CallState.Error) { m_RingTimeOut = true; m_StartTimeOutCounter = false; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Busy); //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); call.HangUp(); call = null; //MessageBox.Show("Error encountered. Please check the format of the number you are calling.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.WireDownCallEvents(); //call = null; } if (CallState_Changed != null) CallState_Changed(this, new CallStateChangedArgs() { PhoneCallState = e.Item, AudioId = AudioId }); }); }
private void call_CallStateChanged(object sender, VoIPEventArgs<CallState> e) { callstate = e.Item; if (e.Item == CallState.Ringing) { m_TimeStart = DateTime.Now.TimeOfDay; m_StartTimeOutCounter = true; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Ring); } else if (e.Item == CallState.InCall) { try { m_StartTimeOutCounter = false; m_MediaUtility.Stop(); recorder.StartStreaming(); //recorder.IsStreaming = true; } catch (Ozeki.Common.Exceptions.MediaException me) { if (CallState_Changed != null) { AudioId = Guid.Empty; CallState_Changed(this, new CallStateChangedArgs() { PhoneCallState = CallState.Rejected }); } if (call != null) call.HangUp(); //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); MessageBox.Show("Your mic or speaker is not working. Please change your mic or speaker in the Phone Settings.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } else if (e.Item == CallState.Completed) { try { recorder.StopStreaming(); //recorder.IsStreaming = false; EndCall(); if (m_RingTimeOut) return; this.WireDownCallEvents(); call = null; recorder.Dispose(); recorder = null; CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); string fileNameTmp = String.Format(@"{0}\tmpwav\{1}_.wav", commonData.ApplicationFolderPath, AudioId); string fileNameCache = String.Format(@"{0}\cachewav\{1}_.wav", commonData.ApplicationFolderPath, AudioId); File.Copy(fileNameTmp, fileNameCache); m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } catch { //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); this.WireDownCallEvents(); call = null; } } else if (e.Item == CallState.Cancelled) { AudioId = Guid.Empty; EndCall(); if (m_RingTimeOut) return; m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Rejected) { AudioId = Guid.Empty; EndCall(); m_StartTimeOutCounter = false; //softPhone.UnregisterPhoneLine(phoneLine); this.WireDownCallEvents(); call = null; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.HangUp); } else if (e.Item == CallState.Busy || e.Item == CallState.Error) { AudioId = Guid.Empty; EndCall(); m_RingTimeOut = true; m_StartTimeOutCounter = false; m_MediaUtility.Start(MediaUtility.ePhoneCallSoundType.Busy); //softPhone.UnregisterPhoneLine(phoneLine); softPhone.Close(); call.HangUp(); call = null; //MessageBox.Show("Error encountered. Please check the format of the number you are calling.", "Bright Sales", MessageBoxButtons.OK, MessageBoxIcon.Information); //this.WireDownCallEvents(); //call = null; } if (CallState_Changed != null) { CallState_Changed(this, new CallStateChangedArgs() { PhoneCallState = e.Item, AudioId = AudioId }); } }
public void CreateCall(string pPhoneNo, int pPhoneRingTimeOut = 30) { if (pPhoneRingTimeOut > 0) m_RingingTimeOut = pPhoneRingTimeOut; m_RingTimeOut = false; m_PhoneNo = pPhoneNo; m_UserMicrophone.Start(); connector.Connect(m_UserMicrophone, mediaSender); AudioId = Guid.NewGuid(); CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); m_UserMicrophone.Start(); string fileNameTmp = String.Format(@"{0}\tmpwav\{1}_.wav", commonData.ApplicationFolderPath, AudioId); recorder = new WaveStreamRecorder(fileNameTmp); recorder.Stopped += new EventHandler<EventArgs>(recorder_Stopped); connector.Connect(m_UserMicrophone, mixer); connector.Connect(mediaReceiver, mixer); connector.Connect(mixer, recorder); m_UserSpeaker.Start(); connector.Connect(mediaReceiver, m_UserSpeaker); call = softPhone.CreateCallObject(phoneLine, m_PhoneNo); mediaSender.AttachToCall(call); mediaReceiver.AttachToCall(call); this.WireUpCallEvents(); //System.Threading.Thread.Sleep(1500); call.Start(); //softPhone.RegisterPhoneLine(phoneLine); //this.InitializeSoftPhone(); }
private static bool AudioFileExist(GridView view, Guid id) { Guid audioId = Guid.Empty; string strAudioId = view.GetFocusedRowCellValue("audio_id").ToString(); var commonData = new CommonApplicationData("BrightVision", "BrightSales", true); string audioCachePath = String.Format("{0}\\cachewav\\{1}", commonData.ApplicationFolderPath, strAudioId + "_.mp3"); string audioTmpPath = String.Format("{0}\\tmpwav\\{1}", commonData.ApplicationFolderPath, strAudioId + "_.wav"); if (File.Exists(audioCachePath) || File.Exists(audioTmpPath)) { return true; } return false; }
public string AudioToCacheFolder(string audioUrl) { var commonData = new CommonApplicationData("BrightVision", "BrightSales", true); string audioPath = string.Empty; try { IResource resource = GetWebDavSession().OpenResource(audioUrl); resource.TimeOut = 36000000; // 10 hours using (Stream webStream = resource.GetReadStream()) { int bufSize = 1048576; // 1Mb byte[] buffer = new byte[bufSize]; int bytesRead = 0; audioPath = String.Format("{0}\\cachewav\\{1}", commonData.ApplicationFolderPath, resource.DisplayName); using (FileStream fileStream = File.OpenWrite(audioPath)) { while ((bytesRead = webStream.Read(buffer, 0, bufSize)) > 0) fileStream.Write(buffer, 0, bytesRead); } } } catch (Exception e) { } return audioPath; }
private void DeleteTempFiles() { try { CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); //string tmpfolder = commonData.ApplicationFolderPath + "\\tmpwav"; //var filesPath = Directory.GetFiles(tmpfolder); //foreach (string path in filesPath) //{ // File.Delete(path); //} string tmpfolder = commonData.ApplicationFolderPath + "\\cachewav"; string[] filesPath = Directory.GetFiles(tmpfolder); foreach (string path in filesPath) { if(!File.Exists(path.Replace("cachewav", "tmpwav"))) File.Delete(path); } } catch { } }
void backWorkerUploader_DoWork(object sender, DoWorkEventArgs e) { for (;;) { if (connectionFail) Thread.Sleep(180000); if (isClose) break; CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); var result = Directory.GetFiles(commonData.ApplicationFolderPath); if (result.Count() > 0) { string[] copyres = GetFileNames(result); Logger log = new Logger(Logging.Enums.BrightVisionApplication.BrightSales); log.SendInfo("array_of_mp3_files", string.Join(", ", result)); } skipAutoCheckConnection = false; Guid audioId = Guid.Empty; foreach (string path in result) { try { string filenameNoExt = Path.GetFileNameWithoutExtension(path); FileInfo fileInfo = new FileInfo(path); if (IsFileLocked(fileInfo)) { Thread.Sleep(3000); continue; } if (filenameNoExt.EndsWith("_") || filenameNoExt.EndsWith("_mic") || filenameNoExt.EndsWith("_receiver")) { string filename = filenameNoExt.Replace("_mic", "").Replace("_receiver", "").Replace("_", ""); audioId = Guid.Empty; if (Guid.TryParse(filename, out audioId)) { BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection); var followup = objDbModel.event_followup_log.Where(param => param.audio_id == audioId).FirstOrDefault(); if (followup != null) { skipAutoCheckConnection = true; SetDaysFolder(followup); var date = followup.date_created.Value; string year = date.Year.ToString(); string month = date.Month.ToString(); string days = date.Day.ToString(); IFolder folder = GetWebDavSession().OpenFolder(salesAudioUri + "/" + year + "/" + month + "/" + days); FileInfo file = new FileInfo(path); if (folder.ItemExists(file.Name)) { IResource todelete = folder.GetResource(file.Name); todelete.Delete(); } IResource resource = folder.CreateResource(file.Name); resource.TimeOut = 36000000; using (Stream webStream = resource.GetWriteStream(file.Length)) { int bufSize = 1048576; // 1Mb byte[] buffer = new byte[bufSize]; int bytesRead = 0; using (FileStream fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read)) { while ((bytesRead = fileStream.Read(buffer, 0, bufSize)) > 0) { webStream.Write(buffer, 0, bytesRead); if (isClose) break; } } } if (isClose) break; //Save to database when file is save to the server if (filenameNoExt.Contains("_mic")) { followup.mic_uploaded = true; objDbModel.SaveChanges(); } else if (filenameNoExt.Contains("_receiver")) { followup.receiver_uploaded = true; objDbModel.SaveChanges(); } else if (filenameNoExt.Contains("_")) { followup.main_uploaded = true; objDbModel.SaveChanges(); } File.Delete(path); if (isClose) break; } //else { // File.Delete(path); //} try { if (followup != null) objDbModel.Detach(followup); } catch { } } else { File.Delete(path); } } } catch (Exception ex) { Logger log = new Logger(Logging.Enums.BrightVisionApplication.BrightSales); log.Error("error_uploadaudio", "WebDavFileManager.backWorkerUploader_DoWork_" + audioId, ex); skipAutoCheckConnection = false; } } if (isClose) break; skipAutoCheckConnection = false; Thread.Sleep(3000); } isUploadDone = true; }
void backWorkerAudioConverter_DoWork(object sender, DoWorkEventArgs e) { for(;;){ if (isClose) { backWorkerAudioConverter.CancelAsync(); break; } CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); var result = Directory.GetFiles(commonData.ApplicationFolderPath + "\\tmpwav"); if (result.Count() > 0) { string[] copyres = GetFileNames(result); Logger log = new Logger(Logging.Enums.BrightVisionApplication.BrightSales); log.SendInfo("array_of_wav_files", string.Join(", ", copyres)); } Guid audioId = Guid.Empty; foreach (string path in result) { try { FileInfo fileInfo = new FileInfo(path); if (isClose) { backWorkerAudioConverter.CancelAsync(); break; } if ( File.Exists(path.Replace(".wav", ".mp3").Replace("\\tmpwav", "")) || IsFileLocked(fileInfo)) { continue; } else { string filenameNoExt = Path.GetFileNameWithoutExtension(path); string filename = filenameNoExt.Replace("_mic", "").Replace("_receiver", "").Replace("_", ""); audioId = Guid.Empty; FileInfo info = new FileInfo(path); if (Guid.TryParse(filename, out audioId) && info.Length > 0) { event_followup_log followup = null; using (BrightPlatformEntities objDbModel = new BrightPlatformEntities(UserSession.EntityConnection)) { followup = objDbModel.event_followup_log.Where(param => param.audio_id == audioId).FirstOrDefault(); if (followup == null) { if (DateTime.Now.Subtract(info.CreationTime).Days > 2) { File.Delete(path); } continue; } else if ( filenameNoExt.Contains("_mic") && followup.mic_uploaded.HasValue && followup.mic_uploaded.Value) { File.Delete(path); objDbModel.Detach(followup); continue; } else if ( filenameNoExt.Contains("_receiver") && followup.mic_uploaded.HasValue && followup.mic_uploaded.Value) { File.Delete(path); objDbModel.Detach(followup); continue; } else if ( filenameNoExt.Contains("_") && followup.main_uploaded.HasValue && followup.main_uploaded.Value) { File.Delete(path); objDbModel.Detach(followup); continue; } subcampaign _eftSubCampaign = null; int _CustomerId = 0; if (followup != null) { int _CampaignId = (int)objDbModel.subcampaigns.FirstOrDefault(i => i.id == followup.subcampaign_id).campaign_id; _CustomerId = (int)objDbModel.campaigns.FirstOrDefault(i => i.id == _CampaignId).customer_id; } if (followup != null) objDbModel.Detach(followup); mciConvertWavMP3(path, true, _CustomerId); Thread.Sleep(3000); } } else { File.Delete(path); continue; } } //This will convert from wav to mp3 move the mp3 to the main folder //if (!File.Exists(path)) // File.Copy(path, path.Replace("tmpwav", "cachewav")); } catch (Exception ex) { Logger log = new Logger(Logging.Enums.BrightVisionApplication.BrightSales); log.Error("error_convertaudio", "WebDavFileManager.backWorkerAudioConverter_DoWork_" + audioId, ex); } if (isClose) break; } if (isClose) break; Thread.Sleep(3000); } isAudioConverterDone = true; }
private static DXMenuItem SaveAudioToLocationOld(GridView view, int rowHandle) { Guid audioId = Guid.Empty; object objAudioId = view.GetFocusedRowCellValue("audio_id"); if (objAudioId == null) return null; bool IsGuid = Guid.TryParse(objAudioId.ToString(), out audioId); if (IsGuid) { if (!AudioFileExist(view, audioId)) { var objDbModel = new BrightPlatformEntities(UserSession.EntityConnection); var followup = objDbModel.event_followup_log.Where(param => param.audio_id == audioId).FirstOrDefault(); if (followup == null || !followup.main_uploaded == null || !(followup.main_uploaded.HasValue && followup.main_uploaded.Value)) { return null; } } } //Create Save Audio To Location MenuItem with Click Event var menuitem = new DXMenuItem { Caption = "Save Audio To Location", Shortcut = Shortcut.CtrlS }; menuitem.Tag = new RowInfo(view, rowHandle); menuitem.Click += delegate(object sender, EventArgs e) { var commonData = new CommonApplicationData("BrightVision", "BrightSales", true); string audioCachePath = String.Format("{0}\\cachewav\\{1}", commonData.ApplicationFolderPath, audioId + "_.mp3"); string audioCachePath2 = String.Format("{0}\\cachewav\\{1}", commonData.ApplicationFolderPath, audioId + "_.wav"); string audioTmpPath = String.Format("{0}\\tmpwav\\{1}", commonData.ApplicationFolderPath, audioId + "_.wav"); if (File.Exists(audioCachePath)) { try { FileManagerUtility.SaveToLocationAudio(audioCachePath); } catch { NotificationDialog.Information("Cannot Play", "Cannot play audio. The audio is still in the process of downloading. Try again later."); } } else if (File.Exists(audioCachePath2)) { try { FileManagerUtility.SaveToLocationAudio(audioCachePath2); } catch { NotificationDialog.Information("Cannot Play", "Cannot play audio. The audio is still in the process of downloading. Try again later."); } } else if (File.Exists(audioTmpPath)) { try { File.Copy(audioTmpPath, audioTmpPath.Replace("tmpwav","cachewav")); FileManagerUtility.SaveToLocationAudio(audioCachePath2); } catch { NotificationDialog.Information("Cannot Play", "Cannot play audio. The audio is being converted to mp3. Try again later."); } } else { audioId = Guid.Parse(objAudioId.ToString()); WaitDialog.Show("Downloading audio files...."); string fileUrl = FileManagerUtility.GetServerUrl(audioId); string fileDir = BrightSalesFacade.WebDavFile.AudioToCacheFolder(fileUrl); Thread.Sleep(2000); WaitDialog.Close(); if (fileUrl == null) return; try { FileManagerUtility.SaveToLocationAudio(fileDir); } catch { NotificationDialog.Information("Cannot Play", "Cannot play audio. The audio is being converted to mp3. Try again later."); } } }; return menuitem; }
private static Configuration GetConfiguration() { string appName = Environment.GetCommandLineArgs()[0]; string tmpConfig =string.Empty; string tmpConfigTmp = string.Empty; CommonApplicationData commonAppFolder = null; if (appName.Contains("SalesConsultant")) { commonAppFolder = new CommonApplicationData("BrightVision", "BrightSales"); tmpConfig = AppDomain.CurrentDomain.BaseDirectory+"SalesConsultant.exe.config.protected"; tmpConfigTmp = commonAppFolder.ApplicationFolderPath + "\\bs.tmp"; }else{ commonAppFolder = new CommonApplicationData("BrightVision", "BrightManager"); tmpConfig = AppDomain.CurrentDomain.BaseDirectory + "ManagerApplication.exe.config.protected"; tmpConfigTmp = commonAppFolder.ApplicationFolderPath + "\\bm.tmp"; } string eC = Resources.p; string configFile = File.ReadAllText(tmpConfig, Encoding.UTF8); int bitStrength = GetBitStrength(eC); eC = RemoveStrengthInString(eC); string config = SecurityUtility.Decrypt(configFile, bitStrength, eC); File.WriteAllText(tmpConfigTmp, config, Encoding.UTF8); Configuration configuration = GetConfigFromPath(tmpConfigTmp); File.Delete(tmpConfigTmp); return configuration; }
private void btnSearchFile_Click(object sender, EventArgs e) { CommonApplicationData commonData = new CommonApplicationData("BrightVision", "BrightSales", true); bool IsFoundMP3 = SearchMP3(commonData.ApplicationFolderPath); bool IsFoundTmpWav = SearchOnTmpWav(commonData.ApplicationFolderPath + "\\tmpwav\\"); bool IsFoundCacheWav = SearchOnTmpWav(commonData.ApplicationFolderPath + "\\cachewav\\"); bool IsFoundFailedUploadFolderMP3 = SearchMP3(commonData.ApplicationFolderPath + "\\FailedUpload\\"); bool IsFoundFailedUploadFolderTmpWav = SearchOnTmpWav(commonData.ApplicationFolderPath + "\\FailedUpload\\"); string audioFileMP3 = commonData.ApplicationFolderPath + "\\" + lblAudioId.Text + "_.mp3"; string audioFileWAV = commonData.ApplicationFolderPath + "\\tmpwav\\" + lblAudioId.Text + "_.wav"; string audioFileCACHE = commonData.ApplicationFolderPath + "\\cachewav\\" + lblAudioId.Text + "_.wav"; string audioFileFailedUploadMP3 = commonData.ApplicationFolderPath + "\\FailedUpload\\" + lblAudioId.Text + "_.mp3"; string audioFileFailedUploadWAV = commonData.ApplicationFolderPath + "\\FailedUpload\\" + lblAudioId.Text + "_.wav"; if (IsFoundTmpWav || IsFoundCacheWav || IsFoundMP3 || IsFoundFailedUploadFolderMP3 || IsFoundFailedUploadFolderTmpWav) { string audioFile = null; if (IsFoundTmpWav) audioFile = audioFileWAV; else if (IsFoundCacheWav) audioFile = audioFileCACHE; else if (IsFoundMP3) audioFile = audioFileMP3; else if (IsFoundFailedUploadFolderMP3) audioFile = audioFileFailedUploadMP3; else if (IsFoundFailedUploadFolderTmpWav) audioFile = audioFileFailedUploadWAV; if (MessageBox.Show("Found a match. Do you want to re-upload the audio file?", "Match found", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { this.Cursor = Cursors.WaitCursor; string _filename = Path.GetFileName(audioFile); if (!IsFoundTmpWav && !IsFoundCacheWav && !IsFoundMP3 && IsFoundFailedUploadFolderMP3) File.Move(audioFile, commonData.ApplicationFolderPath + "\\" + _filename); else if (!IsFoundTmpWav && !IsFoundCacheWav && !IsFoundMP3 && IsFoundFailedUploadFolderTmpWav) File.Move(audioFile, commonData.ApplicationFolderPath + "\\tmpwav" + _filename); if (IsFoundTmpWav && IsFoundMP3) File.Delete(audioFileMP3); (new WindowsAzureStorageBlobUtility()).UploadFile(audioFile); this.Cursor = Cursors.Default; } else { this.Close(); } } else { if (IsFoundMP3) { } MessageBox.Show("No audio file found. Try using the previous computer used by " + lblCreatedBy.Text + ".", "No match found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } this.Close(); }