Beispiel #1
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;
        }
        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);
        }
Beispiel #3
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");
 }
        public static YZMessageCollection GetNewMessages(IDbConnection cn, YZResourceType resType, string resId, int maxReadedMessageId)
        {
            IYZDBProvider dbProvider = YZDBProviderManager.CurrentProvider;
            IDbCommand cmd = dbProvider.GetResourceCommunicationNewMessagesCommand(resType, resId, maxReadedMessageId);
            cmd.Connection = cn;

            using (YZReader reader = new YZReader(cmd.ExecuteReader()))
            {
                YZMessageCollection messages = new YZMessageCollection(reader);
                return messages;
            }
        }
        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;
            }
        }
Beispiel #6
0
 public static Guid ReadGuid(IDataReader reader, int index)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadGuid(index);
 }
Beispiel #7
0
 public static bool ReadBool(IDataReader reader, int index, bool defaultValue)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadBool(index, defaultValue);
 }
Beispiel #8
0
 public static string ReadString(IDataReader reader, int index)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadString(index);
 }
Beispiel #9
0
 public static DateTime ReadDateTime(IDataReader reader, int index)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadDateTime(index);
 }
Beispiel #10
0
 public static int ReadInt32(IDataReader reader, int index)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadInt32(index);
 }
Beispiel #11
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("超时");
                        }

                        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);
            }
        }
Beispiel #12
0
        public static DateTime ReadDateTime(IDataReader reader, int index)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadDateTime(index));
        }
Beispiel #13
0
        public static bool ReadBool(IDataReader reader, int index, bool defaultValue)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadBool(index, defaultValue));
        }
Beispiel #14
0
        public static int ReadInt32(IDataReader reader, int index)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadInt32(index));
        }
Beispiel #15
0
 public static object ReadObject(IDataReader reader, int index, object defaultValue)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadObject(index, defaultValue);
 }
Beispiel #16
0
        public static object ReadEnum(IDataReader reader, int index, Type enumType, object defaultValue)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadEnum(index, enumType, defaultValue));
        }
Beispiel #17
0
        public static object ReadObject(IDataReader reader, int index, object defaultValue)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadObject(index, defaultValue));
        }
Beispiel #18
0
        public static Guid ReadGuid(IDataReader reader, int index)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadGuid(index));
        }
Beispiel #19
0
        public static string ReadString(IDataReader reader, int index)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadString(index));
        }
Beispiel #20
0
 public static object ReadEnum(IDataReader reader, int index, Type enumType, object defaultValue)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadEnum(index, enumType, defaultValue);
 }
Beispiel #21
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;
            }
        }