public async Task <IViewComponentResult> InvokeAsync() { AttentionModel model = new AttentionModel(); DynamicParameters param = new DynamicParameters(); param.Add("EmpUid", _applicationContext.EmpUid); string sqlToDo = $"select count(0) C from WfTask,WfActivityInstance,WfProcessInstance where WfTask.ActivityInsUid=WfActivityInstance.Fid and WfTask.ProcessInsUid= WfProcessInstance.Fid and WfProcessInstance.ProcessState='Running' and WfActivityInstance.ActivityState in('{WfActivityInstanceState.Running}','{WfActivityInstanceState.Ready}') and WfTask.TaskState='{WfTaskState.Handling}' and WfTask.ExecutorEmpUid='{_applicationContext.EmpUid}'"; int todoCount = _dbContext.ExecuteScalar <int>(sqlToDo); var agents = _dbContext.QueryAll <WfAgentSetting>().Where(a => a.Agent == _applicationContext.EmpUid && a.State == 1); //获取待办 var listCount = _dbContext.Query($"select count(0) C,WfTask.BusinessUid from WfTask,WfActivityInstance,WfProcessInstance where WfTask.ActivityInsUid=WfActivityInstance.Fid and WfTask.ProcessInsUid= WfProcessInstance.Fid and WfProcessInstance.ProcessState='Running' and WfActivityInstance.ActivityState in('{WfActivityInstanceState.Running}','{WfActivityInstanceState.Ready}') and WfTask.TaskState='{WfTaskState.Handling}' and WfTask.ExecutorEmpUid in @Agents group by WfTask.BusinessUid", new DynamicParameters(new { Agents = agents.Select(a => a.Principal) })); int agentCount = 0; foreach (var item in listCount) { //检查是否代理了此业务 var existAgents = agents.Where(a => a.BusinessUid.IsMissing() || a.BusinessUid == item.BusinessUid); if (existAgents.Any()) { var cc = listCount.FirstOrDefault(b => b.BusinessUid == item.BusinessUid); agentCount += (cc != null ? (cc.C == null ? 0 : cc.C) : 0); } } model.TodoCount = todoCount; model.AgentCount = agentCount; //消息 IEnumerable <FapMessage> list = _dbContext.QueryWhere <FapMessage>("REmpUid=@EmpUid and HasRead=0 ", param, true).OrderBy(c => c.SendTime); model.Messages = list; //通知 model.Notifications = Nofifications(param) ?? Enumerable.Empty <Notifications>(); return(await Task.FromResult <IViewComponentResult>(View(model)).ConfigureAwait(false)); }
/// <summary> /// 得到一个对象实体 /// </summary> public AttentionModel GetModel(decimal AutoId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select AutoId, UserId, AttentionUserId, AttentionMerId, AttentionType, DynamicLv, FlagInvalid "); strSql.Append(" from Attention "); strSql.Append(" where AutoId=@AutoId"); SqlParameter[] parameters = { new SqlParameter("@AutoId", SqlDbType.Decimal) }; parameters[0].Value = AutoId; AttentionModel model = new AttentionModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["AutoId"].ToString() != "") { model.AutoId = decimal.Parse(ds.Tables[0].Rows[0]["AutoId"].ToString()); } model.UserId = ds.Tables[0].Rows[0]["UserId"].ToString(); model.AttentionUserId = ds.Tables[0].Rows[0]["AttentionUserId"].ToString(); if (ds.Tables[0].Rows[0]["AttentionMerId"].ToString() != "") { model.AttentionMerId = decimal.Parse(ds.Tables[0].Rows[0]["AttentionMerId"].ToString()); } if (ds.Tables[0].Rows[0]["AttentionType"].ToString() != "") { model.AttentionType = int.Parse(ds.Tables[0].Rows[0]["AttentionType"].ToString()); } if (ds.Tables[0].Rows[0]["DynamicLv"].ToString() != "") { model.DynamicLv = int.Parse(ds.Tables[0].Rows[0]["DynamicLv"].ToString()); } if (ds.Tables[0].Rows[0]["FlagInvalid"].ToString() != "") { if ((ds.Tables[0].Rows[0]["FlagInvalid"].ToString() == "1") || (ds.Tables[0].Rows[0]["FlagInvalid"].ToString().ToLower() == "true")) { model.FlagInvalid = true; } else { model.FlagInvalid = false; } } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(AttentionModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update Attention set "); strSql.Append(" UserId = @UserId , "); strSql.Append(" AttentionUserId = @AttentionUserId , "); strSql.Append(" AttentionMerId = @AttentionMerId , "); strSql.Append(" AttentionType = @AttentionType , "); strSql.Append(" DynamicLv = @DynamicLv , "); strSql.Append(" FlagInvalid = @FlagInvalid "); strSql.Append(" where AutoId=@AutoId "); SqlParameter[] parameters = { new SqlParameter("@AutoId", SqlDbType.Decimal, 9), new SqlParameter("@UserId", SqlDbType.NVarChar, 50), new SqlParameter("@AttentionUserId", SqlDbType.NVarChar, 50), new SqlParameter("@AttentionMerId", SqlDbType.Decimal, 9), new SqlParameter("@AttentionType", SqlDbType.Int, 4), new SqlParameter("@DynamicLv", SqlDbType.Int, 4), new SqlParameter("@FlagInvalid", SqlDbType.Bit, 1) }; parameters[0].Value = model.AutoId; parameters[1].Value = model.UserId; parameters[2].Value = model.AttentionUserId; parameters[3].Value = model.AttentionMerId; parameters[4].Value = model.AttentionType; parameters[5].Value = model.DynamicLv; parameters[6].Value = model.FlagInvalid; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(AttentionModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Attention("); strSql.Append("UserId,AttentionUserId,AttentionMerId,AttentionType,DynamicLv,FlagInvalid"); strSql.Append(") values ("); strSql.Append("@UserId,@AttentionUserId,@AttentionMerId,@AttentionType,@DynamicLv,@FlagInvalid"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserId", SqlDbType.NVarChar, 50), new SqlParameter("@AttentionUserId", SqlDbType.NVarChar, 50), new SqlParameter("@AttentionMerId", SqlDbType.Decimal, 9), new SqlParameter("@AttentionType", SqlDbType.Int, 4), new SqlParameter("@DynamicLv", SqlDbType.Int, 4), new SqlParameter("@FlagInvalid", SqlDbType.Bit, 1) }; parameters[0].Value = model.UserId; parameters[1].Value = model.AttentionUserId; parameters[2].Value = model.AttentionMerId; parameters[3].Value = model.AttentionType; parameters[4].Value = model.DynamicLv; parameters[5].Value = model.FlagInvalid; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }
/// <summary> /// 添加商家关注 /// </summary> public void AddAttentionMer(decimal MerId) { DAL.AttentionDAL dal = new DAL.AttentionDAL(); DataTable dt = dal.GetList(" UserId='" + Common.CookieSings.GetCurrentUserId() + "' and AttentionMerId= '" + MerId + "'").Tables[0]; if (!IsAttentionMer(MerId)) { Model.AttentionModel model = new AttentionModel(); model.AttentionMerId = MerId; model.AttentionType = 2; model.AttentionUserId = ""; model.DynamicLv = 1; model.FlagInvalid = false; model.UserId = Common.CookieSings.GetCurrentUserId(); dal.Add(model); } else { throw new Exception("您已经关注了这个商家!"); } }
/// <summary> /// 添加用户关注 /// </summary> public void AddAttentionUser(string AttentionUserId) { DAL.AttentionDAL dal = new DAL.AttentionDAL(); DataTable dt = dal.GetList(" ").Tables[0]; if (!IsAttentionUser(AttentionUserId)) { Model.AttentionModel model = new AttentionModel(); model.AttentionMerId = 0; model.AttentionType = 1; model.AttentionUserId = AttentionUserId; model.DynamicLv = 1; model.FlagInvalid = false; model.UserId = Common.CookieSings.GetCurrentUserId(); dal.Add(model); } else { throw new Exception("您已经关注了这个用户!"); } }
private async void GetAttention() { try { _Loading = true; if (_PageNum == 1) { User_ListView_Attention.Items.Clear(); } User_load_more.IsEnabled = false; User_load_more.Content = "加载中..."; _Loading = true; pr_Load_DT.Visibility = Visibility.Visible; string url = string.Format("http://api.bilibili.com/x/feed/pull?access_key={0}&actionKey=appkey&appkey={1}&platform=wp&pn={2}&ps=30&ts={3}&type=0", ApiHelper.access_key, ApiHelper._appKey, _PageNum, ApiHelper.GetTimeSpan); url += "&sign=" + ApiHelper.GetSign(url); string results = await WebClientClass.GetResults(new Uri(url)); //一层 AttentionModel model1 = JsonConvert.DeserializeObject <AttentionModel>(results); if (model1.code == 0) { AttentionModel model2 = JsonConvert.DeserializeObject <AttentionModel>(model1.data.ToString()); if (model2.feeds.Count == 0) { messShow.Show("加载完了", 3000); } else { try { if (_PageNum == 1) { //var updater = TileUpdateManager.CreateTileUpdaterForApplication(); //updater.EnableNotificationQueueForWide310x150(true); //updater.EnableNotificationQueueForSquare150x150(true); //updater.EnableNotificationQueueForSquare310x310(true); //updater.EnableNotificationQueue(true); List <string> oldList = new List <string>(); //updater.Clear(); string s1 = ""; foreach (var item in model2.feeds) { //if (SettingHelper.Get_DTCT()) //{ // if (model2.feeds.IndexOf(item) <= 4) // { // var doc = new XmlDocument(); // var xml = string.Format(TileTemplateXml, item.addition.pic, item.addition.title, item.addition.title); // doc.LoadXml(WebUtility.HtmlDecode(xml), new XmlLoadSettings // { // ProhibitDtd = false, // ValidateOnParse = false, // ElementContentWhiteSpace = false, // ResolveExternals = false // }); // updater.Update(new TileNotification(doc)); // } //} s1 += item.addition.aid + ","; } s1 = s1.Remove(s1.Length - 1); SettingHelper.Set_TsDt(s1); //container.Values["TsDt"] = s1; } } catch (Exception) { } model2.feeds.ForEach(x => User_ListView_Attention.Items.Add(x)); _PageNum++; } } else { messShow.Show(model1.message, 3000); } } catch (Exception ex) { if (ex.HResult == -2147012867 || ex.HResult == -2147012889) { messShow.Show("无法连接服务器,请检查你的网络连接", 3000); } else { messShow.Show("动态加载错误", 3000); } } finally { _Loading = false; User_load_more.IsEnabled = true; User_load_more.Content = "加载更多"; pr_Load_DT.Visibility = Visibility.Collapsed; if (User_ListView_Attention.Items.Count == 0) { DT_1.Visibility = Visibility.Visible; User_load_more.Visibility = Visibility.Collapsed; } else { DT_1.Visibility = Visibility.Collapsed; User_load_more.Visibility = Visibility.Visible; } } }