/// <summary> /// Download the specified Course Document to the given path if possible. If not, /// choose a new location and return it to the caller. /// </summary> public static int SaveAndUploadNewAssignment( ejsSessionToken sessionToken, string path, ejsService.ejsAssignment assignment) { EjsPublicServiceClient _client = null; try { _client = new EjsPublicServiceClient(); _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); long fileSize = fs.Length; byte[] data = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); fs.Dispose(); assignment.DataSize = data.Length; int NewID = _client.SaveAndUploadAssignment(sessionToken, assignment, data); // let's do not throw ApplicationException here. //if (NewID == -1) // throw new ApplicationException(Properties.Resources.EX_AsgUploadFailed); return(NewID); } catch (FaultException <ejsFailureReport> ex) { if (ex.Detail._failureCode == 7) { sessionToken._isAuthenticated = false; } throw new ApplicationException(ex.Detail._header + "\n" + ex.Detail._message); } catch (Exception) { sessionToken._isAuthenticated = false; //throw new ApplicationException(Properties.Resources.EX_EjsConnectionFailed); throw; } finally { if (_client != null) { _client.Close(); } } }