Ejemplo n.º 1
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 {
                    Type = serializationType
                };
                pep.ElementPaths.Add(elementPath);

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

                if (setContentType)
                {
                    return(GetHttpResponse(result, serializationType));
                }
                else
                {
                    return(result);
                }
            }
            catch (Exception ex)
            {
                SynapseServer.Logger.Error(
                    Utilities.UnwindException(context, ex, asSingleLine: true));
                throw;
            }
        }
Ejemplo n.º 2
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;
            }
        }