示例#1
0
        public static IRawDataSummary CreateRawDataSummaryService(string serverName)
        {
            serverName = string.IsNullOrEmpty(serverName) ? "localhost" : serverName;

            string        uri      = string.Format("net.tcp://{0}:9033/RawDataManagerService", serverName);
            string        identity = string.Format("RawDataManagerService/{0}", serverName);
            NetTcpBinding binding  = new NetTcpBinding();

            binding.Security.Mode = SecurityMode.None;

            // var myBinding = new BasicHttpBinding();
            var endpoint = new EndpointAddress(new Uri(uri),//Uri("http://localhost:9033/RawDataManagerService"),
                                               EndpointIdentity.CreateSpnIdentity(identity));

            var channelFactory = new ChannelFactory <IRawDataSummary>(binding, endpoint);

            IRawDataSummary client = null;

            try
            {
                client = channelFactory.CreateChannel();
                //client.MyServiceOperation();
                //((ICommunicationObject)client).Close();
            }
            catch
            {
                if (client != null)
                {
                    ((ICommunicationObject)client).Abort();
                }
            }
            return(client);
        }
示例#2
0
        private void PopulateTree()
        {
            try
            {
                _tempMeasurement.Clear();
                IRawDataSummary   service  = ChannelFactoryUtility.CreateRawDataSummaryService(_machineName);
                List <IdNamePair> projects = service.GetProjectNames(_connectionString);
                //List<IdNamePair> projects = ChannelFactoryUtility.CallRawDataSummaryServer(proxy => proxy.GetProjectNames(connectionString));
                foreach (var idNamePair in projects)
                {
                    IdNamePairProcessItem pItem = new IdNamePairProcessItem()
                    {
                        Name          = idNamePair.Id + " - " + idNamePair.Name,
                        MeasurementId = idNamePair.Id,
                        CrtDepthLevel = 1 //project level is 1
                    };
                    //_tempMeasurement.Add(pItem);
                    this.Measurements.Add(pItem);

                    List <IdNamePair> experiments = service.GetExperimentsNamesByProjectId((int)idNamePair.Id, _connectionString);
                    //List<IdNamePair> experiments = ChannelFactoryUtility.CallRawDataSummaryServer(proxy => proxy.GetExperimentsNamesByProjectId((int)idNamePair.Id, connectionString));
                    foreach (var experiment in experiments)
                    {
                        IdNamePairProcessItem eItem = new IdNamePairProcessItem()
                        {
                            Name          = experiment.Id + " - " + experiment.Name,
                            MeasurementId = experiment.Id,
                            CrtDepthLevel = 2 //experiment level is 2
                        };
                        pItem.Children.Add(eItem);
                        List <IdNamePair> measurements = service.GetMeasurementNamesByExperimentId(
                            (int)eItem.MeasurementId, _connectionString);
                        //List<IdNamePair> measurements = ChannelFactoryUtility.CallRawDataSummaryServer(proxy => proxy.GetMeasurementNamesByExperimentId((int)eItem.MeasurementId, connectionString));
                        foreach (var measurement in measurements)
                        {
                            IdNamePairProcessItem mItem = new IdNamePairProcessItem()
                            {
                                Name          = measurement.Id + " - " + measurement.Name,
                                MeasurementId = measurement.Id,
                                CrtDepthLevel = 3 //meaurement level is 3
                            };
                            eItem.Children.Add(mItem);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            BatchSetupView.ShowLoadingBar(Visibility.Hidden);
        }