当前位置: 首页>>代码示例>>C#>>正文


C# DataEntities.AddToFile方法代码示例

本文整理汇总了C#中Voodoo.Basement.DataEntities.AddToFile方法的典型用法代码示例。如果您正苦于以下问题:C# DataEntities.AddToFile方法的具体用法?C# DataEntities.AddToFile怎么用?C# DataEntities.AddToFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Voodoo.Basement.DataEntities的用法示例。


在下文中一共展示了DataEntities.AddToFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Form_Save

        protected void Form_Save(object sender, DirectEventArgs e)
        {
            using (DataEntities ent = new DataEntities())
            {
                var n = new Voodoo.Basement.Product();
                try
                {
                    int id = ID.Text.ToInt32();
                    n = (from l in ent.Product where l.ID == id select l).First();
                }
                catch { }

                n.AddTime = AddTime.Value.ToDateTime();
                n.ClassID = ClassID.SelectedItem.Value.ToInt32();
                n.ClassName = ClassID.SelectedItem.Text;
                n.ClickCount = ClickCount.Value.ToInt32();
                n.Contact = Contact.Text;
                n.Enable = Enable.Checked;
                //n.FaceImage = "";

                n.Intro = Intro.Text;
                n.Name = Name.Text;
                n.OrderIndex = OrderIndex.Value.ToInt32();
                n.Price = Price.Value.ToDecimal();
                n.ProduceLocation = ProduceLocation.Text;
                n.SetTop = SetTop.Checked;
                n.Specification = Specification.Text;
                n.Tel = Tel.Text;
                n.Units = Units.Text;
                if (n.ID <= 0)
                {
                    ent.AddToProduct(n);
                }
                ent.SaveChanges();

                if (FaceImage.HasFile)
                {
                    Class cls = (from l in ent.Class where l.ID == n.ClassID select l).First();
                    string fileName = string.Format("/u/products/{0}.jpg", n.ID);
                    Voodoo.Basement.BasePage.UpLoadImage(FaceImage.PostedFile, fileName, cls.ImageWidth.ToInt32(), cls.ImageHeight.ToInt32());//194, 204
                    n.FaceImage = fileName;
                    ent.SaveChanges();
                }

                if (UpFile.HasFile)
                {
                    var files = from l in ent.File where l.ItemID == n.ID select l;
                    foreach (var f in files)
                    {
                        ent.DeleteObject(f);
                    }

                    string ext = UpFile.FileName.GetFileExtNameFromPath();
                    string fileName = string.Format("/u/products/{0}", UpFile.FileName);
                    Voodoo.Basement.BasePage.UpLoadFile(UpFile.PostedFile, fileName);

                    Voodoo.Basement.File file = new Voodoo.Basement.File();
                    file.ClassID = n.ClassID;
                    file.FileDirectory = "/u/products/";
                    file.FileExtName = ext;
                    file.FileName = UpFile.FileName;
                    file.FilePath = fileName;
                    file.FileSize = UpFile.PostedFile.ContentLength;
                    file.FileType = 0;
                    file.ItemID = n.ID;
                    file.SmallPath = "";
                    file.UpTime = DateTime.Now;
                    ent.AddToFile(file);
                    ent.SaveChanges();
                }

                this.GridPanel1.Store.Primary.CommitChanges();
                this.BindData();
                TabPanel1.SetActiveTab(0);
                FormPanel1.Title = "新增";
                FormPanel1.Reset();
                X.Msg.Notify("消息", "保存成功!").Show();

            }
        }
开发者ID:kuibono,项目名称:KCMS2,代码行数:80,代码来源:List.aspx.cs

示例2: btn_Save_Click

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            DataEntities ent = new DataEntities();
            User u=UserAction.opuser;
            UserGroup g = //UserGroupView.GetModelByID(u.Group.ToS());
                (from l in ent.UserGroup where l.ID == u.Group select l).FirstOrDefault();
            if (FileUpload1.FileName.IsNullOrEmpty())
            {
                Js.AlertAndGoback("为提高您文章的排名,请选择一张标题图片");
                return;
            }

            #region  上传图片
            SysSetting ss = BasePage.SystemSetting;

            HttpPostedFile file = Request.Files["FileUpload1"];
            string FileName = file.FileName.GetFileNameFromPath();//文件名
            string ExtName = file.FileName.GetFileExtNameFromPath();//扩展名
            string NewName = @string.GetGuid() + ExtName;//新文件名

            if (!ExtName.Replace(".", "").IsInArray(ss.FileExtNameFilter.Split(',')))
            {
                Js.AlertAndGoback("不允许上传此类文件");
                return;
            }
            if (file.ContentLength > ss.MaxPostFileSize)
            {
                Js.AlertAndGoback("文件太大");
                return;
            }

            string Folder = ss.FileDir + "/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";//文件目录
            string FolderShotCut = Folder + "ShortCut/";//缩略图目录

            string FilePath = Folder + NewName;//文件路径
            string FilePath_ShortCut = FolderShotCut + NewName;//缩略图路径

            file.SaveAs(Server.MapPath(FilePath), true);
            ImageHelper.MakeThumbnail(Server.MapPath(FilePath), Server.MapPath(FilePath_ShortCut), 105, 118, "Cut");

            FileInfo savedFile = new FileInfo(Server.MapPath(FilePath));

            Voodoo.Basement.File f = new Voodoo.Basement.File();

            f.FileDirectory = ss.FileDir;
            f.FileExtName = ExtName;
            f.FilePath = FilePath;
            f.FileSize = (savedFile.Length / 1024).ToInt32();
            //f.FileType=
            f.SmallPath = FilePath_ShortCut;
            f.UpTime = DateTime.Now;

            ent.AddToFile(f);
            ent.SaveChanges();
            #endregion

            News n = new News();
            n.Author = txt_Author.Text.TrimDbDangerousChar();
            n.AutorID = UserAction.opuser.ID;
            n.ClassID = ddl_Class.SelectedValue.ToInt32();
            n.ClickCount = 0;
            n.Content = txt_Content.Text.TrimDbDangerousChar();
            n.Description = txt_Description.Text.TrimDbDangerousChar();
            n.DownCount = 0;
            n.EnableReply = false;
            n.FTitle = txtFtitle.Text.TrimDbDangerousChar();
            n.KeyWords = txt_Keyword.Text.TrimDbDangerousChar();
            n.ModelID = 0;
            n.NavUrl = "";
            n.NewsTime = DateTime.Now;
            n.SetTop = false;
            n.Source = txt_Source.Text.TrimDbDangerousChar();
            n.Title = txt_Title.Text.TrimDbDangerousChar();
            n.TitleColor = "000";
            n.TitleImage = FilePath;//上传图片
            n.ZtID = 0;
            n.Audit = g.PostAotuAudit;
            n.FileForder = DateTime.Now.ToString("yyyy-MM-dd");

            n.ID = WS.RequestInt("id");

            Result r=NewsAction.UserPost(n, UserAction.opuser);

            if (r.Success)
            {
                Js.AlertAndChangUrl(r.Text, "PostList.aspx");
            }
            else
            {
                Js.AlertAndGoback(r.Text);
            }
            ent.Dispose();
        }
开发者ID:svn2github,项目名称:KCMS2,代码行数:93,代码来源:PostNews.aspx.cs


注:本文中的Voodoo.Basement.DataEntities.AddToFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。