Ejemplo n.º 1
0
 internal CypherSession(ConnectionProperties connectionProperties, IWebClient webClient)
 {
     _uri           = connectionProperties.Url;
     _webClient     = webClient;
     _entityCache   = new DictionaryEntityCache();
     _webSerializer = new DefaultJsonSerializer(_entityCache);
 }
Ejemplo n.º 2
0
 internal TransactionalCypherClient(string baseUri, IWebClient webClient, IWebSerializer serializer, IEntityCache entityCache)
 {
     this._transactionUri = UriHelper.Combine(baseUri, "transaction/");
     this._webClient      = webClient;
     this._serializer     = serializer;
     this._entityCache    = entityCache;
 }
Ejemplo n.º 3
0
 public CypherClientFactory(string baseUri, IWebClient webClient, IWebSerializer serializer, IEntityCache entityCache)
 {
     this._baseUri = baseUri;
     this._webClient = webClient;
     this._serializer = serializer;
     this._entityCache = entityCache;
 }
Ejemplo n.º 4
0
 public CypherClientFactory(string baseUri, IWebClient webClient, IWebSerializer serializer, IEntityCache entityCache)
 {
     this._baseUri     = baseUri;
     this._webClient   = webClient;
     this._serializer  = serializer;
     this._entityCache = entityCache;
 }
Ejemplo n.º 5
0
 internal CypherSession(string uri, IWebClient webClient)
 {
     _uri           = uri;
     _webClient     = webClient;
     _entityCache   = new DictionaryEntityCache();
     _webSerializer = new DefaultJsonSerializer(_entityCache);
 }
 internal NonTransactionalCypherClient(string baseUri, string username, string password, IWebClient webClient, IWebSerializer serializer)
 {
     _baseUri    = UriHelper.Combine(baseUri, "transaction/commit");
     _username   = username;
     _password   = password;
     _webClient  = webClient;
     _serializer = serializer;
 }
Ejemplo n.º 7
0
 internal CypherSession(string uri, IWebClient webClient, string username, string password)
 {
     _uri           = uri;
     _webClient     = webClient;
     _username      = username;
     _password      = password;
     _entityCache   = new DictionaryEntityCache();
     _webSerializer = new DefaultJsonSerializer(_entityCache);
 }
Ejemplo n.º 8
0
        private void Awake()
        {
            if (enabled)
            {
                Instance = this;
            }

            serializer = new JsonWebSerializer();
        }
Ejemplo n.º 9
0
 public CypherClientFactory(string baseUri, string username, string password, IWebClient webClient, IWebSerializer serializer, IEntityCache entityCache)
 {
     _baseUri     = baseUri;
     _username    = username;
     _password    = password;
     _webClient   = webClient;
     _serializer  = serializer;
     _entityCache = entityCache;
 }
Ejemplo n.º 10
0
 internal TransactionalCypherClient(string baseUri, string username, string password, IWebClient webClient, IWebSerializer serializer, IEntityCache entityCache)
 {
     _transactionUri = UriHelper.Combine(baseUri, "transaction/");
     _username       = username;
     _password       = password;
     _webClient      = webClient;
     _serializer     = serializer;
     _entityCache    = entityCache;
 }
