Exemplo n.º 1
0
        private static void ApplyDataContractSurrogate(System.ServiceModel.Description.OperationDescription description)
        {
            System.ServiceModel.Description.DataContractSerializerOperationBehavior dcsOperationBehavior =
                description.Behaviors.Find <System.ServiceModel.Description.DataContractSerializerOperationBehavior>();

            if (dcsOperationBehavior != null)
            {
                if (dcsOperationBehavior.DataContractSurrogate == null)
                {
                    dcsOperationBehavior.DataContractSurrogate = new DbusContainerSurrogate();
                }
            }
        }
Exemplo n.º 2
0
 private static void SetMaxItemsInObjectGraph <T>(ChannelFactory <T> channelFactory)
 {
     foreach (System.ServiceModel.Description.OperationDescription op in channelFactory.Endpoint.Contract.Operations)
     {
         System.ServiceModel.Description.DataContractSerializerOperationBehavior dataContractBehavior =
             op.Behaviors.Find <System.ServiceModel.Description.DataContractSerializerOperationBehavior>()
             as System.ServiceModel.Description.DataContractSerializerOperationBehavior;
         if (dataContractBehavior != null)
         {
             dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
         }
     }
 }
Exemplo n.º 3
0
        private void ConnectToManager(object state)
        {
            try
            {
                EndpointAddress address = new EndpointAddress(this._ManagerAddress);
                NetTcpBinding   binding = new NetTcpBinding(SecurityMode.None);
                binding.TransferMode = TransferMode.Buffered;
                binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
                binding.ReaderQuotas.MaxDepth       = 64;
                binding.ReaderQuotas.MaxArrayLength = 16384;

                binding.OpenTimeout            = TimeSpan.FromSeconds(50);
                binding.SendTimeout            = TimeSpan.FromSeconds(180);
                binding.MaxReceivedMessageSize = int.MaxValue;
                binding.MaxBufferSize          = int.MaxValue;
                binding.MaxBufferPoolSize      = 524288;

                DuplexChannelFactory <IExchangeService> factory = new DuplexChannelFactory <IExchangeService>(new InstanceContext(new Callback()), binding, address);

                try
                {
                    foreach (var operationDescription in factory.Endpoint.Contract.Operations)
                    {
                        System.ServiceModel.Description.DataContractSerializerOperationBehavior dcsob =
                            operationDescription.Behaviors.Find <System.ServiceModel.Description.DataContractSerializerOperationBehavior>();
                        if (dcsob != null)
                        {
                            dcsob.MaxItemsInObjectGraph = int.MaxValue;
                        }
                    }
                }
                catch { }

                lock (this._ServiceLock)
                {
                    this._ExchangeService = factory.CreateChannel();
                    this._ExchangeService.Register(this._ExchangeCode, false);
                }
                this._CommandRelayEngine.Resume();

                // create quotation channel
                DuplexChannelFactory <IExchangeService> factory2 = new DuplexChannelFactory <IExchangeService>(new InstanceContext(new Callback()), binding, address);
                this._ExchangeServiceQuotation = factory2.CreateChannel();
                this._ExchangeServiceQuotation.Register(this._ExchangeCode, true);

                AppDebug.LogEvent("ManagerClient",
                                  string.Format("StateServer connected to manager service at:{0}, ExchangeCode:{1}", this._ManagerAddress, this._ExchangeCode), EventLogEntryType.Information);
            }
            catch (Exception ex)
            {
                AppDebug.LogEvent("ManagerClient", "ConnectToManager failed:\r\n" + ex.ToString(), EventLogEntryType.Error);
            }
            finally
            {
                this.inRcorverConnection = false;
            }
        }
