Esempio n. 1
0
        private void HandleJobList(NetIncomingMessage msg)
        {
            int byteNum = msg.ReadInt32();

            byte[] compressedXml = msg.ReadBytes(byteNum);

            string jobListXml = ZipString.UnZipStr(compressedXml);

            JobHandler.Singleton.LoadDefinitionsFromString(jobListXml);
            int pos = 5;

            _jobButtonContainer.components.Clear(); //Properly dispose old buttons !!!!!!!
            foreach (JobDefinition definition in JobHandler.Singleton.JobSettings.JobDefinitions)
            {
                var current = new JobSelectButton(definition.Name, definition.JobIcon, definition.Description,
                                                  ResourceManager)
                {
                    Available = definition.Available,
                    Position  = new Vector2i(5, pos)
                };

                current.Clicked += CurrentClicked;
                current.UserData = definition;
                _jobButtonContainer.components.Add(current);
                pos += current.ClientArea.Height + 20;
            }
        }
Esempio n. 2
0
        public FileResult DownloadFile(int id)
        {
            var cais   = _caisReportsHistoryRepository.Get(id);
            var bytes  = Encoding.UTF8.GetBytes(ZipString.Unzip(cais.FileData));
            var result = new FileContentResult(bytes, "text/plain")
            {
                FileDownloadName = cais.FileName
            };

            return(result);
        }
Esempio n. 3
0
        public string GetOneFile(int id)
        {
            var cais = _caisReportsHistoryRepository.Get(id);

            if (cais == null)
            {
                throw new FileNotFoundException();
            }

            return(ZipString.Unzip(cais.FileData));
        }
Esempio n. 4
0
        public void HandleJobListRequest(NetIncomingMessage msg)
        {
            NetOutgoingMessage jobListMessage = IoCManager.Resolve <ISS14NetServer>().CreateMessage();

            jobListMessage.Write((byte)NetMessage.JobList);
            byte[] compressedStr = ZipString.ZipStr(JobHandler.Singleton.GetDefinitionsString());
            jobListMessage.Write(compressedStr.Length);
            jobListMessage.Write(compressedStr);
            //LogManager.Log("Jobs sent: " + compressedStr.Length.ToString());
            IoCManager.Resolve <ISS14NetServer>().SendMessage(jobListMessage, msg.SenderConnection,
                                                              NetDeliveryMethod.ReliableOrdered);
        }
Esempio n. 5
0
        private void SendCAISFile(int id)
        {
            var file   = _caisReportsHistoryRepository.Get(id);
            var sender = new CaisFileSender();

            try
            {
                sender.UploadData(ZipString.Unzip(file.FileData), file.FileName);
                file.UploadStatus = CaisUploadStatus.Uploaded;
            }
            catch (Exception)
            {
                file.UploadStatus = CaisUploadStatus.UploadError;
                throw;
            }
        }
Esempio n. 6
0
        }         // Name

        public override void Execute()
        {
            SafeReader sr = DB.GetFirst(
                "GetCaisFileData",
                CommandSpecies.StoredProcedure,
                new QueryParameter("CaisId", caisId)
                );

            string fileName = sr["FileName"];
            string dirName  = sr["DirName"];

            var file = caisReportsHistoryRepository.Get(caisId);
            var unzippedFileContent = file != null?ZipString.Unzip(file.FileData) : "";

            File.WriteAllText(string.Format("{0}\\{1}", dirName, fileName), unzippedFileContent, Encoding.ASCII);
        }         // Execute
Esempio n. 7
0
        private void HandleJobList(NetIncomingMessage msg)
        {
            int byteNum = msg.ReadInt32();

            byte[] compressedXml = msg.ReadBytes(byteNum);

            string jobListXml = ZipString.UnZipStr(compressedXml);

            JobHandler.Singleton.LoadDefinitionsFromString(jobListXml);

            _tabJob._shwDepa.ClearItems();
            _tabJob._shwJobs.ClearItems();

            sortedJobs.Clear();

            foreach (DepartmentDefinition dep in JobHandler.Singleton.JobSettings.DepartmentDefinitions)
            {
                var depJobs = (from x in JobHandler.Singleton.JobSettings.JobDefinitions
                               where x.Department.ToLowerInvariant() == dep.Name.ToLowerInvariant()
                               where x.Available
                               orderby x.Name
                               select x).ToList();

                var newEntry = new KeyValuePair <DepartmentDefinition, List <JobDefinition> >(dep, depJobs);
                sortedJobs.Add(newEntry);

                var newDep = new ImageButton
                {
                    ImageNormal = dep.DepartmentIcon,
                };

                DepartmentInfo newInfo = new DepartmentInfo()
                {
                    Department = dep,
                    JobDefs    = depJobs
                };

                _tabJob._shwDepa.AddItem(newDep, newInfo);
            }
        }
