protected void GenerateSiteMapIndexFile(SiteMapOptions options, int nFiles, bool compressed)
        {
            sitemapindex   smIndex = new sitemapindex();
            sitemap        smap;
            List <sitemap> smapList = new List <sitemap>();

            for (int i = 1; i <= nFiles; i++)
            {
                smap = new sitemap();
                if (compressed)
                {
                    smap.loc = GetAbsoluteUrl("~/" + "SiteMap" + i + ".xml.gz");
                }
                else
                {
                    smap.loc = GetAbsoluteUrl("~/" + "SiteMap" + i + ".xml");
                }
                smap.lastmod = LocaleHelper.LocalNow.ToString("yyyy-MM-ddTHH:mm:sszzzzzz");
                smapList.Add(smap);
            }

            smIndex.sitemap = smapList.ToArray();

            string fileData = XmlUtility.Utf8BytesToString(XmlUtility.Serialize(smIndex));
            string fileName = Path.Combine(options.SiteMapDataPath, "SiteMapIndex.xml");

            StreamWriter SiteMapIndexWriter = File.CreateText(fileName);

            using (SiteMapIndexWriter)
            {
                SiteMapIndexWriter.Write(fileData);
                SiteMapIndexWriter.Flush();
                SiteMapIndexWriter.Close();
            }
        }
 public bool UpdateSiteMap(sitemap siteMapInfo, ref int flag)
 {
     try
     {
         using (var db = new expensemanagerportaldbEntities())
         {
             db.sitemaps.Attach(siteMapInfo);
             db.ObjectStateManager.ChangeObjectState(siteMapInfo, EntityState.Modified);
             db.SaveChanges();
             flag = 0;
             return(true);
         }
     }
     catch (Exception ex)
     {
         XPLUG.WEBTOOLS.ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         if (ex.Message.Contains("Duplicate entry") || ex.InnerException.Message.Contains("Duplicate entry"))
         {
             flag = -1;
             return(false);
         }
         flag = 1;
         return(false);
     }
 }
