介面學習

来源:http://www.cnblogs.com/xiaz/archive/2017/11/27/7905551.html
-Advertisement-
Play Games

1 using System; 2 using System.Collections.Generic; 3 using System.Web; 4 using System.Web.Services; 5 using System.Data; 6 using Topevery.EOffice.Log ...


  1 using System;
  2 using System.Collections.Generic;
  3 using System.Web;
  4 using System.Web.Services;
  5 using System.Data;
  6 using Topevery.EOffice.Logic;
  7 using Topevery.EOffice.Entity;
  8 using System.Data.SqlClient;
  9 
 10 namespace Topevery.EOffice.Web.WebService
 11 {
 12     /// <summary>
 13     /// AttendanceMachineImport 的摘要說明
 14     /// </summary>
 15     [WebService(Namespace = "http://tempuri.org/")]
 16     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
 17     [System.ComponentModel.ToolboxItem(false)]
 18     public class AttendanceMachineImport : System.Web.Services.WebService
 19     {
 20         /// <summary>
 21         /// 兩個列
 22         /// [DIN,員工編號][CLOCK,打卡時間]
 23         /// </summary>
 24         /// <param name="data"></param>
 25         /// <returns></returns>
 26         [WebMethod]
 27         public bool Import(DataTable data)
 28         {
 29 
 30             DataSet dsAttendanceData = new DataSet();
 31             using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["efDatabase"].ConnectionString))
 32             {
 33                 conn.Open();
 34                 using (SqlTransaction tran = conn.BeginTransaction())
 35                 {
 36                     foreach (DataRow dr in data.Rows)
 37                     {
 38                         string DIN = dr["DIN"].ToString();
 39                         DateTime Clock = (DateTime)dr["CLOCK"];
 40                         using (SqlCommand command = new SqlCommand("INSERT INTO T_EO_ATTENDANCE_MACHINE(C_DIN , C_CLOCK) VALUES (@DIN , @CLOCK);", conn, tran))
 41                         {
 42                             command.Parameters.Add(new SqlParameter("@DIN", DIN));
 43                             command.Parameters.Add(new SqlParameter("@CLOCK", Clock));
 44                             command.ExecuteNonQuery();
 45                         }
 46                     }
 47                     tran.Commit();
 48                 }
 49 
 50                 using (SqlDataAdapter command = new SqlDataAdapter("P_EO_PROCESS_ATTENDANCE_MACHINE", conn))
 51                 {
 52                     command.SelectCommand.CommandType = CommandType.StoredProcedure;
 53                     command.Fill(dsAttendanceData);
 54                 }
 55             }
 56 
 57             foreach (DataRow dr in dsAttendanceData.Tables[0].Rows)
 58             {
 59                 /*
 60                  C_USER_ID , C_DATE , C_CHECK_IN_DATE , C_CHECK_OUT_DATE
 61                  */
 62                 DateTime? _SignInDate = null; DateTime? _SignOutDate = null;
 63                 if (dr["C_CHECK_IN_DATE"] != DBNull.Value) { _SignInDate = (DateTime)dr["C_CHECK_IN_DATE"]; }
 64                 if (dr["C_CHECK_OUT_DATE"] != DBNull.Value) { _SignOutDate = (DateTime)dr["C_CHECK_OUT_DATE"]; }
 65                 EOAttendanceLogic.InsertStaffAttenceEx(new EOStaffAttence()
 66                 {
 67                     UserID = (Guid)dr["C_USER_ID"],
 68                     CheckDate = (DateTime)dr["C_DATE"],
 69                     SignInDate = _SignInDate,
 70                     SignOutDate = _SignOutDate
 71                 });
 72                 EOAvoidCheckLogic.ProcessAttendanceData((Guid)dr["C_USER_ID"], (DateTime)dr["C_DATE"]);
 73             }
 74 
 75             using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["efDatabase"].ConnectionString))
 76             {
 77                 conn.Open();
 78                 using (SqlTransaction tran = conn.BeginTransaction())
 79                 {
 80                     foreach (DataRow dr in data.Rows)
 81                     {
 82                         using (SqlCommand command = new SqlCommand("TRUNCATE TABLE T_EO_ATTENDANCE_MACHINE ;", conn, tran))
 83                         {
 84                             command.ExecuteNonQuery();
 85                         }
 86                     }
 87                     tran.Commit();
 88                 }
 89             }
 90             return true;
 91         }
 92 
 93         [WebMethod]
 94         public DateTime GetLastTime()
 95         {
 96             DateTime lastTime = DateTime.Now.AddDays(-1);
 97             string sql = @"
 98 select max(d) from(
 99 select max(a.c_sign_in_date) as d from t_eo_staff_attence_bak a 
100 inner join syn_ty_pmi_user u on a.c_user_id = u.user_id
101 where a.c_attence_type = 1
102 union all
103 select max(a.c_sign_out_date) from t_eo_staff_attence_bak a 
104 inner join syn_ty_pmi_user u on a.c_user_id = u.user_id
105 where a.c_attence_type = 1) a";
106 
107             using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["efDatabase"].ConnectionString))
108             {
109                 conn.Open();
110 
111                 using (SqlCommand command = new SqlCommand(sql, conn))
112                 {
113                     lastTime = (DateTime)command.ExecuteScalar();
114                 }
115             }
116 
117             return lastTime;
118         }
119 
120         Dictionary<string, Guid> _EoUserExtBuffer = null;
121         Dictionary<string, Guid> EoUserExtBuffer
122         {
123             get
124             {
125                 if (_EoUserExtBuffer == null)
126                 {
127                     _EoUserExtBuffer = new Dictionary<string, Guid>();
128                 }
129                 EOUserExtCollection eoUserExtColl = EOPersonalLogic.GetUserInfos();
130                 foreach (EOUserExt ext in eoUserExtColl)
131                 {
132 
133                     _EoUserExtBuffer.Add(ext.UserCode, ext.UserID);
134                 }
135 
136                 return _EoUserExtBuffer;
137             }
138         }
139        
140         
141         Guid GetUserId(string DIN)
142         {
143             if (EoUserExtBuffer.ContainsKey(DIN))
144             {
145                 return EoUserExtBuffer[DIN];
146             }
147             return Guid.Empty;
148         }
149     }
150 }
View Code

