Beispiel #1
0
        // NOTE: Returns null on failure
        public static IEnumerator LookupPackagesListAsync()
        {
            var runner = PrjInterface.RunPrjAsync(PrjInterface.CreatePrjRequest("listPackages"));

            while (runner.MoveNext() && !(runner.Current is PrjResponse))
            {
                yield return(runner.Current);
            }

            var response = (PrjResponse)runner.Current;

            if (response.Succeeded)
            {
                var docs = response.Output
                           .Split(new string[] { "---" }, StringSplitOptions.None);

                yield return(PrjHelperResponse.Success(
                                 docs
                                 .Select(x => PrjSerializer.DeserializePackageFolderInfo(x))
                                 .Where(x => x != null).ToList()));
            }
            else
            {
                yield return(PrjHelperResponse.Error(response.ErrorMessage));
            }
        }
Beispiel #2
0
        public static IEnumerator DeletePackagesAsync(List <PackageInfo> infos)
        {
            foreach (var info in infos)
            {
                Log.Debug("Deleting package '{0}'".Fmt(info.Name));

                var req = PrjInterface.CreatePrjRequest("deletePackage");

                req.Param1 = info.Name;

                var runner = PrjInterface.RunPrjAsync(req);

                while (runner.MoveNext() && !(runner.Current is PrjResponse))
                {
                    yield return(runner.Current);
                }

                var response = (PrjResponse)runner.Current;

                if (response.Succeeded)
                {
                    Log.Info("Deleted package '{0}'".Fmt(info.Name));
                }
                else
                {
                    yield return(PrjHelperResponse.Error(response.ErrorMessage));

                    yield break;
                }
            }

            yield return(PrjHelperResponse.Success());
        }
Beispiel #3
0
        static PrjHelperResponse CreateStandardResponse(PrjResponse response)
        {
            if (response.Succeeded)
            {
                return(PrjHelperResponse.Success());
            }

            return(PrjHelperResponse.Error(response.ErrorMessage));
        }