Example #1
0
        netHttp.HttpResponseMessage GetHttpResponse(object content, SerializationType serializationType)
        {
            string   s        = GetStringContent(content, serializationType);
            Encoding encoding = serializationType == SerializationType.Xml ? Encoding.Unicode : Encoding.UTF8;

            return(new netHttp.HttpResponseMessage(System.Net.HttpStatusCode.OK)
            {
                Content = new netHttp.StringContent(s, encoding, SerializationContentType.GetContentType(serializationType))
            });
        }
Example #2
0
        object WaitForTerminalStatusOrTimeout(long instanceId, string planUniqueName, string path, SerializationType serializationType,
                                              int pollingIntervalSeconds, int timeoutSeconds, bool setContentType)
        {
            object result = SyncExecuteHelper.WaitForTerminalStatusOrTimeout(
                this, planUniqueName, instanceId, path, serializationType, pollingIntervalSeconds, timeoutSeconds);

            if (setContentType)
            {
                Encoding encoding = serializationType == SerializationType.Xml ? Encoding.Unicode : Encoding.UTF8;
                netHttp.HttpResponseMessage response = new netHttp.HttpResponseMessage(System.Net.HttpStatusCode.OK);
                response.Content = new netHttp.StringContent(GetStringContent(result, serializationType),
                                                             encoding, SerializationContentType.GetContentType(serializationType));
                return(response);
            }
            else
            {
                return(result);
            }
        }
Example #3
0
        public object GetPlanElements(string planUniqueName, long planInstanceId, string elementPath, SerializationType serializationType = SerializationType.Json, bool setContentType = true)
        {
            InitPlanServer();

            string context = GetContext(nameof(GetPlanStatus),
                                        nameof(planUniqueName), planUniqueName, nameof(planInstanceId), planInstanceId,
                                        nameof(elementPath), elementPath, nameof(serializationType), serializationType);

            try
            {
                SynapseServer.Logger.Debug(context);

                PlanElementParms pep = new PlanElementParms();
                pep.Type = serializationType;
                pep.ElementPaths.Add(elementPath);

                object result = _server.GetPlanElements(planUniqueName, planInstanceId, pep);

                if (setContentType)
                {
                    Encoding encoding = serializationType == SerializationType.Xml ? Encoding.Unicode : Encoding.UTF8;
                    netHttp.HttpResponseMessage response = new netHttp.HttpResponseMessage(System.Net.HttpStatusCode.OK);
                    response.Content = new netHttp.StringContent(GetStringContent(result, serializationType),
                                                                 encoding, SerializationContentType.GetContentType(serializationType));
                    return(response);
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                SynapseServer.Logger.Error(
                    Utilities.UnwindException(context, ex, asSingleLine: true));
                throw;
            }
        }