예제 #1
0
        /// <summary>
        /// This grantRights() method set the rights to the otheruserID
        /// </summary>
        /// <param name="otheruserID"></param>
        /// <param name="containerID"></param>
        /// <param name="writeAccess"></param>
        /// <returns>true/false</returns>
        public Boolean grantRights(int otheruserID, int containerID, Boolean writeAccess)
        {
            DBManager.ResourceM       resmgr = new DBManager.ResourceM();
            Model.AzureContainerModel rmodel = new Model.AzureContainerModel();
            Model.CListModel          cmodel = new Model.CListModel();

            try
            {
                rmodel = resmgr.getResourceById(connection, containerID);
                DBManager.CListM cmgr    = new DBManager.CListM();
                Model.CListModel cmodel1 = new Model.CListModel();
                cmodel1 = cmgr.getSharedResourceByGivenName(connection, otheruserID, rmodel.getGivenName());

                if (cmodel1 != null)
                {
                    //If permission already granted to otheruser, then check if requested permission is same
                    Boolean test = false;
                    if (cmodel1.getReadwrite() == 1)
                    {
                        test = true;
                    }
                    if (test == writeAccess)
                    {
                        return(true);    //already exist with same permission
                    }
                    else
                    {
                        cmgr.deleteUserEntryFromCLIST(connection, otheruserID, containerID); //delete the record and re-enter
                    }
                }

                cmodel.setRid(containerID);
                cmodel.setUid(otheruserID);
                cmodel.setOwner(rmodel.getOwner());
                if (writeAccess)
                {
                    cmodel.setReadwrite(1);
                }
                else
                {
                    cmodel.setReadwrite(0);
                }

                //Insert into CLIST table
                bool success = cmgr.insertIntoCList(connection, cmodel);

                return(success);
            }
            catch (DBLikeExceptions.CloudContainerNotFoundException)
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// This method insert record into CLIST table
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="cm"></param>
 /// <returns></returns>
 public Boolean insertIntoCList(SqlConnection connection, Model.CListModel cm)
 {
     try
     {
         command             = new SqlCommand("INSERT INTO CLIST (UID, RID, READWRITE, OWNER) VALUES (@UID, @RID, @READWRITE, @OWNER)");
         command.CommandType = CommandType.Text;
         command.Connection  = connection;
         command.Parameters.AddWithValue("@UID", cm.getUid());
         command.Parameters.AddWithValue("@RID", cm.getRid());
         command.Parameters.AddWithValue("@OWNER", cm.getOwner());
         command.Parameters.AddWithValue("@READWRITE", cm.getReadwrite());
         command.ExecuteNonQuery();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine("inserIntoCList method says->" + e.Message);
     }
     return(false);
 }