Ejemplo n.º 11
0
        public static Result <UnityWebRequest, WebError> CreateRequest(string url, IWebAction action, WebActionData actionData, IWebSerializer serializer)
        {
            if (action.Method == WebMethod.POST)
            {
                object[] values = actionData.values;

                var form = new Dictionary <string, object>();
                for (int i = 0; i < values.Length; i++)
                {
                    form.Add(action.ParamNames[i], values[i]);
                }

                return(serializer.Serialize(form).Select(postData =>
                {
                    var request = UnityWebRequest.Post(url, postData);
                    serializer.OnBeforeRequest(request);
                    return request;
                }));
            }
            else
            {
                var request = UnityWebRequest.Get(url);
                serializer.OnBeforeRequest(request);
                return(request);
            }
        }
 internal NonTransactionalCypherClient(string baseUri, IWebClient webClient, IWebSerializer serializer)
 {
     _baseUri    = UriHelper.Combine(baseUri, "transaction/commit");
     _webClient  = webClient;
     _serializer = serializer;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Serializes and sends table data back to the client
        /// </summary>
        /// <param name="context"></param>
        private void SendTableData(HttpContext context, string language, string db, string[] tablePath, ResponseBucket cacheResponse)
        {
            //// TODO: Limit data size?
            //string data = "";
            //using (var stream = new StreamReader(context.Request.InputStream))
            //{
            //    data = stream.ReadToEnd();
            //}

            var tableQuery = JsonHelper.Deserialize <TableQuery>(cacheResponse.PostData) as TableQuery;

            if (tableQuery.Response == null || tableQuery.Response.Format == null)
            {
                tableQuery.Response = new QueryResponse()
                {
                    Format = _defaultResponseFormat
                };
            }

            // Initialize the builder
            PCAxis.Paxiom.IPXModelBuilder builder = GetPXBuilder(language, db, tablePath);
            builder.DoNotApplyCurrentValueSet = true;  // DoNotApplyCurrentValueSet means the "client that made the request" is an api(, not a GUI) so that
                                                       // CNMM2.4 property DefaultInGUI (for Valueset/grouping) should not be used
            builder.SetPreferredLanguage(language);
            builder.BuildForSelection();

            // Process selections
            List <PCAxis.Paxiom.Selection> selections;

            try
            {
                selections = PCAxisRepository.BuildSelections(builder, tableQuery);
            }

            catch (Exception ex)
            {
                var message = ex is HttpException ? ex.Message : "Parameter error";

                cacheResponse.ResponseData = context.Response.ContentEncoding.GetBytes(Error(message, false));
                context.SendJSONError(cacheResponse, 400, true);
                // Logs usage
                _usageLogger.Info(String.Format("url={0}, type=error, caller={1}, cached=false, message=Parameter error", context.Request.RawUrl, context.Request.UserHostAddress));
                return;
            }

            // Check that the number of selected cells do not exceed the limit
            long cellCount = 1;

            foreach (var sel in selections)
            {
                if (sel.ValueCodes.Count > 0)
                {
                    cellCount *= sel.ValueCodes.Count;
                }
            }
            if (cellCount > Settings.Current.FetchCellLimit)
            {
                Write403Response(context);
                return;
            }

            builder.BuildForPresentation(selections.ToArray());

            // Output handling starts here
            context.Response.Clear();

            IWebSerializer serializer = WebSerializerSwitch.GetSerializer(tableQuery.Response.Format);

            //serializer.Serialize(builder.Model, context.Response);
            serializer.Serialize(builder.Model, cacheResponse);
            //context.Response.AddHeader("Content-Type", cacheResponse.ContentType);
            //context.Response.OutputStream.Write(cacheResponse.ResponseData, 0, cacheResponse.ResponseData.Length);
            context.Send(cacheResponse, true);
            //Logs usage
            _usageLogger.Info(String.Format("url={0}, type=data, caller={3}, cached=false, format={1}, matrix-size={2}", context.Request.RawUrl, tableQuery.Response.Format, builder.Model.Data.MatrixSize, context.Request.UserHostAddress));
        }
Ejemplo n.º 14
0
 public CypherClientFactory(string baseUri, IWebClient webClient, IWebSerializer serializer)
 {
     _baseUri = baseUri;
     _webClient = webClient;
     _serializer = serializer;
 }
Ejemplo n.º 15
0
 public CypherClientFactory(string baseUri, IWebClient webClient, IWebSerializer serializer)
 {
     _baseUri    = baseUri;
     _webClient  = webClient;
     _serializer = serializer;
 }