コード例 #1
0
ファイル: YZMessage.cs プロジェクト: linxueyang/F7
 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");
 }
コード例 #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);
        }
コード例 #3
0
ファイル: SqlServerProvider.cs プロジェクト: linxueyang/F7
        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;
        }
コード例 #4
0
ファイル: YZReader.cs プロジェクト: linxueyang/F7
 public static string ReadString(IDataReader reader, int index)
 {
     YZReader dbr = new YZReader(reader);
     return dbr.ReadString(index);
 }
コード例 #5
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);
            }
        }
コード例 #6
0
ファイル: YZReader.cs プロジェクト: hzz07/BPMMobile2.x
        public static string ReadString(IDataReader reader, int index)
        {
            YZReader dbr = new YZReader(reader);

            return(dbr.ReadString(index));
        }
コード例 #7
0
ファイル: SqlServerProvider.cs プロジェクト: linxueyang/F7
        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;
            }
        }