Exemplo n.º 1
0
        public JArray GetFactorys(IDbConnection cn)
        {
            JArray factorys = new JArray();

            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.Connection  = cn as SqlConnection;
                cmd.CommandText = "SELECT * FROM iSYSFactory";

                using (YZReader reader = new YZReader(cmd.ExecuteReader()))
                {
                    while (reader.Read())
                    {
                        JObject factory = new JObject();
                        factorys.Add(factory);

                        factory["ID"]   = reader.ReadInt32("ID");
                        factory["Name"] = reader.ReadString("Name");
                        factory["MapX"] = reader.ReadInt32("MapX");
                        factory["MapY"] = reader.ReadInt32("MapY");
                    }
                }
            }
            return(factorys);
        }
Exemplo n.º 2
0
    public JsonItemCollection GetFactorys(IDbConnection cn)
    {
        JsonItemCollection factorys = new JsonItemCollection();

        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.Connection  = cn as SqlConnection;
            cmd.CommandText = "SELECT * FROM iSYSFactory";

            using (YZReader reader = new YZReader(cmd.ExecuteReader()))
            {
                while (reader.Read())
                {
                    JsonItem factory = new JsonItem();
                    factorys.Add(factory);

                    factory.Attributes["ID"]   = reader.ReadInt32("ID");
                    factory.Attributes["Name"] = reader.ReadString("Name");
                    factory.Attributes["MapX"] = reader.ReadInt32("MapX");
                    factory.Attributes["MapY"] = reader.ReadInt32("MapY");
                }
            }
        }
        return(factorys);
    }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 public Speak(YZReader reader)
 {
     this.ItemID   = reader.ReadInt32("ItemID");
     this.Account  = reader.ReadString("Account");
     this.FileID   = reader.ReadString("FileID");
     this.Duration = reader.ReadInt32("Duration");
     this.Comments = reader.ReadString("Comments");
     this.CreateAt = reader.ReadDateTime("CreateAt");
 }
Exemplo n.º 5
0
        public YZMessageVote(IDataReader reader)
        {
            YZReader dbr = new YZReader(reader);

            this.id        = dbr.ReadInt32("id");
            this.messageid = dbr.ReadInt32("messageid");
            this.uid       = dbr.ReadString("uid");
            this.date      = dbr.ReadDateTime("date");
        }
Exemplo n.º 6
0
 public P2PGroup(YZReader reader)
 {
     this.GroupID   = reader.ReadInt32("GroupID");
     this.Account1  = reader.ReadString("Account1");
     this.Account2  = reader.ReadString("Account2");
     this.UserName1 = reader.ReadString("UserName1");
     this.UserName2 = reader.ReadString("UserName2");
     this.FolderID  = reader.ReadInt32("FolderID");
     this.CreateBy  = reader.ReadString("CreateBy");
     this.CreateAt  = reader.ReadDateTime("CreateAt");
 }
Exemplo n.º 7
0
        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");
        }
Exemplo n.º 8
0
        public Member(IDataReader reader)
        {
            YZReader dbr = new YZReader(reader);

            this.ItemID  = dbr.ReadInt32("ItemID");
            this.GroupID = dbr.ReadInt32("GroupID");
            this.UID     = dbr.ReadString("UID");
            this.Role    = dbr.ReadString("Role");

            if (String.IsNullOrEmpty(this.Role))
            {
                this.Role = "Guest";
            }
        }
Exemplo n.º 9
0
Arquivo: File.cs Projeto: radtek/EMIP
 public File(YZReader reader)
 {
     this.ID         = reader.ReadInt32("ID");
     this.FolderID   = reader.ReadInt32("FolderID");
     this.FileID     = reader.ReadString("FileID");
     this.AddBy      = reader.ReadString("AddBy");
     this.AddAt      = reader.ReadDateTime("AddAt");
     this.Comments   = reader.ReadString("Comments");
     this.Deleted    = reader.ReadBool("Deleted", false);
     this.DeleteBy   = reader.ReadString("DeleteBy");
     this.DeleteAt   = reader.ReadDateTime("DeleteAt");
     this.Recyclebin = reader.ReadBool("Recyclebin", false);
     this.Flag       = reader.ReadString("Flag");
     this.OrderIndex = reader.ReadInt32("OrderIndex");
 }
