Com.Aote.ObjectTools.GeneralObject.Load C# (CSharp) Method

Load() public method

开始加载数据
public Load ( ) : void
return void
        public void Load()
        {
            string uuid = System.Guid.NewGuid().ToString();
            Uri uri;
            if (Path == null)
            {
                uri = new Uri(WebClientInfo.BaseAddress);
            }
            else if (Path != null && Path.Equals("null"))
            {
                return;
            }
            else
            {
                uri = new Uri(WebClientInfo.BaseAddress + "/" + Path.Replace("%", "%25").Replace("#", "%23") + "?uuid=" + uuid);
            }
            WebClient client = new WebClient();
            client.DownloadStringCompleted += (o, a) =>
            {
                Log.Debug("加载数据完成");
                if (a.Error == null)
                {
                    //更新数据
                    JsonObject item = JsonValue.Parse(a.Result) as JsonObject;
                    if(item.ContainsKey("error"))
                    {
                        Error = item["error"];
                        State = State.LoadError;
                    }
                    else
                    {
                        FromJson(item);
                        State = State.Loaded;
                    }

                 }
                else
                {
                    Error = a.Error.GetMessage();
                    State = State.LoadError;
                }
                IsBusy = false;
                //通知加载完成
                OnCompleted(a);
                OnDataLoaded(a);
            };
            IsBusy = true;
            OnLoading();
            State = State.StartLoad;
            Log.Debug("开始加载数据, 路径为: " + WebClientInfo.BaseAddress + "/" + Path);
            client.DownloadStringAsync(uri);
        }

Usage Example

 /// <summary>
 /// 安检单列表选择改变
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void checkerGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     GeneralObject item = checkerGrid.SelectedItem as GeneralObject;
     if (item == null)
         return;
     GeneralObject go = new GeneralObject();
     go.WebClientInfo = Application.Current.Resources["dbclient"] as WebClientInfo;
     go.EntityType = "T_INSPECTION";
     if (!item.GetPropertyValue("CONDITION").Equals("未检"))
     {
         go.Path = "one/select distinct t from T_INSPECTION t left join fetch t.LINES where t.id ='" + item.GetPropertyValue("id").ToString() + "'";
         go.DataLoaded += go_DataLoaded;
         //if (!item.GetPropertyValue("CONDITION").Equals("正常"))
         //    userfile.IsEnabled = false;
         //else
         //    userfile.IsEnabled = true;
         go.Load();
     }
     else
     {
         userfile.DataContext = null;
         ClearAll();
         //userfile.IsEnabled = false;
     }
 }
All Usage Examples Of Com.Aote.ObjectTools.GeneralObject::Load