Ejemplo n.º 1
0
        /// <summary>
        /// Download a single assignment with all connected assignment comments
        /// from the eJournalServer.
        /// </summary>
        public static string DownloadCommentsMergedAssignment(
            ejsSessionToken sessionToken, string path,
            ejsService.ejsAssignment assignment, ejsService.ejsAssignment[] assignmentsToMerge)
        {
            EjsPublicServiceClient _client = null;

            try
            {
                _client = new EjsPublicServiceClient();
                _client.Endpoint.Address = new EndpointAddress(ejsBridgeManager.EjsAddress);

                byte[]       data = _client.GetCommentsMergedAssignment(sessionToken, assignment, assignmentsToMerge);
                FileStream   fs   = new FileStream(path, FileMode.Create, FileAccess.Write);
                BinaryWriter br   = new BinaryWriter(fs);
                br.Write(data);
                br.Flush();
                br.Close();
                fs.Close();

                return(path);
            }
            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();
                }
            }
        }