Esempio n. 1
0
        public void DeleteLinkedFiles(int itemId, string uploadFolder, string folderMapPath = "")
        {
            var obj = ObjCtrl.Get(itemId);

            if ((uploadFolder != "" | folderMapPath != "") & obj != null)
            {
                var fldr = PortalSettings.HomeDirectoryMapPath + uploadFolder;
                if (folderMapPath != "")
                {
                    fldr = folderMapPath;
                }
                obj.XMLData = GenXmlFunctions.DeleteFile(obj.XMLData, fldr);
                ObjCtrl.Update(obj);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Gets singe record of language Data.
        /// </summary>
        /// <param name="parentItemId">Parent itemId</param>
        /// <param name="lang">Entity langauge to select</param>
        /// <param name="seluserId">select by userid</param>
        /// <returns></returns>
        public NBrightInfo GetDataLang(int parentItemId, string lang = "", string seluserId = "")
        {
            if (lang == "")
            {
                lang = EntityLangauge;
            }
            var strFilter = " and NB1.parentitemid = '" + parentItemId + "' and ISNULL(NB2.[Lang],ISNULL(NB1.[Lang],'''')) =  '" + lang + "' ";

            if (seluserId != "")
            {
                strFilter += " and userid = '" + seluserId + "' ";
            }
            var l = GetList(PortalId, ModuleId, EntityTypeCodeLang, strFilter, "", 0);

            // START: FIX DATA ISSUES
            // In some cases we have a mismatch between the itemid of the record and the itemid in the XML data
            // I'm not sure how this happens (maybe import/export), but here we just make sure it's OK.
            NBrightInfo rtnObj = null;

            if (l.Count >= 1)
            {
                rtnObj = l[0];
                var i = rtnObj.GetXmlProperty("genxml/hidden/itemid");
                if (i != "" && i != rtnObj.ItemID.ToString("")) // record might not have a hidden itemid field.
                {
                    rtnObj.SetXmlProperty("genxml/hidden/itemid", rtnObj.ItemID.ToString(""));
                    ObjCtrl.Update(rtnObj); // fix record.
                }
            }
            // I think!! because of the above issue we might have multiple lang record, remove the invalid ones.
            if (l.Count >= 2)
            {
                for (int i = 1; i < l.Count; i++)
                {
                    NBrightInfo obj = l[i];
                    ObjCtrl.Delete(obj.ItemID);
                }
            }
            // END: FIX.

            return(rtnObj);
        }