/// 
///WCF service
///FOR TABLE t_online
///By wm  
///on 06/18/2022
/// 
  
using System.Collections.Generic;
using System.Data;
using DeiNiu.wms.Data.Model.Wcf ;
using DeiNiu.wms.Data.Model; 
using DeiNiu.Utils;
using System;
using DeiNiu.wms.Logical;
//using DeiNiu.wms.Logical; 
namespace DeiNiu.Wcf
{
    // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名 。
    public class T_ONLINE : IOnline 
    {
        #region options
        /*: basicService, 
          private static  lOnline  _lOnline ;
           lOnline  lOnlineObj
          {
              get
              {
                  if ( _lOnline  == null ||   _lOnline.operId != getOperId())
                  {
                       _lOnline= new  lOnline(getOperId());
                  }
                  return  _lOnline;
              }
          }
         */
        #endregion
       
        public WcfOnline getObj(int Id)
        {
            LogHelper.debug(typeof(WcfOnline), "收到请求....custId "+ Id);
            Online dbObj = new Online(Id);
            WcfOnline wcfObj = new WcfOnline().getWcfObject(dbObj);
          
    
            if (string.IsNullOrEmpty(wcfObj.custId ))
            {
                wcfObj.state = (int)enumOnlineStatus.过期;
                wcfObj.custName = "未知";
                wcfObj.msg = "请联系供应商";
            }
           
            enumOnlineStatus status = (enumOnlineStatus)wcfObj.state;
            if (!string.IsNullOrEmpty(wcfObj.custId) && status == enumOnlineStatus.试用)
            {
                DateTime endate = Convert.ToDateTime(wcfObj.endDate);
                int result = DateTime.Compare(DateTime.Now, endate);
               
                if (result > 0)
                {
                    wcfObj.state = (int)enumOnlineStatus.过期;
                    dbObj.state = wcfObj.state;
                    dbObj.Update();
                }
            }
          
            LogHelper.debug(typeof(WcfOnline), String.Format("custName {0}, status {1}",wcfObj.custName,status));
            return wcfObj ;
        }
        public int validUser(string userId, string passwd)
        {
            Employee emp = new Employee();
            return emp.ValidUser(userId, passwd);
        }
        public Dictionary> getCatedAuths(int userId, int warehouse)
        {
            Dictionary> rs = new Dictionary>();
            Dictionary> auths = new LAuthority().getCatedAuthorities(userId, warehouse);
            foreach (String cate in auths.Keys)
            {
                List lst = new List();
                foreach (Authority link in auths[cate])
                {
                    if (string.IsNullOrEmpty(link.auth_class))
                    {
                        continue;
                    }
                    lst.Add(link.auth_name + ":" + link.auth_class);
                }
                rs[cate] = lst;
            }
            return rs;
        }
      public  DataTable getDictionary()
        {
            return new DataTable("abc");
        }
    }
 }