예제 #3
0
파일: CourseVSNet.cs 프로젝트: PavelPZ/REW
 public sitemap getSiteMap(LoggerMemory logger) {
   if (_siteMap == null) {
     _siteMap = new sitemap(actNode.url, logger, sitemap.fromFileSystem("/data/instr/std/", logger), sitemap.fromFileSystem("/data/instr/new/", logger));
     if (logger.vsNetForBrowseAction) { //uprava sitemap pro vs.net browse - pouze taskCourse, data a testEx nodes. Nahrad vsechny testGlobalAdmin... nodes apod.
       XElement root;
       using (StringReader rdr = new StringReader(XmlUtils.ObjectToString(_siteMap))) root = XElement.Load(rdr);
       foreach (var highLev in root.Elements().Where(he => he.AttributeValue("type", "").IndexOf("instrs") < 0)) {
         highLev.Name = "taskCourse"; highLev.SetAttributeValue("type", "mod");
         foreach (var el in highLev.Descendants().Where(e => e.Name.LocalName != "ex")) { el.Name = "data"; el.SetAttributeValue("type", null); }
       }
       _siteMap = XmlUtils.StringToObject<sitemap>(root.ToString());
       _siteMap.finish();
     }
   }
   return _siteMap;
 } sitemap _siteMap;
 public long AddSiteMap(sitemap siteMapInfo)
 {
     try
     {
         using (var db = new expensemanagerportaldbEntities())
         {
             db.AddTositemaps(siteMapInfo);
             db.SaveChanges();
             return(siteMapInfo.ID);
         }
     }
     catch (Exception ex)
     {
         XPLUG.WEBTOOLS.ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         if (ex.Message.Contains("Duplicate entry") || ex.InnerException.Message.Contains("Duplicate entry"))
         {
             return(-1);
         }
         return(0);
     }
 }
 public bool DeleteSiteMap(int sitemapId)
 {
     try
     {
         using (var db = new expensemanagerportaldbEntities())
         {
             sitemap myObj = db.sitemaps.Single(s => s.ID == sitemapId);
             if (myObj == null)
             {
                 return(false);
             }
             db.sitemaps.DeleteObject(myObj);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception ex)
     {
         XPLUG.WEBTOOLS.ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
         return(false);
     }
 }
        protected void BtnSubmitClick(Object sender, EventArgs e)
        {
            ErrorDisplay1.ClearError();
            try
            {
                if (ddlTabParent.SelectedIndex == 0)
                {
                    ErrorDisplay1.ShowError("Please select parent tab");
                    return;
                }

                if (txtTabName.Text == "")
                {
                    ErrorDisplay1.ShowError("Tab name is required");
                    return;
                }

                if (ddlTabType.SelectedIndex == 0)
                {
                    ErrorDisplay1.ShowError("Please select tab type");
                    return;
                }


                if (ValidateRole() < 1)
                {
                    ErrorDisplay1.ShowError("You must select at least one role");
                    return;
                }


                string mRoles = String.Empty;
                for (int i = 0; i < chkRoles.Items.Count; i++)
                {
                    if (chkRoles.Items[i].Selected)
                    {
                        mRoles += ";" + chkRoles.Items[i].Value;
                    }
                }

                if (mRoles.Length > 0)
                {
                    if (mRoles.StartsWith(";"))
                    {
                        mRoles = mRoles.Substring(1);
                    }
                    if (mRoles.EndsWith(";"))
                    {
                        mRoles = mRoles.Substring(0, mRoles.Length - 1);
                    }
                }
                else
                {
                    ErrorDisplay1.ShowError("Tab name is required");
                    return;
                }


                var mInfo = new sitemap
                {
                    DateCreated = DateMap.GetLocalDate(),
                    Description = txtDescription.Text,
                    Parent      = (DataCheck.IsNumeric(ddlTabParent.SelectedValue.ToString(CultureInfo.InvariantCulture)))? int.Parse(ddlTabParent.SelectedValue.ToString(CultureInfo.InvariantCulture)): 0,
                    Roles       = mRoles,
                    Title       = txtTabName.Text,
                    TabType     = (DataCheck.IsNumeric(ddlTabType.SelectedValue.ToString(CultureInfo.InvariantCulture)))? int.Parse(ddlTabType.SelectedValue.ToString(CultureInfo.InvariantCulture)): 0,
                    TabOrder    = (DataCheck.IsNumeric(ddlTabOrder.SelectedValue.ToString(CultureInfo.InvariantCulture)))? int.Parse(ddlTabOrder.SelectedValue.ToString(CultureInfo.InvariantCulture)): 0,
                    Url         = txtLink.Text
                };


                switch (int.Parse(btnSubmit.CommandArgument))
                {
                case 1:     //Add
                    long k = (new PortalServiceManager()).AddSiteMap(mInfo);
                    if (k < 1)
                    {
                        if (k == -1)
                        {
                            ErrorDisplay2.ShowError("Duplicate Tab Name! This Tab Name is already registered");
                            mpeDisplayJobDetails.Show();
                            return;
                        }
                        ErrorDisplay2.ShowError("Item was not be added");
                        mpeDisplayJobDetails.Show();
                        return;
                    }
                    Reset();
                    //HideMainDvs();
                    BindSitemMapItemList();
                    //this.listDV.Visible = true;
                    ErrorDisplay1.ShowSuccess("Item Was Added Successfully");
                    mpeDisplayJobDetails.Hide();
                    break;

                case 2:     //Update
                    int id = (DataCheck.IsNumeric(ViewState["mRecordID"].ToString())) ? int.Parse(ViewState["mRecordID"].ToString()) : 0;
                    if (id < 1)
                    {
                        ErrorDisplay2.ShowError("Process Validation Failed!");
                        mpeDisplayJobDetails.Show();
                        return;
                    }
                    mInfo.ID = id;
                    int flag = 0;
                    if (!(new PortalServiceManager()).UpdateSiteMap(mInfo, ref flag))
                    {
                        if (flag == -1)
                        {
                            ErrorDisplay2.ShowError("Duplicate Tab Name! This Tab Name is already registered");
                            mpeDisplayJobDetails.Show();
                            return;
                        }
                        ErrorDisplay2.ShowError("Update failed!");
                        mpeDisplayJobDetails.Show();
                        return;
                    }
                    Reset();
                    BindSitemMapItemList();
                    btnSubmit.Text = "Add New Tab";
                    mpeDisplayJobDetails.Hide();
                    ErrorDisplay1.ShowSuccess("Item Was Updated Successfully");
                    break;
                }
            }
            catch (Exception ex)
            {
                ErrorManager.LogApplicationError(ex.StackTrace, ex.Source, ex.Message);
            }
        }
예제 #7
0
        public List <sitemap> GetSitemap(string blogID, bool isShowHide)
        {
            string showHide = "";

            if (isShowHide == false)
            {
                showHide = " and blog_tb_article.articleIsHidden=0";
            }

            string sql = @"  
            select menuUrl, menuDisplay from blog_tb_menu where blogID=@blogID and menuIsDisabled=0     order by menuOrder DESC;

            select categoryID,categoryDisplay,categoryDomain from blog_tb_category where categoryIsDisabled='0' and blogID=@blogID  order by categoryOrderWeight desc;

            select yyyy,mm  from (
             SELECT DISTINCT YEAR(articleDatetime) as yyyy,LEFT(concat('0',MONTH(articleDatetime)),2) as mm FROM blog_tb_article
            where blogID=@blogID and articleIsDisabled=0 and articleIsHidden=0
            ) c  order by CONCAT(yyyy,mm) desc;

            select 
            articleID,
            articleTitle,
            articleDatetime,
            blog_tb_article.UPDATE_DATE 
            from blog_tb_article 
            LEFT JOIN blog_tb_category c on c.categoryID=blog_tb_article.categoryID
            where blog_tb_article.blogID=@blogID
            and blog_tb_article.articleIsDisabled=0
            {0}
            and blog_tb_article.articleIsDelete=0
            and c.categoryIsDisabled=0
            order by articleDatetime desc;

            SELECT linkName,linkUrl,UPDATE_DATE from blog_tb_link where linkIsDisabled=FALSE
                ";

            sql = String.Format(sql, showHide);

            DataSet ds = DbInstance.GetDataSet(sql, blogID);

            string domain = "";

            if (ds.Tables[0].Rows.Count > 0)
            {
                domain = ds.Tables[0].Rows[0]["blogDomain"].ToString();
            }
            else
            {
                throw new CustomException("博客不存在");
            }

            List <sitemap> list = new List <sitemap>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                sitemap m = new sitemap();
                m.Mtype      = "menu";
                m.Text       = dr["menuDisplay"].ToString();
                m.changefreq = "daily";
                m.priority   = "0.9";
                m.lastmod    = DateTime.Now.ToString("yyyy-MM-dd");
                m.Url        = IocFactory <IBlogFix> .Instance.GetMenuUrl(dr["menuUrl"].ToString());

                list.Add(m);
            }

            foreach (DataRow dr in ds.Tables[1].Rows)
            {
                sitemap m = new sitemap();
                m.Mtype      = "category";
                m.Text       = dr["categoryDisplay"].ToString();
                m.changefreq = "daily";
                m.priority   = "0.8";
                m.lastmod    = DateTime.Now.ToString("yyyy-MM-dd");
                m.Url        = IocFactory <IBlogFix> .Instance.GetCategoryUrl(dr["categoryID"].ToString(), dr["categoryDomain"].ToString());

                list.Add(m);
            }

            foreach (DataRow dr in ds.Tables[2].Rows)
            {
                sitemap m = new sitemap();
                m.Mtype      = "month";
                m.Text       = dr["yyyy"] + "年" + dr["mm"] + "月";
                m.changefreq = "daily";
                m.priority   = "0.7";
                m.lastmod    = dr["yyyy"] + "-" + dr["mm"] + "-28";
                m.Url        = IocFactory <IBlogFix> .Instance.GetMonthUrl(dr["yyyy"].ToString(), dr["mm"].ToString());

                list.Add(m);
            }

            foreach (DataRow dr in ds.Tables[3].Rows)
            {
                sitemap m = new sitemap();
                m.Mtype      = "article";
                m.Text       = dr["articleTitle"].ToString();
                m.changefreq = "never";
                m.priority   = "0.5";
                m.lastmod    = Convert.ToDateTime(dr["UPDATE_DATE"]).ToString("yyyy-MM-dd");
                m.Url        = IocFactory <IBlogFix> .Instance.GetArticleUrl(dr["articleID"].ToString());

                list.Add(m);
            }

            foreach (DataRow dr in ds.Tables[4].Rows)
            {
                sitemap m = new sitemap();
                m.Mtype      = "link";
                m.Text       = dr["linkName"].ToString();
                m.changefreq = "never";
                m.priority   = "0.5";
                m.lastmod    = Convert.ToDateTime(dr["UPDATE_DATE"]).ToString("yyyy-MM-dd");
                m.Url        = dr["linkUrl"].ToString();
                list.Add(m);
            }

            return(list);
        }
