Ejemplo n.º 1
0
        private string GetNavigationValue(bool ignoreCache)
        {
            CSBooster_DataContext csb = new CSBooster_DataContext(Helper.GetSiemeConnectionString());

            string CacheKey = string.Format("{0}_{1}_{2}_{3}", NavigationID, CultureHandler.GetCurrentNeutralLanguageCode().ToLower(), udc.UserRole.ToLower(), (int)NavType);
            string navXml   = Cache[CacheKey] as string;

            if (navXml == null || ignoreCache)
            {
                navXml = "<Tree/>";
                var Navi = csb.hisp_Navigation_GetPreChache(NavigationID.ToGuid(), CultureHandler.GetCurrentNeutralLanguageCode(), udc.UserRole).FirstOrDefault();
                if (Navi != null)
                {
                    navXml = Navi.NPC_PreCacheXML;
                }
                navXml = DataAccess.Business.Navigation.TranformXML(navXml, NavType);
                Cache.Insert(CacheKey, navXml);
            }
            UserDataInfo udi = Cache["UID_" + udc.UserID] as UserDataInfo;

            if (udi == null || ignoreCache)
            {
                udi = new UserDataInfo(udc.UserID);
                Cache.Insert("UID_" + udc.UserID, udi, null, DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration);
            }
            navXml = navXml.Replace("##NEW_MAIL_COUNT##", udi.UnreadMessagesCount.ToString()).Replace("##FRIEND_REQUEST_COUNT##", udi.FriendRequestCount.ToString()).Replace("##ALERT_COUNT##", udi.AlertCount.ToString());
            navXml = navXml.Replace("##CURRENT_PAGE##", Server.UrlEncode(Request.Url.PathAndQuery));
            return(navXml);
        }
Ejemplo n.º 2
0
        private void AddNavNode(string nodeText, string nodeValue, string parentNodeValue)
        {
            Guid currentNavId         = new Guid(hidCurrNavID.Value);
            CSBooster_DataContext csb = new CSBooster_DataContext(Helper.GetSiemeConnectionString());

            hidParentNodeId.Value = parentNodeValue;
            //Savte the Current Node in the struct XML
            var navStructureRecord = csb.hisp_Navigation_GetNavigationStructureXML(currentNavId).SingleOrDefault();

            if (navStructureRecord != null)
            {
                XElement xmlStruct  = XElement.Parse(navStructureRecord.NST_XMLStruct);
                var      parentNode = (from theNodes in xmlStruct.Descendants("Node").Where(x => x.Attribute("Value").Value == parentNodeValue)
                                       select theNodes).SingleOrDefault();
                if (parentNode != null)
                {
                    parentNode.Add(new XElement("Node", new XAttribute("Text", nodeText), new XAttribute("Value", nodeValue)));
                }
                else
                {
                    //The Parent Node is the Root... add it to the Tree
                    xmlStruct.Add(new XElement("Node", new XAttribute("Text", nodeText), new XAttribute("Value", nodeValue)));
                }
                csb.hisp_Navigation_SaveNavigationStructure(currentNavId, null, xmlStruct.ToString());
                lbtnG.Text     = language.GetString("TooltipNotSynchronized");
                lbtnG.CssClass = "icon navnotsynchro";


                var navLanguageRecord = csb.hisp_Navigation_GetNavigationLanguageXML(currentNavId, CultureHandler.GetCurrentNeutralLanguageCode()).SingleOrDefault();
                if (navLanguageRecord != null)
                {
                    XElement xmlLanguage = XElement.Parse(navLanguageRecord.NAV_XMLNames);
                    var      langNode    = (from theLangNodes in xmlLanguage.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                            select theLangNodes).SingleOrDefault();
                    if (langNode == null)
                    {
                        xmlLanguage.Add(new XElement(new XElement("Node", new XAttribute("Text", nodeText), new XAttribute("Value", nodeValue))));
                    }
                    else
                    {
                        //Should never happen...
                        langNode.Attribute("Text").Value = nodeText;
                    }
                    csb.hisp_Navigation_SaveNavigationLanguage(currentNavId, CultureHandler.GetCurrentNeutralLanguageCode(), xmlLanguage.ToString(), string.Empty);
                }
                else
                {
                    csb.hisp_Navigation_SaveNavigationLanguage(currentNavId, CultureHandler.GetCurrentNeutralLanguageCode(), "<Tree/>", string.Empty);
                }
            }
        }