Exemplo n.º 4
0
        public Public.ImageStream Render(Public.WebService.WebServiceHostConfiguration webServiceHostConfiguration, String reportName, Dictionary <String, String> forReportParameters, String format, Dictionary <String, String> extendedProperties)
        {
            Public.ImageStream imageStream = new Public.ImageStream();

            Boolean deviceInfoHumanReadablePdf = ((extendedProperties.ContainsKey("DeviceInfoHumanReadablePdf")) ? Convert.ToBoolean(extendedProperties["DeviceInfoHumanReadablePdf"]) : false);


            #region Initialization

            // ENABLE IMPERSONATION FROM THREAD IDENTITY

            // AppDomain.CurrentDomain.SetPrincipalPolicy (System.Security.Principal.PrincipalPolicy.WindowsPrincipal);

            // System.Security.Principal.WindowsImpersonationContext impersonationContext = null;

            // impersonationContext = ((System.Security.Principal.WindowsIdentity)System.Threading.Thread.CurrentPrincipal.Identity).Impersonate ();


            // CONFIGURE REPORTING SERVICE HOST


            reportExecutionClient = new ReportExecution2005.ReportExecutionServiceSoapClient(webServiceHostConfiguration.BindingConfiguration.Binding, webServiceHostConfiguration.EndpointAddress);

            reportExecutionClient.ClientCredentials.Windows.AllowedImpersonationLevel = webServiceHostConfiguration.ClientCredentials.WindowsImpersonationLevel;

            reportExecutionClient.ClientCredentials.Windows.ClientCredential = webServiceHostConfiguration.ClientCredentials.Credentials;


            #region Old Connection Information

            //Server.Public.WebService.WebServiceHostConfiguration serviceHostReporting = new Server.Public.WebService.WebServiceHostConfiguration (

            //    "qstestmcm001", 80, "ReportServer", "ReportExecution2005.asmx"

            //    );

            //serviceHostReporting.ClientCredentials.WindowsImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;

            //serviceHostReporting.BindingConfiguration = new Server.Public.WebService.BindingConfiguration ("BasicHttpBinding", Server.Public.WebService.Enumerations.WebServiceBindingType.BasicHttpBinding);

            //serviceHostReporting.BindingConfiguration.SecurityMode = System.ServiceModel.BasicHttpSecurityMode.TransportCredentialOnly;

            //serviceHostReporting.BindingConfiguration.TransportCredentialType = System.ServiceModel.HttpClientCredentialType.Ntlm;

            //serviceHostReporting.BindingConfiguration.MessageCredentialType = System.ServiceModel.MessageCredentialType.UserName;


            //System.ServiceModel.BasicHttpBinding binding = (System.ServiceModel.BasicHttpBinding)serviceHostReporting.BindingConfiguration.Binding;

            ////binding.AllowCookies = true;


            //reportExecutionClient = new ReportExecution2005.ReportExecutionServiceSoapClient (binding, serviceHostReporting.EndpointAddress);

            //reportExecutionClient.ClientCredentials.Windows.AllowedImpersonationLevel = serviceHostReporting.ClientCredentials.WindowsImpersonationLevel;

            //reportExecutionClient.ClientCredentials.Windows.ClientCredential = serviceHostReporting.ClientCredentials.Credentials;

            #endregion


            // OPEN UP THE MAX OBJECTS IN GRAPH TO MAXIMUM

            foreach (System.ServiceModel.Description.OperationDescription currentOperation in reportExecutionClient.Endpoint.Contract.Operations)
            {
                System.ServiceModel.Description.DataContractSerializerOperationBehavior dataContractSerializer =

                    (System.ServiceModel.Description.DataContractSerializerOperationBehavior)

                    currentOperation.Behaviors.Find <System.ServiceModel.Description.DataContractSerializerOperationBehavior> ();

                if (dataContractSerializer != null)
                {
                    dataContractSerializer.MaxItemsInObjectGraph = Int32.MaxValue;
                }
            }

            #endregion


            #region Render Report

            SqlServer.ReportExecution2005.ExecutionHeader executionHeader;

            SqlServer.ReportExecution2005.ServerInfoHeader serverInfoHeader;

            SqlServer.ReportExecution2005.ExecutionInfo executionInfo;

            SqlServer.ReportExecution2005.ParameterValue[] parameters = new ReportExecution2005.ParameterValue[forReportParameters.Count];

            Byte[] renderedReport;

            String reportExtension;

            String reportMimeType;

            String reportEncoding;

            SqlServer.ReportExecution2005.Warning[] reportWarnings;

            String[] reportStreamIds;


            executionHeader = reportExecutionClient.LoadReport(null, reportName, null, out serverInfoHeader, out executionInfo);


            // COPY PARAMETERS

            Int32 currentParameterIndex = 0;

            foreach (String currentParameterName in forReportParameters.Keys)
            {
                parameters[currentParameterIndex] = new ReportExecution2005.ParameterValue();

                parameters[currentParameterIndex].Label = currentParameterName;

                parameters[currentParameterIndex].Name = currentParameterName;

                parameters[currentParameterIndex].Value = forReportParameters[currentParameterName];

                currentParameterIndex = currentParameterIndex + 1;
            }

            reportExecutionClient.SetExecutionParameters(executionHeader, null, parameters, "en-us", out executionInfo);


            // SET UP DEVICE INFORMATION

            String deviceInfo = String.Empty;

            switch (format.ToLower())
            {
            case "pdf":

                deviceInfo = (deviceInfoHumanReadablePdf) ? @"<DeviceInfo><HumanReadablePDF>True</HumanReadablePDF></DeviceInfo>" : String.Empty;

                break;
            }


            serverInfoHeader = reportExecutionClient.Render(executionHeader, null, format, ((!String.IsNullOrEmpty(deviceInfo)) ? deviceInfo : null), out renderedReport, out reportExtension, out reportMimeType, out reportEncoding, out reportWarnings, out reportStreamIds);

            imageStream.Image = new System.IO.MemoryStream(renderedReport);

            imageStream.Name = reportName;

            imageStream.Extension = reportExtension;

            imageStream.MimeType = reportMimeType;

            #endregion


            return(imageStream);
        }