public static UserGroupingModel GetLogUserGroupingModel(UserGroupingModel model)
 {
     using (var dbHelper = DbHelper.CreateLogDbHelper(true))
     {
         using (var cmd = new SqlCommand(@"select DeviceId,UserId,Tag,StartDateTime,EndDateTime  from Tuhu_Log..tbl_UserStatisticsGrouping with(nolock) where  DeviceId=@DeviceId and UserId=@UserId and Tag=@Tag "))
         {
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.AddWithValue("@DeviceId", model.DeviceId);
             cmd.Parameters.AddWithValue("@UserId", model.UserId);
             cmd.Parameters.AddWithValue("@Tag", model.Tag);
             return(dbHelper.ExecuteFetch <UserGroupingModel>(cmd));
         }
     }
 }
 public static int UpdatetblUserStatisticsGrouping(UserGroupingModel model)
 {
     using (var dbHelper = DbHelper.CreateLogDbHelper())
     {
         using (var cmd = new SqlCommand(@"Update Tuhu_Log..tbl_UserStatisticsGrouping set StartDateTime=@StartDateTime,EndDateTime=@EndDateTime where DeviceId=@DeviceId and UserId=@UserId and Tag=@Tag"))
         {
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.AddWithValue("@DeviceId", model.DeviceId);
             cmd.Parameters.AddWithValue("@UserId", model.UserId);
             cmd.Parameters.AddWithValue("@Tag", model.Tag);
             cmd.Parameters.AddWithValue("@StartDateTime", model.StartDateTime);
             cmd.Parameters.AddWithValue("@EndDateTime", model.EndDateTime);
             return(dbHelper.ExecuteNonQuery(cmd));
         }
     }
 }
 public static int InserttblUserStatisticsGrouping(UserGroupingModel model)
 {
     using (var dbHelper = DbHelper.CreateLogDbHelper())
     {
         using (var cmd = new SqlCommand(@"Insert into Tuhu_Log..tbl_UserStatisticsGrouping(DeviceId,UserId,Tag,StartDateTime,EndDateTime) values(@DeviceId,@UserId,@Tag,@StartDateTime,@EndDateTime)"))
         {
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.AddWithValue("@DeviceId", model.DeviceId);
             cmd.Parameters.AddWithValue("@UserId", model.UserId);
             cmd.Parameters.AddWithValue("@Tag", model.Tag);
             cmd.Parameters.AddWithValue("@StartDateTime", model.StartDateTime);
             cmd.Parameters.AddWithValue("@EndDateTime", model.EndDateTime);
             return(dbHelper.ExecuteNonQuery(cmd));
         }
     }
 }