コード例 #1
0
    public LocationServiceClient CreateServiceClient()
    {
        string  hostName  = ip;
        string  portNum   = port;
        Binding wsBinding = new BasicHttpBinding();
        //Binding wsBinding = new WSHttpBinding();
        string url =
            string.Format("http://{0}:{1}/LocationService/",
                          hostName, portNum);

        Log.Info("Create Service Client:" + url);

        LocationServiceClient client = null;

        try
        {
            EndpointAddress endpointAddress = new EndpointAddress(url);
            client = new LocationServiceClient(wsBinding, endpointAddress);
        }
        catch
        {
            Debug.LogError("CreateServiceClient报错了!");
            return(null);
        }

        return(client);
    }
コード例 #2
0
    /// <summary>
    /// 登录
    /// </summary>
    /// <param name="ipT"></param>
    /// <param name="portT"></param>
    /// <param name="loginInfo"></param>
    /// <param name="LoginCompletedT"></param>
    public LocationServiceClient Login(string ipT, string portT, string user, string pass, Action <object, LoginCompletedEventArgs> LoginCompletedT)
    {
        LoginInfo loginInfo = new LoginInfo();

        loginInfo.UserName = user;
        loginInfo.Password = pass;

        ip             = ipT;
        port           = portT;
        LoginCompleted = null;
        LoginCompleted = LoginCompletedT;
        if (serviceClient != null)
        {
            serviceClient.Abort();
        }
        EndConnectionServerThread();
        serviceClient = CreateServiceClient();
        if (serviceClient != null)
        {
            lock (serviceClient)//1
            {
                serviceClient.LoginCompleted -= LoginCompleted_CallBack;
                serviceClient.LoginCompleted += LoginCompleted_CallBack; //返回数据回调
                serviceClient.LoginAsync(loginInfo);                     //WCF的异步调用
            }
        }
        return(serviceClient);
    }
コード例 #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();
    }
コード例 #4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            client = AppContext.Instance.Client.InnerClient;
            var treeRoot1 = client.GetPhysicalTopologyTree(0);
            var treeRoot2 = client.GetDepartmentTree();

            ResourceTreeView1.LoadData(treeRoot1, treeRoot2);
            ResourceTreeView1.TopoTree.Tree.SelectedItemChanged += Tree_SelectedItemChanged;

            var devList = client.GetDevInfos(null);

            DeviceListBox1.LoadData(devList);

            var personList = client.GetPersonList();

            PersonListBox1.LoadData(personList);

            var tagList = client.GetTags();

            TagListBox1.LoadData(tagList);

            var archorList = client.GetArchors();

            AchorListBox1.LoadData(archorList);

            AppContext.Instance.CallbackClient.LocAlarmsReceved += CallbackClient_LocAlarmsReceved;

            DeviceAlarm[] devAlarms = client.GetDeviceAlarms(new AlarmSearchArg());
            ShowDeviceAlarms(devAlarms);

            LocationAlarm[] locAlarms = client.GetLocationAlarms(new AlarmSearchArg());
            ShowLocationAlarms(locAlarms);

            InitAlarmHub();
        }
コード例 #5
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();
    }
コード例 #6
0
ファイル: LocationController.cs プロジェクト: 88886/jnmmes
        private void SetParentLocationNameViewData(string viewDataName, LocationLevel level)
        {
            SetViewData();
            if (level != LocationLevel.Factory)
            {
                using (LocationServiceClient client = new LocationServiceClient())
                {
                    LocationLevel parentLevel = LocationLevel.Factory;
                    if (level == LocationLevel.Area)
                    {
                        parentLevel = LocationLevel.Room;
                    }

                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format("Level='{0}'", Convert.ToInt32(parentLevel))
                    };

                    MethodReturnResult <IList <Location> > resultParentLocation = client.Get(ref cfg);
                    if (resultParentLocation.Code <= 0)
                    {
                        IEnumerable <SelectListItem> lst = from item in resultParentLocation.Data
                                                           select new SelectListItem()
                        {
                            Text  = item.Key,
                            Value = item.Key
                        };
                        ViewData[viewDataName] = lst;
                    }
                }
            }
        }
