} // func GetOutFiles public async Task <bool> UpdateOutFileStateAsync(IOdetteFileEndToEndDescription description) { if (service.directoryOut == null) // do we have the directory { return(false); } // check file exists var fi = service.CreateOutFileName(description.Name, OdetteOutFileState.WaitEndToEnd); if (!fi.Exists) { return(false); } // mark file as finish await ChangeOutFileStateAsync(fi, OdetteOutFileState.ReceivedEndToEnd); // update file information var fileItem = await Task.Run(() => new FileItem(service, fi, description.Name, false)); fileItem.Log(log, String.Format("Update file commit: {0} with [{1}] {2}", OdetteFileImmutable.FormatFileName(description.Name, description.UserData), description.ReasonCode, description.ReasonText)); var xCommit = fileItem.Extensions.Root.Element("commit"); if (xCommit == null) { fileItem.Extensions.Root.Add(xCommit = new XElement("commit")); } xCommit.SetAttributeValue("reasonCode", description.ReasonCode); xCommit.SetAttributeValue("reasonText", description.ReasonText); xCommit.SetAttributeValue("userData", description.UserData); await fileItem.SaveExtensionsAsync(); return(true); } // proc UpdateOutFileState
} // func GetOutFiles public bool UpdateOutFileState(IOdetteFileEndToEndDescription description) { if (service.directoryOut == null) // do we have the directory return false; // check file exists var fi = service.CreateOutFileName(description.Name, OdetteOutFileState.WaitEndToEnd); if (!fi.Exists) return false; // mark file as finish ChangeOutFileState(fi, OdetteOutFileState.ReceivedEndToEnd); // update file information var fileItem = new FileItem(service, fi, description.Name, false); fileItem.Log(log, String.Format("Update file commit: {0} with [{1}] {2}", OdetteFileMutable.FormatFileName(description.Name, description.UserData), description.ReasonCode, description.ReasonText)); var xCommit = fileItem.Extensions.Root.Element("commit"); if (xCommit == null) fileItem.Extensions.Root.Add(xCommit = new XElement("commit")); xCommit.SetAttributeValue("reasonCode", description.ReasonCode); xCommit.SetAttributeValue("reasonText", description.ReasonText); xCommit.SetAttributeValue("userData", description.UserData); fileItem.SaveExtensions(); return true; } // proc UpdateOutFileState
} // func GetOutFiles /// <summary>End to end received for a file.</summary> /// <param name="file"></param> /// <param name="description"></param> public void UpdateOutFileState(IOdetteFileEndToEndDescription description) { foreach (var s in services) { if (s.UpdateOutFileState(description)) return; } throw new OdetteFileServiceException(OdetteAnswerReason.InvalidFilename, String.Format("E2E failed for {0}.", OdetteFileMutable.FormatFileName(description.Name, description.UserData)), false); } // proc UpdateOutFileState