Exemplo n.º 10
0
 public Group(YZReader reader)
 {
     this.GroupID          = reader.ReadInt32("GroupID");
     this.GroupType        = reader.ReadString("GroupType");
     this.Name             = reader.ReadString("Name");
     this.Desc             = reader.ReadString("Desc");
     this.DocumentFolderID = reader.ReadInt32("DocumentFolderID");
     this.FolderID         = reader.ReadInt32("FolderID");
     this.Owner            = reader.ReadString("Owner");
     this.CreateAt         = reader.ReadDateTime("CreateAt");
     this.ImageFileID      = reader.ReadString("ImageFileID");
     this.Deleted          = reader.ReadBool("Deleted", false);
     this.DeleteBy         = reader.ReadString("DeleteBy");
     this.DeleteAt         = reader.ReadDateTime("DeleteAt");
 }
Exemplo n.º 11
0
 public WeeklyReport(YZReader reader)
 {
     this.IsEmpty     = false;
     this.ItemID      = reader.ReadInt32("ItemID");
     this.TaskID      = reader.ReadInt32("TaskID");
     this.Account     = reader.ReadString("Account");
     this.Date        = reader.ReadDateTime("Date");
     this.Done        = reader.ReadString("Done");
     this.Undone      = reader.ReadString("Undone");
     this.Coordinate  = reader.ReadString("Coordinate");
     this.Done        = reader.ReadString("Done");
     this.Pics        = reader.ReadString("Pics");
     this.Attachments = reader.ReadString("Attachments");
     this.CreateAt    = reader.ReadDateTime("CreateAt");
 }
Exemplo n.º 12
0
 public Folder(YZReader reader)
 {
     this.FolderID   = reader.ReadInt32("FolderID");
     this.RootID     = reader.ReadInt32("RootID");
     this.ParentID   = reader.ReadInt32("ParentID");
     this.FolderType = reader.ReadString("FolderType");
     this.Name       = reader.ReadString("Name");
     this.Desc       = reader.ReadString("Desc");
     this.Owner      = reader.ReadString("Owner");
     this.CreateAt   = reader.ReadDateTime("CreateAt");
     this.Deleted    = reader.ReadBool("Deleted", false);
     this.DeleteBy   = reader.ReadString("DeleteBy");
     this.DeleteAt   = reader.ReadDateTime("DeleteAt");
     this.OrderIndex = reader.ReadInt32("OrderIndex");
 }
Exemplo n.º 13
0
 public Library(YZReader reader)
 {
     this.LibID            = reader.ReadInt32("LibID");
     this.LibType          = reader.ReadString("LibType");
     this.Name             = reader.ReadString("Name");
     this.Desc             = reader.ReadString("Desc");
     this.DocumentFolderID = reader.ReadInt32("DocumentFolderID");
     this.FolderID         = reader.ReadInt32("FolderID");
     this.Owner            = reader.ReadString("Owner");
     this.CreateAt         = reader.ReadDateTime("CreateAt");
     this.ImageFileID      = reader.ReadString("ImageFileID");
     this.Deleted          = reader.ReadBool("Deleted", false);
     this.DeleteBy         = reader.ReadString("DeleteBy");
     this.DeleteAt         = reader.ReadDateTime("DeleteAt");
     this.OrderIndex       = reader.ReadInt32("OrderIndex");
 }
