Esempio n. 1
0
        static void Main(string[] args)
        {
            //CalculatorClient client = new CalculatorClient();
            LocationServiceClient client = new LocationServiceClient();

            client.ClientCredentials.UserName.UserName = "******";
            client.ClientCredentials.UserName.Password = "******";

            //client.UpdateGeoCoordinate(new zizhujy.services.location.Device() { DeviceName = "Test" },
            //    new zizhujy.services.location.GeoCoordinate() { Remark = "Test" });
            Dictionary <IdentifiedDevice, GeoCoordinate> dic = client.GetLatestGeoCoordinates();

            client.Close();

            /*
             * double value1 = 100.00D;
             * double value2 = 15.99D;
             * double result = client.Add(value1, value2);
             * Console.WriteLine("Add({0}, {1}) = {2}", value1, value2, result);
             * client.Close();
             */

            Console.WriteLine(dic != null ? dic.Count.ToString() : "null");

            Console.WriteLine();
            Console.WriteLine("Press <ENTER> to terminate client.");
            Console.ReadLine();
        }
Esempio n. 2
0
    private void DoGetTagsAsync(Action <Tag[]> callback)
    {
        Log.Info("GetTagsAsync Start >>>>>>>>>>");
        var clet = GetServiceClient();

        clet.BeginGetTags((ar) =>
        {
            Tag[] result = null;
            try
            {
                LocationServiceClient client = ar.AsyncState as LocationServiceClient;
                result = client.EndGetTags(ar);
                client.Close();//异步方式用完Close
            }
            catch (Exception ex)
            {
                LogError("CommunicationObject", ex.ToString());
                Debug.LogError("GetTagsAsync报错!:" + ar.IsCompleted);
            }

            DoCallBack(callback, result);
            if (result == null)
            {
                LogError("GetTagsAsync", "result == null");
            }
            Log.Info("GetTagsAsync End <<<<<<<<");
        }, clet);
        //clet.Close();
    }
Esempio n. 3
0
    public void DoGetAreaStatisticsAsync(int Id, Action <AreaStatistics> callback)
    {
        Log.Info("GetAreaStatisticsAsync Start >>>>>>>>>>");
        var clet = GetServiceClient();

        //Debug.LogError("BeginGetAreaStatistics........");
        clet.BeginGetAreaStatistics(Id, (ar) =>
        {
            AreaStatistics result = null;
            try
            {
                LocationServiceClient client = ar.AsyncState as LocationServiceClient;
                //Debug.LogError("EndGetAreaStatistics........");
                result = client.EndGetAreaStatistics(ar);
                client.Close();//异步方式用完Close
            }
            catch (Exception ex)
            {
                LogError("CommunicationObject", ex.ToString());
            }
            DoCallBack(callback, result);
            if (result == null)
            {
                LogError("GetAreaStatisticsAsync", "result == null");
            }
            Log.Info("GetAreaStatisticsAsync End <<<<<<<<<<");
        }, clet);
        //clet.Close();
    }
Esempio n. 4
0
    private void DoGetPersonTreeAsync(Action <AreaNode> callback)
    {
        Log.Info("GetPersonTreeAsync Start >>>>>>>>>>");
        var clet = GetServiceClient();
        //Debug.LogError("BeginGetPersonTreeAsync........");
        int view = 2; //0:基本数据; 1:设备信息; 2:人员信息; 3:设备信息 + 人员信息

        clet.BeginGetPhysicalTopologyTreeNode(view, (ar) =>
        {
            AreaNode result = null;
            try
            {
                LocationServiceClient client = ar.AsyncState as LocationServiceClient;
                //Debug.LogError("EndGetPersonTreeAsync........");
                result = client.EndGetPhysicalTopologyTreeNode(ar);
                client.Close();//异步方式用完Close
            }
            catch (Exception ex)
            {
                LogError("CommunicationObject", ex.ToString());
            }
            DoCallBack(callback, result);
            if (result == null)
            {
                LogError("GetPersonTreeAsync", "result == null");
            }
            Log.Info("GetPersonTreeAsync End <<<<<<<<");
        }, clet);
        //clet.Close();
    }
 protected LocationServiceClient GetClientOP()
 {
     if (serviceClient == null)
     {
         if (serviceClient != null)
         {
             //if (client.State == CommunicationState.Opened)
             //{
             //    client.Close();
             //}
             serviceClient.Close();
         }
         serviceClient = CreateServiceClient();
     }
     return(serviceClient);
 }
        public void UpdateGeoCoordinate(string userName, string password, Device device, GeoCoordinate geoCoor)
        {
            try
            {
                ZiZhuJYLocationService.LocationServiceClient client = new LocationServiceClient();
                client.ClientCredentials.UserName.UserName = userName;
                client.ClientCredentials.UserName.Password = password;

                client.UpdateGeoCoordinate(device, geoCoor);
                client.Close();
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.GetDebugString());
            }
        }
        public GeoCoordinate GetLatestGeoCoordinateByUserNameAndDevice(string userName, string password, string queryingUserName, Device device)
        {
            GeoCoordinate geoCoor = null;

            try
            {
                LocationServiceClient client = new LocationServiceClient();
                client.ClientCredentials.UserName.UserName = userName;
                client.ClientCredentials.UserName.Password = password;

                geoCoor = client.GetLatestGeoCoordinateByUserNameAndDevice(queryingUserName, device);
                client.Close();
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.GetDebugString());
            }

            return(geoCoor);
        }
        public Dictionary <Device, GeoCoordinate> GetLatestGeoCoordinatesByUserName(string userName, string password, string queryingUserName)
        {
            Dictionary <Device, GeoCoordinate> dic = null;

            try
            {
                ZiZhuJYLocationService.LocationServiceClient client = new LocationServiceClient();
                client.ClientCredentials.UserName.UserName = userName;
                client.ClientCredentials.UserName.Password = password;

                dic = client.GetLatestGeoCoordinatesByUserName(queryingUserName);
                client.Close();
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.GetDebugString());
            }

            return(dic);
        }
Esempio n. 9
0
    private void DoGetTopoTreeAsync(Action <PhysicalTopology> callback)
    {
        var clet = CreateServiceClient();
        {
            int view = 0;         //0:基本数据; 1:设备信息; 2:人员信息; 3:设备信息 + 人员信息
            if (topoRoot == null) //第二次进来就不从数据库获取了
            {
                clet.BeginGetPhysicalTopologyTree(view, (ar) =>
                {
                    topoRoot = null;
                    try
                    {
                        LocationServiceClient client = ar.AsyncState as LocationServiceClient;
                        topoRoot = client.EndGetPhysicalTopologyTree(ar); //异步却不是多线程,服务端关闭时这里还是会卡住
                        client.Close();                                   //异步方式用完Close
                    }
                    catch (Exception ex)
                    {
                        LogError("CommunicationObject", ex.ToString());
                    }

                    DoCallBack(callback, topoRoot);
                    if (topoRoot == null)
                    {
                        LogError("GetTopoTree", "topoRoot == null");
                    }
                    else
                    {
                        Log.Info("GetTopoTree success 1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
                    }
                }, clet);
                //clet.Close();
            }
            else
            {
                Log.Info("GetTopoTree success 2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
            }
        }
    }