Ejemplo n.º 3
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     currentNeutralLanguage = CultureHandler.GetCurrentNeutralLanguageCode();
     ci = new CultureInfo(currentNeutralLanguage);
     LoadDdlLangs(currentNeutralLanguage);
     navId     = new Guid(Request.QueryString["NAV"]);
     nodeValue = Request.QueryString["NID"];
     LoadCurrent();
     if (!Page.IsPostBack)
     {
         LoadTranslation();
     }
 }
Ejemplo n.º 4
0
        protected void lbtnSaveNode_Click(object sender, EventArgs e)
        {
            Guid   currentNavId       = new Guid(hidCurrNavID.Value);
            string nodeValue          = Request.Form[hidCurrentNodeValue.UniqueID];
            CSBooster_DataContext csb = new CSBooster_DataContext(Helper.GetSiemeConnectionString());
            XElement xmlLanguageNode;
            var      navStructureRecord = csb.hisp_Navigation_GetNavigationStructureXML(currentNavId).SingleOrDefault();
            var      navLanguageRecord  = csb.hisp_Navigation_GetNavigationLanguageXML(currentNavId, CultureHandler.GetCurrentNeutralLanguageCode()).SingleOrDefault();

            if (navStructureRecord != null)
            {
                XElement xmlStruct = XElement.Parse(navStructureRecord.NST_XMLStruct);
                XElement xmlLanguage;
                XElement xmlStructNode = (from xmlStructNodes in xmlStruct.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                          select xmlStructNodes).SingleOrDefault();

                if (navLanguageRecord != null)
                {
                    xmlLanguage     = XElement.Parse(navLanguageRecord.NAV_XMLNames);
                    xmlLanguageNode = (from xmlLanguageNodes in xmlLanguage.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                       select xmlLanguageNodes).SingleOrDefault();
                    if (xmlLanguageNode == null)
                    {
                        xmlLanguageNode = XElement.Parse(string.Format(@"<Node Text='' Value='{0}'/>", nodeValue));
                        xmlLanguage.Add(xmlLanguageNode);
                    }
                }
                else
                {
                    xmlLanguage     = XElement.Parse(string.Format(@"<Tree><Node Text='' Value='{0}'/></Tree>", nodeValue));
                    xmlLanguageNode = xmlLanguage.Nodes().OfType <XElement>().FirstOrDefault();
                }
                if (rcRoles.Items.Count == 0)
                {
                    LoadRolesCombobox(xmlStructNode);
                }
                if (rcLinks.Items.Count == 1)
                {
                    LoadPredefinedUrls();
                }
                xmlStructNode.SetAttributeValue("Text", Request.Form[txtText.UniqueID]);
                xmlStructNode.SetAttributeValue("Tooltip", Request.Form[txtTextTool.UniqueID]);
                xmlStructNode.SetAttributeValue("Value", nodeValue);
                xmlStructNode.SetAttributeValue("RolesVisibility", GetRoleVisibility());
                //Attention RadCombobox Returns the text and not the Value of the selected Combo
                xmlStructNode.SetAttributeValue("Target", rcTarget.FindItemByText(Request.Form[rcTarget.UniqueID]).Value);

                xmlLanguageNode.SetAttributeValue("Text", Request.Form[txtText.UniqueID]);
                xmlLanguageNode.SetAttributeValue("Tooltip", Request.Form[txtTextTool.UniqueID]);
                xmlLanguageNode.SetAttributeValue("Value", nodeValue);

                string rcLinksSelectedVal = GetRadComboboxValue(rcLinks);

                if (rcLinksSelectedVal == "URL")
                {
                    string url = Request.Form[txtUrl.UniqueID];
                    xmlLanguageNode.SetAttributeValue("NavigateUrl", url);
                    xmlStructNode.SetAttributeValue("ObjectUrl", string.Empty);
                    xmlStructNode.SetAttributeValue("PredefinedUrl", string.Empty);
                }
                else if (rcLinksSelectedVal.StartsWith("OT_"))
                {
                    string url = Request.Form[txtUrl.UniqueID];
                    xmlLanguageNode.SetAttributeValue("NavigateUrl", url);
                    xmlStructNode.SetAttributeValue("ObjectUrl", rcLinksSelectedVal.Substring(3));
                    xmlStructNode.SetAttributeValue("PredefinedUrl", string.Empty);
                }
                else
                {
                    var xPredefinedNavies = Constants.Links[rcLinksSelectedVal];
                    if (xPredefinedNavies != null)
                    {
                        string url = xPredefinedNavies.Url;
                        xmlLanguageNode.SetAttributeValue("NavigateUrl", url);
                        string localizationBaseFileName = "Navigation";
                        if (!string.IsNullOrEmpty(xPredefinedNavies.LocalizationBaseFileName))
                        {
                            localizationBaseFileName = xPredefinedNavies.LocalizationBaseFileName;
                        }

                        xmlLanguageNode.SetAttributeValue("Text", GuiLanguage.GetGuiLanguage(localizationBaseFileName).GetString(xPredefinedNavies.UrlTextKey) ?? Request.Form[txtText.UniqueID]);
                    }
                    else
                    {
                        xmlLanguageNode.SetAttributeValue("NavigateUrl", null);
                    }
                    xmlStructNode.SetAttributeValue("PredefinedUrl", rcLinksSelectedVal);
                    xmlStructNode.SetAttributeValue("ObjectUrl", string.Empty);
                }
                csb.hisp_Navigation_SaveNavigationStructure(currentNavId, null, xmlStruct.ToString());
                lbtnG.Text     = language.GetString("TooltipNotSynchronized");
                lbtnG.CssClass = "icon navnotsynchro";

                csb.hisp_Navigation_SaveNavigationLanguage(currentNavId, CultureHandler.GetCurrentNeutralLanguageCode(), xmlLanguage.ToString(), string.Empty);
                rtv1.SelectedNode.Text = xmlLanguageNode.Attribute("Text").Value;
                ShowNodeEdit(Request.Form[hidCurrentNodeValue.UniqueID], true);
            }
        }
