///<summary>Also deletes the voice mail file. Throws exceptions.</summary> public static void Delete(VoiceMail voiceMail) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), voiceMail); return; } if (PrefC.GetBool(PrefName.VoiceMailSMB2Enabled)) { string remoteName = PrefC.GetString(PrefName.VoiceMailArchivePath); if (!voiceMail.FileName.StartsWith(remoteName) && voiceMail.FileName != "") { remoteName = Path.GetDirectoryName(voiceMail.FileName); } //This is brutal because we need to create a network connection to the archive path but the path might not exist. //We cannot check if the directory exists without first making a network connection to it (or a parent dir). //Therefore, instead of coding some sort of directory waterfall loop, I'm simply going to let the exception throw and we'll manually create it. using (new ODNetworkConnection(remoteName, PrefC.VoiceMailNetworkCredentialsSMB2)) { //Now that we have a network connection to the directory that the file supposedly resides we can check to see if the file in fact exists. if (File.Exists(voiceMail.FileName)) { File.Delete(voiceMail.FileName); } } } else { if (File.Exists(voiceMail.FileName)) { File.Delete(voiceMail.FileName); } } Crud.VoiceMailCrud.Delete(voiceMail.VoiceMailNum); }
///<summary>Changes the voice mail's status to Deleted and moves the .wav file into the Archived folder. Permanently deletes the .txt and .ogg ///files. Throws exceptions purposefully.</summary> public static void Archive(VoiceMail voiceMail) { //No need to check RemotingRole; no call to db. voiceMail.StatusVM = VoiceMailStatus.Deleted; string oldFileName = voiceMail.FileName; voiceMail.FileName = ""; //So that we don't end up with an incorrect file name if the stuff below fails. Update(voiceMail); //Updating now in case the file I/O stuff fails. Signalods.Insert(new Signalod { IType = InvalidType.VoiceMails }); //Move the .wav file to the Archived folder. string archivePath = PrefC.GetString(PrefName.VoiceMailArchivePath); string newFileName; if (PrefC.GetBool(PrefName.VoiceMailSMB2Enabled)) { //This is brutal because we need to create a network connection to the archive path but the path might not exist. //We cannot check if the directory exists and we cannot create the directory without first making a network connection to it (or parent dir). //Therefore, instead of coding some sort of directory waterfall loop, I'm simply going to let the exception throw and we'll manually create it. using (new ODNetworkConnection(archivePath, PrefC.VoiceMailNetworkCredentialsSMB2)) { //Now that we have a network connection to the "parent" archive path we can do file IO like usual (assuming we have permission to). newFileName = ArchiveFile(oldFileName); } } else { newFileName = ArchiveFile(oldFileName); } voiceMail.FileName = newFileName; Update(voiceMail); }
///<summary></summary> public static void Update(VoiceMail voiceMail, VoiceMail voiceMailOld) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), voiceMail, voiceMailOld); return; } Crud.VoiceMailCrud.Update(voiceMail, voiceMailOld); }
///<summary>Called from PhoneTrackingServer.</summary> public static long Insert(VoiceMail voiceMail) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { voiceMail.VoiceMailNum = Meth.GetLong(MethodBase.GetCurrentMethod(), voiceMail); return(voiceMail.VoiceMailNum); } return(Crud.VoiceMailCrud.Insert(voiceMail)); }