// GET: Cluster Delete
        public ActionResult Delete(Cluster cluster)
        {
            Cluster removeCluster = _clusterSvc.Get(cluster.Id);

            _clusterSvc.Remove(removeCluster);

            return(View("List", _clusterSvc.GetList().Select(CreateViewModel)));
        }
        // GET: Cluster Delete
        public ActionResult Delete(Cluster cluster)
        {
            Cluster removeCluster = _clusterSvc.Get(cluster.Id);

            _clusterSvc.Remove(removeCluster);

            return(RedirectToAction("List"));
        }
Exemple #3
0
        /// <summary>对集群进行多次调用</summary>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="cluster"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static TResult InvokeAll <TKey, TValue, TResult>(this ICluster <TKey, TValue> cluster, Func <TValue, TResult> func)
        {
            Exception error = null;
            var       item  = default(TValue);
            var       count = cluster.GetItems().Count();

            for (var i = 0; i < count; i++)
            {
                try
                {
                    item = cluster.Get();
                    return(func(item));
                }
                catch (Exception ex)
                {
                    error = ex;
                }
                finally
                {
                    cluster.Put(item);
                }
            }

            //throw error;
            throw new ClusterException(item + "", error);
        }
Exemple #4
0
        /// <summary>借助集群资源处理事务</summary>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="cluster"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static async Task <TResult> InvokeAsync <TKey, TValue, TResult>(this ICluster <TKey, TValue> cluster, Func <TValue, Task <TResult> > func)
        {
            var item = default(TValue);

            try
            {
                item = cluster.Get();
                return(await func(item));
            }
            finally
            {
                cluster.Put(item);
            }
        }
Exemple #5
0
        /// <summary>借助集群资源处理事务</summary>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="cluster"></param>
        /// <param name="func"></param>
        /// <returns></returns>
        public static TResult Invoke <TKey, TValue, TResult>(this ICluster <TKey, TValue> cluster, Func <TValue, TResult> func)
        {
            var item = default(TValue);

            try
            {
                item = cluster.Get();
                return(func(item));
            }
            finally
            {
                cluster.Put(item);
            }
        }
        // GET: Cluster Update
        public ActionResult Update(int id)
        {
            var editedCluster = _clusterSvc.Get(id);

            return(View("Create", editedCluster));
        }