public static IntResult SaveStorageSpace(StorageSpace space)
 {
     return SaveStorageSpaceInternal(space);
 }
        private static IntResult SaveStorageSpaceInternal(StorageSpace space, bool isShared = false)
        {

            var result = TaskManager.StartResultTask<IntResult>("STORAGE_SPACES", "SAVE_STORAGE_SPACE");

            try
            {
                if (space == null)
                {
                    throw new ArgumentNullException("space");
                }

                var ss = GetStorageSpaceService(space.ServiceId);

                if (isShared)
                {
                    var share = ShareStorageSpaceFolderInternal(space.Id, space.Path, space.Name);

                    space.IsShared = true;
                    space.UncPath = share.UncPath;
                }

                if (space.Id > 0)
                {
                    DataProvider.UpdateStorageSpace(space);

                    TaskManager.Write("Updating Storage Space with id = {0}", space.Id.ToString(CultureInfo.InvariantCulture));

                    result.Value = space.Id;
                }
                else
                {
                    result.Value = DataProvider.InsertStorageSpace(space);
                    TaskManager.Write("Inserting new Storage Space, obtained id = {0}", space.Id.ToString(CultureInfo.InvariantCulture));

                    space.Id = result.Value;
                }

                ss.UpdateStorageSettings(space.Path, space.FsrmQuotaSizeBytes, space.FsrmQuotaType);
            }
            catch (Exception exception)
            {
                TaskManager.WriteError(exception);
                result.AddError("Error saving Storage Space", exception);
            }
            finally
            {
                if (!result.IsSuccess)
                {
                    TaskManager.CompleteResultTask(result);
                }
                else
                {
                    TaskManager.CompleteResultTask();
                }
            }

            return result;
        }
예제 #3
0
        public static int InsertStorageSpace(StorageSpace space)
        {
            SqlParameter id = new SqlParameter("@ID", SqlDbType.Int);
            id.Direction = ParameterDirection.Output;

            SqlHelper.ExecuteNonQuery(
                ConnectionString,
                CommandType.StoredProcedure,
                "InsertStorageSpace",
                id,
                new SqlParameter("@Name", space.Name),
                new SqlParameter("@ServiceId", space.ServiceId),
                new SqlParameter("@ServerId", space.ServerId),
                new SqlParameter("@LevelId", space.LevelId),
                new SqlParameter("@Path", space.Path),
                new SqlParameter("@FsrmQuotaType", space.FsrmQuotaType),
                new SqlParameter("@FsrmQuotaSizeBytes", space.FsrmQuotaSizeBytes),
                new SqlParameter("@IsShared", space.IsShared),
                new SqlParameter("@IsDisabled", space.IsDisabled),
                new SqlParameter("@UncPath", space.UncPath)
            );

            // read identity
            return Convert.ToInt32(id.Value);
        }
 public IntResult SaveStorageSpace(StorageSpace space)
 {
     return StorageSpacesController.SaveStorageSpace(space);
 }
예제 #5
0
        public static int UpdateStorageSpace(StorageSpace space)
        {
            SqlHelper.ExecuteNonQuery(
                ConnectionString,
                CommandType.StoredProcedure,
                "UpdateStorageSpace",
                new SqlParameter("@ID", space.Id),
                new SqlParameter("@Name", space.Name),
                new SqlParameter("@ServiceId", space.ServiceId),
                new SqlParameter("@ServerId", space.ServerId),
                new SqlParameter("@LevelId", space.LevelId),
                new SqlParameter("@Path", space.Path),
                new SqlParameter("@FsrmQuotaType", space.FsrmQuotaType),
                new SqlParameter("@FsrmQuotaSizeBytes", space.FsrmQuotaSizeBytes),
                new SqlParameter("@IsShared", space.IsShared),
                new SqlParameter("@IsDisabled", space.IsDisabled),
                new SqlParameter("@UncPath", space.UncPath)
            );

            return space.Id;
        }
 /// <remarks/>
 public void SaveStorageSpaceAsync(StorageSpace space, object userState) {
     if ((this.SaveStorageSpaceOperationCompleted == null)) {
         this.SaveStorageSpaceOperationCompleted = new System.Threading.SendOrPostCallback(this.OnSaveStorageSpaceOperationCompleted);
     }
     this.InvokeAsync("SaveStorageSpace", new object[] {
                 space}, this.SaveStorageSpaceOperationCompleted, userState);
 }
 /// <remarks/>
 public void SaveStorageSpaceAsync(StorageSpace space) {
     this.SaveStorageSpaceAsync(space, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginSaveStorageSpace(StorageSpace space, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("SaveStorageSpace", new object[] {
                 space}, callback, asyncState);
 }
 public IntResult SaveStorageSpace(StorageSpace space) {
     object[] results = this.Invoke("SaveStorageSpace", new object[] {
                 space});
     return ((IntResult)(results[0]));
 }