Example #1
0
        void EndAsync(IAsyncResult ar)
        {
            if (ar is ImportCompletedSyncResult)
            {
                return;
            }

            try
            {
                _Import       = false;
                _IsImportWork = false;
                importCommand.EndExecuteNonQuery(ar);
            }
            catch
            {
                if (importConnection != null)
                {
                    importConnection.Close();
                }
                UnSuccessfulImportMessageBox.Show();
            }
        }
Example #2
0
        protected void ImportButton_Click(object sender, EventArgs e)
        {
            if (!Frame.ImportUpload.HasFile)
            {
                NoFileMessageBox.Show();
                return;
            }

            var savePath = Server.MapPath(@"~\Import\");

            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }

            var newPath = _Path = Path.Combine(savePath, Path.GetFileName(Frame.ImportUpload.FileName));

            Frame.ImportUpload.SaveAs(newPath);

            _Import = true;
            this.Page.AddOnPreRenderCompleteAsync(new BeginEventHandler(BeginAsync), new EndEventHandler(EndAsync));

#if truef
            try
            {
                using (var conn = new SqlConnection(Global.ConnectionString))
                    using (var cmd = new SqlCommand("EXEC [Import].[ImportData] @personID, @fileName, @add", conn))
                    {
                        cmd.CommandTimeout = 600;
                        cmd.Parameters.Add(
                            new SqlParameter
                        {
                            ParameterName = "personID",
                            DbType        = System.Data.DbType.Int32,
                            Value         = this.GetSystemUser()
                        });

                        cmd.Parameters.Add(
                            new SqlParameter
                        {
                            ParameterName = "fileName",
                            DbType        = System.Data.DbType.String,
                            Value         = newPath
                        });

                        cmd.Parameters.Add(
                            new SqlParameter
                        {
                            ParameterName = "add",
                            DbType        = System.Data.DbType.String,
                            Value         = int.Parse(ImportModeList.SelectedValue)
                        });

                        conn.Open();
                        cmd.ExecuteNonQuery();
                        SuccessfulImportMessageBox.Show();
                    }
            }
            catch
            {
                UnSuccessfulImportMessageBox.Show();
                return;
            }
#endif
        }