Esempio n. 1
0
        /// <summary>
        /// Cloning DC from another DB
        /// </summary>
        /// <param name="from">DB-transmitter</param>
        /// <param name="dc_name">DC name to clone</param>
        /// <returns></returns>
        public bool CloneDataContainer(DataBase from, String dc_name)
        {
            // TODO: cloning operation with calling an Transmit() function on the other DB

            if (from != null)
            {
                if (inner_dc_dict.ContainsKey(dc_name))
                    return false;

                var cloned_dc = new DataContainer(this, this.Name);
                if (from.Transmit(ref cloned_dc, dc_name))
                {
                    cloned_dc.AssignOwnerDB(this); // assigning new owner DB
                    return true;
                }
            }
            return false;
        }
Esempio n. 2
0
 /// <summary>
 /// Adding a new data container to a database
 /// </summary>
 /// <param name="new_dc">DataContainer</param>
 /// <returns></returns>
 public bool AddNewDataContainer(DataContainer new_dc, User.User user)
 {
     if (Global.CheckAccess.CheckWriteAccess(this, user))
     {
         if (CheckDCNameUnique(new_dc.Name))
         {
             // TODO: loading data new container into stack and file chunks
             inner_dc_dict.Add(new_dc.Name, new_dc);
             MemStorage.Add(new_dc);
             new_dc.AssignOwnerDB(this);
             // Don't try to save new_dc in this method!
             return true;
         }
         else {
             Errors.Messages.DisplayError(
                 String.Format("DataContainer named \"{0}\" already exists in DB!", new_dc.Name),
                 "Adding new DC",
                 "Check the DB structure or select another name",
                 DateTime.Now);
         }
     }
     else {
         Errors.Messages.DisplayError(
             String.Format(Global.StaticResourceManager.GetStringResource("ACCESS_REASON_DENIED_FOR_SOME PROBLEMS"), new_dc.Name),
             "Adding new DC",
             "Check the DB structure or select another name",
             DateTime.Now);
     }
     return false;
 }