Exemplo n.º 14
0
        public static GroupCollection GetGroupsAndMemberCount(IYZDbProvider provider, IDbConnection cn, string uid, string filter, string sort)
        {
            try
            {
                GroupCollection groups = new GroupCollection();
                using (YZReader reader = new YZReader(provider.GetGroupsAndMemberCount(cn, uid, filter, sort)))
                {
                    while (reader.Read())
                    {
                        Group group = new Group(reader);
                        group.MemberCount = reader.ReadInt32("MemberCount");

                        if (!String.IsNullOrEmpty(group.Name))
                        {
                            groups.Add(group);
                        }
                    }
                }
                return(groups);
            }
            catch (Exception e)
            {
                throw new BPMException(BPMExceptionType.DBLoadDataErr, "YZAppGroup", e.Message);
            }
        }
Exemplo n.º 15
0
        public virtual IDataReader GetTopicNewMessageCount(IDbConnection cn, YZResourceType resType, string resId, string uid)
        {
            using (OracleCommand cmd = new OracleCommand())
            {
                cmd.Connection = cn as OracleConnection;
                cmd.BindByName = true;

                cmd.CommandText = "select NVL(max(readId),0) from YZAppCommunicationRead WHERE resType=:resType and resId=:resId and \"UID\"=:pm_uid";
                cmd.Parameters.Add(":resType", OracleDbType.NVarchar2).Value = resType.ToString();
                cmd.Parameters.Add(":resId", OracleDbType.NVarchar2).Value   = resId;
                cmd.Parameters.Add(":pm_uid", OracleDbType.NVarchar2).Value  = uid;

                int readId = 0;
                using (YZReader rd = new YZReader(cmd.ExecuteReader()))
                {
                    if (rd.Read())
                    {
                        readId = rd.ReadInt32(0);
                    }
                }

                cmd.Parameters.Clear();
                cmd.CommandText = "select count(*) from YZAppCommunication WHERE resType=:resType and resId=:resId and id>:readId";

                cmd.Parameters.Add(":resType", OracleDbType.NVarchar2).Value = resType.ToString();
                cmd.Parameters.Add(":resId", OracleDbType.NVarchar2).Value   = resId;
                cmd.Parameters.Add(":readId", OracleDbType.Int32).Value      = readId;

                return(cmd.ExecuteReader());
            }
        }
Exemplo n.º 16
0
 public ServiceContacts(YZReader reader)
 {
     this.Product       = reader.ReadString("Product");
     this.ServiceCenter = reader.ReadString("ServiceCenter");
     this.Description   = reader.ReadString("Description");
     this.Tel           = reader.ReadString("Tel");
     this.OrderIndex    = reader.ReadInt32("OrderIndex");
 }
Exemplo n.º 17
0
 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");
 }
Exemplo n.º 18
0
 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");
 }
Exemplo n.º 19
0
 public Barcode(YZReader reader)
 {
     this.ItemID       = reader.ReadInt32("ItemID");
     this.Account      = reader.ReadString("Account");
     this.BarcodeValue = reader.ReadString("Barcode");
     this.Format       = reader.ReadString("Format");
     this.ProductName  = reader.ReadString("ProductName");
     this.Comments     = reader.ReadString("Comments");
     this.CreateAt     = reader.ReadDateTime("CreateAt");
 }
Exemplo n.º 20
0
 public Cash(YZReader reader)
 {
     this.ItemID   = reader.ReadInt32("ItemID");
     this.Account  = reader.ReadString("Account");
     this.Type     = reader.ReadString("Type");
     this.Date     = reader.ReadDateTime("Date");
     this.Amount   = reader.ReadDecimal("Amount");
     this.Invoice  = reader.ReadString("Invoice");
     this.Comments = reader.ReadString("Comments");
     this.CreateAt = reader.ReadDateTime("CreateAt");
 }
