Example #1
0
        public ActionResult Upload(HttpPostedFileBase upload)
        {
            if (upload == null)
            {
                return(View("Error"));
            }

            using (var context = new ProfileSampleEntities())
            {
                using (var stream = upload.InputStream)
                {
                    byte[] buff = new byte[stream.Length];

                    stream.Read(buff, 0, (int)stream.Length);

                    var entity = new ImgSource()
                    {
                        Name = upload.FileName,
                        Data = buff,
                    };

                    context.ImgSources.Add(entity);
                    context.SaveChanges();
                }
            }

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult Convert()
        {
            var files = Directory.GetFiles(Server.MapPath("~/Content/Img"), "*.jpg");

            using (var context = new ProfileSampleEntities())
            {
                foreach (var file in files)
                {
                    using (var stream = new FileStream(file, FileMode.Open))
                    {
                        byte[] buff = new byte[stream.Length];

                        stream.Read(buff, 0, (int)stream.Length);

                        var entity = new ImgSource()
                        {
                            Name = Path.GetFileName(file),
                            Data = buff,
                        };

                        context.ImgSources.Add(entity);
                        context.SaveChanges();
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Example #3
0
        public override CodeSourceCollection CreateSources(string aFileName)
        {
            SIImage image = SIImage.New(base.Tracer, aFileName);

            if (image == null)
            {
                throw new NotSupportedException("The specified image file is not supported");
            }

            // We need to make a source and (single) collection for each content object within the image.
            // This enables relocation support when an image is actually used (i.e. read & decompress code
            // on demand, rather than up front).
            CodeSourceCollection sources = new CodeSourceCollection();

            //
            foreach (SIContent content in image)
            {
                CodeCollection collection = CodeCollection.New(base.IdAllocator, aFileName, content.FileName);
                collection.IsRelocatable = content.IsRelocationSupported;

                // The URI must be unique
                string    uri    = string.Format("{0} [{1}]", aFileName, content.FileName);
                ImgSource source = new ImgSource(uri, this, collection, content);
                sources.Add(source);
            }
            //
            return(sources);
        }
Example #4
0
        public string AnalySisImgName(string name, out ImgSource source, out ImgType type)
        {
            string clampName = name;

            if (name.Contains(sepraterCharimg.ToString()))
            {
                var index = name.IndexOf(sepraterCharimg);
                clampName = name.Remove(index);

                name = name.ToUpper();
                if (name.Contains((sepraterCharimg + asGoubleMark).ToUpper()))
                {
                    source = ImgSource.Globle;
                }
                else if (name.Contains((sepraterCharimg + asNoRepetMark).ToUpper()))
                {
                    source = ImgSource.Normal;
                }
                else if (name.Contains((sepraterCharimg + asCustomMark).ToUpper()))
                {
                    source = ImgSource.Custom;
                }
                else
                {
                    source = defultImgSource;
                }

                if (name.Contains((sepraterCharimg + asSingleMark).ToUpper()))
                {
                    type = ImgType.Image;
                }
                else if (name.Contains((sepraterCharimg + asTextureMark).ToUpper()))
                {
                    type = ImgType.Texture;
                }
                else if (name.Contains((sepraterCharimg + asAtalsMark).ToUpper()))
                {
                    type = ImgType.AtlasImage;
                }
                else
                {
                    type = createAtlas ? ImgType.AtlasImage : ImgType.Image;
                }
            }
            else
            {
                clampName = name;
                type      = createAtlas ? ImgType.AtlasImage : ImgType.Image;
                source    = defultImgSource;
            }
            return(clampName);
        }
Example #5
0
 public ImgReader(ImgSource aSource, ITracer aTracer)
 {
     iSource       = aSource;
     iImageContent = aSource.ImageContent;
     iImageContent.DecompressionEvent += new SIContent.DecompressionEventHandler(ImageContent_PreparationEvent);
 }
Example #6
0
        public static List <RebateApplyImageConfig> GetRebateApplyImageConfig(SqlConnection conn, int parentId, ImgSource source)
        {
            const string sql = @"
           SELECT raic.ParentId ,
                raic.ImgUrl ,
                raic.Source ,
                raic.Remarks
         FROM   Activity..RebateApplyImageConfig AS raic WITH ( NOLOCK )
         WHERE  raic.ParentId = @ParentId
                AND ( ( @Source = N'UserImg'
                        AND ( raic.Source IS NULL
                              OR raic.Source = @Source
                            )
                      )
                      OR ( @Source = N'PageImg'
                           AND raic.Source = @Source
                         )
                    )";

            return(conn.Query <RebateApplyImageConfig>(sql, new
            {
                ParentId = parentId,
                Source = source.ToString()
            }, commandType: CommandType.Text).ToList());
        }
Example #7
0
        public static int InsertRebateImgConfig(SqlConnection conn, int parentId, string imgUrl, ImgSource source, string remarks)
        {
            const string sql = @"
            INSERT  INTO Activity..RebateApplyImageConfig
                    ( ParentId ,
                      ImgUrl ,
                      Source ,
                      Remarks ,
                      CreateTime ,
                      UpdateTime
                    )
            VALUES  ( @ParentId ,
                      @ImgUrl ,
                      @Source ,
                      @Remarks ,
                      GETDATE() ,
                      GETDATE()
                    );";

            return(conn.Execute(sql, new
            {
                ParentId = parentId,
                ImgUrl = imgUrl,
                Source = source.ToString(),
                Remarks = remarks
            }, commandType: CommandType.Text));
        }