Esempio n. 8
0
		/// <summary>
		/// Set the file comment to be recorded when the current update is <see cref="CommitUpdate">commited</see>.
		/// </summary>
		/// <param name="comment">The comment to record.</param>
		/// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
		public void SetComment(string comment)
		{
			if ( isDisposed_ ) {
				throw new ObjectDisposedException("ZipFile");
			}

			CheckUpdating();

			newComment_ = new ZipString(comment);

			if ( newComment_.RawLength  > 0xffff ) {
				newComment_ = null;
				throw new ZipException("Comment length exceeds maximum - 65535");
			}

			// We dont take account of the original and current comment appearing to be the same
			// as encoding may be different.
			commentEdited_ = true;
		}
Esempio n. 9
0
        /// <summary>
        /// Begin updating this <see cref="ZipFile"/> archive.
        /// </summary>
        /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param>
        /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param>
        /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
        /// <exception cref="ArgumentNullException">One of the arguments provided is null</exception>
        /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
        public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource)
        {
            if ( archiveStorage == null ) {
                throw new ArgumentNullException("archiveStorage");
            }

            if ( dataSource == null ) {
                throw new ArgumentNullException("dataSource");
            }

            if ( isDisposed_ ) {
                throw new ObjectDisposedException("ZipFile");
            }

            if ( IsEmbeddedArchive ) {
                throw new ZipException ("Cannot update embedded/SFX archives");
            }

            archiveStorage_ = archiveStorage;
            updateDataSource_ = dataSource;

            // NOTE: the baseStream_ may not currently support writing or seeking.

            updateIndex_ = new Hashtable();

            updates_ = new ArrayList(entries_.Length);
            foreach(ZipEntry entry in entries_) {
                int index = updates_.Add(new ZipUpdate(entry));
                updateIndex_.Add(entry.Name, index);
            }

            updateCount_ = updates_.Count;

            contentsEdited_ = false;
            commentEdited_ = false;
            newComment_ = null;
        }
Esempio n. 10
0
        /// <summary>
        /// Begin updating this <see cref="ZipFile"/> archive.
        /// </summary>
        /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param>
        /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param>
        /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
        /// <exception cref="ArgumentNullException">One of the arguments provided is null</exception>
        /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
        public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource)
        {
            if (archiveStorage == null)
            {
                throw new ArgumentNullException("archiveStorage");
            }

            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource");
            }

            if (isDisposed_)
            {
                throw new ObjectDisposedException("ZipFile");
            }

            if (IsEmbeddedArchive)
            {
                throw new ZipException("Cannot update embedded/SFX archives");
            }

            archiveStorage_ = archiveStorage;
            updateDataSource_ = dataSource;

            // NOTE: the baseStream_ may not currently support writing or seeking.

            updateIndex_ = new Hashtable();

            updates_ = new ArrayList(entries_.Length);
            foreach (ZipEntry entry in entries_)
            {
                int index = updates_.Add(new ZipUpdate(entry));
                updateIndex_.Add(entry.Name, index);
            }

            // We must sort by offset before using offset's calculated sizes
            updates_.Sort(new UpdateComparer());

            int idx = 0;
            foreach (ZipUpdate update in updates_)
            {
                //If last entry, there is no next entry offset to use
                if (idx == updates_.Count - 1)
                    break;

                update.OffsetBasedSize = ((ZipUpdate)updates_[idx + 1]).Entry.Offset - update.Entry.Offset;
                idx++;
            }
            updateCount_ = updates_.Count;

            contentsEdited_ = false;
            commentEdited_ = false;
            newComment_ = null;
        }
Esempio n. 11
0
        /// <summary>
        /// Begin updating this <see cref="ZipFile"/> archive.
        /// </summary>
        /// <param name="archiveStorage">The <see cref="IArchiveStorage">archive storage</see> for use during the update.</param>
        /// <param name="dataSource">The <see cref="IDynamicDataSource">data source</see> to utilise during updating.</param>
        public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource)
        {
            if ( IsEmbeddedArchive ) {
                throw new ZipException ("Cannot update embedded/SFX archives");
            }

            if ( archiveStorage == null ) {
                throw new ArgumentNullException("archiveStorage");
            }

            if ( dataSource == null ) {
                throw new ArgumentNullException("dataSource");
            }

            archiveStorage_ = archiveStorage;
            updateDataSource_ = dataSource;

            // NOTE: the baseStream_ may not currently support writing or seeking.

            if ( entries_ != null ) {
                updates_ = new ArrayList(entries_.Length);
                foreach(ZipEntry entry in entries_) {
                    updates_.Add(new ZipUpdate(entry));
                }
            }
            else {
                updates_ = new ArrayList();
            }

            contentsEdited_ = false;
            commentEdited_ = false;
            newComment_ = null;
        }
