コード例 #1
0
 public void Load()
 {
   IReadService service = new WcfClientAddressBase<ReadServiceClient>("../ReadService.svc").GetService();
   HomeViewModel.Instance.Progress.ShowProgress("正在获取下载列表...");
   service.BeginGetDownloads(ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
   {
     string result = service.EndGetDownloads(ar);
     Collection = result.Load<EsuInfoCollection<Links>>();
   })), null);
 }
コード例 #2
0
 public void Load()
 {
   IReadService service = new WcfClientAddressBase<ReadServiceClient>("../ReadService.svc").GetService();
   HomeViewModel.Instance.Progress.ShowProgress("正在获取用户信息...");
   service.BeginGetEnterpriseUserJson(HomeViewModel.Instance.CurrentUserID,
     ThreadHelper.SyncContextCallback(ar =>
     {
       var result = service.EndGetEnterpriseUserJson(ar);
       User = result.Load<EnterpriseUser>();
       HomeViewModel.Instance.Progress.HideProgress();
     }), null);
 }
コード例 #3
0
 public void Load()
 {
   IReadService service = new WcfClientAddressBase<ReadServiceClient>("../ReadService.svc").GetService();
   HomeViewModel.Instance.Progress.ShowProgress("正在获取问题记录...");
   service.BeginGetRequirements(0, ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
   {
     Cache = new Dictionary<int, EsuInfoCollection<Comment>>();
     string result = service.EndGetRequirements(ar);
     Requirements = result.Load<EsuInfoCollection<Requirement>>();
     Requirements.CurrentItemChanged = CurrentItemChanged;
     Requirements.AcceptChanges();
   })), null);
 }
コード例 #4
0
 private void Save()
 {
   IWriteService service = new WcfClientAddressBase<WriteServiceClient>("../WriteService.svc").GetService();
   HomeViewModel.Instance.Progress.ShowProgress("正在保存用户信息...");
   service.BeginUpdateEnterpriseUser(user.ToString(),
    ThreadHelper.SyncContextCallback(ar =>
    {
      var result = service.EndUpdateEnterpriseUser(ar);
      if (!string.IsNullOrEmpty(result))
        MessageBox.Show("用户信息保存失败:" + result);
      else
      {
        MessageBox.Show("用户信息保存成功!");
      }
      HomeViewModel.Instance.Progress.HideProgress();
    }), null);
 }
コード例 #5
0
ファイル: LoginViewModel.cs プロジェクト: EinsteinSu/HrPortal
 protected override void Login()
 {
   if (!ShowCheckLoginError())
     return;
   HomeViewModel.Instance.Progress.ShowProgress("正在登录...");
   IReadService service = new WcfClientAddressBase<ReadServiceClient>("../ReadService.svc").GetService();
   service.BeginLogin(UserName, Password, ThreadHelper.SyncContextCallback(ar =>
   {
     string data = service.EndLogin(ar);
     bool result = !string.IsNullOrEmpty(data);
     if (result)
     {
       SaveLogin();
       HomeViewModel.Instance.CurrentUser = data.Load<User>();
     }
     if (loginDone != null)
       loginDone(result);
   }), null);
 }
コード例 #6
0
 private void LoadComment()
 {
   if (requirements.CurrentItem == null)
     return;
   if (Cache.ContainsKey(requirements.CurrentItem.Id))
     Cache.Remove(requirements.CurrentItem.Id);
   HomeViewModel.Instance.Progress.ShowProgress("正在加载评论...");
   IReadService service = new WcfClientAddressBase<ReadServiceClient>("../ReadService.svc").GetService();
   service.BeginGetComments(requirements.CurrentItem.Id, ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
   {
     var result = service.EndGetComments(ar);
     var collection = result.Load<EsuInfoCollection<Comment>>();
     requirements.CurrentItem.Comments = collection;
     Cache.Add(requirements.CurrentItem.Id, collection);
   })), null);
 }
コード例 #7
0
 private void DeleteComment(Requirement requirement)
 {
   var comment = requirement.Comments.CurrentItem;
   if (comment == null || requirements.CurrentItem == null)
     return;
   if (!comment.CreateUserID.Equals(HomeViewModel.Instance.CurrentUserID))
   {
     MessageBox.Show("不是你的评论不能修改及删除!");
     return;
   }
   if (Utils.DeleteMessage("评论及意见"))
   {
     IWriteService service = new WcfClientAddressBase<WriteServiceClient>("../WriteService.svc").GetService();
     service.BeginDeleteComment(comment.ToString(), requirements.CurrentItem.Id,
       ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
       {
         string message = service.EndDeleteComment(ar);
         if (string.IsNullOrEmpty(message))
           LoadComment();
         else
           MessageBox.Show(message);
       })), null);
   }
 }
コード例 #8
0
 private void UpdateComment(Requirement requirement)
 {
   var comment = requirement.Comments.CurrentItem;
   if (comment == null || requirements.CurrentItem == null)
     return;
   if (!comment.CreateUserID.Equals(HomeViewModel.Instance.CurrentUserID))
   {
     MessageBox.Show("不是你的评论不能修改及删除!");
     return;
   }
   var c = comment.ToString().Load<Comment>();
   var viewModel = new CommentEditWindow(c);
   DialogWindowHelper.ShowDialogWindow(viewModel, result =>
   {
     if (result)
     {
       IWriteService service = new WcfClientAddressBase<WriteServiceClient>("../WriteService.svc").GetService();
       service.BeginUpdateComment(viewModel.Data.ToString(), requirements.CurrentItem.Id,
         ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
         {
           string message = service.EndUpdateComment(ar);
           if (string.IsNullOrEmpty(message))
             LoadComment();
           else
             MessageBox.Show(message);
         })), null);
     }
   });
 }
コード例 #9
0
 private void AddComment(Requirement requirement)
 {
   if (requirement == null)
     return;
   var c = new Comment
   {
     CreateUserID = HomeViewModel.Instance.CurrentUserID,
     CreateUserName = HomeViewModel.Instance.CurrentUser.Name
   };
   var viewModel = new CommentEditWindow(c);
   DialogWindowHelper.ShowDialogWindow(viewModel, result =>
   {
     if (result)
     {
       #region save to service
       IWriteService service = new WcfClientAddressBase<WriteServiceClient>("../WriteService.svc").GetService();
       service.BeginInsertComment(viewModel.Data.ToString(), requirement.Id,
         ThreadHelper.SyncContextCallback(ar => Globals.ProcessAsyncServiceData(() =>
         {
           string message = service.EndInsertComment(ar);
           if (string.IsNullOrEmpty(message))
             LoadComment();
           else
             MessageBox.Show(message);
         })), null);
       #endregion
     }
   });
 }