Esempio n. 1
0
    /// <summary>
    /// Starts the import process inside its own thread.
    /// </summary>
    /// <param name="args">The args.</param>
    public void StartImportProcess(Object args)
    {
        SetImportSourceValue();
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (importManager != null)
        {
            SetStartProcessInfo();

            try
            {
                //Page.Session["importManager"] = null;
                SetStartProcessInfo();
                AddJob(importManager);
                AddCrossReferenceMananager(importManager);
                importManager.StartImportProcess(ImportHandler);
                SetCompleteProcessInfo();
                string sourceFileName = ((ImportCSVReader)importManager.SourceReader).SourceFileName;
                if (sourceFileName != null)
                {
                    string targetFileName = ImportService.GetImportCompletedPath() + importManager.ImportHistory.ImportNumber + ".csv";
                    ImportService.MoveToPath(sourceFileName, targetFileName);
                }
                //Page.Session["importHistoryId"] = importManager.ImportHistory.Id;
            }
            catch
            {
            }
            finally
            {
                SetCompleteProcessInfo();
                RemoveJob(importManager);
                importManager.Dispose();
                importManager = null;
                object objShutDown = Page.Session["SessionShutDown"];
                if (System.Convert.ToBoolean(objShutDown))
                {
                    if (CanShutDown())
                    {
                        ApplicationContext.Shutdown();
                        Page.Session.Abandon();
                    }
                }
            }
        }
        else
        {
            //raise exception
        }
    }