コード例 #7
0
 protected PhysicalTopology GetTopoTreeSync()
 {
     Debug.Log("CommunicationObject->GetTopoTree...");
     serviceClient = GetServiceClient();
     if (serviceClient == null)
     {
         return(null);
     }
     lock (serviceClient)      //1
     {
         int view = 0;         //0:基本数据; 1:设备信息; 2:人员信息; 3:设备信息 + 人员信息
         if (topoRoot == null) //第二次进来就不从数据库获取了
         {
             topoRoot = serviceClient.GetPhysicalTopologyTree(view);
         }
         else
         {
             Log.Info("GetTopoTree success 2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
         }
         if (topoRoot == null)
         {
             LogError("GetTopoTree", "topoRoot == null");
         }
         else
         {
             Log.Info("GetTopoTree success 1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
         }
         //string txt = ShowTopo(topoRoot, 0);
         //Debug.Log(txt);
         return(topoRoot);
     }
 }
コード例 #8
0
ファイル: WorkOrderViewModels.cs プロジェクト: 88886/jnmmes
        /// <summary> 根据ERP车间代码取得MES车间代码 </summary>
        /// <param name="orderType">ERP车间代码</param>
        /// <returns></returns>
        public string GetLocationName(string ERPDeptCode)
        {
            string locationName = "";

            using (LocationServiceClient client = new LocationServiceClient())
            {
                //取得对应的ID号
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"ERPDeptCode = '{0}'
                                           AND Level = '2'"
                                             , ERPDeptCode),
                    OrderBy = "Key"
                };

                MethodReturnResult <IList <Location> > result = client.Get(ref cfg);

                if (result.Code == 0 && result.Data.Count > 0)
                {
                    locationName = result.Data[0].Key;
                }
            }

            return(locationName);
        }
コード例 #9
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();
    }
コード例 #10
0
ファイル: Program.cs プロジェクト: pa-pa-me/zizhujy.com
        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();
        }
