Пример #1
0
    public bool AddVideoToCatalog(Guid[] catalogId, Guid itemId)
    {
        DataTable mapTable = new DataTable();

        mapTable.Columns.Add("VideoStorageid", typeof(Guid));
        mapTable.Columns.Add("Catalogid", typeof(Guid));

        for (int i = 0; i < catalogId.Length; i++)
        {
            DataRow newRow = mapTable.NewRow();

            newRow["VideoStorageid"] = itemId;
            newRow["Catalogid"]      = catalogId[i];

            mapTable.Rows.Add(newRow);
        }


        string sql = "Delete From VideoStorage_Catalogs Where videoStorageId=@itemId";

        SqlParameter[] Parameters = new SqlParameter[1];

        Parameters[0]       = new SqlParameter("@itemId", SqlDbType.UniqueIdentifier);
        Parameters[0].Value = itemId;


        SqlConnection  con   = null;
        SqlTransaction trans = null;

        try
        {
            con = new SqlConnection(CommonInfo.ConQJVRMS);
            con.Open();

            trans = con.BeginTransaction();

            SqlHelper.ExecuteNonQuery(trans, CommandType.Text, sql, Parameters);
            SqlHelperExtend.Update("videoStorage_Catalogs", mapTable, trans);

            trans.Commit();
            return(true);
        }
        catch (Exception ex)
        {
            trans.Rollback();
            LogWriter.WriteExceptionLog(ex);

            return(false);
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }
Пример #2
0
    public bool AddADUsersToDB(string userListStr, Guid groupid)
    {
        DataTable userTable = new DataTable();

        userTable.Columns.Add("UserId", typeof(Guid));
        userTable.Columns.Add("GroupId", typeof(Guid));
        userTable.Columns.Add("loginName", typeof(string));
        userTable.Columns.Add("UserName", typeof(string));
        userTable.Columns.Add("Tel", typeof(string));
        userTable.Columns.Add("Email", typeof(string));
        userTable.Columns.Add("uType", typeof(string));

        userTable.Columns.Add("password", typeof(string));
        userTable.Columns.Add("isLocked", typeof(string));
        userTable.Columns.Add("isDownload", typeof(string));
        userTable.Columns.Add("isIpValidate", typeof(string));
        userTable.Columns.Add("IpAddress", typeof(string));
        userTable.Columns.Add("CreateDate", typeof(DateTime));



        SerializeObjectFactory sof = new SerializeObjectFactory();
        ArrayList userList         = (ArrayList)sof.DesializeFromBase64(userListStr);

        foreach (object ouser in userList)
        {
            QJVRMS.Business.User user = ouser as QJVRMS.Business.User;

            DataRow userRow = userTable.NewRow();

            userRow["UserId"]    = user.UserId;
            userRow["GroupId"]   = groupid;
            userRow["loginName"] = user.UserLoginName;
            userRow["UserName"]  = user.UserName;
            userRow["Tel"]       = user.Telphone;
            userRow["Email"]     = user.Email;
            userRow["uType"]     = "1";
            userRow["password"]  = "******";
            userTable.Rows.Add(userRow);
        }

        SqlConnection  con   = null;
        SqlTransaction trans = null;

        try
        {
            con = new SqlConnection(CommonInfo.ConQJVRMS);
            con.Open();

            trans = con.BeginTransaction();
            SqlHelperExtend.Update("Users", userTable, trans);

            trans.Commit();
            return(true);
        }
        catch (Exception ex)
        {
            trans.Rollback();
            LogWriter.WriteExceptionLog(ex);

            return(false);
        }
        finally
        {
            if (con != null)
            {
                con.Close();
            }
        }
    }