調用方式

1 TYEO.AttendanceMachineImport ser = new AttendanceMachineTool.TYEO.AttendanceMachineImport();
2             dtStart.Value = ser.GetLastTime();

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 正則表達式可以用來處理大量的文件和字元串,運維工作中過濾日記簡單高效,Linux最常應用正則表達式的命令有grep(egrep)、sed、awk。 正則表達式和文本通配符不同容易混淆。 字元匹配 . 匹配任意單個字元 [] 匹配指定範圍內的任意單個字元 [^] 匹配指定範圍外的任意單個字元 [:al ...
  • Linux的特點 1.免費的、開源的 2.支持多線程。多用戶的 3.安全性好 4.對記憶體和文件管理優越 5.linux最小隻需要4m->嵌入式開發 缺點: 操作相對困難 命令: shutdown -h now 立即進行關機 shutdown -r now 現在重新啟動電腦 reboot 現在重新啟 ...
  • 版本: Windows_server_2012-r2_x64 工具: VMware vSphere Client 鏡像地址: http://www.xpgod.com/soft/10718.html(地址為參考,可根據需求自行下載~) 首先鏈接虛機 鏈接成功後將本地資源進行上傳~ 滑鼠右擊datab ...
  • 從線程執行任務的方式上可以分為線程同步和線程非同步。而為了方便理解,後面描述中用“同步線程”指代與線程同步相關的線程,同樣,用“非同步線程”表示與線程非同步相關的線程。 線程非同步就是解決類似前面提到的執行耗時任務時界面控制項不能使用的問題。如創建一個次線程去專門執行耗時的任務,而其他如界面控制項響應這樣的任務 ...
  • var num = 1; var str = '1'; var test = 1; test == num //true 相同類型 相同值 test num //true 相同類型 相同值 test !== num //false test與num類型相同,其值也相同, 非運算肯定是false nu ...
  • Delphi DataTypeC# datatypeansistringstringbooleanboolbytebytecharcharcompdoublecurrencydecimaldoubledoubleextendeddoubleint64longint32intint16shortint... ...
  • 返回總目錄 本小節目錄 Replace Nested Conditional with Guard Claues(以衛語句取代嵌套條件表達式) Replace Conditional with Polymorphism(以多態取代條件表達式) 5Replace Nested Conditional ...
  • 這是使用ODP.NET鏈接Orcl資料庫常見錯誤,需要配置系統環境變數。 解決方法如下: 找到以下路徑文件:C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config 註意:修改前最好先備份以免.... 將下麵這段配置文件加 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...