Ejemplo n.º 5
0
        private void ShowNodeEdit(string nodeValue, bool updateValues)
        {
            pnlNavNodeProp.Visible  = true;
            pnlNaviNameEdit.Visible = false;
            Guid currentNavId           = new Guid(hidCurrNavID.Value);
            CSBooster_DataContext csb   = new CSBooster_DataContext(Helper.GetSiemeConnectionString());
            XElement xmlStructNode      = null;
            XElement xmlLanguageNode    = null;
            var      navStructureRecord = csb.hisp_Navigation_GetNavigationStructureXML(currentNavId).SingleOrDefault();
            var      navLanguageRecord  = csb.hisp_Navigation_GetNavigationLanguageXML(currentNavId, CultureHandler.GetCurrentNeutralLanguageCode()).SingleOrDefault();

            if (navStructureRecord != null)
            {
                XElement xmlStruct = XElement.Parse(navStructureRecord.NST_XMLStruct);
                xmlStructNode = (from xmlStructNodes in xmlStruct.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                 select xmlStructNodes).SingleOrDefault();

                if (navLanguageRecord != null)
                {
                    XElement xmlLanguage = XElement.Parse(navLanguageRecord.NAV_XMLNames);
                    xmlLanguageNode = (from xmlLanguageNodes in xmlLanguage.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                       select xmlLanguageNodes).SingleOrDefault() ?? XElement.Parse(string.Format(@"<Node Text='' Value='{0}'/>", nodeValue));
                }
                else
                {
                    xmlLanguageNode = XElement.Parse(string.Format(@"<Node Text='' Value='{0}'/>", nodeValue));
                }
            }
            LoadRolesCombobox(xmlStructNode);
            txtText.Text = xmlLanguageNode.Attribute("Text") != null?xmlLanguageNode.Attribute("Text").Value : string.Empty;

            txtTextTool.Text = xmlLanguageNode.Attribute("Tooltip") != null?xmlLanguageNode.Attribute("Tooltip").Value : string.Empty;

            string target = xmlStructNode.Attribute("Target") != null?xmlStructNode.Attribute("Target").Value : "_self";

            rcTarget.SelectedIndex = rcTarget.Items.FindItemIndexByValue(target);
            LoadPredefinedUrls();
            if (updateValues)
            {
                if ((xmlStructNode.Attribute("PredefinedUrl") == null || xmlStructNode.Attribute("PredefinedUrl").Value == "") &&
                    (xmlStructNode.Attribute("ObjectUrl") == null || string.IsNullOrEmpty(xmlStructNode.Attribute("ObjectUrl").Value)))
                {
                    //Neither Predeifined nor link to an object
                    rcLinks.SelectedIndex = 0;
                    if (xmlLanguageNode.Attribute("NavigateUrl") != null && !string.IsNullOrEmpty(xmlLanguageNode.Attribute("NavigateUrl").Value))
                    {
                        txtUrl.Text = xmlLanguageNode.Attribute("NavigateUrl").Value;
                    }
                    else
                    {
                        txtUrl.Text = string.Empty;
                    }
                    txtUrl.Visible = true;
                    pnlLinkPicker.Controls.Clear();
                }
                else if (xmlStructNode.Attribute("ObjectUrl") != null && !string.IsNullOrEmpty(xmlStructNode.Attribute("ObjectUrl").Value))
                {
                    //link to an object
                    rcLinks.SelectedIndex = rcLinks.Items.FindItemIndexByValue("OT_" + xmlStructNode.Attribute("ObjectUrl").Value);
                    if (xmlLanguageNode.Attribute("NavigateUrl") != null && !string.IsNullOrEmpty(xmlLanguageNode.Attribute("NavigateUrl").Value))
                    {
                        txtUrl.Text = xmlLanguageNode.Attribute("NavigateUrl").Value;
                    }
                    else
                    {
                        txtUrl.Text = string.Empty;
                    }

                    txtUrl.Visible = true;
                    RcLinkSingleObjectType(xmlStructNode.Attribute("ObjectUrl").Value);
                }
                else
                {
                    pnlLinkPicker.Controls.Clear();
                    //Predeifined
                    try
                    {
                        try
                        {
                            txtUrl.Attributes.Remove("style");
                        }
                        catch
                        {
                        }
                        txtUrl.Attributes.Add("style", "display:none;visibility:hidden;");
                        txtUrl.Text = string.Empty;
                    }
                    catch
                    {
                        rcLinks.SelectedIndex = 0;
                        txtUrl.Text           = string.Empty;
                        txtUrl.Visible        = true;
                    }
                }
            }
            lbtnT.NavigateUrl = string.Format("javascript:radWinOpen('/Pages/Popups/NavigationTranslate.aspx?NAV={0}&NID={1}&Target={2}', 'Navigation', 550, 400, true)", currentNavId, nodeValue, "NodeTrans");

            lbtnT.Visible = SiteConfig.NeutralLanguages.Count > 1;
        }
