using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

namespace FineUIPro.Web
{
    /// <summary>
    /// MyWebService 的摘要说明
    /// </summary>
    [WebService(Namespace = "https://eproject-test.basf-ypc.net.cn/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class MyWebService : System.Web.Services.WebService
    {
        /// <summary>
        /// 根据年份获取项目
        /// </summary>
        /// <param name="years">年份</param>
        /// <returns></returns>
        [WebMethod(Description = "根据年份获取项目")]
        public string GetEproject(string years)
        {

            var getEproject = (from x in BLL.Funs.DB.Editor_EProject
                               select new Model.EprojectItem
                               {
                                   JobCode = x.ProjectControl_JobNo,
                                   PM = x.ProjectControl_ProjectManager,
                                   CM = x.ProjectControl_ConstManager,
                                   JobStatus = x.ProjectControl_JobStatus,
                                   Account = x.ProjectControl_Account,
                                   JobTitle = x.ProjectControl_JobTitle
                               }).ToList();
            if (!string.IsNullOrEmpty(years))
            {
                string yy = years.Substring(2, 2);
                getEproject = (from x in getEproject
                               where x.JobCode.Substring(0, 2) == yy
                               select x).ToList();
            }
            if (getEproject.Count() > 0)
            {

                return BLL.JsonHelper.ListToJson(getEproject);
            }
            else
            {
                return "该年份没有项目记录!";
            }
        }
    }
}