Example #1
0
        private object UpdateDetailData(Repeater rp1, string typeCode, string uploadFolderMapPath, string itemId = "0", string selUserId = "", string GUIDKey = "")
        {
            if (!Utils.IsNumeric(selUserId))
            {
                selUserId = UserId.ToString("");
            }

            var objInfo = new NBrightInfo();

            if (Utils.IsNumeric(GenXmlFunctions.GetHiddenField(rp1, "ItemID")))
            {
                itemId = GenXmlFunctions.GetHiddenField(rp1, "ItemID");
            }

            if (Utils.IsNumeric(itemId))
            {
                // read any existing data or create new.
                objInfo = ObjCtrl.Get(Convert.ToInt32(itemId));
                if (objInfo == null)
                {
                    objInfo = new NBrightInfo();
                    // populate data
                    objInfo.PortalId = PortalId;
                    objInfo.ModuleId = ModuleId;
                    objInfo.ItemID   = Convert.ToInt32(itemId);
                    objInfo.TypeCode = typeCode;
                    objInfo.UserId   = Convert.ToInt32(selUserId);
                    objInfo.GUIDKey  = GUIDKey;
                }

                // populate changed data
                GenXmlFunctions.SetHiddenField(rp1, "dteModifiedDate", Convert.ToString(DateTime.Now));
                objInfo.ModifiedDate = DateTime.Now;

                objInfo.UserId = Convert.ToInt32(selUserId);

                //rebuild xml
                objInfo.XMLData = GenXmlFunctions.GetGenXml(rp1, "", uploadFolderMapPath);

                //update GUIDKey
                if (GUIDKey != "")
                {
                    objInfo.GUIDKey = GUIDKey;
                }

                objInfo.ItemID = ((DataCtrlInterface)ObjCtrl).Update(objInfo);
            }
            return(objInfo);
        }
Example #2
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);
            }
        }
Example #3
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);
        }
Example #4
0
        public List <NBrightInfo> GetListByUserDataInfoVar(string typeCode, string webserviceurl = "")
        {
            try
            {
                var weblist     = new List <NBrightInfo>();
                var recordCount = 0;

                // in some ascx we want to run a wesvice on the OnLoad event, the base.OnLoad doesn;t allow us to pass the webservice url, so we can use this to override the normal function and force a webservice to be used.
                if (!string.IsNullOrEmpty(OverRideWebserviceUrl))
                {
                    webserviceurl = OverRideWebserviceUrl;
                }

                if (EntityTypeCode == "" && !string.IsNullOrEmpty(webserviceurl))
                {
                    // No EntityType, therefore data must be selected from WebService.
                    var l      = new List <NBrightInfo>();
                    var xmlDoc = new XmlDocument();

                    // pass the userdatainfo into the header request (saves using or creating a post field or adding to url)
                    var objInfo      = ObjCtrl.Get(UInfo.ItemId);
                    var userdatainfo = "";
                    if (objInfo != null)
                    {
                        if (objInfo.TypeCode == "USERDATAINFO")
                        {
                            //userdatainfo = DotNetNuke.Common.Globals.HTTPPOSTEncode(objInfo.XMLData);
                            userdatainfo = objInfo.XMLData;
                        }
                    }

                    string strResp = DnnUtils.GetDataResponseAsString(webserviceurl, "userdatainfo", userdatainfo);
                    try
                    {
                        xmlDoc.LoadXml(strResp);
                    }
                    catch (Exception)
                    {
                        return(null);
                    }

                    var rc = xmlDoc.SelectSingleNode("root/recordcount");
                    if (rc != null && Utils.IsNumeric(rc.InnerText))
                    {
                        recordCount = Convert.ToInt32(rc.InnerText);
                    }

                    var xmlNodeList = xmlDoc.SelectNodes("root/item");
                    if (xmlNodeList != null)
                    {
                        foreach (XmlNode xmlNod in xmlNodeList)
                        {
                            var obj = new NBrightInfo();
                            obj.FromXmlItem(xmlNod.OuterXml);
                            l.Add(obj);
                        }
                    }
                    weblist = l;
                    if (recordCount == 0)
                    {
                        recordCount = weblist.Count;
                    }
                }
                else
                {
                    if (OverRideInfoList != null)
                    {
                        recordCount = OverRideInfoList.Count;
                    }
                    else
                    {
                        recordCount = ObjCtrl.GetListCount(UInfo.SearchPortalId, UInfo.SearchModuleId, EntityTypeCode, UInfo.SearchFilters, EntityTypeCodeLang, EntityLangauge);
                    }
                }


                if (!Utils.IsNumeric(UInfo.SearchPageNumber))
                {
                    UInfo.SearchPageNumber = "1";
                }
                UInfo.SearchPageSize = GenXmlFunctions.GetHiddenField(CtrlSearch, "searchpagesize");
                if (UInfo.SearchPageSize == "")
                {
                    UInfo.SearchPageSize = GenXmlFunctions.GetHiddenField(CtrlSearch, "pagesize");
                }
                UInfo.SearchReturnLimit = GenXmlFunctions.GetHiddenField(CtrlSearch, "searchreturnlimit");
                if (!Utils.IsNumeric(UInfo.SearchPageSize))
                {
                    UInfo.SearchPageSize = "25";
                }
                if (!Utils.IsNumeric(UInfo.SearchReturnLimit))
                {
                    UInfo.SearchReturnLimit = "0";
                }

                if (_activatePaging)
                {
                    CtrlPaging.PageSize     = Convert.ToInt32(UInfo.SearchPageSize);
                    CtrlPaging.TotalRecords = recordCount;
                    CtrlPaging.CurrentPage  = Convert.ToInt32(UInfo.SearchPageNumber);
                    CtrlPaging.BindPageLinks();
                }
                else
                {
                    CtrlPaging.Visible = false;
                }

                if (UInfo.SearchClearAfter == "1")
                {
                    UInfo.ClearSearchData();
                }

                if (OverRideInfoList != null)
                {
                    //overiding list passed from control, so use linq to do the paging, select
                    var records = (from o in OverRideInfoList select o);

                    var pgNo  = Convert.ToInt32(UInfo.SearchPageNumber);
                    var pgRec = Convert.ToInt32(UInfo.SearchPageSize);

                    var rtnRecords = records.Skip((pgNo - 1) * pgRec).Take(pgRec).ToList();

                    return(rtnRecords);
                }

                if (EntityTypeCode == "" & webserviceurl != "")
                {
                    // use website (Might be empty).
                    return(weblist);
                }
                else
                {
                    var l = GetList(UInfo.SearchPortalId, UInfo.SearchModuleId, EntityTypeCode, UInfo.SearchFilters, UInfo.SearchOrderby, Convert.ToInt32(UInfo.SearchReturnLimit), Convert.ToInt32(UInfo.SearchPageNumber), Convert.ToInt32(UInfo.SearchPageSize), recordCount, EntityTypeCodeLang, EntityLangauge);
                    return(l);
                }
            }
            catch (Exception)
            {
                //clear data incase error in userdata
                UInfo.ClearSearchData();
                throw;
            }
        }