Пример #1
0
        public int User_Rights_Insert_Barth(List <User_RightsInfo> _list)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConfigInfo.ConnectionString))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    var bulkCopy = new SqlBulkCopy(conn);
                    bulkCopy.DestinationTableName = "user_rights";

                    bulkCopy.ColumnMappings.Add("User_Name", "User_Name");
                    bulkCopy.ColumnMappings.Add("funcid", "funcid");
                    bulkCopy.ColumnMappings.Add("authcode", "authcode");

                    using (var datareader = new ObjectDataReader <User_RightsInfo>(_list))
                    {
                        bulkCopy.WriteToServer(datareader);
                    }
                }

                return(0);
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
                return(-1);
            }
        }
Пример #2
0
        public int Function_Group_Insert_Batch(List <Function_GroupInfo> _list)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConfigInfo.ConnectionString))
                {
                    if (conn.State == ConnectionState.Closed)
                    {
                        conn.Open();
                    }
                    var bulkCopy = new SqlBulkCopy(conn);
                    bulkCopy.DestinationTableName = "functions_group";

                    bulkCopy.ColumnMappings.Add("group_id", "group_id");
                    bulkCopy.ColumnMappings.Add("functionid", "functionid");

                    using (var datareader = new ObjectDataReader <Function_GroupInfo>(_list))
                    {
                        bulkCopy.WriteToServer(datareader);
                    }
                }

                return(0);
            }
            catch (Exception ex)
            {
                ErrorLog.log.Error(ex.ToString());
                return(-1);
            }
        }