前端界面后台:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ServiceModel.DomainServices.Client;
using System.Collections.ObjectModel;

using SilverlightRiaService.Web;


namespace SilverlightRiaService
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();

            ServiceClass sc = new ServiceClass();

            sc.GetUnitType(1, "admin", DateTime.Now.AddDays(-20), DateTime.Now, o =>
            {
                if (o.HasError)
                {
                    MessageBox.Show("error");
                }
                else
                {
                    string strvalue = o.Value;
                    MessageBox.Show("直接调" + strvalue);
                }
            }, null);
            sc.InvokeOperation("GetUnitType", typeof(IEnumerable<string>),
                new Dictionary<string, object> { { "unit", 1 }, { "systype", "admin" }, { "startTime", DateTime.Now.AddDays(-20) }, { "endTime", DateTime.Now } }, true, evv =>
                {
                    if (!evv.HasError)
                    {
                        var sd = evv.Value;
                        MessageBox.Show("Invoke" + sd.ToString());
                    }
                }, null);

            /*
             在Silverlight中创建数据源集合可以使用内建的ObservableCollection类,
             因为ObservableCollection类既实现了INotifyPropertyChanged接口,又实现了INotifyCollectionChanged接口。
             使用ObservableCollection类不但可以实现Add、Remove、Clear和Insert操作,还可以触发PropertyChanged事件。
             */

            ObservableCollection<Student> stulist = new ObservableCollection<Student>();
            sc.GetStudentByName("叶薇", ye =>
            {
                if (!ye.HasError)
                {
                    stulist = (ObservableCollection<Student>)ye.Value;
                }
            }, null);
            sc.InvokeOperation("GetStudentByName", typeof(ObservableCollection<Student>),
                new Dictionary<string, object> { { "name", "叶朔" } }, true, shuo =>
                {
                    if (!shuo.HasError)
                    {
                        stulist = new ObservableCollection<Student>(shuo.Value as IEnumerable<Student>);
                        List<Student> sdstulist = new List<Student>(shuo.Value as IEnumerable<Student>);
                    }
                }, null);
        }
    }
}
View Code

相关文章:

  • 2022-01-08
  • 2021-12-23
  • 2021-09-28
  • 2022-12-23
  • 2021-08-05
  • 2021-12-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-22
  • 2022-01-18
  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案