using System; using System.Security.Cryptography; using System.Text; using System.Web.Services; using System.Web.Script.Services; using WebLib; namespace 報到系統 { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] [ScriptService] public class BPSNService : System.Web.Services.WebService { /// /// 下載員工資料 /// [WebMethod(EnableSession = true)] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public BaseResponse Download() { try { DAC_BPSN dac = new DAC_BPSN(); BPSNList result = dac.SelectForClient(); // 因為決定客戶端離線模式不驗證密碼,所以不把密碼雜湊值傳給客戶端了 //foreach (var item in result) //{ // string decryptedPassword = EncDec.KeyDec(item.BPAWD); // string combined = item.BPENO + decryptedPassword; // using (SHA1 sha1 = SHA1.Create()) // { // byte[] hash = sha1.ComputeHash(Encoding.UTF8.GetBytes(combined)); // item.BPAWD = Convert.ToBase64String(hash); // } //} if (result == null || result.Count == 0) { return new BaseResponse { Success = true, Message = "沒有員工資料", Data = new BPSNList() }; } return new BaseResponse { Success = true, Message = "下載成功", Data = result }; } catch (Exception ex) { return new BaseResponse { Success = false, Message = "下載員工資料發生錯誤:" + ex.Message }; } } } }