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


C# Tag.Save方法代码示例

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


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

示例1: AddNewTag

 public static void AddNewTag(string t, Article obj)
 {
     var tag = Tag.FindOne(p => p.Name == t);
     if (tag != null)
     {
         var c = new CrossArticleTag {Tag = tag};
         tag.Count++;
         obj.Cross.Add(c);
         tag.Save();
     }
     else
     {
         var c = new CrossArticleTag();
         var tt = new Tag {Name = t, Count = 1};
         tt.Save();
         c.Tag = tt;
         obj.Cross.Add(c);
     }
 }
开发者ID:jefth,项目名称:Blog,代码行数:19,代码来源:CommonHelper.cs

示例2: test022_createCommitTag

        public void test022_createCommitTag()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            var almostEmptyTree = new Tree(db);
            almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Constants.encodeASCII("empty"), false));
            ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);

            var almostEmptyCommit = new Commit(db)
                                        {
                                            Author = new PersonIdent(jauthor, 1154236443L, -2*60),
                                            Committer = new PersonIdent(jauthor, 1154236443L, -2*60),
                                            Message = "test022\n",
                                            TreeId = almostEmptyTreeId
                                        };

            ObjectId almostEmptyCommitId = new ObjectWriter(db).WriteCommit(almostEmptyCommit);

            var t = new Tag(db)
                        {
                            Id = almostEmptyCommitId,
                            TagType = "commit",
                            TagName = "test022",
                            Author = new PersonIdent(jauthor, 1154236443L, -4*60),
                            Message = "test022 tagged\n"
                        };

            t.Save();
            Assert.AreEqual("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", t.TagId.ToString());

            Tag mapTag = db.MapTag("test022");
            Assert.AreEqual("commit", mapTag.TagType);
            Assert.AreEqual("test022 tagged\n", mapTag.Message);
            Assert.AreEqual(new PersonIdent(jauthor, 1154236443L, -4 * 60), mapTag.Author);
            Assert.AreEqual("b5d3b45a96b340441f5abb9080411705c51cc86c", mapTag.Id.ToString());
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:35,代码来源:WriteTests.cs

示例3: test021_createTreeTag

        public void test021_createTreeTag()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            var almostEmptyTree = new Tree(db);
            almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Encoding.ASCII.GetBytes("empty"), false));
            ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);

            var t = new Tag(db)
                        {
                            Id = almostEmptyTreeId,
                            TagType = "tree",
                            TagName = "test021",
                            Author = new PersonIdent(jauthor, 1154236443L, -4*60),
                            Message = "test021 tagged\n"
                        };

            t.Save();
            Assert.AreEqual("b0517bc8dbe2096b419d42424cd7030733f4abe5", t.TagId.ToString());

            Tag MapTag = db.MapTag("test021");
            Assert.AreEqual("tree", MapTag.TagType);
            Assert.AreEqual("test021 tagged\n", MapTag.Message);
            Assert.AreEqual(new PersonIdent(jauthor, 1154236443L, -4 * 60), MapTag.Author);
            Assert.AreEqual("417c01c8795a35b8e835113a85a5c0c1c77f67fb", MapTag.Id.ToString());
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:25,代码来源:WriteTests.cs

示例4: test020_createBlobTag

        public void test020_createBlobTag()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            var t = new Tag(db)
                        {
                            Id = (emptyId),
                            TagType = ("blob"),
                            TagName = ("test020"),
                            Author = (new PersonIdent(jauthor, 1154236443L, -4*60)),
                            Message = ("test020 tagged\n")
                        };
            t.Save();
            Assert.AreEqual("6759556b09fbb4fd8ae5e315134481cc25d46954", t.TagId.ToString());

            Tag MapTag = db.MapTag("test020");
            Assert.AreEqual("blob", MapTag.TagType);
            Assert.AreEqual("test020 tagged\n", MapTag.Message);
            Assert.AreEqual(new PersonIdent(jauthor, 1154236443L, -4 * 60), MapTag.Author);
            Assert.AreEqual("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", MapTag.Id.ToString());
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:20,代码来源:WriteTests.cs