Exemplo n.º 21
0
        public virtual JArray GetDeletedObjects(HttpContext context)
        {
            YZRequest request = new YZRequest(context);
            BPMObjectNameCollection libTypes = BPMObjectNameCollection.FromStringList(request.GetString("libTypes"), ',');
            string uid = YZAuthHelper.LoginUserAccount;

            JArray rv = new JArray();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    using (YZReader reader = new YZReader(provider.GetDeletedObjects(cn, libTypes, uid)))
                    {
                        while (reader.Read())
                        {
                            JObject jItem = new JObject();
                            rv.Add(jItem);

                            jItem["LibID"]    = reader.ReadInt32("LibID");
                            jItem["LibType"]  = reader.ReadString("LibType");
                            jItem["LibName"]  = reader.ReadString("LibName");
                            jItem["LibDesc"]  = reader.ReadString("LibDesc");
                            jItem["DeleteBy"] = reader.ReadString("DeleteBy");
                            jItem["DeleteAt"] = reader.ReadDateTime("DeleteAt");
                            jItem["Path"]     = reader.ReadString("Path");
                            jItem["FolderID"] = reader.ReadInt32("FolderID");
                            jItem["Name"]     = reader.ReadString("Name");
                            jItem["ID"]       = reader.ReadInt32("ID");
                            jItem["FileID"]   = reader.ReadString("FileID");
                            jItem["Ext"]      = reader.ReadString("Ext");
                            jItem["Size"]     = reader.ReadInt32("Size");
                            jItem["ObjectID"] = (int)jItem["ID"] == -1 ? String.Format("Folder-{0}", jItem["FolderID"]) : String.Format("File-{0}", jItem["ID"]);
                        }
                    }
                }
            }

            return(rv);
        }
Exemplo n.º 22
0
 public static int GetVotePraisedCount(IYZDbProvider provider, IDbConnection cn, int messageid)
 {
     try
     {
         using (YZReader reader = new YZReader(provider.GetVotePraisedCount(cn, messageid)))
         {
             reader.Read();
             return(reader.ReadInt32(0));
         }
     }
     catch (Exception e)
     {
         throw new BPMException(BPMExceptionType.DBInsertDataErr, "YZAppCommunicationVote", e.Message);
     }
 }
Exemplo n.º 23
0
 public static bool HasVoted(IYZDbProvider provider, IDbConnection cn, int messageid, string uid)
 {
     try
     {
         using (YZReader reader = new YZReader(provider.HasVoted(cn, messageid, uid)))
         {
             reader.Read();
             return(reader.ReadInt32(0) == 0 ? false:true);
         }
     }
     catch (Exception e)
     {
         throw new BPMException(BPMExceptionType.DBLoadDataErr, "YZAppCommunicationVote", e.Message);
     }
 }
Exemplo n.º 24
0
 public static int GetNewMessageCount(IYZDbProvider provider, IDbConnection cn, YZResourceType resType, string resId, string uid)
 {
     try
     {
         using (YZReader reader = new YZReader(provider.GetTopicNewMessageCount(cn, resType, resId, uid)))
         {
             reader.Read();
             return(reader.ReadInt32(0));
         }
     }
     catch (Exception e)
     {
         throw new BPMException(BPMExceptionType.DBInsertDataErr, "YZAppCommunication", e.Message);
     }
 }
Exemplo n.º 25
0
 public static bool HasFavorited(IYZDbProvider provider, IDbConnection cn, string uid, YZResourceType resType, string resId)
 {
     try
     {
         using (YZReader reader = new YZReader(provider.HasFavorited(cn, uid, resType, resId)))
         {
             reader.Read();
             return(reader.ReadInt32(0) == 0 ? false : true);
         }
     }
     catch (Exception e)
     {
         throw new BPMException(BPMExceptionType.DBLoadDataErr, "YZSysFavorites", e.Message);
     }
 }
