示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //System.Diagnostics.Debugger.Launch();
                var      blltag = new BllTag();
                string   tag    = hdntag.Value;
                string[] level1 = tag.Split('|');

                if (ViewState["flow"].ToString().ToLower() == "userprofile")
                {
                    for (int i = 1; i < level1.Length; i++)
                    {
                        string[] level2 = level1[i].Split(',');
                        if (level2[3] == "1")
                        {
                            blltag.AddUserTags(level2[0], Convert.ToInt64(ViewState["ProfileUserID"]),
                                               Convert.ToInt64(ViewState["UserID"]));
                        }
                    }
                }
                else if (ViewState["flow"].ToString().ToLower() == "tagged")
                {
                    for (int i = 1; i < level1.Length; i++)
                    {
                        string[] level2 = level1[i].Split(',');
                        if (level2[3] == "1")
                        {
                            blltag.AddTagged(new DtoTag
                            {
                                TagName = level2[0],
                                TagId   = Convert.ToInt64(ViewState["TagId"]),
                                UserId  = Convert.ToInt64(ViewState["UserID"])
                            });
                        }
                    }
                }
                else if (ViewState["flow"].ToString().ToLower() == "inlinecode")
                {
                    for (int i = 1; i < level1.Length; i++)
                    {
                        string[] level2 = level1[i].Split(',');
                        if (level2[3] == "1")
                        {
                            if (ViewState["WebsiteName"].ToString() == "")
                            {
                                var u = new Uri(ViewState["Premalink"].ToString());
                                ViewState["WebsiteName"] = u.Host;
                            }
                            blltag.AddTag(new DtoTag
                            {
                                TagName     = level2[0],
                                Link        = ViewState["Premalink"].ToString(),
                                WebsiteName = ViewState["WebsiteName"].ToString(),
                                TagType     = "0",
                                UserId      = Convert.ToInt64(ViewState["UserID"])
                            });
                        }
                    }
                }
                else if (ViewState["flow"].ToString().ToLower() == "bookmarklet")
                {
                    for (int i = 1; i < level1.Length; i++)
                    {
                        string[] level2 = level1[i].Split(',');
                        if (level2[3] == "1")
                        {
                            blltag.AddTag(new DtoTag
                            {
                                TagName = level2[0],
                                Link    = ViewState["Premalink"].ToString(),
                                TagType = "0",
                                UserId  = Convert.ToInt64(ViewState["UserID"])
                            });
                        }
                    }
                }
                else
                {
                    for (int i = 1; i < level1.Length; i++)
                    {
                        string[] level2 = level1[i].Split(',');
                        if (level2[3] == "1")
                        {
                            if (ViewState["WebsiteName"].ToString() == "")
                            {
                                var u = new Uri(ViewState["Premalink"].ToString());
                                ViewState["WebsiteName"] = u.Host;
                            }
                            blltag.AddTag(new DtoTag
                            {
                                TagName     = level2[0],
                                Link        = ViewState["Premalink"].ToString(),
                                WebsiteName = ViewState["WebsiteName"].ToString(),
                                TagType     = "0",
                                UserId      = Convert.ToInt64(ViewState["UserID"])
                            });
                        }
                    }
                }
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
        }