示例#1
0
 /// <summary>
 /// 从学校获取读者 信息
 /// </summary>
 /// <param name="user"></param>
 /// <param name="school"></param>
 /// <returns></returns>
 public ClassModel.ReaderInfo CheckAndGetReaderInfo(ClassModel.UserInfo user, AMS.Model.AMS_School school)
 {
     SeatManage.IPocketBespeakBllService.IPocketBespeakBllService pocketBespeak = BespeakServiceConnProxy.BespeakServiceConnProxy.CreateChannelPocketBespeakBllService(school.ConnectionString);
     try
     {
         return(pocketBespeak.CheckAndGetReaderInfo(user));
     }
     catch (LoginFailed ex)
     {
         throw ex;
     }
     catch (ReaderHandlerFailed ex)
     {
         throw ex;
     }
     catch (EndpointNotFoundException ex)
     {
         throw new RemoteServiceLinkFailed();
     }
     catch (CommunicationException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         ICommunicationObject ICommObjectService = pocketBespeak as ICommunicationObject;
         try
         {
             if (ICommObjectService.State == CommunicationState.Faulted)
             {
                 ICommObjectService.Abort();
             }
             else
             {
                 ICommObjectService.Close();
             }
         }
         catch
         {
             ICommObjectService.Abort();
         }
     }
 }
 public void BookUserData()
 {
     try
     {
         if (Progress != null)
         {
             Progress("数据获取中……");
         }
         int     allcount = 0;
         int     nownum   = 0;
         int     okcount  = 0;
         string  sqlstr   = "SELECT [UsrName],[UsrPwd],[LoginID],[IsDel],[UsrType] FROM [Users_ALL] where [UsrType]='s' and [IsDel]='N'";
         DataSet ds       = Query(sqlstr, Old_connectionString, null);
         allcount = ds.Tables[0].Rows.Count;
         foreach (DataRow dr in ds.Tables[0].Rows)
         {
             SeatManage.ClassModel.UserInfo user = new ClassModel.UserInfo();
             user.IsAdmin  = false;
             user.IsUsing  = SeatManage.EnumType.LogStatus.Valid;
             user.LoginId  = dr["LoginID"].ToString();
             user.Password = SeatManageComm.MD5Algorithm.GetMD5Str32(dr["UsrPwd"].ToString());
             user.UserName = dr["UsrName"].ToString();
             user.UserType = SeatManage.EnumType.UserType.Reader;
             if (SeatManage.Bll.Users_ALL.AddNewUser(user))
             {
                 okcount++;
             }
             nownum++;
             if (Progress != null)
             {
                 Progress("同步中…… " + nownum + "/" + allcount);
             }
         }
         if (Progress != null)
         {
             Progress("导入完成,总共" + allcount + "条,成功" + (okcount) + "条");
         }
     }
     catch
     {
         if (Progress != null)
         {
             Progress("导入失败!");
         }
     }
 }
 public string CheckUser(string loginId, string password)
 {
     try
     {
         if (string.IsNullOrEmpty(loginId))
         {
             return(null);
         }
         Users_ALL      dalUser_All = new Users_ALL();
         string         strWhere    = "LoginId=@loginId";
         SqlParameter[] parameters  =
         {
             new SqlParameter("@loginId", loginId)
         };
         DataSet ds = dalUser_All.GetList(strWhere, parameters);
         if (ds.Tables[0].Rows.Count > 0)
         {
             ClassModel.UserInfo userInfo = new ClassModel.UserInfo();
             userInfo.LoginId  = ds.Tables[0].Rows[0]["LoginID"].ToString();
             userInfo.Password = ds.Tables[0].Rows[0]["UsrPwd"].ToString();
             userInfo.IsUsing  = (LogStatus)int.Parse(ds.Tables[0].Rows[0]["UsrEnabled"].ToString());
             if (userInfo.Password.Equals(SeatManageComm.MD5Algorithm.GetMD5Str32(password)) && userInfo.IsUsing == LogStatus.Valid)
             {
                 return(userInfo.LoginId);
             }
             else
             {
                 return("");
             }
         }
         else
         {
             return("");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public void Run()
        {
            try
            {
                if (Progress != null)
                {
                    Progress("数据获取中……");
                }
                int     allcount = 0;
                int     nownum   = 0;
                int     okcount  = 0;
                string  sqlstr   = "SELECT [CardNo] ,[CardID] ,[ReaderName],[Sex],[ReaderTypeName],[ReaderDeptName],[ReaderProName],[Flag] FROM [dbo].[T_SM_Reader]";
                DataSet ds       = Query(sqlstr, connectionString, null);
                allcount = ds.Tables[0].Rows.Count;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string  isSameSQL = "SELECT [LoginID],[UsrName],[UsrPwd],[UsrType],[UsrEnabled],[Remark] FROM [dbo].[Users_ALL] WHERE [LoginID]='" + dr["CardNo"] + "'";
                    DataSet sds       = Query(isSameSQL, connectionString, null);
                    if (sds.Tables[0].Rows.Count > 0)
                    {
                        if (Progress != null)
                        {
                            Progress(nownum + "/" + allcount + "  " + dr["CardNo"].ToString().Trim() + " " + dr["ReaderName"].ToString().Trim() + " 已存在");
                        }
                    }
                    else
                    {
                        SeatManage.ClassModel.UserInfo user = new ClassModel.UserInfo();
                        user.IsAdmin  = false;
                        user.IsUsing  = SeatManage.EnumType.LogStatus.Valid;
                        user.LoginId  = dr["CardNo"].ToString();
                        user.Password = SeatManageComm.MD5Algorithm.GetMD5Str32(dr["CardNo"].ToString());
                        user.UserName = dr["ReaderName"].ToString();
                        user.UserType = SeatManage.EnumType.UserType.Reader;
                        user.Remark   = "同步工具添加";
                        if (SeatManage.Bll.Users_ALL.AddNewUser(user))
                        {
                            okcount++;

                            if (Progress != null)
                            {
                                Progress(nownum + "/" + allcount + "  " + dr["CardNo"].ToString().Trim() + " " + dr["ReaderName"].ToString().Trim() + " 添加成功");
                            }
                        }
                        else
                        {
                            if (Progress != null)
                            {
                                Progress(nownum + "/" + allcount + "  " + dr["CardNo"].ToString().Trim() + " " + dr["ReaderName"].ToString().Trim() + " 添加失败");
                            }
                        }
                    }
                    nownum++;
                }
                if (Progress != null)
                {
                    Progress("导入完成,总共" + allcount + "条,添加" + okcount + "条");
                }
            }
            catch
            {
                if (Progress != null)
                {
                    Progress("导入失败!");
                }
            }
        }