コード例 #1
0
        public void AvrServiceCopyLayoutTest()
        {
            long id = VirtualLayoutCopierTests.GetFirstlayoutId();

            if (id > 0)
            {
                var tasks = new List <Action>();
                // todo [ivan] change VirtualLayoutCopier to use different connections and test multithread
                for (int i = 0; i < 1; i++)
                {
                    var copyTask = new Action(() =>
                    {
                        //Assert.IsTrue(false);
                        AvrServiceCopyLayoutResult result = ServiceClientHelper.AvrServiceCopyLayout(id);
                        Assert.IsNotNull(result);
                        Assert.IsTrue(result.IsOk, result.ErrorMessage);
                        Assert.IsTrue(result.Model > 0);
                    });
                    tasks.Add(copyTask);
                }
                Parallel.Invoke(new ParallelOptions {
                    MaxDegreeOfParallelism = 2
                }, tasks.ToArray());
            }
        }
コード例 #2
0
        public JsonResult CopyNode(long id)
        {
            //проверим, что это именно Layout
            List <AvrTreeElement> tree = GetQueryTree();
            AvrTreeElement        elem = tree.FirstOrDefault(c => c.ID == id);
            bool   wasError            = false;
            string errStr       = String.Empty;
            long   idLayoutCopy = 0;

            if ((elem == null) || !elem.IsLayout)
            {
                wasError = true;
            }
            else
            {
                AvrServiceCopyLayoutResult result = ServiceClientHelper.AvrServiceCopyLayout(id);
                if (result.IsOk)
                {
                    idLayoutCopy = result.Model;
                }
                else
                {
                    errStr   = result.ErrorMessage;
                    wasError = true;
                }
            }

            if (!wasError)
            {
                RefreshTree();
            }

            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new
                {
                    result = wasError ? "ERROR" : "OK",
                    idflLayoutCopy = idLayoutCopy,
                    errorString = errStr,
                    url = Url.Action("QueryLayoutTree", GetQueryTree()),
                }
            });
        }