zoukankan      html  css  js  c++  java
  • 创建一个Low-touch Silverlight 集成

    创建一个Low-touch Silverlight 集成

    你能够创建一个与SharePoint之间self-contained, low-touch的集成。
    1. 打开VS,新建项目,选择Silverlight应用程序,命名LowIntegrationSLApp,点击确定。

    2. 清除复选框“在新站点上承载Silverlight应用程序”。
    3. 右击醒目加入新建项。
    4. 选择数据--XML文件。
    5. 命名Employee.xml。

    6. 加入代码到XML文件。
    <?xml version="1.0" encoding="utf-8" ?

    > John Doe8379013.23.43.8Kelly Jackson9830112.82.93.0Sam Sheppard102904.24.34.5Lamont Smyth1297753.83.63.2Beth Canyon389212.12.22.0Barry McCathry2019823.32.93.7Steve Denn2901224.54.64.5Ahmed Habul09928123.93.83.9

    7. 右击项目加入新类Employees。点击确定。
    8. 加入例如以下代码。

    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    
    namespace LowIntegrationSLApp
    {
        public class Employees
        {
            public string empName { get; set; }
            public string empID { get; set; }
            public string empFY08 { get; set; }
            public string empFY09 { get; set; }
            public string empFy10 { get; set; }
        }
    }
    
    9. 右击MainPage.xaml。选择视图查看器。
    10. 加入控件。


    11. 最后代码是这种:
    
            
            
            
            
            
            
            
            
            
            
            
        
    界面是这种:

    12. 界面完毕后。

    加入后台代码。

    using System;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.Xml;
    using System.Linq;
    using System.Collections.Generic;
    using System.Windows.Media.Imaging;
    using System.Xml.Linq;
    
    namespace LowIntegrationSLApp
    {
        public partial class MainPage : UserControl
        {
            string promotion = "";
            string fastTrack = "";
            double avgScore = 0.0;
    
            List myEmployeeList = new List();
    
            public MainPage()
            {
                InitializeComponent();
            }
    
            private void btnRefresh_Click(object sender, RoutedEventArgs e)
            {
                XElement employee = XElement.Load(@"Employee.xml");
                resetThermometer();
                string tempEmpName = "";
                string tempEmpID = "";
                string tempFY08 = "";
                string tempFY09 = "";
                string tempFY10 = "";
                var employees =
                    from emp in employee.Elements("Employee")
                    select new
                    {
                        tempEmpName = (string)emp.Element("Name"),
                        tempEmpID = (string)emp.Element("EmpID"),
                        tempFY08 = (string)emp.Element("FY08"),
                        tempFY09 = (string)emp.Element("FY09"),
                        tempFY10 = (string)emp.Element("FY10")
                    };
                foreach (var item in employees)
                {
                    Employees tempEmployee = new Employees();
                    tempEmployee.empName = item.tempEmpName.ToString();
                    lstbxEmployeeNames.Items.Add(tempEmployee.empName);
                    tempEmployee.empID = item.tempEmpID.ToString();
                    tempEmployee.empFY08 = item.tempFY08.ToString();
                    tempEmployee.empFY09 = item.tempFY09.ToString();
                    tempEmployee.empFy10 = item.tempFY10.ToString();
                    myEmployeeList.Add(tempEmployee);
                }
            }
            private void lstbxEmployeeNames_SelectionChanged(object sender,
            SelectionChangedEventArgs e)
            {
                resetThermometer();
                string tempEmpID = "";
                string tempFY08 = "";
                string tempFY09 = "";
                string tempFY10 = "";
                string empFilter = lstbxEmployeeNames.SelectedItem.ToString();
                var expr =
                from emp in myEmployeeList
                select new
                {
                    emp.empName,
                    emp.empID,
                    emp.empFY08,
                    emp.empFY09,
                    emp.empFy10
                };
                foreach (var item in expr)
                {
                    if (item.empName == empFilter)
                    {
                        txtbxEmplID.Text = item.empID;
                        txtbxFY08.Text = item.empFY08;
                        txtbxFY09.Text = item.empFY09;
                        txtbxFY10.Text = item.empFy10;
                    }
                }
            }
            private void btnCalc_Click(object sender, RoutedEventArgs e)
            {
                resetThermometer();
                double rvwFY08 = Double.Parse(txtbxFY08.Text);
                double rvwFY09 = Double.Parse(txtbxFY09.Text);
                double rvwFY10 = Double.Parse(txtbxFY10.Text);
                avgScore = Math.Round(((rvwFY08 + rvwFY09 + rvwFY10) /
                3), 2) * 100 / 100;
                if (avgScore >= 4.5)
                {
                    promotion = "Yes";
                    fastTrack = "Yes";
                    shapeRectanglePromo.Height = 3;
                    lblMessage.Content = "High Reward";
                }
                else if (avgScore >= 4.0)
                {
                    promotion = "Yes";
                    fastTrack = "No";
                    shapeRectangleNoPromo.Height = 3;
                    lblMessage.Content = "Med. Reward";
                }
                else
                {
                    promotion = "No";
                    fastTrack = "No";
                    shapeRectangleLowScore.Height = 3;
                    lblMessage.Content = "Low Reward";
                }
                txtbxPromo.Text = promotion;
                txtbxFastTrack.Text = fastTrack;
                txtbxAVGScore.Text = avgScore.ToString();
            }
            private void resetThermometer()
            {
                shapeRectanglePromo.Height = 0;
                shapeRectangleNoPromo.Height = 0;
                shapeRectangleLowScore.Height = 0;
                txtbxAVGScore.Text = "";
                txtbxFastTrack.Text = "";
                txtbxPromo.Text = "";
    
                lblMessage.Content = "";
            }
        }
    }
    
    要加入引用System.Xml.Linq。

    13. 找到相应bin中的.xap文件,放在SharePoint站点中。

    PS:资源和源代码能够在我的资源中下载。

  • 相关阅读:
    Local File Manage in JavaScript Using FileSystemObject
    How to Register COM in VS
    Permission Error When Building C++ in VS2010
    Upload and Download File using Java
    JavaScript Interactive with ActiveX Control
    一个完整的Installshield安装程序实例
    一个.NET(C#)的双键字典类
    C#实现内存中字符串或byte[]的加解密
    判断请求是否来自 AJAX
    Reflector 7.3.018
  • 原文地址:https://www.cnblogs.com/mqxnongmin/p/10800387.html
Copyright © 2011-2022 走看看