示例5: test020b_createBlobPlainTag

        public void test020b_createBlobPlainTag()
        {
            test020_createBlobTag();
            var t = new Tag(db)
                        {
                            TagName = ("test020b"),
                            Id = (ObjectId.FromString("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391"))
                        };
            t.Save();

            Tag MapTag = db.MapTag("test020b");
            Assert.AreEqual("e69de29bb2d1d6434b8b29ae775ad8c2e48c5391", MapTag.Id.ToString());

            // We do not repeat the plain tag test for other object types
        }
开发者ID:HackerBaloo,项目名称:GitSharp,代码行数:15,代码来源:WriteTests.cs

示例6: SaveArticle

        protected void SaveArticle(object sender, ActiveEventArgs e)
        {
            string header = e.Params["Header"].Get<string>();
            string ingress = e.Params["Ingress"].Get<string>();
            string body = e.Params["Body"].Get<string>();
            string image = e.Params["Image"].Get<string>();
            string[] tags = e.Params["Tags"].Get<string[]>();
            int id = e.Params["ID"].Get<int>();

            // Extracting image and saving in different formats...
            string imagePath = HttpContext.Current.Server.MapPath("~/" + image);

            string fileName = imagePath.Substring(imagePath.LastIndexOf("\\") + 1);
            fileName = fileName.Substring(0, fileName.IndexOf("."));

            // Saving server main resource folder
            string resourceFolder = HttpContext.Current.Server.MapPath("~/Resources/");
            using (Image original = Image.FromFile(imagePath))
            {
                double ratio = (double)original.Height / (double)original.Width;
                if (!File.Exists(resourceFolder + "Images\\Small\\" + fileName + ".png"))
                {
                    using (Image icon = new Bitmap(100, (int)(100 * ratio)))
                    {
                        using (Graphics g = Graphics.FromImage(icon))
                        {
                            g.DrawImage(original, new Rectangle(0, 0, icon.Width, icon.Height));
                        }
                        icon.Save(resourceFolder + "Images\\Small\\" + fileName + ".png", ImageFormat.Png);
                    }
                }
                if (!File.Exists(resourceFolder + "Images\\Medium\\" + fileName + ".png"))
                {
                    using (Image main = new Bitmap(350, (int)(350 * ratio)))
                    {
                        using (Graphics g = Graphics.FromImage(main))
                        {
                            g.DrawImage(original, new Rectangle(0, 0, main.Width, main.Height));
                        }
                        main.Save(resourceFolder + "Images\\Medium\\" + fileName + ".png", ImageFormat.Png);
                    }
                }
            }

            // Creating actual article and saving it...
            Article a;
            bool isNewArticle = false;
            if (id == -1)
            {
                // NEW article...!
                a = new Article();
                a.Published = DateTime.Now;

                Node node = new Node();
                node["Username"].Value = Users.LoggedInUserName;
                ActiveEvents.Instance.RaiseActiveEvent(
                    this,
                    "UserCreatedNewArticle",
                    node);
                isNewArticle = true;
            }
            else
            {
                // Editing old article...
                a = Article.SelectByID(id);
            }
            a.Header = header;
            a.Ingress = ingress;
            a.OriginalImage = image;
            a.IconImage = "Resources/Images/Small/" + fileName + ".png";
            a.MainImage = "Resources/Images/Medium/" + fileName + ".png";
            a.Body = body;

            // Adding up tags
            a.Tags.Clear();
            foreach (string tagIdx in tags)
            {
                string tagName = tagIdx.ToLowerInvariant().Trim();
                if (tagName == string.Empty)
                    continue;
                Tag tag = Tag.SelectFirst(Criteria.Eq("Name", tagName));
                if (tag == null)
                {
                    tag = new Tag();
                    tag.Name = tagName;
                    tag.Save();
                }
                a.Tags.Add(tag);
            }

            // Saving article...
            a.Save();

            if (isNewArticle)
            {
                // Signaling that a *NEWLY* created article was saved
                Node nodeSignal = new Node();
                nodeSignal["URL"].Value = ApplicationRoot.Root +
                        a.URL + ConfigurationManager.AppSettings["DefaultPageExtension"];
                nodeSignal["Header"].Value = a.Header;
//.........这里部分代码省略.........
开发者ID:greaterwinner,项目名称:ra-brix,代码行数:101,代码来源:ArticlePublisherController.cs

示例7: test022_createCommitTag

        public void test022_createCommitTag()
        {
            ObjectId emptyId = new ObjectWriter(db).WriteBlob(new byte[0]);
            Tree almostEmptyTree = new Tree(db);
            almostEmptyTree.AddEntry(new FileTreeEntry(almostEmptyTree, emptyId, Encoding.ASCII.GetBytes("empty"), false));
            ObjectId almostEmptyTreeId = new ObjectWriter(db).WriteTree(almostEmptyTree);
            Commit almostEmptyCommit = new Commit(db);
            almostEmptyCommit.Author = (new PersonIdent(jauthor, 1154236443L, -2 * 60)); // not exactly the same
            almostEmptyCommit.Committer = (new PersonIdent(jauthor, 1154236443L, -2 * 60));
            almostEmptyCommit.Message = ("test022\n");
            almostEmptyCommit.TreeId = (almostEmptyTreeId);
            ObjectId almostEmptyCommitId = new ObjectWriter(db).WriteCommit(almostEmptyCommit);
            Tag t = new Tag(db);
            t.Id = (almostEmptyCommitId);
            t.TagType = ("commit");
            t.TagName = ("test022");
            t.Author = (new PersonIdent(jauthor, 1154236443L, -4 * 60));
            t.Message = ("test022 tagged\n");
            t.Save();
            Assert.AreEqual("0ce2ebdb36076ef0b38adbe077a07d43b43e3807", t.TagId.ToString());

            Tag MapTag = db.MapTag("test022");
            Assert.AreEqual("commit", MapTag.TagType);
            Assert.AreEqual("test022 tagged\n", MapTag.Message);
            Assert.AreEqual(new PersonIdent(jauthor, 1154236443L, -4 * 60), MapTag.Author);
            Assert.AreEqual("b5d3b45a96b340441f5abb9080411705c51cc86c", MapTag.Id.ToString());
        }
开发者ID:mneedham,项目名称:GitSharp,代码行数:27,代码来源:WriteTests.cs

示例8: btnSubmit_Click

 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     wndAsk.Visible = false;
     QuizItem q = new QuizItem();
     q.CreatedBy = Operator.Current;
     q.Header = header.Text;
     q.Body = body.Text;
     string[] ents = tags.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
     if (ents != null && ents.Length > 0)
     {
         q.Tags = new List<Tag>();
         foreach (string idx in ents)
         {
             if (idx.Trim().Length > 0)
             {
                 string idx2 = idx.ToLower();
                 Tag t = Tag.FindOne(Expression.Eq("Name", idx2));
                 if (t == null)
                 {
                     t = new Tag();
                     t.Name = idx2;
                     t.Save();
                 }
                 q.Tags.Add(t);
             }
         }
     }
     q.Save();
     if (QuestionAsked != null)
         QuestionAsked(this, new QuestionAskedEventArgs(q.Url));
 }
开发者ID:andrelotto,项目名称:stacked,代码行数:31,代码来源:AskQuestion.ascx.cs

示例9: btnSave_Click

        protected void btnSave_Click(object sender, EventArgs e)
        {
            Guid pID = new Guid();//模块ID
            if (ddlModuleP.SelectedValue == "0")
            {
                this.lbErr.InnerText = "请选择栏目";
                return;
            }
            else
            {
                pID = new Guid(ddlModuleP.SelectedValue.ToString());
            }

            NewsContent newsC = NewsContent.Load(newsID);
            newsC.Title = tbTitle.Text.Trim();
            newsC.ModuleID = pID;
            newsC.Source = tbSource.Text.Trim();
            newsC.Content = fck.Value;
            newsC.Status = 1;//修改
            DateTime temp=DateTime.Now;

            newsC.PublishTime = CY.Utility.Common.ParseUtility.TryParseDateTime(tbPublishTime.Text.Trim(), out temp) ? temp : DateTime.Now;

            int isAn = IsAnnex();
            newsC.Annex = isAn;
            newsC.Author = u.Name;
            newsC.Index = int.Parse(ddlIndex.SelectedValue.ToString());
            newsC.Save();

            if (isAn == 1)
            {
                SaveAttach(newsC.Id);
            }
            /*Tag*/
            if (!string.IsNullOrEmpty(tbTag.Text.Trim()))
            {
                string tagTemp = tbTag.Text.Trim();
                if (tagTemp.Contains(","))
                {
                    tagTemp = tagTemp.Replace(",", ",");
                }
                else if (tagTemp.Contains(" "))
                {
                    tagTemp = tagTemp.Replace(" ", ",");
                }
                CY.CSTS.Core.Business.Tag tagG = CY.CSTS.Core.Business.Tag.SelectTagsDynamic(" ContentID='" + newsC.Id + "'", "");
                if (tagG != null)
                {
                    tagG.TagName = tagTemp;
                    tagG.Save();
                }
                else
                {
                    CY.CSTS.Core.Business.Tag t = new Tag();
                    t.TagName = tagTemp;
                    t.ContentID = newsC.Id;
                    t.ContentType = 2;
                    t.Save();
                }
            }
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('修改成功');window.location.href='NewsList.aspx?id=" + newsID + "&tabIndex=" + hdTabIndex.Value + "'</script>");
        }
开发者ID:dalinhuang,项目名称:cy-csts,代码行数:62,代码来源:NewEdit.aspx.cs

示例10: SaveData

        private bool SaveData(int status)
        {
            string strMidList = hdSelectModuleList.Value;
            if (strMidList != "")
            {
                string[] listMID = strMidList.Split(',');
                for (int i = 0; i < listMID.Length; i++)
                {
                    if (CY.Utility.Common.StringHelper.IsGuid(listMID[i]))
                    {

                        if (string.IsNullOrEmpty(tbTitle.Text.Trim()))
                        {
                            lbErr.Text = "请输入标题";
                            tbTitle.Focus();
                            return false;
                        }

                        NewsContent newsC = new NewsContent();
                        newsC.ModuleID = new Guid(listMID[i]);
                        newsC.Title = tbTitle.Text.Trim();

                        newsC.Source = tbSource.Text.Trim();

                        newsC.Content = fck.Value;

                        DateTime temp = DateTime.Now;

                        newsC.PublishTime = CY.Utility.Common.ParseUtility.TryParseDateTime(tbPublishTime.Text.Trim(), out temp) ? temp : DateTime.Now;

                        newsC.Status = status;//发表

                        newsC.Author = u.Name;//session["UserName"]
                        newsC.PublishTime = DateTime.Now;
                        HttpFileCollection files = HttpContext.Current.Request.Files;
                        bool hasAnnex = false;

                        if (files[0].FileName == "" || files[0].ContentLength == 0)
                        {
                            newsC.Annex = 2;//没有附件
                            hasAnnex = false;
                        }
                        else
                        {
                            newsC.Annex = 1;//有附件
                            hasAnnex = true;
                        }
                        newsC.Index = int.Parse(ddlIndex.SelectedValue.ToString());
                        newsC.Traffic = 0;
                        newsC.Save();

                        if (hasAnnex == true)
                        {
                            SaveAttach(newsC.Id);
                        }
                        if (!string.IsNullOrEmpty(tbTag.Text.Trim()))
                        {
                            string tagTemp = tbTag.Text.Trim();
                            if (tagTemp.Contains(","))
                            {
                                tagTemp = tagTemp.Replace(",", ",");
                            }
                            else if (tagTemp.Contains(" "))
                            {
                                tagTemp = tagTemp.Replace(" ", ",");
                            }
                            CY.CSTS.Core.Business.Tag tag = new Tag();
                            tag.TagName = tagTemp;
                            tag.ContentID = newsC.Id;
                            tag.ContentType = 2;
                            tag.Save();
                        }

                    }
                }
                return true;
            }
            else
            {
                lbErr.Text = "请选择模块";
                return false;
            }
            return false;
        }
开发者ID:dalinhuang,项目名称:cy-csts,代码行数:84,代码来源:NewsAdd.aspx.cs


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