private string insertExcuse(string mac, string from_date, string to_date, string reason, string type_id, string latitude, string longitude) { string methodName = "insertExcuse()"; log.DebugFormat("------------START---{0}-{1}-({2})-----------", className, methodName, ""); log.DebugFormat("----------{0}-{1}-({2})-----------", className, methodName, ""); string result = ""; try { DateTime fdate = DateTime.Parse(from_date); DateTime tdate = DateTime.Parse(to_date); log.DebugFormat("------------DATA---{0}-{1}-({2})-----------", className, methodName, from_date + "|" + to_date + "|" + latitude + longitude); result = Excuse.insertExcuse(mac, fdate, tdate, reason, int.Parse(type_id), latitude, longitude); } catch (Exception ex) { log.Error(ex); } log.DebugFormat("------------END---{0}-{1}-({2})-----------", className, methodName, result); return(result); }
private string insertExcuse(string mac, string from_date, string to_date, string reason, string excuse_type, string latitude, string longitude) { string methodName = string.Format("insertExcuse({0},{1},{2},{3},{4},{5})", mac, from_date, to_date, reason, latitude, longitude); LogHelper.DebugFormat("{0}.{1}:--- start ---", className, methodName); log.DebugFormat("{0}.{1}:--- {2},{3}, {4}, {5}, {6} ---", className, methodName, mac, from_date, to_date, reason, excuse_type); string result = ""; DateTime f_date = DateTime.MinValue; DateTime t_date = DateTime.MinValue; string pattern = "yyyy-MM-dd HH:mm:ss"; bool ok_fdate = DateTime.TryParseExact(from_date, pattern, null, DateTimeStyles.None, out f_date); bool ok_tdate = DateTime.TryParseExact(to_date, pattern, null, DateTimeStyles.None, out t_date); if (!ok_fdate) { pattern = "yyyy-MM-dd"; ok_fdate = DateTime.TryParseExact(from_date, pattern, null, DateTimeStyles.None, out f_date); ok_tdate = DateTime.TryParseExact(to_date, pattern, null, DateTimeStyles.None, out t_date); } if (ok_fdate && ok_tdate) { log.DebugFormat("{0}.{1}:--- end ---, pass parsing: f_date{2} , t_date{3}", className, methodName, f_date.ToString(), t_date.ToString()); result = Excuse.insertExcuse(mac, f_date, t_date, reason, int.Parse(excuse_type), latitude, longitude); } LogHelper.DebugFormat("{0}.{1}:--- end ---", className, methodName); return(result); }
private string approveExcuse(string mac, string excuse_id, string approve, string ip) { string methodName = string.Format("approveExcuse({0},{1},{2},{3})", mac, ip, excuse_id, approve); LogHelper.DebugFormat("{0}.{1}:--- start ---", className, methodName); string result = Excuse.approveExcuse(mac, excuse_id, approve, ip); LogHelper.DebugFormat("{0}.{1}:--- end ---", className, methodName); return(result); }
public static string pendingApproval(string macAdds, DateTime from_date, DateTime to_date, string approve, string reason_type) { string methodName = "pendingApproval()"; log.DebugFormat("------------START---{0}-{1}-({2})-----------", className, methodName, from_date + "," + to_date); List <Excuse> excuseList = new List <Excuse>(); string Approvals = ""; try { using (SqlConnection conn = new SqlConnection(ConnectionString)) { using (SqlCommand cmd = new SqlCommand("getPendingExcuse", conn)) { if (macAdds != "") { cmd.Parameters.Add("@selectedMacString", SqlDbType.VarChar).SqlValue = macAdds; } else { cmd.Parameters.AddWithValue("@selectedMacString", DBNull.Value); } cmd.Parameters.Add("@from", SqlDbType.DateTime).SqlValue = from_date; cmd.Parameters.Add("@to", SqlDbType.DateTime).SqlValue = to_date; cmd.Parameters.Add("@type", SqlDbType.VarChar).SqlValue = approve; cmd.Parameters.Add("@excuse_type", SqlDbType.VarChar).SqlValue = reason_type; cmd.CommandType = CommandType.StoredProcedure; conn.Open(); using (SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)) { Excuse x; while (reader.Read()) { x = new Excuse(); x.excuse_id = ((int)reader["id"]); x.from_date = ((DateTime)reader["from_Date"]).ToString(); x.to_date = ((DateTime)reader["to_Date"]).ToString(); x.excuse_type = reader["type"].ToString(); x.excuse_reason = (string)reader["excuse_reason"]; x.approved = (string)reader["approved"]; x.logdate = ((DateTime)reader["createdate"]).ToString(); x.owner = (string)reader["name"]; excuseList.Add(x); } } conn.Close(); } } } catch (Exception ex) { log.Error(ex); } Approvals = new JavaScriptSerializer().Serialize(excuseList); log.DebugFormat("------------END---{0}-{1}-({2})-----------", className, methodName, Approvals); return(Approvals); }
private string ApproveExcuse(string mac, string ip, string Excuse_id, string approve, string pass) { return(Excuse.approveExcuse(mac, Excuse_id, approve, ip)); }