private static SourceInfo ReaderToEntity(YZReader reader) { reader.Read(); SourceInfo source = new SourceInfo(); source.sourceId = reader.ReadInt32("sourceId"); source.sourceName = reader.ReadString("sourceName"); source.sourceType = reader.ReadEnum <SourceTypeEnum>("connectType", SourceTypeEnum.NoType); source.sourceStr = reader.ReadString("sourceStr"); source.caption = reader.ReadString("caption"); source.createTime = reader.ReadDateTime("createTime"); source.updateTime = reader.ReadDateTime("updateTime"); source.isvalid = reader.ReadBool("isvalid", false); ConnectInfo connect = new ConnectInfo(); connect.connectId = reader.ReadInt32("connectId"); connect.connectName = reader.ReadString("connectName"); connect.connectType = reader.ReadEnum <SourceTypeEnum>("connectType", SourceTypeEnum.NoType); connect.caption = reader.ReadString("caption"); connect.connectStr = reader.ReadString("connectStr"); connect.createTime = reader.ReadDateTime("createTime"); connect.updateTime = reader.ReadDateTime("updateTime"); connect.isvalid = reader.ReadBool("isvalid", false); source.connectInfo = connect; return(source); }
public SpriteLink(YZReader reader) { this.FileID = reader.ReadString("FileID"); this.SpriteID = reader.ReadString("SpriteID"); this.LinkType = reader.ReadEnum <ReferenceType>("LinkType", ReferenceType.SpriteToSprite); this.LinkedFileID = reader.ReadString("LinkedFileID"); this.LinkedSpriteID = reader.ReadString("LinkedSpriteID"); this.LinkedByProperty = reader.ReadString("LinkedByProperty"); }
public Favorite(YZReader reader) { this.uid = reader.ReadString("uid"); this.resType = (YZResourceType)reader.ReadEnum("resType", typeof(YZResourceType), YZResourceType.Process); this.resId = reader.ReadString("resId"); this.date = reader.ReadDateTime("date"); this.comments = reader.ReadString("comments"); this.orderIndex = reader.ReadInt32("orderIndex"); }
public YZMessage(YZReader reader) { this.id = reader.ReadInt32("id"); this.uid = reader.ReadString("uid"); this.date = reader.ReadDateTime("date"); this.resType = (YZResourceType)reader.ReadEnum("resType", typeof(YZResourceType), YZResourceType.Task); this.resId = reader.ReadString("resId"); this.message = reader.ReadString("message"); }
public YZMessage(IDataReader reader) { YZReader dbr = new YZReader(reader); this.id = dbr.ReadInt32("id"); this.replyto = dbr.ReadInt32("replyto"); this.uid = dbr.ReadString("uid"); this.date = dbr.ReadDateTime("date"); this.resType = (YZResourceType)dbr.ReadEnum("resType", typeof(YZResourceType), YZResourceType.Task); this.resId = dbr.ReadString("resId"); this.message = dbr.ReadString("message"); this.duration = dbr.ReadInt32("duration"); }
private static ConnectInfoCollection ReaderToEntityList(YZReader reader) { ConnectInfoCollection rv = new ConnectInfoCollection(); while (reader.Read()) { ConnectInfo connect = new ConnectInfo(); connect.connectId = reader.ReadInt32("connectId"); connect.connectName = reader.ReadString("connectName"); connect.connectType = reader.ReadEnum <SourceTypeEnum>("connectType", SourceTypeEnum.NoType); connect.caption = reader.ReadString("caption"); connect.connectStr = reader.ReadString("connectStr"); connect.createTime = reader.ReadDateTime("createTime"); connect.updateTime = reader.ReadDateTime("updateTime"); connect.isvalid = reader.ReadBool("isvalid", false); rv.Add(connect); } return(rv); }
public void ProcessRequest(HttpContext context) { try { YZAuthHelper.OAuth(); //YZAuthHelper.AshxAuthCheck(); string loginUid = YZAuthHelper.LoginUserAccount; IDBProvider dbProvider = YZDBProviderManager.CurrentProvider; string method = context.Request.Params["method"]; JsonItem rv = new JsonItem(); // System.Threading.Thread.Sleep(2000); if (method == "Send") { //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&restype=1&message=添加一条哦啊讨论啊&resId=216928&method=Send YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; string msg = context.Request.Params["message"]; if (!string.IsNullOrEmpty(msg.Trim())) { using (IDbConnection cn = dbProvider.OpenConnection()) { YZMessage message = new YZMessage(loginUid, DateTime.Now, resType, resId, msg); message.Insert(cn); YZCommunicationManager.UpdateReaded(cn, loginUid, resType, resId, message.id); JsonItem result = new JsonItem(); rv.Attributes.Add("message", result); message.Serialize(result); } } } else if (method == "GetTaskCommunicationList") { GridPageInfo gridPageInfo = new GridPageInfo(context); SecurityToken token = null; using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); token = bpmcn.Token; } using (IDbConnection cn = dbProvider.OpenConnection()) { //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&method=GetTaskCommunicationList&SearchType=QuickSearch&Keyword=216928 //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&method=GetTaskCommunicationList&SearchType=QuickSearch&Keyword=REQ2014090001 using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); IDbCommand cmd = dbProvider.GetTaskCommunicationListCommand(cn, loginUid, token.SIDs, dbProvider.FilterStringCommunicationListTaskTableFilter, dbProvider.FilterStringCommunicationMessageTableFilter, gridPageInfo.Start, gridPageInfo.Limit); cmd.Connection = cn; JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); using (YZReader reader = new YZReader(cmd.ExecuteReader())) { while (reader.Read()) { JsonItem item = new JsonItem(); children.Add(item); string ownerAccount = reader.ReadString("OwnerAccount"); User owner = User.TryGetUser(bpmcn, ownerAccount); string ownerDisplayName = owner != null ? owner.DisplayName : ownerAccount; string lastMsgUid = reader.ReadString("uid"); User lastMsgUser = User.TryGetUser(bpmcn, lastMsgUid); string lastMessageUserShortName = lastMsgUser != null ? lastMsgUser.ShortName : lastMsgUid; TaskState state = (TaskState)reader.ReadEnum("State", typeof(TaskState), TaskState.Unknow); int taskid = reader.ReadInt32("TaskID"); item.Attributes["tid"] = taskid; item.Attributes["sn"] = reader.ReadString("SerialNum"); item.Attributes["pn"] = reader.ReadString("ProcessName"); item.Attributes["user"] = YZStringHelper.GetUserShortName(ownerAccount, ownerDisplayName); item.Attributes["state"] = state.ToString(); item.Attributes["stateText"] = YZStringHelper.GetTaskStateDisplayString(bpmcn, state, taskid); item.Attributes["date"] = YZStringHelper.DateToStringL(reader.ReadDateTime("CreateAt")); string desc = Convert.ToString(reader.ReadString("Description")); item.Attributes["desc"] = String.IsNullOrEmpty(desc) ? "无内容摘要" : desc.CutStrHTML(isHTML: true); item.Attributes["count"] = reader.ReadInt32("count"); item.Attributes["total"] = reader.ReadInt32("total"); item.Attributes["Id"] = reader.ReadInt32("Id"); item.Attributes["lastMessageId"] = reader.ReadInt32("lastMsgId"); item.Attributes["lastMessageUid"] = lastMsgUid; item.Attributes["lastMessageUserShortName"] = lastMessageUserShortName; item.Attributes["lastMessageDate"] = YZStringHelper.DateToStringL(reader.ReadDateTime("date")); item.Attributes["lastMessage"] = reader.ReadString("message"); } } } rv.Attributes["newMessageCount"] = dbProvider.GetTaskCommunicationNewMessageCount(cn, loginUid, token.SIDs); } } else if (method == "GetBadge") { YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; using (IDbConnection cn = dbProvider.OpenConnection()) { rv.Attributes["total"] = YZCommunicationManager.GetMessageCount(cn, resType, resId); rv.Attributes["newMessageCount"] = YZCommunicationManager.GetNewMessageCount(cn, loginUid, resType, resId); } } else if (method == "UpdateReaded") { YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; string strLastId = context.Request.Params["lastid"]; if (String.IsNullOrEmpty(strLastId)) { strLastId = "-1"; } int lastId = Convert.ToInt32(strLastId); using (IDbConnection cn = dbProvider.OpenConnection()) { YZCommunicationManager.UpdateReaded(cn, loginUid, resType, resId, lastId); } } else { //http://bpm.sdt.com/YZSoft/Forms/XForm/%E5%B7%A5%E4%BD%9C%E6%8A%A5%E5%91%8A/%E5%B7%A5%E4%BD%9C%E6%8A%A5%E5%91%8A.aspx?tid=216928 //http://oauth.skyworthdigital.com/WebService/Iservice/Communication.ashx?UserAccount=SDT12872&restype=1&lastid=306&resId=216928 YZResourceType resType = (YZResourceType)Enum.Parse(typeof(YZResourceType), context.Request.Params["resType"], true); string resId = context.Request.Params["resId"]; string strLastId = context.Request.Params["lastid"]; if (String.IsNullOrEmpty(strLastId)) { strLastId = "-1"; } int lastId = Convert.ToInt32(strLastId); //获得数据 JsonItemCollection children = new JsonItemCollection(); rv.Attributes.Add("children", children); using (BPMConnection bpmcn = new BPMConnection()) { bpmcn.WebOpen(); using (IDbConnection cn = dbProvider.OpenConnection()) { YZMessageCollection messages = YZCommunicationManager.GetNewMessages(cn, resType, resId, lastId); messages.Serialize(bpmcn, children); } } } //输出数据 context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); // 响应类型 context.Response.AppendHeader("Access-Control-Allow-Methods", "POST"); // 响应头设置 context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type"); context.Response.Charset = "gb2312"; //设置字符集类型 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); context.Response.ContentType = "application/json;charset=gb2312"; //输出数据 rv.Attributes.Add("success", true); context.Response.Write(rv.ToString()); } catch (Exception e) { JsonItem rv = new JsonItem(); context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); // 响应类型 context.Response.AppendHeader("Access-Control-Allow-Methods", "POST"); // 响应头设置 context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with,content-type"); context.Response.Charset = "gb2312"; //设置字符集类型 context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); context.Response.ContentType = "application/json;charset=gb2312"; rv.Attributes.Add("success", false); rv.Attributes.Add("errorMessage", e.Message); context.Response.Write(rv.ToString()); } }
public static object ReadEnum(IDataReader reader, int index, Type enumType, object defaultValue) { YZReader dbr = new YZReader(reader); return(dbr.ReadEnum(index, enumType, defaultValue)); }