//protected void Timer1_Tick(object sender, EventArgs e)
        //{
        //    litStatus.Text = "Panel refreshed at: " + DateTime.Now.ToLongTimeString();
        //    if (dataSyncJob != null)
        //    {
        //        if (dataSyncJob.logBuilder != null)
        //        {
        //            var processedItems = dataSyncJob.logBuilder.ProcessedItems;
        //            litStatus.Text += processedItems + "";
        //        }
        //    }
        //}
        //public delegate void LongTimeTask_Delegate(string str);
        //public void LongTimeTask(string str)
        //{
        //    Item dataSyncItem = currentDB.Items[ddlImport.SelectedValue];
        //    if (dataSyncItem != null)
        //    {
        //        Logging logBuilder = new Logging();
        //        DataSyncManager.RunDataSyncJob(dataSyncItem, ref logBuilder);
        //        if (logBuilder != null)
        //        {
        //            txtMessage.Text = logBuilder.LogBuilder.Length < 1 ? "The import completed successfully. \r\nStatus: \r\n" + logBuilder.GetItemStatusText() : logBuilder.LogBuilder + "\r\nStatus: \r\n" + logBuilder.GetItemStatusText();
        //        }
        //        else
        //        {
        //            txtMessage.Text = "The log object was null.";
        //        }
        //    }
        //}
        //public void TaskCompleted(IAsyncResult r)
        //{
        //    litStatus.Text = "Job done: " + DateTime.Now.ToLongTimeString();
        //    this.updatePanelStatus.Update();
        //}
        //protected void btnImport_Click(object sender, EventArgs e)
        //{
        //    //LongTimeTask_Delegate d = new LongTimeTask_Delegate(LongTimeTask);
        //    //IAsyncResult r = d.BeginInvoke("String", new AsyncCallback(TaskCompleted), null);
        //    //d.EndInvoke(r);
        //}
        protected void btnImport_Click(object sender, EventArgs e)
        {
            Item dataSyncItem = currentDB.Items[ddlImport.SelectedValue];
            if (dataSyncItem != null)
            {
                LevelLogger logger = Manager.CreateLogger(dataSyncItem);
                var dataSyncManager = new DataSyncManager();
                dataSyncManager.RunDataSyncJob(dataSyncItem, ref logger);

                if (logger != null)
                {
                    var exporter = Manager.CreateOutputHandler(dataSyncItem, logger);
                    if (exporter != null)
                    {
                        txtMessage.Text = exporter.Export();
                    }
                    else
                    {
                        txtMessage.Text = "The Exporter class was null. Therefor the log was not written out.";
                    }
                }
                else
                {
                    txtMessage.Text = "The log object was null.";
                }
            }
        }
        public void Work()
        {
            Item dataSyncItem = currentDB.Items[dataSyncItemId];
            logger = Manager.CreateLogger(dataSyncItem);

            if (dataSyncItem != null)
            {
                var dataSyncManager = new DataSyncManager();
                dataSyncManager.RunDataSyncJob(dataSyncItem, ref logger);

                //if (logBuilder != null)
                //{
                //    txtMessage.Text = logBuilder.LogBuilder.Length < 1 ? "The import completed successfully. \r\nStatus: \r\n" + logBuilder.GetItemStatusText() : logBuilder.LogBuilder + "\r\nStatus: \r\n" + logBuilder.GetItemStatusText();
                //}
                //else
                //{
                //    txtMessage.Text = "The log object was null.";
                //}
            }
        }