コード例 #11
0
ファイル: LocationController.cs プロジェクト: 88886/jnmmes
        public async Task <ActionResult> Save(LocationViewModel model)
        {
            using (LocationServiceClient client = new LocationServiceClient())
            {
                Location obj = new Location()
                {
                    Key                = model.Name,
                    Description        = model.Description,
                    ParentLocationName = model.ParentLocationName,
                    Level              = model.Level,
                    ERPDeptCode        = model.ERPDeptCode,         //ERP部门代码
                    Editor             = User.Identity.Name,
                    EditTime           = DateTime.Now,
                    CreateTime         = DateTime.Now,
                    Creator            = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.Location_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
コード例 #12
0
ファイル: LocationController.cs プロジェクト: 88886/jnmmes
 public ActionResult GetParentLocations(LocationLevel?level)
 {
     if (level != null && level != LocationLevel.Factory)
     {
         using (LocationServiceClient client = new LocationServiceClient())
         {
             LocationLevel parentLevel = LocationLevel.Factory;
             if (level == LocationLevel.Area)
             {
                 parentLevel = LocationLevel.Room;
             }
             PagingConfig cfg = new PagingConfig()
             {
                 IsPaging = false,
                 Where    = string.Format("Level='{0}'", Convert.ToInt32(parentLevel))
             };
             MethodReturnResult <IList <Location> > result = client.Get(ref cfg);
             if (result.Code <= 0)
             {
                 if (Request.IsAjaxRequest())
                 {
                     return(Json(result.Data, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     return(View(""));
                 }
             }
         }
     }
     return(Json(new List <Location>(), JsonRequestBehavior.AllowGet));
 }
コード例 #13
0
ファイル: LocationController.cs プロジェクト: 88886/jnmmes
        //
        // GET: /FMM/Location/Modify
        public async Task <ActionResult> Modify(string name)
        {
            LocationViewModel viewModel = new LocationViewModel();

            using (LocationServiceClient client = new LocationServiceClient())
            {
                MethodReturnResult <Location> result = await client.GetAsync(name);

                if (result.Code == 0)
                {
                    viewModel = new LocationViewModel()
                    {
                        Name = result.Data.Key,
                        ParentLocationName = result.Data.ParentLocationName,
                        Level       = result.Data.Level,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    SetParentLocationNameViewData("ParentLocationName", viewModel.Level);

                    return(PartialView("_ModifyPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_ModifyPartial"));
        }
コード例 #14
0
        public IEnumerable <SelectListItem> GetLocation()
        {
            IList <Location> lst = new List <Location>();

            //获取车间名称
            using (LocationServiceClient client = new LocationServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = " Level='2'"
                };

                MethodReturnResult <IList <Location> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    lst = result.Data;
                }
            }
            return(from item in lst
                   select new SelectListItem()
            {
                Text = item.Key,
                Value = item.Key
            });
        }
コード例 #15
0
ファイル: LocationController.cs プロジェクト: 88886/jnmmes
        public async Task <ActionResult> SaveModify(LocationViewModel model)
        {
            using (LocationServiceClient client = new LocationServiceClient())
            {
                MethodReturnResult <Location> result = await client.GetAsync(model.Name);

                if (result.Code == 0)
                {
                    result.Data.Level = model.Level;
                    result.Data.ParentLocationName = model.ParentLocationName;
                    result.Data.ERPDeptCode        = model.ERPDeptCode;                 //ERP部门代码
                    result.Data.Description        = model.Description;
                    result.Data.Editor             = User.Identity.Name;
                    result.Data.EditTime           = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(FMMResources.StringResource.Location_SaveModify_Success
                                                    , model.Name);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
コード例 #16
0
ファイル: LocationController.cs プロジェクト: 88886/jnmmes
        //
        // GET: /FMM/Location/Detail
        public async Task <ActionResult> Detail(string name)
        {
            using (LocationServiceClient client = new LocationServiceClient())
            {
                MethodReturnResult <Location> result = await client.GetAsync(name);

                if (result.Code == 0)
                {
                    LocationViewModel viewModel = new LocationViewModel()
                    {
                        Name = result.Data.Key,
                        ParentLocationName = result.Data.ParentLocationName,
                        Level       = result.Data.Level,
                        ERPDeptCode = result.Data.ERPDeptCode,                  //ERP部门代码
                        Description = result.Data.Description,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
コード例 #17
0
 public SettingsController(IUserService userService, IAuthProvider authProvider,
                           ILocationService locationService, IHash hash)
 {
     _userService     = new UserServiceClient();
     _authProvider    = authProvider;
     _locationService = new LocationServiceClient();
     _hash            = hash;
 }
コード例 #18
0
 public SettingsController(IUserService userService, IAuthProvider authProvider, 
     ILocationService locationService, IHash hash)
 {
     _userService = new UserServiceClient();
     _authProvider = authProvider;
     _locationService = new LocationServiceClient();
     _hash = hash;
 }
コード例 #19
0
    public void Hello()
    {
        Debug.Log("->Hello");
        LocationServiceClient client = GetLocationServiceClient();
        string hello = client.Hello("abc");

        Debug.Log("Hello:" + hello);
    }
コード例 #20
0
 protected AreaPoints[] GetPointsByPidSync(int areaId)
 {
     serviceClient = GetServiceClient();
     lock (serviceClient)
     {
         return(serviceClient.GetPointsByPid(areaId));
     }
 }
コード例 #21
0
 public void GetTopoList()
 {
     client = GetLocationServiceClient();
     PhysicalTopology[] list = client.GetPhysicalTopologyList();
     foreach (PhysicalTopology item in list)
     {
         Debug.Log(item.Name);
     }
 }
コード例 #22
0
 public virtual void DebugLog(string msg)
 {
     Debug.Log("->DebugLog");
     serviceClient = GetServiceClient();
     lock (serviceClient)//1
     {
         serviceClient.DebugMessage(msg);
     }
 }
コード例 #23
0
    public void GetTopoTree()
    {
        Debug.Log("->GetTopoTree");
        client = GetLocationServiceClient();
        PhysicalTopology topoRoot = client.GetPhysicalTopologyTree();
        string           txt      = ShowTopo(topoRoot, 0);

        Debug.Log("length:" + txt.Length);
        Debug.Log(txt);
    }
コード例 #24
0
    void GetPosts()
    {
        Debug.Log("->GetPosts");
        LocationServiceClient client = GetLocationServiceClient();

        Post[] list = client.GetPostList();
        foreach (Post post in list)
        {
            Debug.Log("Post:" + post);
        }
    }
コード例 #25
0
 /// <summary>
 /// 获取定位卡相信息
 /// </summary>
 /// <returns></returns>
 protected Tag[] GetTagsSync()
 {
     serviceClient = GetServiceClient();
     if (serviceClient == null)
     {
         return(null);
     }
     lock (serviceClient)//1
     {
         return(serviceClient.GetTags());
     }
 }
コード例 #26
0
 /// <summary>
 /// 园区信息统计
 /// </summary>
 /// <param name="Id"></param>
 /// <returns></returns>
 protected AreaStatistics GetAreaStatisticsSync(int Id)
 {
     serviceClient = GetServiceClient();
     if (serviceClient == null)
     {
         return(null);
     }
     lock (serviceClient)                                        //1
     {
         return(serviceClient.GetAreaStatistics(Id));
     }
 }
コード例 #27
0
    void GetLocationAlarms()
    {
        Debug.Log("->GetLocationAlarms");
        LocationServiceClient client = GetLocationServiceClient();
        AlarmSearchArg        arg    = new AlarmSearchArg();

        LocationAlarm[] list = client.GetLocationAlarms(arg);
        foreach (LocationAlarm item in list)
        {
            Debug.Log("item:" + item.Content);
        }
    }
コード例 #28
0
 /// <summary>
 /// 获取定位卡相信息
 /// </summary>
 /// <returns></returns>
 protected Tag GetTagSync(int id)
 {
     serviceClient = GetServiceClient();
     if (serviceClient == null)
     {
         return(null);
     }
     lock (serviceClient)//1
     {
         return(serviceClient.GetTag(id));
     }
 }
コード例 #29
0
ファイル: Form1.cs プロジェクト: tokembe/Track
        async void GetAll()
        {
            var proxy = new LocationServiceClient();// создаем клиента к сервису WCF, класс LocationServiceClient генерируется 
                                                    // из метадаты, он описывает какие данные будут возвращаться

            var phones = await proxy.GetAllAsync(); //получаем список устройств
            for (var i = 0; i < phones.Count(); i++)
            {
                var phone = phones[i];
                AddMarker(phone.Uid, phone.Lat, phone.Lng); 
            }
        }
コード例 #30
0
    public void Download(DownloadInfo info)
    {
        Debug.Log(string.Format("Download:{0},{1},{2},{3},{4}", info.CId, info.Ip, info.Channel, info.StartTime, info.EndTime));
        this.info = info;//将参数设置到属性中
        if (client == null)
        {
            client = CommunicationObject.Instance.GetServiceClient();
        }

        ThreadManager.Run(() =>
        {
            var r = client.StartGetNVSVideo(info);//开始下载视频
            return(r);
        }, (r) =>
        {
            Debug.Log("Info==null?" + (info == null) + transform.name);
            if (r != null)
            {
                WriteLog(r.Result + "|" + r.Message + "|" + r.Url);
                this.info = r;//服务端会把下载用的id返回过来
                if (r.Result)
                {
                    if (string.IsNullOrEmpty(r.Url))
                    {
                        InvokeRepeating("GetProgress", 0, 1);//开始获取下载进度
                    }
                    else
                    {
                        Play(r.Url);//已经查询并下载成功了的时间段
                    }
                }
                else
                {
                    if (r.Message == "It is downloading!")//有文件在下载
                    {
                        //todo:等待,休眠1s,并重新尝试下载。重试次数10次,还是这样则提示,并不重试。
                        UGUIMessageBox.Show("文件正在下载");
                    }
                    else
                    {
                        //todo:提示Message内容
                        UGUIMessageBox.Show("下载失败");
                    }
                }
            }
            else
            {
                UGUIMessageBox.Show("下载失败");
                WriteLog("结果为空");
            }
        }, "");
    }
コード例 #31
0
    //public void GetUser()
    //{
    //    Debug.Log("->GetUser");
    //    LocationServiceClient client = GetLocationServiceClient();
    //    User user = client.GetUser();
    //    Debug.Log("Id:" + user.Id);
    //    Debug.Log("Name:" + user.Name);
    //}

    //public void GetUsers()
    //{
    //    Debug.Log("->GetUsers");
    //    LocationServiceClient client = GetLocationServiceClient();
    //    User[] list = client.GetUsers();
    //    for (int i = 0; i < list.Length; i++)
    //    {
    //        Debug.Log("i:" + i);
    //        Debug.Log("Id:" + list[i].Id);
    //        Debug.Log("Name:" + list[i].Name);
    //    }
    //}


    public void GetTags()
    {
        Debug.Log("->GetTags");
        LocationServiceClient client = GetLocationServiceClient();

        Tag[] list = client.GetTags();
        for (int i = 0; i < list.Length; i++)
        {
            Debug.Log("i:" + i);
            Debug.Log("Id:" + list[i].Id);
            Debug.Log("Name:" + list[i].Name);
        }
    }
コード例 #32
0
 public LocationService(string urlWebService)
 {
     try
     {
         _LocationService = new LocationServiceClient();
         Initialize(urlWebService);
     }
     catch (Exception ex)
     {
         _LocationService = null;
         throw new RMSWebException(this, "0500", "LocationService ctor failed. " + ex.Message, ex, false);
     }
 }
コード例 #33
0
 public SearchController()
 {
     _locationService = new LocationServiceClient();
     _userService = new UserServiceClient();
 }
コード例 #34
0
ファイル: MainActivity.cs プロジェクト: tokembe/Track
		private void InitializeProxy()
		{
			BasicHttpBinding binding = CreateBasicHttp();//метод, который создает соединение
			_proxy = new LocationServiceClient(binding, EndPoint);//
			_proxy.SetLocationCompleted+= HandleSetLocationCompleted;//подписка на события
		}