예제 #8
0
파일: Author.cs 프로젝트: PavelPZ/REW
 IEnumerable<xrefPageObj> generateXref(docTagsMeta meta, sitemap smap, LoggerMemory sb) {
   var typeDir = meta.types.ToDictionary(t => t.name, t => t); //type => docType 
   //vsechny property vsech objektu => materska property (napr. gapFill.correctValue => edit.correctValue prop)
   var propsDir = meta.props.SelectMany(prop => typeDir[prop.ownerType].descendantsAndSelf.Select(typeId => new { typeId, prop })).ToDictionary(tp => tp.typeId + "." + tp.prop.name, tp => tp.prop);
   //return allExs().
   //  Select(fn => new { fn, url = fn.Substring(Machines.rootDir.Length).Replace(".xml", null).Replace('\\', '/') }).
   //  Select(fn => pageObj.fromXml(fn.url, loadAndValidate(fn.fn), propsDir, smap));
   return smap.scan().Where(n => n is ex || n.type == runtimeType.mediaCutFile).Select(ex => xrefPageObj.fromXml(ex.url, CourseModel.tag.loadExerciseXml(ex.fileName(), sb), propsDir, smap));
 }
예제 #9
0
파일: Author.cs 프로젝트: PavelPZ/REW
 public static xrefPageObj fromXml(string url, XElement root, Dictionary<string, docProp> propDir, sitemap smap) {
   xrefPageObj res = new xrefPageObj { url = url };
   data sm; if (smap.TryGetValue(url, out sm)) res.sitemapParents = sm.parents(false).Select(p => p.uniqId).ToArray();
   var tit = root.Descendants("title").FirstOrDefault(); res.title = tit == null ? null : tit.Value;
   res.types = root.DescendantsAndSelf().Where(el => !ignTags.Contains(el.Name.LocalName)).Select(el => xrefTypeObj.fromXml(res, el, propDir)).ToArray();
   if (res.types.Length == 0) res.types = null;
   return res;
 }
예제 #10
0
파일: CourseVSNet.cs 프로젝트: PavelPZ/REW
 public serverContext(string ctxUrl, LoggerMemory logger) {
   url = ctxUrl;
   string fileName = ex.fileNameFromUrl(ctxUrl);
   //nacti actNode
   actNode = data.readObject<data>(fileName);
   //zjisti Line
   line = LineIds.no; data nd = actNode;
   while (true) {
     line = nd.line;
     if (line != LineIds.no) break;
     var parts = fileName.Split('\\'); fileName = parts.Take(parts.Length - 2).Aggregate((r, i) => r + "\\" + i) + "\\meta.xml";
     if (!File.Exists(fileName)) break;
     try {
       nd = data.readObject<data>(fileName);
     } catch (Exception exp) {
       throw new Exception("XML Error in " + fileName, exp);
     }
   }
   //vybuduj sitemap z actNode
   siteMap = new sitemap(actNode.url, logger, sitemap.fromFileSystem("/data/instr/std/", logger), sitemap.fromFileSystem("/data/instr/new/", logger));
   //if (actNode.isType(runtimeType.project)) XmlUtils.ObjectToFile(Path.ChangeExtension(fileName, ".sitemap"), siteMap);
 }