public static UploadingFiles LoadUploadingInfo(string fileName)
        {
            UploadingFiles uploadingFiles = new UploadingFiles();
            try
            {
                uploadingFiles = ObjectXMLSerializer<UploadingFiles>.Load(fileName);
            }
            catch (Exception exception)
            {
                ProcessException.Handle(exception, "UploadingFileManager.LoadUploadingInfo() Error");
            }

            return uploadingFiles;
        }
		public void TryDoUploads()
		{
			int k = 100;

			string errorType = string.Empty;
			string metaFileName = string.Empty;
			SummaryField[] summaryItems = new SummaryField[0];
			string[] filesUploading = new string[0];
      
			PackageForUpload packageForUpload = packageUploadManager.GetPackageForUpload(maxContentLength, fileExt, out metaFileName,
			                                                                             out errorType, out summaryItems,
			                                                                             out filesUploading);
			//ReLoad uploading queue
			string uploadingQueueFileName = string.Empty;
			if(filesUploading.Length>0)
			{
				uploadingQueueFileName = System.IO.Path.GetDirectoryName(filesUploading[0]);
				uploadingQueueFileName = uploadingQueueFileName.Substring(0, uploadingQueueFileName.LastIndexOf(@"\"));
				uploadingQueueFileName = System.IO.Path.Combine(uploadingQueueFileName, "UploadingQueue.xml");

				if (System.IO.File.Exists(uploadingQueueFileName))
					uploadingFiles = UploadingFileManager.LoadUploadingInfo(uploadingQueueFileName);	
			}
			
			while (k-- > 0 && packageForUpload != null)
			{
				string errorID = null;
				try
				{
					if (serviceInvoker == null)
					{
						serviceInvoker = new WebServiceInvoker();
						serviceInvoker.SetServiceUrl(myServiceUrl);
					}

					if (filesUploading.Length > 0)
					{
						errorID = null;

						if (uploadingFiles != null)
							errorID = uploadingFiles.GetErrorIDByFileName(filesUploading[0]);
						
						if(errorID == null)
						{
							errorID = serviceInvoker.CreateError(metaFileName, errorType, packageForUpload.ShortVersion);	
						}
						else
						{
							serviceInvoker.InitLastErrorInfo(errorID);
						}
            
						if (errorID != null)
						{

							if (uploadingFiles == null)
							{
								uploadingFiles = new UploadingFiles(errorID, filesUploading);
							}
							else
							{
								uploadingFiles.AddUploadingFiles(errorID, filesUploading);
							}

							//Save the Queue before upload data
							UploadingFileManager.SaveUploadingInfo(uploadingFiles, uploadingQueueFileName);

							if(summaryItems.Length > 0)
								serviceInvoker.InsertSummaryInfo(errorID, summaryItems);

							#region Upload File

							int uploadedFilesCount = 0;
								for (int i = 0; i < filesUploading.Length; i++)
								{
									string uploading = filesUploading[i];

									//Thread thread = new Thread(new ParameterizedThreadStart(ThreadUploadFile));
									//thread.Start(errorID, uploading, FileUtils.GetFileContent(uploading));

									int numberOfUploadingTimes = 10;
									bool resultUploading = false;
									int times = 0;
									while (times < numberOfUploadingTimes && !resultUploading)
									{
										times++;
										resultUploading = serviceInvoker.UploadErrorFile(System.IO.Path.GetFileName(uploading), FileUtils.GetFileContent(uploading));
									}

									if (!resultUploading)
									{
										//packageUploadManager.PutPackageBack(packageForUpload.PackageName);
									}
									else
									{
										uploadedFilesCount++;
										uploadingFiles.MarkUploaded(errorID, uploading);
										System.IO.File.Delete(uploading);
									}
								}
							#endregion
								if (uploadedFilesCount > 0)
									packageUploadManager.MarkFinishedUpload(packageForUpload.PackageName);
							//Save the Queue again
							UploadingFileManager.SaveUploadingInfo(uploadingFiles, uploadingQueueFileName);
						}
					}
				}
				catch (Exception exception)
				{
                    try
                    {
                        //If the error processed but did not upload any file, we have to push back to upload later.
                        if (errorID == null)
                        {
                            packageUploadManager.PutPackageBack(packageForUpload.PackageName);
                            errorID = "null";
                        }
					else
					{
						packageUploadManager.MarkFinishedUpload(packageForUpload.PackageName);
					}
                        ProcessException.Handle(exception,"ApplicationUtils.ErrorReporting.Upload.Uploader.TryDoUpLoad()",
                                                          string.Format("Uploder.TryDoUploads({0}) Error", errorID));
                    }
                    catch {
                    }
				}
				packageForUpload = packageUploadManager.GetPackageForUpload(maxContentLength, fileExt, out metaFileName, out errorType,
				                                                            out summaryItems, out filesUploading);				
			}

			return;
		}
        public static void SaveUploadingInfo(UploadingFiles uploadingFiles, string fileName)
        {
            try
            {
                ObjectXMLSerializer<UploadingFiles>.Save(uploadingFiles, fileName);
            }
            catch (Exception exception)
            {
                ProcessException.Handle(exception, "UploadingFileManager.SaveUploadingInfo() Error");
            }

        }