Esempio n. 12
0
 private void SaveCAISFile(string data, string name, string foldername, int type, int ofItems, int goodUsers, int defaults)
 {
     //File.WriteAllText(@"c:\temp\" + name, data);
     this.caisReportsHistoryRepository.AddFile(ZipString.Zip(data), name, foldername, type, ofItems, goodUsers, defaults);
 }         // SaveCAISFile
Esempio n. 13
0
 public void SetComment(string comment)
 {
     if (isDisposed_)
     {
         throw new ObjectDisposedException("ZipFile");
     }
     CheckUpdating();
     newComment_ = new ZipString(comment);
     if (newComment_.RawLength > 0xffff)
     {
         newComment_ = null;
         throw new ZipException("Comment length exceeds maximum - 65535");
     }
     commentEdited_ = true;
 }
Esempio n. 14
0
 public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource)
 {
     if (archiveStorage == null)
     {
         throw new ArgumentNullException("archiveStorage");
     }
     if (dataSource == null)
     {
         throw new ArgumentNullException("dataSource");
     }
     if (isDisposed_)
     {
         throw new ObjectDisposedException("ZipFile");
     }
     if (IsEmbeddedArchive)
     {
         throw new ZipException("Cannot update embedded/SFX archives");
     }
     archiveStorage_ = archiveStorage;
     updateDataSource_ = dataSource;
     updateIndex_ = new Hashtable();
     updates_ = new ArrayList(entries_.Length);
     foreach (ZipEntry entry in entries_)
     {
         int num = updates_.Add(new ZipUpdate(entry));
         updateIndex_.Add(entry.Name, num);
     }
     updates_.Sort(new UpdateComparer());
     int num2 = 0;
     foreach (ZipUpdate update in updates_)
     {
         if (num2 == (updates_.Count - 1))
         {
             break;
         }
         update.OffsetBasedSize = ((ZipUpdate)updates_[num2 + 1]).Entry.Offset - update.Entry.Offset;
         num2++;
     }
     updateCount_ = updates_.Count;
     contentsEdited_ = false;
     commentEdited_ = false;
     newComment_ = null;
 }
Esempio n. 15
0
        /// <summary>
        /// Set the file comment to be recorded when the current update is <see cref="CommitUpdate">commited</see>.
        /// </summary>
        /// <param name="comment">The comment to record.</param>
        /// <exception cref="ObjectDisposedException">ZipFile has been closed.</exception>
        public void SetComment(string comment)
        {
            if ( isDisposed_ ) {
                throw new ObjectDisposedException("ZipFile");
            }

            CheckUpdating();

            newComment_ = new ZipString(comment);

            // We dont take account of the original and current comment appearing to be the same
            // as encoding may be different.
            commentEdited_ = true;
        }
Esempio n. 16
0
 public void SaveFileChange(string fileContent, int id)
 {
     _caisReportsHistoryRepository.UpdateFile(ZipString.Zip(fileContent), id);
     m_oServiceClient.Instance.CaisUpdate(_context.User.Id, id);
 }
Esempio n. 17
0
 public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource)
 {
     if (archiveStorage == null)
     {
         throw new ArgumentNullException(nameof(archiveStorage));
     }
     if (dataSource == null)
     {
         throw new ArgumentNullException(nameof(dataSource));
     }
     if (_isDisposed)
     {
         throw new ObjectDisposedException("ZipFile");
     }
     if (IsEmbeddedArchive)
     {
         throw new ZipException("Cannot update embedded/SFX archives");
     }
     _archiveStorage = archiveStorage;
     _updateDataSource = dataSource;
     _updateIndex = new Hashtable();
     _updates = new ArrayList(_entries.Length);
     foreach (var entry in _entries)
     {
         var num = _updates.Add(new ZipUpdate(entry));
         _updateIndex.Add(entry.Name, num);
     }
     _updates.Sort(new UpdateComparer());
     var num2 = 0;
     foreach (ZipUpdate update in _updates)
     {
         if (num2 == (_updates.Count - 1))
         {
             break;
         }
         update.OffsetBasedSize = ((ZipUpdate)_updates[num2 + 1]).Entry.Offset - update.Entry.Offset;
         num2++;
     }
     _updateCount = _updates.Count;
     _contentsEdited = false;
     _commentEdited = false;
     _newComment = null;
 }