/// <summary> /// 添加命令 /// </summary> /// <param name="model"></param> /// <returns></returns> public static AdvertManage.Model.Enum.HandleResult AddAMS_CommandList(AdvertManage.Model.AMS_CommandListModel model) { IWCFService.IAdvertManageService advertService = WcfAccessProxy.AMS_ServiceProxy.CreateChannelAdvertManageService(); bool error = false; try { return(advertService.AddAMS_CommandList(model)); } catch (Exception ex) { error = true; SeatManage.SeatManageComm.WriteLog.Write(string.Format("添加下发命令失败 ,异常来自:{0};信息:{1}", ex.Source, ex.Message)); throw ex; } finally { ICommunicationObject ICommObjectService = advertService as ICommunicationObject; try { if (ICommObjectService.State == CommunicationState.Faulted) { ICommObjectService.Abort(); } else { ICommObjectService.Close(); } } catch { ICommObjectService.Abort(); } } }
/// <summary> /// 下发操作 /// </summary> public bool Issue(int commandId, AdvertManage.Model.Enum.CommandType command) { try { foreach (SchoolNodes school in SchoolInfo) { if (school.IsChecked) { AdvertManage.Model.AMS_CommandListModel model = new AdvertManage.Model.AMS_CommandListModel(); model.Command = command; model.CommandId = commandId; model.FinishFlag = AdvertManage.Model.Enum.CommandHandleResult.Wait; model.ReleaseTime = DateTime.Now; model.SchoolId = school.SchoolId; AdvertManage.BLL.AMS_CommandBLL.AddAMS_CommandList(model); } } return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }
/// <summary> /// 根据学校编号获取有效的命令列表 /// </summary> /// <returns></returns> public List <AdvertManage.Model.AMS_CommandListModel> GetCommandListBySchoolNum(string schoolNum) { StringBuilder strWhere = new StringBuilder(); List <AdvertManage.Model.AMS_CommandListModel> list = new List <Model.AMS_CommandListModel>(); //添加条件 if (!string.IsNullOrEmpty(schoolNum)) { strWhere.AppendFormat("SchoolNum=@SchoolNum and (FinishFlag={0} or FinishFlag={1} or FinishFlag={2}) ", (int)Model.Enum.CommandHandleResult.Wait, (int)Model.Enum.CommandHandleResult.Getting, (int)Model.Enum.CommandHandleResult.Failed); SqlParameter[] parameters = { new SqlParameter("@SchoolNum", SqlDbType.NVarChar) }; parameters[0].Value = schoolNum; try { DataSet ds = commandDal.GetList(strWhere.ToString(), parameters); //遍历查询结果,转换为Model,添加到List里面 for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AdvertManage.Model.AMS_CommandListModel model = DataRowToAMS_CammandListModel(ds.Tables[0].Rows[i]); list.Add(model); } } catch (Exception ex) { throw ex; } } return(list); }
private AdvertManage.Model.AMS_CommandListModel DataRowToAMS_CammandListModel(DataRow dr) { AdvertManage.Model.AMS_CommandListModel model = new AdvertManage.Model.AMS_CommandListModel(); if (dr["ID"] != null && dr["ID"].ToString() != "") { model.ID = int.Parse(dr["ID"].ToString()); } if (dr["SchoolId"] != null && dr["SchoolId"].ToString() != "") { model.SchoolId = int.Parse(dr["SchoolId"].ToString()); } if (dr["Command"] != null && dr["Command"].ToString() != "") { model.Command = (Model.Enum.CommandType) int.Parse(dr["Command"].ToString()); } if (dr["CommandId"] != null && dr["CommandId"].ToString() != "") { model.CommandId = int.Parse(dr["CommandId"].ToString()); } if (dr["ReleaseTime"] != null && dr["ReleaseTime"].ToString() != "") { model.ReleaseTime = DateTime.Parse(dr["ReleaseTime"].ToString()); } if (dr["FinishTime"] != null && dr["FinishTime"].ToString() != "") { model.FinishTime = DateTime.Parse(dr["FinishTime"].ToString()); } if (dr["FinishFlag"] != null && dr["FinishFlag"].ToString() != "") { model.FinishFlag = (Model.Enum.CommandHandleResult) int.Parse(dr["FinishFlag"].ToString()); } if (dr["SchoolNum"] != null && dr["SchoolNum"].ToString() != "") { model.SchoolNum = dr["SchoolNum"].ToString(); } if (dr["SchoolName"] != null && dr["SchoolName"].ToString() != "") { model.SchoolName = dr["SchoolName"].ToString(); } if (dr["SchoolConnectionString"] != null && dr["SchoolConnectionString"].ToString() != "") { model.SchoolConnectionString = dr["SchoolConnectionString"].ToString(); } if (dr["SchoolDescribe"] != null && dr["SchoolDescribe"].ToString() != "") { model.SchoolDescribe = dr["SchoolDescribe"].ToString(); } if (dr["SchoolDTUip"] != null && dr["SchoolDTUip"].ToString() != "") { model.SchoolDTUip = dr["SchoolDTUip"].ToString(); } return(model); }
/// <summary> /// 下发的时候添加一条命令 /// </summary> /// <param name="model"></param> /// <returns></returns> public AdvertManage.Model.Enum.HandleResult AddAMS_CommandList(AdvertManage.Model.AMS_CommandListModel model) { try { if (commandDal.Add(model) > 0) { return(Model.Enum.HandleResult.Successed); } else { return(Model.Enum.HandleResult.Failed); } } catch (Exception ex) { throw ex; } }
/// <summary> /// 数据中转服务一条命令处理完成后,更新这条命令的状态 /// </summary> /// <param name="id"></param> /// <returns></returns> public AdvertManage.Model.Enum.HandleResult UpdateFinishFlag(AdvertManage.Model.AMS_CommandListModel model) { StringBuilder strWhere = new StringBuilder(); if (model != null) { model.FinishTime = GetServerDateTime(); if (commandDal.Update(model)) { return(Model.Enum.HandleResult.Successed); } else { return(Model.Enum.HandleResult.Failed); } } return(Model.Enum.HandleResult.Failed); }
/// <summary> /// 下发优惠券 /// </summary> public bool SCRelease() { try { foreach (SlipNodes schoolnode in _SchoolList) { foreach (SlipNodes campusnode in schoolnode.ChildNode) { if (campusnode.IsChecked) { foreach (int slipid in ReleaseSlipid) { int new_id = AdvertManage.BLL.SlipReleaseCampusBLL.AddSlipRelease(slipid, campusnode.Id); if (new_id > 0) { AdvertManage.Model.AMS_CommandListModel commandmodel = new AdvertManage.Model.AMS_CommandListModel(); commandmodel.Command = AdvertManage.Model.Enum.CommandType.SlipCustomer; commandmodel.CommandId = new_id; commandmodel.FinishFlag = AdvertManage.Model.Enum.CommandHandleResult.Wait; commandmodel.ReleaseTime = DateTime.Now; commandmodel.SchoolId = schoolnode.Id; if (AdvertManage.BLL.AMS_CommandBLL.AddAMS_CommandList(commandmodel) == AdvertManage.Model.Enum.HandleResult.Failed) { throw new Exception("获取优惠券命令发布失败!"); } } else { throw new Exception("优惠券下发失败!"); } } } } } return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); return(false); } }