public static bool DownloadTenderingFile(int tenderingId, TenderingIndex docIndex, int?contractorId, string version, Grid layoutRoot, int?advertisementId = null, int?meetingId = null, int?warrantyId = null)
        {
            int docid = DataManagement.RetrieveTenderingDocumentId(docIndex);

            if (docid == -1)
            {
                return(false);
            }
            layoutRoot.Children.Add(busy);
            Task <bool> .Factory.StartNew(delegate
            {
                FileDataObject t = DataManagement.RetrieveTenderingFile(tenderingId, docid, contractorId, advertisementId, meetingId, warrantyId);
                if (t == null)
                {
                    return(false);
                }
                OpenFileHandler.OpenFileFromByte(t.FileContent, t.FileName);
                t = null;
                GC.Collect();
                return(true);
            }).ContinueWith(Pre =>
            {
                layoutRoot.Children.Remove(busy);
                if (!Pre.Result)
                {
                    ErrorHandler.ShowErrorMessage(ErrorHandler.ErrorMessages["NoFile"]);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(true);
        }
        public static bool DownloadContractFile(int contractId, ContractIndex docIndex, int?fileId, Grid layoutRoot)
        {
            int docid = (int)docIndex;

            if (docid == -1)
            {
                return(false);
            }
            layoutRoot.Children.Add(busy);
            Task <bool> .Factory.StartNew(delegate
            {
                FileDataObject t = DataManagement.RetrieveContractFile(contractId, docid, fileId);
                if (t == null)
                {
                    return(false);
                }
                OpenFileHandler.OpenFileFromByte(t.FileContent, t.FileName);
                t = null;
                GC.Collect();
                return(true);
            }).ContinueWith(Pre =>
            {
                layoutRoot.Children.Remove(busy);
                if (!Pre.Result)
                {
                    ErrorHandler.ShowErrorMessage(ErrorHandler.ErrorMessages["NoFile"]);
                }
                if (TransactionFinished != null)
                {
                    TransactionFinished();
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());

            return(true);
        }
        public static FileDataObject GetFileDataObject()
        {
            FileDataObject result       = new FileDataObject();
            string         fileLocation = OpenFileHandler.OpenFileToUpload();

            if (fileLocation == null)
            {
                return(null);
            }
            result.FileContent = OpenFileHandler.GetFileFromLocation(fileLocation);
            result.FileName    = System.IO.Path.GetFileName(fileLocation);
            return(result);
        }