/// <summary> /// 服务时间递增 /// </summary> /// <param name="ServiceID">业务编号</param> /// <param name="Seconds">需要递增的服务时长,小于等于0意味着不限制服务时长(秒)</param> /// <returns></returns> public bool IncrementChannelDuration(string ConversationRoomID, string ServiceID, int Seconds, string OrderNo, string NewUpgradeOrderNo) { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["KMEHospEntities"].ConnectionString)) { SqlCommand cmd = new SqlCommand(@"if(select top 1 1 from ConversationRoomUpgrades where ServiceID=@ServiceID and OrderNo=@OrderNo and NewUpgradeOrderNo=@NewUpgradeOrderNo) begin update ConversationRooms set Duration=case when Duration<0 then 1 else Duration end + @Seconds where ServiceID = @ServiceID insert into ConversationRoomUpgrades(ServiceID,Duration,CreateTime,IsDeleted,OrderNo,NewUpgradeOrderNo) values(@ServiceID,@Seconds,@CreateTime,0,@OrderNo,@NewUpgradeOrderNo) end"); cmd.Parameters.Add("@ServiceID", SqlDbType.VarChar).Value = ServiceID; cmd.Parameters.Add("@OrderNo", SqlDbType.VarChar).Value = OrderNo; cmd.Parameters.Add("@NewUpgradeOrderNo", SqlDbType.VarChar).Value = NewUpgradeOrderNo; cmd.Parameters.Add("@Seconds", SqlDbType.Int).Value = Seconds; cmd.Parameters.Add("@CreateTime", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@ModifyTime", SqlDbType.DateTime).Value = DateTime.Now; var ret = cmd.ExecuteNonQuery() > 0; if (ret) { var cacheKey = new StringCacheKey(StringCacheKeyType.Channel, ConversationRoomID); cacheKey.RemoveCache(); } return(ret); } }
/// <summary> /// 替换频道成员 /// </summary> /// <param name="ConversationRoomID"></param> /// <param name="members"></param> /// <returns></returns> public bool ReplaceChannelMembers(string ConversationRoomID, List <RequestChannelMemberDTO> members) { using (DBEntities db = new DBEntities()) { var oldmembers = db.ConversationRoomUids.Where(a => a.ConversationRoomID == ConversationRoomID).ToList(); foreach (var member in members) { var roomUid = new ConversationRoomUid() { ConversationRoomID = ConversationRoomID, UserType = member.UserType, Identifier = member.Identifier, UserMemberID = member.UserMemberID.IfNull(""), UserCNName = member.UserCNName.IfNull(""), UserENName = member.UserENName.IfNull(""), PhotoUrl = member.PhotoUrl.IfNull(""), UserID = member.UserID }; db.ConversationRoomUids.Add(roomUid); } if (db.SaveChanges() > 0) { var cacheKey = new StringCacheKey(StringCacheKeyType.Channel_Member, ConversationRoomID); cacheKey.RemoveCache(); return(true); } else { return(false); } } }
public bool UpdateChannelChargeSeq(string conversationRoomID, int chargingSeq, DateTime chargingTime, int chargingInterval , EnumRoomState?roomState, DateTime?endTime) { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["KMEHospEntities"].ConnectionString)) { var sql = ""; if (roomState.HasValue) { sql = @"update ConversationRooms set ChargingTime=@ChargingTime,ChargingSeq=@ChargingSeq, ChargingInterval=@ChargingInterval,RoomState=@RoomState,EndTime=@EndTime,ModifyTime=@ModifyTime where ConversationRooms.ConversationRoomID=@ConversationRoomID"; } else { sql = @"update ConversationRooms set ChargingTime=@ChargingTime,ChargingSeq=@ChargingSeq, ChargingInterval=@ChargingInterval,ModifyTime=@ModifyTime where ConversationRooms.ConversationRoomID=@ConversationRoomID"; } SqlCommand cmd = new SqlCommand(@"update ConversationRooms set ChargingTime=@ChargingTime,ChargingSeq=@ChargingSeq, ChargingInterval=@ChargingInterval,RoomState=@RoomState,ModifyTime=@ModifyTime where ConversationRooms.ConversationRoomID=@ConversationRoomID"); if (roomState.HasValue) { cmd.Parameters.Add("@RoomState", SqlDbType.Int).Value = (int)roomState.Value; cmd.Parameters.Add("@EndTime", SqlDbType.DateTime).Value = endTime.Value; } cmd.Parameters.Add("@ChargingTime", SqlDbType.DateTime).Value = chargingTime; cmd.Parameters.Add("@ChargingSeq", SqlDbType.Int).Value = chargingSeq; cmd.Parameters.Add("@ChargingInterval", SqlDbType.Int).Value = chargingInterval; cmd.Parameters.Add("@ModifyTime", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@ConversationRoomID", SqlDbType.Int).Value = conversationRoomID; var ret = cmd.ExecuteNonQuery() > 0; if (ret) { var cacheKey = new StringCacheKey(StringCacheKeyType.Channel, conversationRoomID); cacheKey.RemoveCache(); } return(ret); } }
/// <summary> /// 修改分诊编号 /// </summary> /// <param name="ConversationRoomID"></param> /// <param name="triageID"></param> /// <returns></returns> public bool UpdateTriageID(string ConversationRoomID, long triageID) { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["KMEHospEntities"].ConnectionString)) { SqlCommand cmd = new SqlCommand(@"update ConversationRooms set TriageID=@TriageID,ModifyTime=@ModifyTime where ConversationRooms.ConversationRoomID=@ConversationRoomID"); cmd.Parameters.Add("@ModifyTime", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@TriageID", SqlDbType.BigInt).Value = triageID; cmd.Parameters.Add("@ConversationRoomID", SqlDbType.Int).Value = ConversationRoomID; var ret = cmd.ExecuteNonQuery() > 0; if (ret) { var cacheKey = new StringCacheKey(StringCacheKeyType.Channel, ConversationRoomID); cacheKey.RemoveCache(); } return(ret); } }
/// <summary> /// 设置频道计费状态 /// </summary> /// <param name="room"></param> /// <returns></returns> public bool UpdateChannelChargeState(string ConversationRoomID, EnumRoomChargingState chargingState) { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["KMEHospEntities"].ConnectionString)) { SqlCommand cmd = new SqlCommand(@"update ConversationRooms set ChargingState=@ChargingState,ModifyTime=@ModifyTime where ConversationRooms.ConversationRoomID=@ConversationRoomID"); cmd.Parameters.Add("@ModifyTime", SqlDbType.DateTime).Value = DateTime.Now; cmd.Parameters.Add("@ChargingState", SqlDbType.Int).Value = (int)chargingState; cmd.Parameters.Add("@ConversationRoomID", SqlDbType.Int).Value = ConversationRoomID; var ret = cmd.ExecuteNonQuery() > 0; if (ret) { var cacheKey = new StringCacheKey(StringCacheKeyType.Channel, ConversationRoomID.ToString()); cacheKey.RemoveCache(); } return(ret); } }