public CollectionCallBatch GetCollectionCallBatchByHID(int hid)
        {
            CollectionCallBatch batch = new CollectionCallBatch();
            string queryString        = "SELECT * FROM dbo.msmCollectionCallBulkProcess WHERE HID = @hid";

            using (SqlConnection connection = new SqlConnection(GlobalVars.DBConnection["Conn"].ToString()))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                command.Parameters.AddWithValue("@hid", hid);

                try
                {
                    connection.Open();

                    DataTable dt = new DataTable();
                    dt.Load(command.ExecuteReader());
                    if (dt.Rows.Count > 0)
                    {
                        batch = Setup(dt.Rows[0]);
                    }
                    else
                    {
                        batch = null;
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
                return(batch);
            }
        }
Beispiel #2
0
        public void InsertCollectionCallBatch(string hid, string hidBatch)
        {
            //first check if a row already exists with this hid.  If so, update instead of delete
            string queryString;

            CollectionCallBatch _batchService = new CollectionCallBatch();
            CollectionCallBatch extBatch      = _batchService.GetCollectionCallBatchByHID(Convert.ToInt32(hid));

            if (extBatch != null)
            {
                queryString = "UPDATE dbo.msmCollectionCallBulkProcess SET HIDs = " + hidBatch;
            }
            else
            {
                queryString = "INSERT INTO dbo.msmCollectionCallBulkProcess(HID, HIDs) VALUES(" + hid + ", '" + hidBatch + "')";
            }
            using (SqlConnection connection = new SqlConnection(GlobalVars.DBConnection["Conn"].ToString()))
            {
                SqlCommand command = new SqlCommand(queryString, connection);

                try
                {
                    connection.Open();
                    command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    connection.Close();
                }
            }
        }
        public CollectionCallBatch Setup(DataRow r)
        {
            CollectionCallBatch batch = new CollectionCallBatch();

            batch.ID   = r["HID"].ToString();
            batch.HIDs = r["HIDs"].ToString();

            return(batch);
        }