Ejemplo n.º 6
0
        private void LoadNaviTree(Guid?navTreeId)
        {
            //Load The structure of the Navigation
            CSBooster_DataContext csb         = new CSBooster_DataContext(Helper.GetSiemeConnectionString());
            XDocument             xNavigation = new XDocument();

            if (navTreeId.HasValue)
            {
                hidCurrNavID.Value = navTreeId.ToString();
                var navStructureRecord = csb.hisp_Navigation_GetNavigationStructureXML(navTreeId).SingleOrDefault();
                var navLanguageRecord  = csb.hisp_Navigation_GetNavigationLanguageXML(navTreeId, CultureHandler.GetCurrentNeutralLanguageCode()).SingleOrDefault();
                if (navStructureRecord != null)
                {
                    XElement xmlStruct = XElement.Parse(navStructureRecord.NST_XMLStruct);

                    XElement xmlLanguage = navLanguageRecord != null?XElement.Parse(navLanguageRecord.NAV_XMLNames) : XElement.Parse(@"<Tree/>");

                    xNavigation = new XDocument();
                    XElement xRoot           = new XElement("Tree");
                    XElement xCurrentParrent = new XElement("Node", new XAttribute("Text", csb.hisp_Navigation_GetNavigationKeyName(navTreeId).SingleOrDefault().NST_KeyName), new XAttribute("Value", navTreeId.ToString()));

                    foreach (var xnode in xmlStruct.Elements("Node"))
                    {
                        XElement xnewChild = DataAccess.Business.Navigation.ReplaceData(xnode, xmlLanguage, true);
                        if (xnewChild != null)
                        {
                            xCurrentParrent.Add(xnewChild);
                        }
                    }

                    xRoot.Add(xCurrentParrent);
                    xNavigation.Add(xRoot);
                    if (navStructureRecord.NST_IsDirty)
                    {
                        lbtnG.Text     = language.GetString("TooltipNotSynchronized");
                        lbtnG.CssClass = "icon navnotsynchro";
                    }
                    else
                    {
                        lbtnG.Text     = language.GetString("TooltipSynchronized");
                        lbtnG.CssClass = "icon navsynchro";
                    }
                }
            }
            else
            {
                navTreeId          = Guid.NewGuid();
                hidCurrNavID.Value = navTreeId.ToString();
                xNavigation        = XDocument.Parse(string.Format(@"<Tree><Node Text=""Neue Navigation"" Value=""{0}""/></Tree>", hidCurrNavID.Value));
                //Create a New Navigation
                XDocument xStruct = new XDocument(
                    new XElement("Tree"));
                XDocument xLang = new XDocument(
                    new XElement("Tree"));
                csb.hisp_Navigation_SaveNavigationStructure(navTreeId, "Neue Navigation", xStruct.ToString());
                lbtnG.Text     = language.GetString("TooltipNotSynchronized");
                lbtnG.CssClass = "icon navnotsynchro";

                csb.hisp_Navigation_SaveNavigationLanguage(navTreeId, CultureHandler.GetCurrentNeutralLanguageCode(), xLang.ToString(), string.Empty);
                lbtnG.Text     = language.GetString("TooltipSynchronized");
                lbtnG.CssClass = "icon navnotsynchro";
            }
            rtv1.LoadXmlString(xNavigation.ToString());
            rtv1.Nodes[0].EnableContextMenu = true;
            rtv1.Nodes[0].ContextMenuID     = rtvCMRoot.ID;
        }