Exemplo n.º 26
0
 public Footmark(YZReader reader) : this()
 {
     this.ItemID           = reader.ReadInt32("ItemID");
     this.Account          = reader.ReadString("Account");
     this.Time             = reader.ReadDateTime("Time");
     this.Position.RawLat  = reader.ReadFloat("RawLat");
     this.Position.RawLon  = reader.ReadFloat("RawLon");
     this.Position.Lat     = reader.ReadFloat("Lat");
     this.Position.Lon     = reader.ReadFloat("Lon");
     this.Position.Id      = reader.ReadString("LocId");
     this.Position.Name    = reader.ReadString("LocName");
     this.Position.Address = reader.ReadString("LocAddress");
     this.Contact          = reader.ReadString("Contact");
     this.Comments         = reader.ReadString("Comments");
     this.Attachments      = reader.ReadString("Attachments");
 }
Exemplo n.º 27
0
        public static int GetNewMessageCount(IDbConnection cn, string uid, YZResourceType resType, string resId)
        {
            IYZDBProvider dbProvider = YZDBProviderManager.CurrentProvider;
            IDbCommand    cmd        = dbProvider.GetResourceCommunicationNewMessageCountCommand(uid, resType, resId);

            cmd.Connection = cn;

            using (YZReader reader = new YZReader(cmd.ExecuteReader()))
            {
                if (reader.Read())
                {
                    return(reader.ReadInt32(0));
                }
                else
                {
                    return(0);
                }
            }
        }
Exemplo n.º 28
0
        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);
        }
Exemplo n.º 29
0
        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());
            }
        }
Exemplo n.º 30
0
    public byte[] Excel2Image(MemoryStream stream, int timeout, out Size size, out string error)
    {
        error = null;
        size  = new Size(0, 0);
        string itemGuid = Guid.NewGuid().ToString();

        try
        {
            byte[] bytes = null;
            using (SqlConnection cn = new SqlConnection())
            {
                cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["BPMDB"].ConnectionString;
                cn.Open();

                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = cn;
                    cmd.CommandText = "INSERT INTO YZAppFileConvert(ItemGuid,FileBody,CreateDate,Processed) VALUES(@ItemGuid,@FileBody,@now,0)";
                    cmd.Parameters.Add("@ItemGuid", SqlDbType.NVarChar).Value = itemGuid;
                    cmd.Parameters.Add("@FileBody", SqlDbType.Binary).Value   = stream.ToArray();
                    cmd.Parameters.Add("@now", SqlDbType.DateTime).Value      = DateTime.Now;

                    cmd.ExecuteNonQuery();
                }

                bool readed   = false;
                int  tickFrom = Environment.TickCount;
                while (!readed)
                {
                    if (Environment.TickCount - tickFrom >= timeout)
                    {
                        throw new Exception(Resources.YZStrings.Aspx_Excel2Image_Timeout);
                    }

                    Thread.Sleep(50);

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cn;
                        cmd.CommandText = "SELECT ErrorMsg,Image,Width,Height FROM YZAppFileConvert WHERE ItemGuid=@ItemGuid AND Processed=1";
                        cmd.Parameters.Add("@ItemGuid", SqlDbType.NVarChar).Value = itemGuid;

                        using (YZReader reader = new YZReader(cmd.ExecuteReader()))
                        {
                            if (reader.Read())
                            {
                                readed      = true;
                                error       = reader.ReadString(0);
                                bytes       = (byte[])(Convert.IsDBNull(reader.Reader[1]) ? null : reader.Reader[1]);
                                size.Width  = reader.ReadInt32(2);
                                size.Height = reader.ReadInt32(3);
                            }
                        }
                    }
                }

                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = cn;
                    cmd.CommandText = "DELETE FROM YZAppFileConvert WHERE ItemGuid=@ItemGuid";
                    cmd.Parameters.Add("@ItemGuid", SqlDbType.NVarChar).Value = itemGuid;

                    cmd.ExecuteNonQuery();
                }
            }

            return(bytes);
        }
        catch (Exception exp)
        {
            error = exp.Message;
            return(null);
        }
    }