Interface learning,

Source: Internet
Author: User

Interface learning,

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 /// summary of 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 /// two columns 22 /// [DIN, employee ID] [CLOCK, clock-in time] 23 // </summary> 24 // <param name = "data"> </param> 25 /// <returns> </returns> 26 [webMethod] 27 public bool Import (DataTable data) 28 {29 30 DataSe T 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 Clo Ck = (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 SQL DataAdapter ("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 (. c_sign_in_date) as d from t_eo_staff_attence_bak a 100 inner join syn_ty_pmi_user u on. c_user_id = u. user_id101 where. c_attence_type = 1102 union all103 select max (. c_sign_out_date) from t_eo_staff_attence_bak a 104 inner join syn_ty_pmi_user u on. c_user_id = u. user_id105 where. 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> EoUserExtBuffer122 {123 get124 {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

Call Method

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.