public PackageForUpload GetPackageForUpload()
        {
            lock (synchRoot)
            {
                RecycleTimeoutUploads();
                if (uploadingPackages.Count > 2)
                {
                    return null;
                }
                string fullFilePath = tools.PickPackageForUpload();
                if (fullFilePath == null)
                {
                    return null;
                }

                byte[] packageContent = FileUtils.GetFileContent(fullFilePath);
                byte[] shortVersionContent = null;

                try
                {
                    //if the size of the package is bigger then let's say 100.000 bytes, create a short-version of the package too

                    if (packageContent.Length > 100000)
                    {
                        FastZip zipFile = new FastZip();

                        //get a temporary directory name
                        string tmpDirName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

                        //unzip the archive
                        zipFile.ExtractZip(fullFilePath, tmpDirName, "");

                        //add -short to the name of the package
                        string shortFileName = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(fullFilePath) + "-short.zip");


                        try
                        {
                            DirectoryInfo tmpLogsDir = new DirectoryInfo(Path.Combine(tmpDirName, "Logs"));
                            if (tmpLogsDir.Exists)
                            {
                                FileInfo[] files = tmpLogsDir.GetFiles();
                                foreach (FileInfo logFile in files)
                                {
                                    logFile.CopyTo(Path.Combine(tmpDirName, logFile.Name));
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            ProcessException.Handle(e);
                            Debug.Fail(e.Message);
                        }

                        //create a new package, but without Data folder
                        zipFile.CreateZip(shortFileName, tmpDirName, false, string.Empty);

                        shortVersionContent = FileUtils.GetFileContent(shortFileName);

                        try
                        {
                            //clean up
                            Directory.Delete(tmpDirName, true);
                            File.Delete(shortFileName);
                        }
                        catch (Exception ex)
                        {
                            ProcessException.Handle(ex);
                            Debug.Fail(ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ProcessException.Handle(ex);
                    Debug.Fail(ex.Message);
                }

                uploadingPackages.Add(fullFilePath, DateTime.Now);
                PackageForUpload packageForUpload = new PackageForUpload(Path.GetFileName(fullFilePath), packageContent, shortVersionContent);

                return packageForUpload;
            }
        }
        public PackageForUpload GetPackageForUpload(int maxContentLength, string fileExt, out string metaFileName, out string errorType, out SummaryField[] summaryItems, out string[] splittedFiles)
        {
            lock (synchRoot)
            {
                #region Validate info
                RecycleTimeoutUploads();

                metaFileName = null;
                summaryItems = new SummaryField[0];
                errorType = string.Empty;
                splittedFiles = new string[0];
                byte[] shortVersionContent = null;

                PackageForUpload packageForUpload = null;

                string fullFilePath = tools.PickPackageForUpload();
                if (fullFilePath == null)
                {
                    return null;
                }

                if (System.IO.Path.GetExtension(fullFilePath).ToLower().Equals(fileExt.ToLower()))
                {
                    uploadingPackages.Add(fullFilePath, DateTime.Now);
                    shortVersionContent = FileUtils.GetFileContent(fullFilePath);
                    packageForUpload = new PackageForUpload(Path.GetFileName(fullFilePath), null, shortVersionContent);
                    splittedFiles = new string[1];
                    splittedFiles[0] = fullFilePath;
                    return packageForUpload;

                }
                string storeFolder = Path.GetDirectoryName(fullFilePath);
                #endregion

                byte[] packageContent = FileUtils.GetFileContent(fullFilePath);


                try
                {
                    FastZip zipFile = new FastZip();

                    //get a temporary directory name
                    string tmpDirName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

                    //unzip the archive
                    zipFile.ExtractZip(fullFilePath, tmpDirName, "");

                    string xmlFilename = System.IO.Path.Combine(tmpDirName, "ReportDetails.xml");

                    //add -short to the name of the package
                    metaFileName = Path.GetFileNameWithoutExtension(fullFilePath) + "-meta.zip";
                    string shortFilePath = Path.Combine(Path.GetTempPath(), metaFileName);

                    #region Get Summary information from ReportDetails.xml
                    string xmlDefineFields = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SummaryFields.xml");

                    XmlMetaProcessing metaProcessing = new XmlMetaProcessing(xmlDefineFields, xmlFilename);
                    summaryItems = metaProcessing.SummaryFields;

                    string snapShotFolderName = System.IO.Path.Combine(tmpDirName, "Data");

                    string hasSnapShot = "False";
                    if (System.IO.Directory.Exists(snapShotFolderName))
                        hasSnapShot = "True";


                    if (summaryItems.Length > 0)
                    {
                        foreach (SummaryField item in summaryItems)
                        {
                            if (item.Name.ToLower().Equals("errorlocation"))
                            {
                                errorType = (item.Value != null ? item.Value.ToString() : "");
                            }
                            else if (item.Name.ToLower().Equals("hassnapshot"))
                            {
                                item.Value = hasSnapShot;
                            }
                        }
                    }

                    #endregion

#if SHORT_INFO_INCLUDE_LOG
						try
						{
							DirectoryInfo tmpLogsDir = new DirectoryInfo(Path.Combine(tmpDirName, "Logs"));
							if (tmpLogsDir.Exists)
							{
								FileInfo[] files = tmpLogsDir.GetFiles();
								foreach (FileInfo logFile in files)
								{
									logFile.CopyTo(Path.Combine(tmpDirName, logFile.Name));
								}
							}
						}
						catch (Exception e)
						{
							ProcessException.Handle(e);
							Debug.Fail(e.Message);
						}
#endif
                    //create a new package, but without Data folder - this is Meta package
                    zipFile.CreateZip(shortFilePath, tmpDirName, false, string.Empty);

                    shortVersionContent = FileUtils.GetFileContent(shortFilePath);
                    if (packageContent.Length > maxContentLength)
                    {
                        splittedFiles = SplitFile(maxContentLength, fullFilePath, fileExt);
                    }
                    else
                    {
                        splittedFiles = new string[1];
                        splittedFiles[0] = fullFilePath;
                    }

                    try
                    {
                        //clean up
                        Directory.Delete(tmpDirName, true);
                        File.Delete(shortFilePath);
                        //Delete the main file after splited
                        File.Delete(fullFilePath);
                    }
                    catch (Exception ex)
                    {
                        ProcessException.Handle(ex);
                        Debug.Fail(ex.Message);
                    }
                }
                catch (Exception ex)
                {
                    ProcessException.Handle(ex);
                    Debug.Fail(ex.Message);
                }

                uploadingPackages.Add(fullFilePath, DateTime.Now);
                packageForUpload = new PackageForUpload(Path.GetFileName(fullFilePath), null, shortVersionContent);

                return packageForUpload;
            }
        }