Ejemplo n.º 7
0
        private void LoadCurrent()
        {
            CSBooster_DataContext csb = new CSBooster_DataContext(Helper.GetSiemeConnectionString());
            XElement xmlLanguageNode  = null;

            litCurrLang.Text = ci.NativeName;
            var navStructureRecord = csb.hisp_Navigation_GetNavigationStructureXML(navId).SingleOrDefault();
            var navLanguageRecord  = csb.hisp_Navigation_GetNavigationLanguageXML(navId, CultureHandler.GetCurrentNeutralLanguageCode()).SingleOrDefault();

            XElement xmlStruct     = XElement.Parse(navStructureRecord.NST_XMLStruct);
            XElement xmlStructNode = (from xmlStructNodes in xmlStruct.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                      select xmlStructNodes).SingleOrDefault();

            if (navLanguageRecord != null)
            {
                XElement xmlLanguage = XElement.Parse(navLanguageRecord.NAV_XMLNames);
                xmlLanguageNode = (from xmlLanguageNodes in xmlLanguage.Descendants("Node").Where(x => x.Attribute("Value").Value == nodeValue)
                                   select xmlLanguageNodes).SingleOrDefault();
            }
            if (xmlLanguageNode != null)
            {
                litText.Text = xmlLanguageNode.Attribute("Text") != null?xmlLanguageNode.Attribute("Text").Value : string.Empty;

                litTooltip.Text = xmlLanguageNode.Attribute("Tooltip") != null?xmlLanguageNode.Attribute("Tooltip").Value : string.Empty;

                if (xmlStructNode.Attribute("PredefinedUrl") == null || string.IsNullOrEmpty(xmlStructNode.Attribute("PredefinedUrl").Value))
                {
                    litLink.Text = xmlLanguageNode.Attribute("NavigateUrl") != null?xmlLanguageNode.Attribute("NavigateUrl").Value : string.Empty;
                }
                else
                {
                    litLink.Text = " Vordefiniert ";
                }
            }
        }