Example #1
0
        protected void SaveToStore(WebData_v2 <TSource, TData> webData)
        {
            //Trace.WriteLine($"WebDataManager_v5.SaveToStore()");

            BsonDocument document = Serialize(webData);

            if (_store.GenerateId)
            {
                BsonValue id = webData.Id;
                if (id == null)
                {
                    webData.Id = id = _store.GetNewId();
                    webData.Data.zSetId(id);
                }
                _store.SaveWithId(id, document);
            }
            else
            {
                _store.SaveWithKey(webData.Key, document);
            }
        }
Example #2
0
        private void Load_v2()
        {
            //BsonValue id = null;
            //BsonValue key = null;
            bool dataExists = false;

            _dataStore = _webDataManager_v4.DataStore;
            //_webLoadImageManager = _webDataManager_v4.WebLoadImageManager;
            bool useDocumentStore = _dataStore != null && !_webDataManager_v4.DesactivateDocumentStore;

            if (useDocumentStore)
            {
                _key = _webDataManager_v4._GetKeyFromHttpRequest(_request.HttpRequest);
                if (_dataStore.GenerateId)
                {
                    _id = _dataStore.GetId(_key);
                    if (_id != null)
                    {
                        dataExists = true;
                    }
                }
                else
                {
                    dataExists = _dataStore.Exists(_key);
                }
            }

            if (_dataStore == null || !dataExists || _request.ReloadFromWeb || _request.RefreshDocumentStore)
            {
                _LoadFromWeb_v2(_webDataManager_v4.WebLoadDataManager);
                if (!_result_v2.Success)
                {
                    return;
                }
            }
            else
            {
                _LoadFromDocumentStore_v2(_key);
            }

            // _error is not used actually
            //if (_error)
            //    return;

            if (_dataStore != null && _dataLoadedFromWeb)
            {
                BsonDocument document = Serialize();
                if (_dataStore.GenerateId)
                {
                    if (_id == null)
                    {
                        _id = _dataStore.GetNewId();
                    }
                    _data.zSetId(_id);
                    _dataStore.SaveWithId(_id, document);
                }
                else
                {
                    _dataStore.SaveWithKey(_key, document);
                }
            }

            //if (_webLoadImageManager == null)
            //    LoadImages_v1(_request.ImageRequest);
            //else
            //    LoadImages_v3(_request.ImageRequest);
            //LoadImages_v1(_request.ImageRequest);
            LoadImages_v3(_request.ImageRequest);
        }