Пример #1
0
        public static Guid InsertNewWidget(Guid pageId, Guid widgetId, string langCode)
        {
            try
            {
                WidgetElement widget = WidgetSection.CachedInstance.Widgets.Cast <WidgetElement>().Where(w => w.Id == widgetId).Single();

                HitblWidgetInstanceIn newWidgetIns = new HitblWidgetInstanceIn();
                newWidgetIns.InsId              = Guid.NewGuid();
                newWidgetIns.InsColumnNo        = 0;
                newWidgetIns.InsCreatedDate     = newWidgetIns.InsLastUpdate = DateTime.Now;
                newWidgetIns.InsShowAfterInsert = 0;
                newWidgetIns.InsOrderNo         = 0;
                newWidgetIns.InsPagId           = pageId;
                newWidgetIns.InsXmlStateData    = widget.Settings.Value;
                newWidgetIns.WdgId              = widgetId;
                newWidgetIns.Save();

                HitblWidgetInstanceTextWit newWidgetInsTxt = new HitblWidgetInstanceTextWit();
                newWidgetInsTxt.InsId       = newWidgetIns.InsId;
                newWidgetInsTxt.WitLangCode = langCode;
                newWidgetInsTxt.WitTitle    = GuiLanguage.GetGuiLanguage("WidgetsBase").GetString(widget.TitleKey);
                newWidgetInsTxt.Save();

                SPs.HispMoveWidgetInstance(newWidgetIns.InsId, 0, 0).Execute();

                return(newWidgetIns.InsId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        public void Insert(Guid InsId, string WitLangCode, string WitTitle)
        {
            HitblWidgetInstanceTextWit item = new HitblWidgetInstanceTextWit();

            item.InsId = InsId;

            item.WitLangCode = WitLangCode;

            item.WitTitle = WitTitle;


            item.Save(UserName);
        }
Пример #3
0
        public void Update(Guid InsId, string WitLangCode, string WitTitle)
        {
            HitblWidgetInstanceTextWit item = new HitblWidgetInstanceTextWit();

            item.MarkOld();
            item.IsLoaded = true;

            item.InsId = InsId;

            item.WitLangCode = WitLangCode;

            item.WitTitle = WitTitle;

            item.Save(UserName);
        }
Пример #4
0
 public bool Destroy(object InsId)
 {
     return(HitblWidgetInstanceTextWit.Destroy(InsId) == 1);
 }
Пример #5
0
        public static void CreateDefaultWidgets(Guid pageId, string pageType, string page, string langCode)
        {
            XmlDocument  xmlDefaultWidgets = new XmlDocument();
            StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("/Configurations/DefaultWidgets.config"));

            xmlDefaultWidgets.LoadXml(sr.ReadToEnd());
            sr.Close();

            XmlNodeList xmlLayoutCols = xmlDefaultWidgets.SelectNodes(string.Format("//root/Community[@pageType='{0}' and @page='{1}']/Column", pageType, page));

            foreach (XmlNode xmlLayoutCol in xmlLayoutCols)
            {
                int         intColNr   = Convert.ToInt32(xmlLayoutCol.Attributes["number"].Value);
                XmlNodeList xmlWidgtes = xmlLayoutCol.SelectNodes("widget");
                int         intOrderNr = 0;
                foreach (XmlNode xmlWidget in xmlWidgtes)
                {
                    bool   isFixed                  = false;
                    bool   hideIfNoContent          = false;
                    string roleVisibility           = string.Empty;
                    string templateId               = string.Empty;
                    string outputTemplate           = string.Empty;
                    string localizationBaseFileName = string.Empty;
                    string titleKey                 = string.Empty;
                    if (xmlWidget.Attributes["IsFixed"] != null)
                    {
                        bool.TryParse(xmlWidget.Attributes["IsFixed"].Value, out isFixed);
                    }
                    if (xmlWidget.Attributes["HideIfNoContent"] != null)
                    {
                        bool.TryParse(xmlWidget.Attributes["HideIfNoContent"].Value, out hideIfNoContent);
                    }
                    if (xmlWidget.Attributes["ViewRoles"] != null)
                    {
                        roleVisibility = xmlWidget.Attributes["ViewRoles"].Value.Replace(',', Constants.TAG_DELIMITER);
                    }
                    if (xmlWidget.Attributes["WTP_ID"] != null)
                    {
                        templateId = xmlWidget.Attributes["WTP_ID"].Value;
                    }
                    if (xmlWidget.Attributes["OutputTemplate"] != null)
                    {
                        outputTemplate = xmlWidget.Attributes["OutputTemplate"].Value;
                    }
                    if (xmlWidget.Attributes["LocalizationBaseFileName"] != null)
                    {
                        localizationBaseFileName = xmlWidget.Attributes["LocalizationBaseFileName"].Value;
                    }
                    if (xmlWidget.Attributes["TitleKey"] != null)
                    {
                        titleKey = xmlWidget.Attributes["TitleKey"].Value;
                    }
                    Guid   widgetId          = new Guid(xmlWidget.Attributes["id"].Value);
                    string predefinedContent = string.Empty;
                    if (xmlWidget.HasChildNodes)
                    {
                        predefinedContent = xmlWidget.InnerText;
                    }
                    WidgetElement         widget       = WidgetSection.CachedInstance.Widgets.Cast <WidgetElement>().Where(w => w.Id == widgetId).Single();
                    HitblWidgetInstanceIn newWidgetIns = new HitblWidgetInstanceIn();
                    newWidgetIns.InsId              = Guid.NewGuid();
                    newWidgetIns.InsColumnNo        = intColNr;
                    newWidgetIns.InsCreatedDate     = newWidgetIns.InsLastUpdate = DateTime.Now;
                    newWidgetIns.InsShowAfterInsert = 0;
                    newWidgetIns.InsOrderNo         = intOrderNr;
                    newWidgetIns.InsPagId           = pageId;
                    newWidgetIns.InsIsFixed         = isFixed;
                    newWidgetIns.InsHideIfNoContent = hideIfNoContent;
                    newWidgetIns.InsViewRoles       = roleVisibility;
                    if (!string.IsNullOrEmpty(templateId))
                    {
                        newWidgetIns.WtpId = templateId.ToGuid();
                    }
                    if (!string.IsNullOrEmpty(outputTemplate))
                    {
                        newWidgetIns.InsOutputTemplate = outputTemplate.ToGuid();
                    }
                    else
                    {
                        string[] outputTemplates = new string[] { "" };
                        if (!string.IsNullOrEmpty(widget.OutputTemplates))
                        {
                            outputTemplates = widget.OutputTemplates.Split(';');
                        }
                        if (!string.IsNullOrEmpty(outputTemplates[0]))
                        {
                            newWidgetIns.InsOutputTemplate = outputTemplates[0].ToGuid();
                        }
                    }
                    newWidgetIns.InsXmlStateData = predefinedContent.Length == 0 ? widget.Settings.Value : predefinedContent;
                    newWidgetIns.WdgId           = widgetId;
                    newWidgetIns.Save();
                    HitblWidgetInstanceTextWit newWidgetInsTxt = new HitblWidgetInstanceTextWit();
                    newWidgetInsTxt.InsId       = newWidgetIns.InsId;
                    newWidgetInsTxt.WitLangCode = langCode;

                    if (!string.IsNullOrEmpty(localizationBaseFileName))
                    {
                        newWidgetInsTxt.WitTitle = GuiLanguage.GetGuiLanguage(localizationBaseFileName).GetString(titleKey);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(widget.LocalizationBaseFileName))
                        {
                            newWidgetInsTxt.WitTitle = GuiLanguage.GetGuiLanguage(widget.LocalizationBaseFileName).GetString(widget.TitleKey);
                        }
                        else
                        {
                            newWidgetInsTxt.WitTitle = GuiLanguage.GetGuiLanguage("WidgetsBase").GetString(widget.TitleKey);
                        }
                    }
                    newWidgetInsTxt.Save();

                    if (!string.IsNullOrEmpty(templateId))
                    {
                        SPs.HispWidgetTemplatesIncreaseCount(pageId, newWidgetIns.WtpId).Execute();
                    }
                    intOrderNr++;
                }
            }
        }