Exemple #1
0
        public JsonResult CheckLayout(long layoutId, bool forceViewShowing, bool forceLayoutShowing)
        {
            bool   isNewLayout        = false;
            bool   isQueryCasheExists = false;
            string error = String.Empty;

            try
            {
                using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                {
                    var ps = new List <object>
                    {
                        manager.Parameter("LayoutID", layoutId),
                    };

                    var command = manager.SetSpCommand("dbo.spAsLayoutIsNew", ps.ToArray());

                    isNewLayout = command.ExecuteScalar <int>(ScalarSourceType.ReturnValue) == 1;

                    List <AvrTreeElement> tree = GetQueryTree();
                    AvrTreeElement        elem = tree.FirstOrDefault(c => c.ID == layoutId);
                    if (elem != null)
                    {
                        isQueryCasheExists = ServiceClientHelper.DoesCachedQueryExists(elem.QueryID,
                                                                                       ModelUserContext.CurrentLanguage, elem.IsUseArchiveData);
                    }
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new
                {
                    err = error,
                    isQueryExists = isQueryCasheExists? "Yes": "No",
                    isNewLayout = isNewLayout? "Yes" : "No",
                    okFunction = string.Format("queryTreeList.showLayoutViewInternal({0}, {1}, {2}, {3}, '{4}');", layoutId, Bool2JsBool(isNewLayout), Bool2JsBool(forceViewShowing), Bool2JsBool(forceLayoutShowing), isNewLayout ? Translator.GetMessageString("msgCantShowView") : ""),
                    Message = !isQueryCasheExists?Translator.GetMessageString("msgShouldOpenLayout") : (isNewLayout ? Translator.GetMessageString("msgCantShowView") : "")
                }
            });
        }
Exemple #2
0
        public void DoesCachedQueryExistsTest()
        {
            ServiceClientHelper.CallAvrServiceToForceLOHMemoryAllocations();

            bool exists = ServiceClientHelper.DoesCachedQueryExists(-1, "en", false);

            Assert.IsFalse(exists);

            var queryId = 49539640000000;

            ServiceClientHelper.AvrServiceClearQueryCache(queryId);
            exists = ServiceClientHelper.DoesCachedQueryExists(queryId, ModelUserContext.CurrentLanguage, false);
            Assert.IsFalse(exists);

            CachedQueryResult result = ServiceClientHelper.GetAvrServiceQueryResult(queryId, false, string.Empty);

            Assert.IsNotNull(result);

            exists = ServiceClientHelper.DoesCachedQueryExists(queryId, ModelUserContext.CurrentLanguage, false);
            Assert.IsTrue(exists);
            exists = ServiceClientHelper.DoesCachedQueryExists(queryId, ModelUserContext.CurrentLanguage, true);
            Assert.IsFalse(exists);
        }