Exemple #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);
        }
Exemple #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 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;
            }
        }
Exemple #5
0
 public static int ReadInt32(IDataReader reader, int index)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadInt32(index);
 }
        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);
            }
        }
Exemple #7
0
        public static int ReadInt32(IDataReader reader, int index)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadInt32(index));
        }
Exemple #8
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;
            }
        }