Esempio n. 1
0
 public static Boolean ValidateLangaugeRef(int portalId, int categoryId)
 {
     var updaterequired = false;
     foreach (var lang in DnnUtils.GetCultureCodeList(portalId))
     {
         var objCtrl = new NBrightBuyController();
         var parentCatData = GetCategoryData(categoryId, lang);
         var grpCatCtrl = new GrpCatController(lang);
         var newGuidKey = grpCatCtrl.GetBreadCrumb(categoryId, 0, "-", false);
         if (newGuidKey != "") newGuidKey = GetUniqueGuidKey(portalId, categoryId, Utils.UrlFriendly(newGuidKey)).ToLower();
         if (parentCatData.DataLangRecord.GUIDKey != newGuidKey)
         {
             parentCatData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryref", newGuidKey);
             parentCatData.DataLangRecord.GUIDKey = newGuidKey;
             objCtrl.Update(parentCatData.DataLangRecord);
             updaterequired = true;
             // need to update all children, so call validate recursive.
             foreach (var ch in parentCatData.GetDirectChildren())
             {
                 if (ch.ItemID != categoryId) ValidateLangaugeRef(portalId, ch.ItemID);
             }
         }
     }
     return updaterequired;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="portalfinfo"></param>
        /// <returns></returns>
        public override string DoWork()
        {
            try
            {
                var objCtrl = new NBrightBuyController();

                // the sceduler runs at host level, we therefore need to loop through ALL portals to process data at a portal level.
                var portalList = NBrightDNN.DnnUtils.GetAllPortals();
                foreach (var portal in portalList)
                {
                    // check if we have NBS in this portal by looking for default settings.
                    var nbssetting = objCtrl.GetByGuidKey(portal.PortalID, -1, "SETTINGS", "NBrightBuySettings");
                    if (nbssetting != null)
                    {
                        var storeSettings = new StoreSettings(portal.PortalID);
                        var pluginData = new PluginData(portal.PortalID); // get plugin data to see if this scheduler is active on this portal
                        var plugin = pluginData.GetPluginByCtrl("dnnsearchindex");
                        if (plugin != null && plugin.GetXmlPropertyBool("genxml/checkbox/active"))
                        {
                            // The NBS scheduler is normally set to run hourly, therefore if we only want a process to run daily we need the logic this function.
                            // To to this we keep a last run flag on the sceduler settings
                            var setting = objCtrl.GetByGuidKey(portal.PortalID, -1, "DNNIDXSCHEDULER", "DNNIDXSCHEDULER");
                            if (setting == null)
                            {
                                setting = new NBrightInfo(true);
                                setting.ItemID = -1;
                                setting.PortalId = portal.PortalID;
                                setting.TypeCode = "DNNIDXSCHEDULER";
                                setting.GUIDKey = "DNNIDXSCHEDULER";
                                setting.ModuleId = -1;
                                setting.XMLData = "<genxml></genxml>";
                            }

                            var lastrun = setting.GetXmlPropertyRaw("genxml/lastrun");
                            var lastrundate = DateTime.Now.AddYears(-99);
                            if (Utils.IsDate(lastrun)) lastrundate = Convert.ToDateTime(lastrun);

                            var rtnmsg = DoProductIdx(portal, lastrundate, storeSettings.DebugMode);
                            setting.SetXmlProperty("genxml/lastrun", DateTime.Now.ToString("s"), TypeCode.DateTime);
                            objCtrl.Update(setting);
                            if (rtnmsg != "") return rtnmsg;

                        }
                    }

                }

                return " - NBS-DNNIDX scheduler OK ";
            }
            catch (Exception ex)
            {
                return " - NBS-DNNIDX scheduler FAIL: " + ex.ToString() + " : ";
            }
        }
Esempio n. 3
0
        public static void ResequenceRecords()
        {
            var objCtrl = new NBrightBuyController();
            var pdata   = PluginUtils.GetPluginList();
            var lp      = 0;

            foreach (var p in pdata)
            {
                p.SetXmlProperty("genxml/hidden/index", lp.ToString(), TypeCode.Double);
                objCtrl.Update(p);
                lp += 1;
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Save cart
 /// </summary>
 public void Save(Boolean debugMode = false)
 {
     if (Info != null)
     {
         var modCtrl = new NBrightBuyController();
         Info.ItemID = modCtrl.Update(Info);
         if (StoreSettings.Current.DebugModeFileOut)
         {
             Info.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_userdata.xml");
         }
         Exists = true;
     }
 }
Esempio n. 5
0
        public string SavePluginSinglePageData(HttpContext context)
        {
            try
            {
                var objCtrl = new NBrightBuyController();

                //get uploaded params
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                var lang     = NBrightBuyUtils.SetContextLangauge(ajaxInfo); // Ajax breaks context with DNN, so reset the context language to match the client.
                var editlang = NBrightBuyUtils.GetEditLang(ajaxInfo);

                var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
                if (Utils.IsNumeric(itemid))
                {
                    var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                    if (nbi != null)
                    {
                        // get data passed back by ajax
                        var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                        // update record with ajax data
                        nbi.UpdateAjax(strIn);
                        objCtrl.Update(nbi);

                        // do langauge record
                        var nbi2 = objCtrl.GetDataLang(Convert.ToInt32(itemid), editlang);
                        nbi2.UpdateAjax(strIn);
                        objCtrl.Update(nbi2);
                    }
                    DataCache.ClearCache(); // clear ALL cache.
                }
                return("");
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Esempio n. 6
0
        public static void DeleteFriendlyImages(int productid)
        {
            var objCtrl          = new NBrightBuyController();
            var productImgFolder = StoreSettings.Current.FolderImagesMapPath.TrimEnd('\\') + "\\" + productid;

            Utils.DeleteFolder(productImgFolder, true);
            var list = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "PRDLANG", " and NB1.ParentItemId = " + productid);

            foreach (var i in list)
            {
                i.RemoveXmlNode("genxml/hidden/imageurl");
                i.RemoveXmlNode("genxml/hidden/imagepath");
                objCtrl.Update(i);
            }
        }
Esempio n. 7
0
        public static void CopySystemPluginsToPortal()
        {
            var objCtrl = new NBrightBuyController();
            var rtnList = objCtrl.GetList(99999, -1, "PLUGIN", "", "order by nb1.xmldata.value('(genxml/hidden/index)[1]','float')");

            foreach (var p in rtnList)
            {
                var existingrecord = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PLUGIN", p.GUIDKey);
                if (existingrecord == null)
                {
                    p.ItemID   = -1;
                    p.PortalId = PortalSettings.Current.PortalId;
                    objCtrl.Update(p);
                }
            }
            PluginUtils.ResequenceRecords();
        }
Esempio n. 8
0
        private static void CreateDBrecords(List <NBrightInfo> pluginList, int portalId)
        {
            var objCtrl = new NBrightBuyController();

            foreach (var p in pluginList)
            {
                p.ItemID       = -1;
                p.GUIDKey      = p.GetXmlProperty("genxml/textbox/ctrl");
                p.PortalId     = portalId;
                p.Lang         = "";
                p.ParentItemId = 0;
                p.ModuleId     = -1;
                p.XrefItemId   = 0;
                p.UserId       = 0;
                p.TypeCode     = "PLUGIN";

                p.SetXmlProperty("genxml/hidden/index", p.GetXmlPropertyDouble("genxml/hidden/index").ToString("00.0"), TypeCode.Double);

                var interfaces = p.XMLDoc.SelectNodes("genxml/interfaces/*");
                if (interfaces.Count == 0)
                {
                    // possible legacy format, change.
                    p.SetXmlProperty("genxml/interfaces", "");
                    p.SetXmlProperty("genxml/interfaces/genxml", "");
                    p.SetXmlProperty("genxml/interfaces/genxml/dropdownlist", "");
                    p.SetXmlProperty("genxml/interfaces/genxml/checkbox", "");
                    p.SetXmlProperty("genxml/interfaces/genxml/textbox", "");
                    p.SetXmlProperty("genxml/interfaces/genxml/dropdownlist/providertype", p.GetXmlProperty("genxml/dropdownlist/providertype"));
                    p.SetXmlProperty("genxml/interfaces/genxml/checkbox/active", p.GetXmlProperty("genxml/checkbox/active"));
                    p.SetXmlProperty("genxml/interfaces/genxml/textbox/namespaceclass", p.GetXmlProperty("genxml/textbox/namespaceclass"));
                    p.SetXmlProperty("genxml/interfaces/genxml/textbox/assembly", p.GetXmlProperty("genxml/textbox/assembly"));
                }

                // check if record exists (should NOT) but lets replace if it does.
                var existingrecord = objCtrl.GetByGuidKey(portalId, -1, "PLUGIN", p.GUIDKey);
                if (existingrecord != null)
                {
                    p.ItemID = existingrecord.ItemID;
                }
                objCtrl.Update(p);
            }
        }
Esempio n. 9
0
        private void AddCatCascadeRecord(int categoryid, int productid)
        {
            var strGuid = categoryid.ToString("") + "x" + productid.ToString("");
            var nbi     = _objCtrl.GetByGuidKey(_portalId, -1, "CATCASCADE", strGuid);

            if (nbi == null)
            {
                nbi              = new NBrightInfo();
                nbi.ItemID       = -1;
                nbi.PortalId     = _portalId;
                nbi.ModuleId     = -1;
                nbi.TypeCode     = "CATCASCADE";
                nbi.XrefItemId   = categoryid;
                nbi.ParentItemId = productid;
                nbi.XMLData      = null;
                nbi.TextData     = null;
                nbi.Lang         = null;
                nbi.GUIDKey      = strGuid;
                _objCtrl.Update(nbi);
            }
        }
Esempio n. 10
0
        public void Update(NBrightInfo updateInfo)
        {
            // update email
            var email = updateInfo.GetXmlProperty("genxml/textbox/email");

            if (_userInfo != null && Utils.IsEmail(email) && (_userInfo.Email != email))
            {
                _userInfo.Email = email;
                UserController.UpdateUser(PortalSettings.Current.PortalId, _userInfo);
            }

            // ClientEditorRole
            var clientEditorRole = updateInfo.GetXmlProperty("genxml/checkbox/clienteditorrole");

            if (clientEditorRole == "True")
            {
                AddClientEditorRole();
            }
            else
            {
                RemoveClientEditorRole();
            }

            // save client data fields.
            var objCtrl = new NBrightBuyController();

            DataRecord         = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString(""));
            DataRecord.XMLData = updateInfo.XMLData;
            DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatediscountcodedata");
            DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatevouchercodedata");
            objCtrl.Update(DataRecord);

            // update Discount codes
            var strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatediscountcodedata"));

            UpdateDiscountCodes(strXml);
            strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatevouchercodedata"));
            UpdateVoucherCodes(strXml);
        }
Esempio n. 11
0
        private void DoImport(NBrightInfo nbi)
        {
            var fname = StoreSettings.Current.FolderTempMapPath + "\\" + nbi.GetXmlProperty("genxml/hidden/hiddatafile");
            if (System.IO.File.Exists(fname))
            {
                var xmlFile = new XmlDocument();
                try
                {
                    xmlFile.Load(fname);
                }
                catch (Exception e)
                {
                    Exceptions.LogException(e);
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, "xmlloadfail", NotifyCode.fail, ControlPath + "/App_LocalResources/Import.ascx.resx");
                    return;
                }

                // Ref old cat id , id new cat
                ////////////////////////////////////////////////////////////////////////////
                Dictionary<string, int> categoryListIDGiud = new Dictionary<string, int>();
                Dictionary<int, int> categoryListIDFather = new Dictionary<int, int>();
                ///////////////////////////////////////////////////////////////////////////

                var objCtrl = new NBrightBuyController();

                // get all valid languages
                var langList = DnnUtils.GetCultureCodeList(PortalId);
                foreach (var lang in langList)
                {

                    //Import Categories

                    #region "categories"

                    var nodList = xmlFile.SelectNodes("root/categories/" + lang + "/NB_Store_CategoriesInfo");
                    if (nodList != null)
                    {
                        var categoryid = -1;
                        foreach (XmlNode nod in nodList)
                        {
                            try
                            {

                                //if category Id exist replage guidKey
                                var guidKeyNod = nod.SelectSingleNode("CategoryID").InnerText;
                                if (guidKeyNod != null)
                                {

                                    var guidKey = guidKeyNod;
                                    categoryid = -1;
                                    // see if category already exists (update if so)
                                    var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATEGORY", guidKey);
                                    if (nbiImport != null) categoryid = nbiImport.ItemID;
                                    var CategoryData = new CategoryData(categoryid, lang);

                                    // clear down existing XML data
                                    var i = new NBrightInfo(true);
                                    i.PortalId = PortalSettings.Current.PortalId;
                                    CategoryData.DataRecord.XMLData = i.XMLData;
                                    CategoryData.DataLangRecord.XMLData = i.XMLData;

                                    // assign guidkey to legacy productid (guidKey)
                                    CategoryData.DataRecord.GUIDKey = guidKey;
                                    CategoryData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", guidKey);

                                    // do mapping of XML data
                                    // DATA FIELDS
                                    var cD_CategoryID = nod.SelectSingleNode("CategoryID").InnerText;
                                    var cD_PortalID = nod.SelectSingleNode("PortalID").InnerText;
                                    var cD_Archived = nod.SelectSingleNode("Archived").InnerText;
                                    var cD_Hide = nod.SelectSingleNode("Hide").InnerText;
                                    var cD_CreatedByUser = nod.SelectSingleNode("CreatedByUser").InnerText;
                                    var cD_CreatedDate = nod.SelectSingleNode("CreatedDate").InnerText;
                                    var cD_ParentCategoryID = nod.SelectSingleNode("ParentCategoryID").InnerText;
                                    var cD_ListOrder = nod.SelectSingleNode("ListOrder").InnerText;
                                    var cD_Lang = nod.SelectSingleNode("Lang").InnerText;
                                    var cD_ProductCount = nod.SelectSingleNode("ProductCount").InnerText;
                                    var cD_ProductTemplate = nod.SelectSingleNode("ProductTemplate").InnerText;
                                    var cD_ListItemTemplate = nod.SelectSingleNode("ListItemTemplate").InnerText;
                                    var cD_ListAltItemTemplate = nod.SelectSingleNode("ListAltItemTemplate").InnerText;
                                    var cD_ImageURL = nod.SelectSingleNode("ImageURL").InnerText;

                                    // DATA LANG FIELDS
                                    var cL_CategoryName = nod.SelectSingleNode("CategoryName").InnerText;
                                    var cL_ParentName = nod.SelectSingleNode("ParentName").InnerText;
                                    var cL_CategoryDesc = nod.SelectSingleNode("CategoryDesc").InnerText;
                                    var cL_Message = nod.SelectSingleNode("Message").InnerText;
                                    var cL_SEOPageTitle = nod.SelectSingleNode("SEOPageTitle").InnerText;
                                    var cL_SEOName = nod.SelectSingleNode("SEOName").InnerText;
                                    var cL_MetaDescription = nod.SelectSingleNode("MetaDescription").InnerText;
                                    var cL_MetaKeywords = nod.SelectSingleNode("MetaKeywords").InnerText;

                                    // Populate DATA CATEGORY
                                    CategoryData.DataRecord.SetXmlProperty("genxml/hidden/recordsortorder", cD_ListOrder);
                                    CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkishidden", cD_Hide);
                                    CategoryData.DataRecord.SetXmlProperty("genxml/checkbox/chkdisable", "False");
                                    CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlgrouptype", "cat");

                                    if (cD_ParentCategoryID != null && cD_ParentCategoryID != "0") CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", cD_ParentCategoryID);

                                    // Populate DATA CATEGORY LANG

                                    if (cL_CategoryName != null && cL_CategoryName != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategoryname", cL_CategoryName);
                                    if (cL_CategoryDesc != null && cL_CategoryDesc != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtcategorydesc", cL_CategoryDesc);
                                    if (cL_MetaDescription != null && cL_MetaDescription != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetadescription", cL_MetaDescription);
                                    if (cL_MetaKeywords != null && cL_MetaKeywords != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtmetakeywords", cL_MetaKeywords);
                                    if (cL_SEOPageTitle != null && cL_SEOPageTitle != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", cL_SEOPageTitle);
                                    if (cL_SEOName != null && cL_SEOName != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", cL_SEOName);
                                    if (cL_Message != null && cL_Message != "") CategoryData.DataLangRecord.SetXmlProperty("genxml/edt/message", cL_Message);

                                    categoryListIDGiud.Add(CategoryData.CategoryRef, CategoryData.CategoryId);
                                    if (cD_ParentCategoryID != null && cD_ParentCategoryID != "" && cD_ParentCategoryID != "0")
                                        categoryListIDFather.Add(CategoryData.CategoryId, Convert.ToInt32(cD_ParentCategoryID));

                                    CategoryData.Save();

                                }

                            }
                            catch (Exception e)
                            {
                                var logMessage = "CATEGORY: CategoryId: " + categoryid.ToString() + " : " + e.ToString();
                                LogOutput.LogWrite(logMessage);
                            }

                        }

                    //loop on The dictionary
                    foreach (var catl in categoryListIDFather)
                        {
                            //Key
                            var tempNewID = catl.Key;
                            //Value
                            var tempOldFather = catl.Value;

                            var tempNewFather = categoryListIDGiud[tempOldFather.ToString()];

                            var CategoryData = new CategoryData(tempNewID, lang);
                            CategoryData.ParentItemId = tempNewFather;
                            CategoryData.DataRecord.SetXmlProperty("genxml/dropdownlist/ddlparentcatid", tempNewFather.ToString());
                            CategoryData.Save();

                        }

                    }

                    #endregion

                    // Import Products

                    #region "data"

                    nodList = xmlFile.SelectNodes("root/products/" + lang + "/P");
                    if (nodList != null)
                    {
                        var productid = -1;
                        var prodname = "";
                        foreach (XmlNode nod in nodList)
                        {

                            try
                            {

                                var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID");
                                if (guidKeyNod != null)
                                {
                                    var guidKey = guidKeyNod.InnerText;
                                    productid = -1;
                                    // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate)
                                    var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey);
                                    if (nbiImport != null) productid = nbiImport.ItemID;
                                    var productData = new ProductData(productid, lang);

                                    productid = productData.Info.ItemID; // set productid, so we have the id if it goes wrong.
                                    prodname = productData.ProductName;

                                    // clear down existing XML data
                                    var i = new NBrightInfo(true);
                                    productData.DataRecord.XMLData = i.XMLData;
                                    productData.DataLangRecord.XMLData = i.XMLData;

                                    // assign guidkey to legacy productid (guidKey)
                                    productData.DataRecord.GUIDKey = guidKey;
                                    productData.DataRecord.SetXmlProperty("genxml/importref", guidKey);

                                    // do mapping of XML data
                                    // DATA FIELDS
                                    var pD_ProductID = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID").InnerText;
                                    var pD_PortalID = nod.SelectSingleNode("NB_Store_ProductsInfo/PortalID").InnerText;
                                    var pD_TaxCategoryID = nod.SelectSingleNode("NB_Store_ProductsInfo/TaxCategoryID").InnerText;
                                    var pD_Featured = nod.SelectSingleNode("NB_Store_ProductsInfo/Featured").InnerText;
                                    var pD_Archived = nod.SelectSingleNode("NB_Store_ProductsInfo/Archived").InnerText;
                                    var pD_CreatedByUser = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedByUser").InnerText;
                                    var pD_CreatedDate = nod.SelectSingleNode("NB_Store_ProductsInfo/CreatedDate").InnerText;
                                    var pD_IsDeleted = nod.SelectSingleNode("NB_Store_ProductsInfo/IsDeleted").InnerText;
                                    var pD_ProductRef = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductRef").InnerText;
                                    var pD_Lang = nod.SelectSingleNode("NB_Store_ProductsInfo/Lang").InnerText;
                                    var pD_Manufacturer = nod.SelectSingleNode("NB_Store_ProductsInfo/Manufacturer").InnerText;
                                    var pD_ModifiedDate = nod.SelectSingleNode("NB_Store_ProductsInfo/ModifiedDate").InnerText;
                                    var pD_IsHidden = nod.SelectSingleNode("NB_Store_ProductsInfo/IsHidden").InnerText;
                                    // DATA LANG FIELDS
                                    var pL_ProductName = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductName").InnerText;
                                    var pL_Summary = nod.SelectSingleNode("NB_Store_ProductsInfo/Summary").InnerText;
                                    var pL_Description = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText;
                                    var pL_SEOName = nod.SelectSingleNode("NB_Store_ProductsInfo/SEOName").InnerText;
                                    var pL_TagWords = nod.SelectSingleNode("NB_Store_ProductsInfo/TagWords").InnerText;
                                    var pL_Desc = nod.SelectSingleNode("NB_Store_ProductsInfo/Description").InnerText;

                                    if (pD_ProductRef != null) productData.DataRecord.SetXmlProperty("genxml/textbox/txtproductref", pD_ProductRef);
                                    if (pD_Manufacturer != null) productData.DataRecord.SetXmlProperty("genxml/textbox/customorder", pD_Manufacturer);

                                    // langauge main fields
                                    if (pL_ProductName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtproductname", pL_ProductName);
                                    if (pL_Summary != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtsummary", pL_Summary);
                                    if (pL_SEOName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseoname", pL_SEOName);
                                    if (pL_SEOName != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txtseopagetitle", pL_SEOName);
                                    if (pL_TagWords != null) productData.DataLangRecord.SetXmlProperty("genxml/textbox/txttagwords", pL_TagWords);

                                    //edt

                                    if (pL_Desc != null)
                                    {
                                        productData.DataLangRecord.SetXmlProperty("genxml/edt", "");
                                        productData.DataLangRecord.SetXmlProperty("genxml/edt/description", pL_Desc);
                                    }

                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// CUSTOM FIELDS /////////////////////////////////////
                                    #region "Custom Fields"

                                    // Custom Fields the Custom fields in Nbstore are stored in XmlData xml file area.

                                    if (nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").FirstChild != null) // verify if there are custom fileds
                                    {

                                        var InputCustomFieldsXml = new XmlDocument();
                                        InputCustomFieldsXml.Load(new StringReader(nod.SelectSingleNode("NB_Store_ProductsInfo/XMLData").InnerText));
                                        var nodListCustom = InputCustomFieldsXml.SelectSingleNode("genxml");
                                        var custominfo = new NBrightInfo();
                                        custominfo.XMLData = nodListCustom.OuterXml;

                                        // ***************************
                                        // process custom fields here.
                                        // ***************************

                                    }

                                    #endregion
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////
                                    ////////////////////////////// END CUSTOM FIELDS /////////////////////////////////////

                                    // Models
                                    var nodListModels = nod.SelectNodes("M/NB_Store_ModelInfo");
                                    foreach (XmlNode nodMod in nodListModels)
                                    {
                                        //load single node module strucuture
                                        var ModelID = nodMod.SelectSingleNode("ModelID").InnerText;

                                        var ProductID = nodMod.SelectSingleNode("ProductID").InnerText;
                                        var ListOrder = nodMod.SelectSingleNode("ListOrder").InnerText;
                                        var UnitCost = nodMod.SelectSingleNode("UnitCost").InnerText;
                                        var Barcode = nodMod.SelectSingleNode("Barcode").InnerText;
                                        var ModelRef = nodMod.SelectSingleNode("ModelRef").InnerText;
                                        var Lang = nodMod.SelectSingleNode("Lang").InnerText;
                                        var ModelName = nodMod.SelectSingleNode("ModelName").InnerText;
                                        var QtyRemaining = nodMod.SelectSingleNode("QtyRemaining").InnerText;
                                        var QtyTrans = nodMod.SelectSingleNode("QtyTrans").InnerText;
                                        var QtyTransDate = nodMod.SelectSingleNode("QtyTransDate").InnerText;
                                        var ProductName = nodMod.SelectSingleNode("ProductName").InnerText;
                                        var PortalID = nodMod.SelectSingleNode("PortalID").InnerText;
                                        var Weight = nodMod.SelectSingleNode("Weight").InnerText;
                                        var Height = nodMod.SelectSingleNode("Height").InnerText;
                                        var Length = nodMod.SelectSingleNode("Length").InnerText;
                                        var Width = nodMod.SelectSingleNode("Width").InnerText;
                                        var Deleted = nodMod.SelectSingleNode("Deleted").InnerText;
                                        var QtyStockSet = nodMod.SelectSingleNode("QtyStockSet").InnerText;
                                        var DealerCost = nodMod.SelectSingleNode("DealerCost").InnerText;
                                        var PurchaseCost = nodMod.SelectSingleNode("PurchaseCost").InnerText;
                                        var XMLData = nodMod.SelectSingleNode("XMLData").InnerText;
                                        var Extra = nodMod.SelectSingleNode("Extra").InnerText;
                                        var DealerOnly = nodMod.SelectSingleNode("DealerOnly").InnerText;
                                        var Allow = nodMod.SelectSingleNode("Allow").InnerText;

                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////
                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////
                                        ////////////////////////////// FINE CUSTOM FIELDS /////////////////////////////////////

                                        //il dentro al tag model cè un genxml che identifica il modello
                                        // MODELLI CAMPI DATA
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        ////////////////////////////// MODELS /////////////////////////////////////
                                        var newkey = Utils.GetUniqueKey();

                                        var strXmlModel = @"<genxml><models><genxml>
                                      <files />
                                      <hidden><modelid>" + newkey + "</modelid>" +
                                                          @"</hidden>
                                      <textbox>
                                        <availabledate datatype=""date"" />
                                        <txtqtyminstock>0</txtqtyminstock>
                                        <txtmodelref>" + ModelRef + @"</txtmodelref>
                                        <txtunitcost>" + UnitCost + @"</txtunitcost>
                                        <txtsaleprice>0.00</txtsaleprice>
                                        <txtbarcode>" + Barcode + @"</txtbarcode>
                                        <txtqtyremaining>" + QtyRemaining + @"</txtqtyremaining>
                                        <txtqtystockset>" + QtyStockSet + @"</txtqtystockset>
                                        <txtdealercost>" + DealerCost + @"</txtdealercost>
                                        <txtpurchasecost>" + PurchaseCost + @"</txtpurchasecost>
                                        <weight>" + Weight + @"</weight>
                                        <depth>" + Length + @"</depth>
                                        <width>" + Width + @"</width>
                                        <height>" + Height + @"</height>
                                        <unit />
                                        <delay />
                                      </textbox>
                                      <checkbox>
                                        <chkstockon>False</chkstockon>
                                        <chkishidden>False</chkishidden>
                                        <chkdeleted>False</chkdeleted>
                                        <chkdealeronly>False</chkdealeronly>
                                      </checkbox>
                                      <dropdownlist>
                                        <modelstatus>010</modelstatus>
                                      </dropdownlist>
                                      <checkboxlist />
                                      <radiobuttonlist />
                                    </genxml></models></genxml>";

                                        var strXmlModelLang = @"<genxml><models><genxml>
                                        <files />
                                        <hidden />
                                        <textbox>
                                            <txtmodelname>" + ModelName + "</txtmodelname>" +
                                                              "<txtextra>" + Extra + @"</txtextra>
                                        </textbox>
                                        <checkbox /><dropdownlist /><checkboxlist /><radiobuttonlist />
                                        </genxml></models></genxml>";

                                        if (productData.DataRecord.XMLDoc.SelectSingleNode("genxml/models") == null)
                                        {
                                            productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models", "genxml");
                                            productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models", "genxml");
                                        }
                                        else
                                        {
                                            productData.DataRecord.AddXmlNode(strXmlModel, "genxml/models/genxml", "genxml/models");
                                            productData.DataLangRecord.AddXmlNode(strXmlModelLang, "genxml/models/genxml", "genxml/models");
                                        }

                                    }

                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    ////////////////////////////// IMAGES /////////////////////////////////////
                                    // copy all the images from Portals\0\productimages to Portals\0\NBStore\images

                                    var nodListImages = nod.SelectNodes("I/NB_Store_ProductImageInfo");
                                    foreach (XmlNode nodImg in nodListImages)
                                    {
                                        var ImageID = nodImg.SelectSingleNode("ImageID").InnerText;
                                        var Hidden = nodImg.SelectSingleNode("Hidden").InnerText;
                                        var ImageUrl = nodImg.SelectSingleNode("ImageURL").InnerText;
                                        var ImagePath = nodImg.SelectSingleNode("ImagePath").InnerText;

                                        productData.AddNewImage(ImageUrl, ImagePath);
                                    }
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    ////////////////////////////// DOCS /////////////////////////////////////
                                    // copy all the DOCS from Portals\0\productdocs to Portals\0\NBStore\docs

                                    var nodListDocs = nod.SelectNodes("D/NB_Store_ProductDocInfo");
                                    var lp = 1;
                                    var objCtrlDoc = new NBrightBuyController();

                                    foreach (XmlNode nodDoc in nodListDocs)
                                    {
                                        var DocID = nodDoc.SelectSingleNode("DocID").InnerText;
                                        var ProductID = nodDoc.SelectSingleNode("ProductID").InnerText;
                                        var DocPath = nodDoc.SelectSingleNode("DocPath").InnerText;
                                        var ListOrder = nodDoc.SelectSingleNode("ListOrder").InnerText;
                                        var Hidden = nodDoc.SelectSingleNode("Hidden").InnerText;
                                        var FileName = nodDoc.SelectSingleNode("FileName").InnerText;
                                        var FileExt = nodDoc.SelectSingleNode("FileExt").InnerText;
                                        var Lang = nodDoc.SelectSingleNode("Lang").InnerText;
                                        var DocDesc = nodDoc.SelectSingleNode("DocDesc").InnerText;

                                        productData.AddNewDoc(DocPath, FileName);

                                        productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/fileext", FileExt);
                                        DocPath = DocPath.Replace("productdocs", @"NBStore\docs");
                                        productData.DataRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/hidden/filepath", DocPath);

                                        objCtrlDoc.Update(productData.DataRecord);

                                        // if doesen't exisit the xml genxml strucuture inside the DataLangRecor I create it
                                        var strXml = "<genxml><docs><genxml><textbox/></genxml></docs></genxml>";
                                        if (productData.DataLangRecord.XMLDoc.SelectSingleNode("genxml/docs") == null)
                                        {
                                            productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs", "genxml");
                                        }
                                        else
                                        {
                                            productData.DataLangRecord.AddXmlNode(strXml, "genxml/docs/genxml", "genxml/docs");
                                        }
                                        /////////////////////////////////////////////////
                                        productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txtdocdesc", DocDesc);
                                        productData.DataLangRecord.SetXmlProperty("genxml/docs/genxml[" + lp.ToString() + "]/textbox/txttitle", FileName);

                                        objCtrlDoc.Update(productData.DataLangRecord);

                                        lp += 1;
                                    }

                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////
                                    ////////////////////////////// CATEGORIES /////////////////////////////////////

                                    var nodListCat = nod.SelectNodes("C/NB_Store_ProductCategoryInfo");
                                    foreach (XmlNode nodCat in nodListCat)
                                    {
                                        var ProductID = nodCat.SelectSingleNode("ProductID").InnerText;
                                        var CategoryID = nodCat.SelectSingleNode("CategoryID").InnerText;

                                        if (ProductID == guidKey)
                                        {
                                            var newCategoryId = categoryListIDGiud[CategoryID];
                                            productData.AddCategory(newCategoryId);
                                        }

                                    }

                                    ////////////////////////////// SAVE PRODUCT /////////////////////////////////////
                                    productData.Save();

                                }

                            }
                            catch (Exception e)
                            {
                                var logMessage = "PRODUCTS: " + prodname +  " ProductId: " + productid.ToString() + " : " + e.ToString();
                                LogOutput.LogWrite(logMessage);
                            }

                        }
                    }

                    ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                    //recicle on all the xml import Product and reconnect the related product
                    foreach (var lang2 in langList)
                    {
                        if (nodList != null)
                        {
                            foreach (XmlNode nod in nodList)
                            {

                                var guidKeyNod = nod.SelectSingleNode("NB_Store_ProductsInfo/ProductID");
                                if (guidKeyNod != null)
                                {

                                    var guidKey = guidKeyNod.InnerText;
                                    var productid = -1;
                                    try
                                    {
                                        // See if e already have a product imported, if so we want to update (maybe multiple languages, or a 2nd migrate)
                                        var nbiImport = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", guidKey);
                                        if (nbiImport != null) productid = nbiImport.ItemID;
                                        var productData = new ProductData(productid, lang2);

                                        ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                                        ////////////////////////////// RELATED PRODUCTS /////////////////////////////////////
                                        var nodListRelated = nod.SelectNodes("R/NB_Store_ProductRelatedInfo");
                                        if (nodListRelated != null) //if there are related
                                        {

                                            foreach (XmlNode nodRel in nodListRelated)
                                            {
                                                // id in the related product import file
                                                var ImportRelatedProductID = nodRel.SelectSingleNode("RelatedProductID").InnerText;
                                                // extract Id of the new created product thet have the old id in the guidKey
                                                var tempID = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "PRD", ImportRelatedProductID);

                                                if (tempID != null)
                                                {
                                                    int IDRelatedprod = tempID.ItemID;
                                                    productData.AddRelatedProduct(IDRelatedprod);
                                                    productData.Save();
                                                }

                                            }
                                        }

                                    }
                                    catch (Exception e)
                                    {
                                        var logMessage = "RELATED PRODUCTS: ProductId: " + productid.ToString() + " : " + e.ToString();
                                        LogOutput.LogWrite(logMessage);
                                    }

                                }

                        }
                        }
                    }

                    LogOutput.LogWrite("END: " + DateTime.Now);

                    #endregion

                }

                NBrightBuyUtils.SetNotfiyMessage(ModuleId, "Import", NotifyCode.ok, ControlPath + "/App_LocalResources/Import.ascx.resx");

            }
        }
Esempio n. 12
0
        public int Validate()
        {
            var errorcount = 0;
            var objCtrl    = new NBrightBuyController();

            DataRecord.ValidateXmlFormat();
            if (DataLangRecord == null)
            {
                // we have no datalang record for this language, so get an existing one and save it.
                var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
                if (l.Count > 0)
                {
                    DataLangRecord        = (NBrightInfo)l[0].Clone();
                    DataLangRecord.ItemID = -1;
                    DataLangRecord.Lang   = _lang;
                    DataLangRecord.ValidateXmlFormat();
                    objCtrl.Update(DataLangRecord);
                }
            }

            var defaultname = Name;

            if (defaultname == "")
            {
                // find a valid default name
                foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
                {
                    var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'");
                    if (l.Count == 1)
                    {
                        var nbi2 = (NBrightInfo)l[0];
                        if (nbi2.GetXmlProperty("genxml/textbox/groupname") != "")
                        {
                            defaultname = nbi2.GetXmlProperty("genxml/textbox/groupname");
                            Name        = defaultname;
                            Save();
                            break;
                        }
                    }
                }
            }

            // fix langauge records
            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'");
                if (l.Count == 0 && DataLangRecord != null)
                {
                    var nbi = (NBrightInfo)DataLangRecord.Clone();
                    nbi.ItemID = -1;
                    nbi.Lang   = lang;
                    objCtrl.Update(nbi);
                    errorcount += 1;
                }

                if (l.Count == 1)
                {
                    var nbi2 = (NBrightInfo)l[0];
                    if (nbi2.GetXmlProperty("genxml/textbox/groupname") == "")
                    {
                        // if we have no name, use the default name we found early to update.
                        nbi2.SetXmlProperty("genxml/textbox/groupname", defaultname);
                        objCtrl.Update(nbi2);
                    }
                }

                if (l.Count > 1)
                {
                    // we have more records than should exists, remove any old ones.
                    var l2 = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'", "order by Modifieddate desc");
                    var lp = 1;
                    foreach (var i in l2)
                    {
                        if (lp >= 2)
                        {
                            objCtrl.Delete(i.ItemID);
                        }
                        lp += 1;
                    }
                }
            }

            if (Ref == "")
            {
                Ref = DataRecord.GUIDKey;
                objCtrl.Update(DataRecord);
            }

            // add required field values to make getting group easier.
            if (Ref != "" && DataRecord.GUIDKey != Ref)
            {
                DataRecord.GUIDKey = Ref;
                objCtrl.Update(DataRecord);
            }

            // check we have a groupt type, it might be missing if upgraded.
            if (Type == "")
            {
                if (Ref == "cat")
                {
                    Type = "2";
                }
                else
                {
                    Type = "1";
                }
                objCtrl.Update(DataRecord);
            }


            return(errorcount);
        }
Esempio n. 13
0
 public void TurnOffEditMode()
 {
     var modCtrl = new NBrightBuyController();
     EditMode = "";
     _entryId = modCtrl.Update(PurchaseInfo);
 }
Esempio n. 14
0
        private void Update()
        {
            var modCtrl = new NBrightBuyController();
            var strXml = GenXmlFunctions.GetGenXml(rpDataH);
            _info.XMLData = strXml;
            _info.SetXmlProperty("genxml/debugmsg", "");
            modCtrl.Update(_info);

            var resxDic = GenXmlFunctions.GetGenXmlResx(rpDataH);
            var genTempl = (GenXmlTemplate)rpDataH.ItemTemplate;
            var resxfolders = genTempl.GetResxFolders();
            var resxUpdate = NBrightBuyUtils.UpdateResxFields(resxDic, resxfolders, StoreSettings.Current.EditLanguage, true);

            //remove current setting from cache for reload
            Utils.RemoveCache("NBrightPayPalPaymentProvider" + PortalSettings.Current.PortalId.ToString(""));
        }
Esempio n. 15
0
 public void Save()
 {
     var objCtrl = new NBrightBuyController();
     objCtrl.Update(DataRecord);
     objCtrl.Update(DataLangRecord);
 }
Esempio n. 16
0
        /// <summary>
        /// Save Purchase record
        /// </summary>
        /// <param name="copyrecord">Copy this data as a new record in the DB with a new id</param>
        /// <returns></returns>
        public int SavePurchaseData(Boolean copyrecord = false )
        {
            if (copyrecord)
            {
                _entryId = -1;
                PurchaseInfo.SetXmlProperty("genxml/audit", ""); // remove audit
            }

            var strXml = "<items>";
            foreach (var info in _itemList)
            {
                // remove injected group header record for the product
                if (!info.GetXmlPropertyBool("genxml/groupheader")) strXml += info.XMLData;
            }
            strXml += "</items>";
            PurchaseInfo.RemoveXmlNode("genxml/items");
            PurchaseInfo.AddXmlNode(strXml, "items", "genxml");

            var modCtrl = new NBrightBuyController();
            PurchaseInfo.ItemID = _entryId;
            PurchaseInfo.PortalId = PortalId;
            PurchaseInfo.ModuleId = -1;
            PurchaseInfo.TypeCode = PurchaseTypeCode;
            if (UserController.GetCurrentUserInfo().UserID != -1)  // This might be updated from out of context (payment provider)
            {
                if (UserId != UserController.GetCurrentUserInfo().UserID && EditMode == "") UserId = UserController.GetCurrentUserInfo().UserID;
                PurchaseInfo.UserId = UserId;
            }
            _entryId = modCtrl.Update(PurchaseInfo);

            NBrightBuyUtils.ProcessEventProvider(EventActions.AfterSavePurchaseData, PurchaseInfo);

            return _entryId;
        }
Esempio n. 17
0
        private void PopulateClientData(int userId, bool debugmode = false)
        {
            _clientInfo          = new NBrightInfo(true);
            _clientInfo.ItemID   = userId;
            _clientInfo.UserId   = userId;
            _clientInfo.PortalId = PortalId;

            DataRecord = (NBrightInfo)NBrightBuyUtils.GetModCache(_cacheKey);

            if (DataRecord == null)
            {
                // get any datarecord on DB
                var objCtrl = new NBrightBuyController();
                DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", userId.ToString(""), "", "", debugmode);
                if (DataRecord == null)
                {
                    DataRecord          = new NBrightInfo(true);
                    DataRecord.ItemID   = -1;
                    DataRecord.UserId   = userId;
                    DataRecord.PortalId = PortalId;
                    DataRecord.ModuleId = -1;
                    DataRecord.TypeCode = "CLIENT";
                    objCtrl.Update(DataRecord);
                }
                else
                {
                    _clientInfo.XMLData = DataRecord.XMLData;
                }

                NBrightBuyUtils.SetModCache(-1, _cacheKey, DataRecord);
            }
            else
            {
                _clientInfo.XMLData = DataRecord.XMLData;
            }

            _userInfo = UserController.GetUserById(PortalId, userId);
            if (_userInfo != null)
            {
                Exists = true;

                _clientInfo.ModifiedDate = _userInfo.Membership.CreatedDate;

                foreach (var propertyInfo in _userInfo.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        object pv = null;
                        try
                        {
                            pv = propertyInfo.GetValue(_userInfo, null);
                            if (pv == null)
                            {
                                pv = "";
                            }
                        }
                        catch (Exception)
                        {
                            pv = "";
                        }
                        _clientInfo.SetXmlProperty("genxml/textbox/" + propertyInfo.Name.ToLower(), pv.ToString());
                    }
                }

                foreach (DotNetNuke.Entities.Profile.ProfilePropertyDefinition p in _userInfo.Profile.ProfileProperties)
                {
                    _clientInfo.SetXmlProperty("genxml/textbox/" + p.PropertyName.ToLower(), p.PropertyValue);
                }

                _clientInfo.AddSingleNode("membership", "", "genxml");
                foreach (var propertyInfo in _userInfo.Membership.GetType().GetProperties())
                {
                    if (propertyInfo.CanRead)
                    {
                        var pv = propertyInfo.GetValue(_userInfo.Membership, null);
                        if (pv != null)
                        {
                            _clientInfo.SetXmlProperty("genxml/membership/" + propertyInfo.Name.ToLower(), pv.ToString());
                        }
                    }
                }

                if (_userInfo.IsInRole(StoreSettings.ClientEditorRole))
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "True");
                }
                else
                {
                    _clientInfo.SetXmlProperty("genxml/checkbox/clienteditorrole", "False");
                }

                DiscountCodes = GetEntityList("discountcodes");
                VoucherCodes  = GetEntityList("vouchercodes");
            }
        }
Esempio n. 18
0
        public void FillEmptyLanguageFields()
        {
            var objCtrl = new NBrightBuyController();
            foreach (var toLang in DnnUtils.GetCultureCodeList(_portalId))
            {
                if (toLang != _lang)
                {
                    var dlang = objCtrl.GetDataLang(DataRecord.ItemID, toLang) ?? DataLangRecord;
                    dlang.Lang = toLang;
                    // product
                        var nodList = DataLangRecord.XMLDoc.SelectNodes("genxml/textbox/*");
                        if (nodList != null)
                        {
                            foreach (XmlNode nod in nodList)
                            {
                                if (nod.InnerText.Trim() != "")
                                {
                                    if (dlang.GetXmlProperty("genxml/textbox/" + nod.Name) == "")
                                    {
                                        dlang.SetXmlProperty("genxml/textbox/" + nod.Name, nod.InnerText);
                                    }
                                }
                            }
                        }

                        // editor
                        if (DataLangRecord.GetXmlProperty("genxml/edt/description") != "")
                        {
                            if (dlang.GetXmlProperty("genxml/edt/description") == "")
                            {
                                dlang.SetXmlProperty("genxml/edt/description", DataLangRecord.GetXmlPropertyRaw("genxml/edt/description"));
                            }
                        }

                        // models
                        var nodList1 = DataLangRecord.XMLDoc.SelectNodes("genxml/models/genxml");
                        if (nodList1 != null)
                        {
                            var c = 1;
                            foreach (XmlNode nod1 in nodList1)
                            {
                                nodList = nod1.SelectNodes("textbox/*");
                                if (nodList != null)
                                {
                                    foreach (XmlNode nod in nodList)
                                    {
                                        if (nod.InnerText.Trim() != "")
                                        {
                                            if (dlang.GetXmlProperty("genxml/models/genxml[" + c + "]/textbox/" + nod.Name) == "")
                                            {
                                                dlang.SetXmlProperty("genxml/models/genxml[" + c + "]/textbox/" + nod.Name, nod.InnerText);
                                            }
                                        }
                                    }
                                }
                                c += 1;
                            }
                        }

                        // options
                        nodList1 = DataLangRecord.XMLDoc.SelectNodes("genxml/options/genxml");
                        if (nodList1 != null)
                        {
                            var c = 1;
                            foreach (XmlNode nod1 in nodList1)
                            {
                                nodList = nod1.SelectNodes("textbox/*");
                                if (nodList != null)
                                {
                                    foreach (XmlNode nod in nodList)
                                    {
                                        if (nod.InnerText.Trim() != "")
                                        {
                                            if (dlang.GetXmlProperty("genxml/options/genxml[" + c + "]/textbox/" + nod.Name) == "")
                                            {
                                                dlang.SetXmlProperty("genxml/options/genxml[" + c + "]/textbox/" + nod.Name, nod.InnerText);
                                            }
                                        }
                                    }
                                }
                                c += 1;
                            }
                        }

                        // imgs
                        nodList1 = DataLangRecord.XMLDoc.SelectNodes("genxml/imgs/genxml");
                        if (nodList1 != null)
                        {
                            var c = 1;
                            foreach (XmlNode nod1 in nodList1)
                            {
                                nodList = nod1.SelectNodes("textbox/*");
                                if (nodList != null)
                                {
                                    foreach (XmlNode nod in nodList)
                                    {
                                        if (nod.InnerText.Trim() != "")
                                        {
                                            if (dlang.GetXmlProperty("genxml/imgs/genxml[" + c + "]/textbox/" + nod.Name) == "")
                                            {
                                                dlang.SetXmlProperty("genxml/imgs/genxml[" + c + "]/textbox/" + nod.Name, nod.InnerText);
                                            }
                                        }
                                    }
                                }
                                c += 1;
                            }
                        }

                        // docs
                        nodList1 = DataLangRecord.XMLDoc.SelectNodes("genxml/docs/genxml");
                        if (nodList1 != null)
                        {
                            var c = 1;
                            foreach (XmlNode nod1 in nodList1)
                            {
                                nodList = nod1.SelectNodes("textbox/*");
                                if (nodList != null)
                                {
                                    foreach (XmlNode nod in nodList)
                                    {
                                        if (nod.InnerText.Trim() != "")
                                        {
                                            if (dlang.GetXmlProperty("genxml/docs/genxml[" + c + "]/textbox/" + nod.Name) == "")
                                            {
                                                dlang.SetXmlProperty("genxml/docs/genxml[" + c + "]/textbox/" + nod.Name, nod.InnerText);
                                            }
                                        }
                                    }
                                }
                                c += 1;
                            }
                        }

                        // optionvalues
                        nodList1 = DataLangRecord.XMLDoc.SelectNodes("genxml/optionvalues/genxml");
                        if (nodList1 != null)
                        {
                            var c = 1;
                            foreach (XmlNode nod1 in nodList1)
                            {
                                nodList = nod1.SelectNodes("textbox/*");
                                if (nodList != null)
                                {
                                    foreach (XmlNode nod in nodList)
                                    {
                                        if (nod.InnerText.Trim() != "")
                                        {
                                            if (dlang.GetXmlProperty("genxml/optionvalues/genxml[" + c + "]/textbox/" + nod.Name) == "")
                                            {
                                                dlang.SetXmlProperty("genxml/optionvalues/genxml[" + c + "]/textbox/" + nod.Name, nod.InnerText);
                                            }
                                        }
                                    }
                                }
                                c += 1;
                            }
                        }

                    objCtrl.Update(dlang);
                }
            }
        }
Esempio n. 19
0
 public void AddClient(int userid)
 {
     var strGuid = userid.ToString("") + "x" + Info.ItemID.ToString("");
     var objCtrl = new NBrightBuyController();
     var nbi = objCtrl.GetByGuidKey(_portalId, -1, "USERPRDXREF", strGuid);
     if (nbi == null)
     {
         nbi = new NBrightInfo();
         nbi.ItemID = -1;
         nbi.PortalId = _portalId;
         nbi.ModuleId = -1;
         nbi.TypeCode = "USERPRDXREF";
         nbi.XrefItemId = 0;
         nbi.ParentItemId = Info.ItemID;
         nbi.TextData = null;
         nbi.Lang = null;
         nbi.UserId = userid;
         nbi.GUIDKey = strGuid;
         objCtrl.Update(nbi);
     }
 }
Esempio n. 20
0
        public int Validate()
        {
            var errorcount = 0;

            var objCtrl = new NBrightBuyController();

            SetGuidKey();
            objCtrl.Update(DataRecord);

            DataRecord.ValidateXmlFormat();
            if (DataLangRecord == null)
            {
                // we have no datalang record for this language, so get an existing one and save it.
                var l = objCtrl.GetList(_portalId, -1, _typeLangCode, " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
                if (l.Count > 0)
                    DataLangRecord = (NBrightInfo) l[0].Clone();
                else
                    DataLangRecord = new NBrightInfo(true);

                DataLangRecord.ItemID = -1;
                DataLangRecord.ValidateXmlFormat();
                DataLangRecord.TypeCode = _typeLangCode;
                DataLangRecord.ParentItemId = Info.ItemID;
                DataLangRecord.Lang = _lang;
                objCtrl.Update(DataLangRecord);
            }

            //Fix image paths
            var lp = 1;
            foreach (var i in Imgs)
            {
                if (!File.Exists(i.GetXmlProperty("genxml/hidden/imagepath"))) // products shared across portals may have different image path.
                {
                    if (!i.GetXmlProperty("genxml/hidden/imageurl").StartsWith(_storeSettings.FolderImages))
                    {
                        var iname = Path.GetFileName(i.GetXmlProperty("genxml/hidden/imagepath"));
                        DataRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/imageurl", _storeSettings.FolderImages.TrimEnd('/') + "/" + iname);
                        errorcount += 1;
                    }
                    if (!i.GetXmlProperty("genxml/hidden/imagepath").StartsWith(_storeSettings.FolderImagesMapPath))
                    {
                        var iname = Path.GetFileName(i.GetXmlProperty("genxml/hidden/imagepath"));
                        DataRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/imagepath", _storeSettings.FolderImagesMapPath.TrimEnd('\\') + "\\" + iname);
                        errorcount += 1;
                    }
                }
                lp += 1;
            }
            //Fix document paths
            lp = 1;
            foreach (var d in Docs)
            {
                if (!File.Exists(d.GetXmlProperty("genxml/hidden/filepath"))) // products shared across portals may have different path.
                {
                    if (!d.GetXmlProperty("genxml/hidden/filepath").StartsWith(_storeSettings.FolderDocumentsMapPath))
                    {
                        var fname = d.GetXmlProperty("genxml/textbox/txtfilename");
                        if (d.GetXmlProperty("genxml/hidden/filerelpath") != "")
                        {
                            fname = Path.GetFileName("D:" + d.GetXmlProperty("genxml/hidden/filerelpath").Replace("/", "\\"));
                        }
                        DataRecord.SetXmlProperty("genxml/docs/genxml/hidden/filepath", _storeSettings.FolderDocumentsMapPath.TrimEnd('\\') + "\\" + fname);
                        errorcount += 1;
                    }
                }
                lp += 1;
            }

            if (errorcount > 0) objCtrl.Update(DataRecord); // update if we find a error

            // fix langauge records
            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                var l = objCtrl.GetList(_portalId, -1, _typeLangCode, " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'");
                if (l.Count == 0 && DataLangRecord != null)
                {
                    var nbi = (NBrightInfo)DataLangRecord.Clone();
                    nbi.ItemID = -1;
                    nbi.Lang = lang;
                    objCtrl.Update(nbi);
                    errorcount += 1;
                }
                if (l.Count > 1)
                {
                    // we have more records than should exists, remove any old ones.
                    var l2 = objCtrl.GetList(_portalId, -1, _typeLangCode, " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'", "order by Modifieddate desc");
                    var lp2 = 1;
                    foreach (var i in l2)
                    {
                        if (lp2 >= 2) objCtrl.Delete(i.ItemID);
                        errorcount += 1;
                        lp2 += 1;
                    }
                }
            }

            // remove duplicate category xrefs.
            var catlist = GetCategories();
            foreach (var c in catlist)
            {
                var l = objCtrl.GetList(_portalId, -1, "CATXREF", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.XrefItemId = " + c.categoryid.ToString(""));
                if (l.Count > 1)
                {
                    var catlp = 0;
                    foreach (var i in l)
                    {
                        if (catlp >= 1)
                        {
                            objCtrl.Delete(i.ItemID);
                            errorcount += 1;
                        }
                        catlp += 1;
                    }
                }
            }

            // remove duplicate catcascade records
            var cascadeList = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATCASCADE", " and NB1.ParentItemId = " + Info.ItemID.ToString("") );
            foreach (var c in cascadeList)
            {
                var l2 = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATCASCADE", " and GUIDKey = '" + c.GUIDKey + "'");
                if (l2.Count > 1)
                {
                    for (int i = 1; i < l2.Count; i++)
                    {
                        objCtrl.Delete(l2[i].ItemID);
                        errorcount += 1;
                    }
                }
            }

            // remove any unlinked catacscade records
            cascadeList = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATCASCADE", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.XrefItemId = 0");
            foreach (var c in cascadeList)
            {
                objCtrl.Delete(c.ItemID);
                errorcount += 1;
            }

            return errorcount;
        }
Esempio n. 21
0
        public static int ValidateStore()
        {
            // clear all cache to start.
            DataCache.ClearCache();

            var objCtrl = new NBrightBuyController();
            var errcount = 0;

            // Validate Products
            var prodList = objCtrl.GetList(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, -1, "PRD");
            foreach (var p in prodList)
            {
                var prodData = ProductUtils.GetProductData(p.ItemID, StoreSettings.Current.EditLanguage);
                errcount += prodData.Validate();
            }

            // Validate Categories
            var catList = objCtrl.GetList(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, -1, "CATEGORY");
            foreach (var c in catList)
            {
                var catData = CategoryUtils.GetCategoryData(c.ItemID, StoreSettings.Current.EditLanguage);
                errcount += catData.Validate();
            }

            // Validate Groups
            var grpList = objCtrl.GetList(DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId, -1, "GROUP");
            foreach (var c in grpList)
            {
                var grpData = new GroupData(c.ItemID, StoreSettings.Current.EditLanguage);
                errcount += grpData.Validate();
            }

            // reset catid from catref
            var l = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, "SETTINGS", "", Utils.GetCurrentCulture(), " and [XMLdata].value('(genxml/catref)[1]','nvarchar(max)') != ''","");
            foreach (var s in l)
            {
                var info = ModuleSettingsResetCatIdFromRef(s);
                objCtrl.Update(info);
            }

            return errcount;
        }
Esempio n. 22
0
 private void AddNewImage(int itemId,String imageurl, String imagepath)
 {
     var objCtrl = new NBrightBuyController();
     var dataRecord = objCtrl.Get(itemId);
     if (dataRecord != null)
     {
         var strXml = "<genxml><imgs><genxml><hidden><imagepath>" + imagepath + "</imagepath><imageurl>" + imageurl + "</imageurl></hidden></genxml></imgs></genxml>";
         if (dataRecord.XMLDoc.SelectSingleNode("genxml/imgs") == null)
         {
             dataRecord.AddXmlNode(strXml, "genxml/imgs", "genxml");
         }
         else
         {
             dataRecord.AddXmlNode(strXml, "genxml/imgs/genxml", "genxml/imgs");
         }
         objCtrl.Update(dataRecord);
     }
 }
Esempio n. 23
0
        public int Validate()
        {
            var errorcount = 0;

            var objCtrl = new NBrightBuyController();

            SetGuidKey();
            objCtrl.Update(DataRecord);

            DataRecord.ValidateXmlFormat();
            if (DataLangRecord == null)
            {
                // we have no datalang record for this language, so get an existing one and save it.
                var l = objCtrl.GetList(_portalId, -1, "PRDLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
                if (l.Count > 0)
                    DataLangRecord = (NBrightInfo) l[0].Clone();
                else
                    DataLangRecord = new NBrightInfo(true);

                DataLangRecord.ItemID = -1;
                DataLangRecord.ValidateXmlFormat();
                DataLangRecord.TypeCode = "PRDLANG";
                DataLangRecord.ParentItemId = Info.ItemID;
                DataLangRecord.Lang = _lang;
                objCtrl.Update(DataLangRecord);
            }

            //Fix image paths
            var lp = 1;
            foreach (var i in Imgs)
            {
                if (!i.GetXmlProperty("genxml/hidden/imageurl").StartsWith(_storeSettings.FolderImages))
                {
                    var iname = Path.GetFileName(i.GetXmlProperty("genxml/hidden/imagepath"));
                    DataRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/imageurl", _storeSettings.FolderImages.TrimEnd('/') + "/" + iname);
                    errorcount += 1;
                }
                if (!i.GetXmlProperty("genxml/hidden/imagepath").StartsWith(_storeSettings.FolderImagesMapPath))
                {
                    var iname = Path.GetFileName(i.GetXmlProperty("genxml/hidden/imagepath"));
                    DataRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/imagepath", _storeSettings.FolderImagesMapPath.TrimEnd('\\') + "\\" + iname);
                    errorcount += 1;
                }
                lp += 1;
            }
            //Fix document paths
            lp = 1;
            foreach (var d in Docs)
            {
                if (!d.GetXmlProperty("genxml/hidden/filepath").StartsWith(_storeSettings.FolderDocumentsMapPath))
                {
                    DataRecord.SetXmlProperty("genxml/docs/genxml/hidden/filepath", _storeSettings.FolderDocumentsMapPath.TrimEnd('\\') + "\\" + d.GetXmlProperty("genxml/textbox/txtfilename"));
                    errorcount += 1;
                }
                lp += 1;
            }

            if (errorcount > 0) objCtrl.Update(DataRecord); // update if we find a error

            // fix langauge records
            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                var l = objCtrl.GetList(_portalId, -1, "PRDLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'");
                if (l.Count == 0 && DataLangRecord != null)
                {
                    var nbi = (NBrightInfo)DataLangRecord.Clone();
                    nbi.ItemID = -1;
                    nbi.Lang = lang;
                    objCtrl.Update(nbi);
                    errorcount += 1;
                }
                if (l.Count > 1)
                {
                    // we have more records than shoudl exists, remove any old ones.
                    var l2 = objCtrl.GetList(_portalId, -1, "PRDLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'", "order by Modifieddate desc");
                    var lp2 = 1;
                    foreach (var i in l2)
                    {
                        if (lp2 >= 2) objCtrl.Delete(i.ItemID);
                        lp2 += 1;
                    }
                }
            }

            return errorcount;
        }
Esempio n. 24
0
        private int AddNew()
        {
            var nbi = new NBrightInfo(true);
            if (StoreSettings.Current.Get("shareproducts") == "True") // option in storesetting to share products created here across all portals.
                _portalId = -1;
            else
                _portalId = PortalSettings.Current.PortalId;
            nbi.PortalId = _portalId;
            nbi.TypeCode = "PRD";
            nbi.ModuleId = -1;
            nbi.ItemID = -1;
            nbi.SetXmlProperty("genxml/checkbox/chkishidden", "True");
            nbi.AddSingleNode("models", "<genxml><hidden><modelid>" + Utils.GetUniqueKey() + "</modelid></hidden></genxml>", "genxml");
            var objCtrl = new NBrightBuyController();
            var itemId = objCtrl.Update(nbi);

            foreach (var lang in DnnUtils.GetCultureCodeList(_portalId))
            {
                nbi = new NBrightInfo(true);
                nbi.PortalId = _portalId;
                nbi.TypeCode = "PRDLANG";
                nbi.ModuleId = -1;
                nbi.ItemID = -1;
                nbi.Lang = lang;
                nbi.ParentItemId = itemId;
                objCtrl.Update(nbi);
            }

            return itemId;
        }
Esempio n. 25
0
 /// <summary>
 /// Save cart
 /// </summary>
 public void Save(Boolean debugMode = false)
 {
     if (Info != null)
     {
         var modCtrl = new NBrightBuyController();
         Info.ItemID = modCtrl.Update(Info);
         if (StoreSettings.Current.DebugModeFileOut) Info.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_userdata.xml");
         Exists = true;
     }
 }
Esempio n. 26
0
        public void AddCategory(int categoryid)
        {
            if (Info != null)
            {
                var strGuid = categoryid.ToString("") + "x" + Info.ItemID.ToString("");
                var objCtrl = new NBrightBuyController();
                var nbi = objCtrl.GetByGuidKey(_portalId, -1, "CATXREF", strGuid);
                if (nbi == null)
                {
                    nbi = new NBrightInfo();
                    nbi.ItemID = -1;
                    nbi.PortalId = _portalId;
                    nbi.ModuleId = -1;
                    nbi.TypeCode = "CATXREF";
                    nbi.XrefItemId = categoryid;
                    nbi.ParentItemId = Info.ItemID;
                    nbi.XMLData = null;
                    nbi.TextData = null;
                    nbi.Lang = null;
                    nbi.GUIDKey = strGuid;
                    var newitemid = objCtrl.Update(nbi);
                    nbi = objCtrl.Get(newitemid);
                    nbi.XMLData = "<genxml><sort>" + newitemid.ToString() + "</sort></genxml>";
                    objCtrl.Update(nbi);

                    //add all cascade xref
                    var objGrpCtrl = new GrpCatController(_lang, true);
                    var parentcats = objGrpCtrl.GetCategory(categoryid);
                    if (parentcats != null)
                    {
                        foreach (var p in parentcats.Parents)
                        {
                            strGuid = p.ToString("") + "x" + Info.ItemID.ToString("");
                            var obj = objCtrl.GetByGuidKey(_portalId, -1, "CATCASCADE", strGuid);
                            if (obj == null)
                            {
                                nbi = new NBrightInfo();
                                nbi.ItemID = -1;
                                nbi.PortalId = _portalId;
                                nbi.ModuleId = -1;
                                nbi.XrefItemId = p;
                                nbi.ParentItemId = Info.ItemID;
                                nbi.TypeCode = "CATCASCADE";
                                nbi.GUIDKey = strGuid;
                                newitemid = objCtrl.Update(nbi);
                                nbi = objCtrl.Get(newitemid);
                                nbi.XMLData = "<genxml><sort>" + newitemid.ToString() + "</sort></genxml>";
                                objCtrl.Update(nbi);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 27
0
        private void AddNew()
        {
            var nbi = new NBrightInfo(true);
            nbi.PortalId = PortalSettings.Current.PortalId; ;
            nbi.TypeCode = "GROUP";
            nbi.ModuleId = -1;
            nbi.ItemID = -1;
            var objCtrl = new NBrightBuyController();
            var itemId = objCtrl.Update(nbi);

            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                nbi = new NBrightInfo(true);
                nbi.PortalId = PortalSettings.Current.PortalId;
                nbi.TypeCode = "GROUPLANG";
                nbi.ModuleId = -1;
                nbi.ItemID = -1;
                nbi.Lang = lang;
                nbi.ParentItemId = itemId;
                objCtrl.Update(nbi);
            }

            LoadData(itemId);
        }
Esempio n. 28
0
 public void AddRelatedProduct(int productid)
 {
     if (productid!= Info.ItemID)  //cannot be related to itself
     {
         var strGuid = productid.ToString("") + "x" + Info.ItemID.ToString("");
         var objCtrl = new NBrightBuyController();
         var nbi = objCtrl.GetByGuidKey(_portalId, -1, "PRDXREF", strGuid);
         if (nbi == null)
         {
             nbi = new NBrightInfo();
             nbi.ItemID = -1;
             nbi.PortalId = _portalId;
             nbi.ModuleId = -1;
             nbi.TypeCode = "PRDXREF";
             nbi.XrefItemId = productid;
             nbi.ParentItemId = Info.ItemID;
             nbi.XMLData = null;
             nbi.TextData = null;
             nbi.Lang = null;
             nbi.GUIDKey = strGuid;
             objCtrl.Update(nbi);
         }
     }
 }
Esempio n. 29
0
        public int Validate()
        {
            var errorcount = 0;
            var objCtrl = new NBrightBuyController();

            DataRecord.ValidateXmlFormat();
            if (DataLangRecord == null)
            {
                // we have no datalang record for this language, so get an existing one and save it.
                var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
                if (l.Count > 0)
                {
                    DataLangRecord = (NBrightInfo)l[0].Clone();
                    DataLangRecord.ItemID = -1;
                    DataLangRecord.Lang = _lang;
                    DataLangRecord.ValidateXmlFormat();
                    objCtrl.Update(DataLangRecord);
                }
            }

            var defaultname = Name;
            if (defaultname == "")
            {
                // find a valid default name
                foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
                {
                    var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'");
                    if (l.Count == 1)
                    {
                        var nbi2 = (NBrightInfo) l[0];
                        if (nbi2.GetXmlProperty("genxml/textbox/groupname") != "")
                        {
                            defaultname = nbi2.GetXmlProperty("genxml/textbox/groupname");
                            Name = defaultname;
                            Save();
                            break;
                        }
                    }
                }
            }

            // fix langauge records
            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                var l = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'");
                if (l.Count == 0 && DataLangRecord != null)
                {
                    var nbi = (NBrightInfo)DataLangRecord.Clone();
                    nbi.ItemID = -1;
                    nbi.Lang = lang;
                    objCtrl.Update(nbi);
                    errorcount += 1;
                }

                if (l.Count == 1)
                {
                    var nbi2 = (NBrightInfo) l[0];
                    if (nbi2.GetXmlProperty("genxml/textbox/groupname") == "")
                    {
                        // if we have no name, use the default name we found early to update.
                        nbi2.SetXmlProperty("genxml/textbox/groupname", defaultname);
                        objCtrl.Update(nbi2);
                    }
                }

                if (l.Count > 1)
                {
                    // we have more records than should exists, remove any old ones.
                    var l2 = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "GROUPLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString("") + " and NB1.Lang = '" + lang + "'", "order by Modifieddate desc");
                    var lp = 1;
                    foreach (var i in l2)
                    {
                        if (lp >= 2) objCtrl.Delete(i.ItemID);
                        lp += 1;
                    }
                }
            }

            // add required field values to make getting group easier.
            if (DataRecord.GUIDKey != Ref)
            {
                DataRecord.GUIDKey = Ref;
                objCtrl.Update(DataRecord);
            }

            return errorcount;
        }
Esempio n. 30
0
        public int Copy()
        {
            var objCtrl = new NBrightBuyController();

            //Copy Base record
            var dr = (NBrightInfo)DataRecord.Clone();
            dr.ItemID = -1;
            dr.SetXmlProperty("genxml/importref", Utils.GetUniqueKey());
            var newid = objCtrl.Update(dr);

            // copy all language records
            var l = objCtrl.GetList(_portalId, -1, "PRDLANG", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
            foreach (var dlr in l)
            {
                dlr.ParentItemId = newid;
                dlr.ItemID = -1;
                objCtrl.Update(dlr);
            }

            // copy CATXREF records
            l = objCtrl.GetList(_portalId, -1, "CATXREF", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
            foreach (var dr1 in l)
            {
                dr1.ParentItemId = newid;
                dr1.ItemID = -1;
                dr1.GUIDKey = dr1.GUIDKey.Replace("x" + Info.ItemID.ToString(""), "x" + newid.ToString(""));
                objCtrl.Update(dr1);
            }

            // copy CATCASCADE records
            l = objCtrl.GetList(_portalId, -1, "CATCASCADE", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
            foreach (var dr2 in l)
            {
                dr2.ParentItemId = newid;
                dr2.ItemID = -1;
                dr2.GUIDKey = dr2.GUIDKey.Replace("x" + Info.ItemID.ToString(""), "x" + newid.ToString(""));
                objCtrl.Update(dr2);
            }

            // copy PRDXREF records
            l = objCtrl.GetList(_portalId, -1, "PRDXREF", " and NB1.ParentItemId = " + Info.ItemID.ToString(""));
            foreach (var dr3 in l)
            {
                dr3.ParentItemId = newid;
                dr3.ItemID = -1;
                dr3.GUIDKey = dr3.GUIDKey.Replace("x" + Info.ItemID.ToString(""), "x" + newid.ToString(""));
                objCtrl.Update(dr);
            }

            return newid;
        }
Esempio n. 31
0
        /// <summary>
        /// Save Purchase record
        /// </summary>
        /// <param name="copyrecord">Copy this data as a new record in the DB with a new id</param>
        /// <returns></returns>
        public int SavePurchaseData(Boolean copyrecord = false )
        {
            if (copyrecord)
            {
                _entryId = -1;
                PurchaseInfo.SetXmlProperty("genxml/audit", ""); // remove audit
            }

            // langauge
            if (Lang == "")
            {
                Lang = Utils.GetCurrentCulture();
            }
            ClientLang = Lang;

            var strXml = "<items>";
            foreach (var info in _itemList)
            {
                // remove injected group header record for the product
                if (!info.GetXmlPropertyBool("genxml/groupheader")) strXml += info.XMLData;
            }
            strXml += "</items>";
            PurchaseInfo.RemoveXmlNode("genxml/items");
            PurchaseInfo.AddXmlNode(strXml, "items", "genxml");

            var modCtrl = new NBrightBuyController();
            PurchaseInfo.ItemID = _entryId;
            PurchaseInfo.PortalId = PortalId;
            PurchaseInfo.ModuleId = -1;
            PurchaseInfo.TypeCode = PurchaseTypeCode;
            if (UserController.Instance.GetCurrentUserInfo().UserID != -1)  // This might be updated from out of context (payment provider)
            {
                if (UserId != UserController.Instance.GetCurrentUserInfo().UserID && EditMode == "") UserId = UserController.Instance.GetCurrentUserInfo().UserID;
                PurchaseInfo.UserId = UserId;
                if (EditMode == "" && !string.IsNullOrEmpty(UserController.Instance.GetCurrentUserInfo().Profile.PreferredLocale))
                {
                    ClientLang = UserController.Instance.GetCurrentUserInfo().Profile.PreferredLocale;
                }
            }

            // save the product refs of the order to an XML node, so we can search for product ref in the BO Order Admin.
            var productrefs = "";
            foreach (var i in GetCartItemList())
            {
                productrefs += i.GetXmlProperty("genxml/productxml/genxml/textbox/txtproductref") + ",";
            }
            PurchaseInfo.SetXmlProperty("genxml/productrefs", productrefs);

            if (PurchaseInfo.TypeCode != null) // if we're using this class to build cart in memory for procesisng only, don;t save to DB.
            {
                _entryId = modCtrl.Update(PurchaseInfo);
                NBrightBuyUtils.ProcessEventProvider(EventActions.AfterSavePurchaseData, PurchaseInfo);
            }

            return _entryId;
        }
Esempio n. 32
0
        public void RemoveCategory(int categoryid)
        {
            var objCtrl = new NBrightBuyController();
            if (Utils.IsNumeric(DataRecord.GetXmlProperty("genxml/defaultcatid")) && categoryid == Convert.ToInt32(DataRecord.GetXmlProperty("genxml/defaultcatid")))
            {
                DataRecord.SetXmlProperty("genxml/defaultcatid", "");
                objCtrl.Update(DataRecord);
            }

            var parentitemid = Info.ItemID.ToString("");
            var xrefitemid = categoryid.ToString("");
            var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
            var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
            var stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + xrefitemid + " and parentitemid = " + parentitemid;
            objCtrl.ExecSql(stmt);
            //remove all cascade xref
            var objGrpCtrl = new GrpCatController(_lang, true);
            var parentcats = objGrpCtrl.GetCategory(Convert.ToInt32(xrefitemid));
            if (parentcats != null)
            {
                foreach (var p in parentcats.Parents)
                {
                    var xreflist = objCtrl.GetList(_portalId, -1, "CATXREF", " and NB1.parentitemid = " + parentitemid);
                    if (xreflist != null)
                    {
                        var deleterecord = true;
                        foreach (var xref in xreflist)
                        {
                            var catid = xref.XrefItemId;
                            var xrefparentcats = objGrpCtrl.GetCategory(Convert.ToInt32(catid));
                            if (xrefparentcats != null && xrefparentcats.Parents.Contains(p))
                            {
                                deleterecord = false;
                                break;
                            }
                        }
                        if (deleterecord)
                        {
                            stmt = "delete from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATCASCADE' and XrefItemId = " + p.ToString("") + " and parentitemid = " + parentitemid;
                            objCtrl.ExecSql(stmt);
                        }

                    }
                }
            }
        }
Esempio n. 33
0
        public void Save()
        {
            _objCtrl.Update(DataRecord);
            _objCtrl.Update(DataLangRecord);

            //do reindex of cascade records.
            if (_doCascadeIndex)
            {
                var objGrpCtrl = new GrpCatController(_lang);
                objGrpCtrl.ReIndexCascade(_oldcatcascadeid);  // reindex form parnet and parents
                objGrpCtrl.ReIndexCascade(DataRecord.ItemID); // reindex self
                objGrpCtrl.Reload();
            }

            NBrightBuyUtils.ProcessEventProvider(EventActions.AfterCategorySave, DataRecord);
            // reload data so if event has altered data we use that.
            DataRecord     = _objCtrl.Get(DataRecord.ItemID);
            DataLangRecord = _objCtrl.Get(DataLangRecord.ItemID);

            Utils.RemoveCacheList("category_cachelist");
        }
Esempio n. 34
0
 public void ResetLanguage(String resetToLang)
 {
     if (resetToLang != DataLangRecord.Lang)
     {
         var resetToLangData = ProductUtils.GetProductData(DataRecord.ItemID, resetToLang);
         var objCtrl = new NBrightBuyController();
         DataLangRecord.XMLData = resetToLangData.DataLangRecord.XMLData;
         objCtrl.Update(DataLangRecord);
     }
 }
        private String AddNew(String moduleid,String typeCode)
        {
            if (!Utils.IsNumeric(moduleid)) moduleid = "-2"; // -2 for razor

            var objCtrl = new NBrightBuyController();
            var nbi = new NBrightInfo(true);
            nbi.PortalId = PortalSettings.Current.PortalId;
            nbi.TypeCode = typeCode;
            nbi.ModuleId = Convert.ToInt32(moduleid);
            nbi.ItemID = -1;
            nbi.SetXmlProperty("genxml/textbox/code", Utils.GetUniqueKey().ToUpper());
            nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
            var itemId = objCtrl.Update(nbi);
            nbi.ItemID = itemId;

            foreach (var lang in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
            {
                var nbi2 = new NBrightInfo(true);
                nbi2.PortalId = PortalSettings.Current.PortalId;
                nbi2.TypeCode = typeCode + "LANG";
                nbi2.ModuleId = Convert.ToInt32(moduleid);
                nbi2.ItemID = -1;
                nbi2.Lang = lang;
                nbi2.ParentItemId = itemId;
                nbi2.GUIDKey = "";
                nbi2.ItemID = objCtrl.Update(nbi2);
            }

            NBrightBuyUtils.RemoveModCache(nbi.ModuleId);

            return nbi.ItemID.ToString("");
        }
Esempio n. 36
0
        /// <summary>
        /// Search filesystem for any new plugins that have been added. Removed any deleted ones.
        /// </summary>
        public static void UpdateSystemPlugins()
        {
            // Add new plugins
            var updated             = false;
            var pluginfoldermappath = System.Web.Hosting.HostingEnvironment.MapPath(StoreSettings.NBrightBuyPath() + "/Plugins");

            if (pluginfoldermappath != null && Directory.Exists(pluginfoldermappath))
            {
                var objCtrl = new NBrightBuyController();
                var flist   = Directory.GetFiles(pluginfoldermappath, "*.xml");
                foreach (var f in flist)
                {
                    if (f.EndsWith(".xml"))
                    {
                        var datain = File.ReadAllText(f);
                        try
                        {
                            var nbi = new NBrightInfo();
                            nbi.XMLData = datain;
                            // check if we are injecting multiple
                            var nodlist = nbi.XMLDoc.SelectNodes("genxml");
                            if (nodlist != null && nodlist.Count > 0)
                            {
                                foreach (XmlNode nod in nodlist)
                                {
                                    var nbi2 = new NBrightInfo();
                                    nbi2.XMLData      = nod.OuterXml;
                                    nbi2.ItemID       = -1;
                                    nbi2.GUIDKey      = nbi.GetXmlProperty("genxml/textbox/ctrl");
                                    nbi2.PortalId     = 99999;
                                    nbi2.Lang         = "";
                                    nbi2.ParentItemId = 0;
                                    nbi2.ModuleId     = -1;
                                    nbi2.XrefItemId   = 0;
                                    nbi2.UserId       = 0;
                                    nbi2.TypeCode     = "PLUGIN";

                                    // check if record exists (should NOT) but lets replace if it does.
                                    var existingrecord = objCtrl.GetByGuidKey(-1, -1, "PLUGIN", nbi2.GUIDKey);
                                    if (existingrecord != null)
                                    {
                                        nbi2.ItemID = existingrecord.ItemID;
                                        if (nbi2.GetXmlPropertyBool("genxml/delete"))
                                        {
                                            objCtrl.Delete(existingrecord.ItemID);
                                        }
                                        else
                                        {
                                            objCtrl.Update(nbi2);
                                            updated = true;
                                        }
                                    }
                                    else
                                    {
                                        objCtrl.Update(nbi2);
                                        updated = true;
                                    }
                                }
                            }
                            if (updated)
                            {
                                File.Delete(f);
                            }
                        }
                        catch (Exception)
                        {
                            // data might not be XML complient (ignore)
                        }
                    }
                }
            }

            if (updated)
            {
                CopySystemPluginsToPortal();
                ClearPluginCache(PortalSettings.Current.PortalId);
            }
        }
Esempio n. 37
0
 /// <summary>
 /// Save cart
 /// </summary>
 public void Save(Boolean debugMode = false)
 {
     //save cart
         var strXML = "<list>";
         var lp = 0;
         foreach (var info in _shippingList)
         {
             info.SetXmlProperty("genxml/hidden/index",lp.ToString("D"));
             strXML += info.XMLData;
             lp += 1;
         }
         strXML += "</list>";
         Info.RemoveXmlNode("genxml/list");
         Info.AddXmlNode(strXML, "list", "genxml");
         if (Info != null)
         {
             var modCtrl = new NBrightBuyController();
             Info.ItemID = modCtrl.Update(Info);
         }
 }
Esempio n. 38
0
        public static void CreateFriendlyImages(int productid, string lang)
        {
            var objCtrl          = new NBrightBuyController();
            var imgList          = new List <string>();
            var productData      = new ProductData(productid, lang);
            var productImgFolder = StoreSettings.Current.FolderImagesMapPath.TrimEnd('\\') + "\\" + productData.DataRecord.ItemID + "\\" + lang;

            Utils.CreateFolder(productImgFolder);

            foreach (var i in productData.Imgs)
            {
                //becuase of updates to sort order and alt text we NEED to delete the existing files.
                Utils.DeleteSysFile(i.GetXmlProperty("genxml/lang/genxml/hidden/fimagepath"));
            }

            var lp = 1;

            foreach (var i in productData.Imgs)
            {
                // use imageref to link langauges
                var imageref = i.GetXmlProperty("genxml/hidden/imageref");
                if (imageref == "")
                {
                    imageref = Utils.GetUniqueKey();
                    productData.DataRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/imageref", imageref);
                }

                var imgname = i.GetXmlProperty("genxml/lang/genxml/textbox/txtimagedesc");
                if (imgname == "")
                {
                    imgname = productData.ProductName;
                }
                if (imgname == "")
                {
                    imgname = productData.ProductRef;
                }
                if (imgname != "")
                {
                    var fullName  = i.GetXmlProperty("genxml/hidden/imagepath");
                    var extension = Path.GetExtension(fullName);
                    imgname = AlphaNumeric(CleanFileName(imgname.Replace(" ", "-")));
                    var imgnameext       = imgname + extension;
                    var newImageFileName = productImgFolder + "\\" + imgnameext;
                    var lp2 = 1;
                    while (File.Exists(newImageFileName))
                    {
                        imgnameext       = imgname + "-" + lp2 + extension;
                        newImageFileName = productImgFolder + "\\" + imgnameext;
                        lp2++;
                    }
                    var imgSize = StoreSettings.Current.GetInt(StoreSettingKeys.productimageresize);
                    if (imgSize == 0)
                    {
                        imgSize = 960;
                    }
                    if (extension != null && extension.ToLower() == ".png")
                    {
                        newImageFileName = ImgUtils.ResizeImageToPng(fullName, newImageFileName, imgSize);
                    }
                    else
                    {
                        newImageFileName = ImgUtils.ResizeImageToJpg(fullName, newImageFileName, imgSize);
                    }
                    var newimageurl = StoreSettings.Current.FolderImages.TrimEnd('/') + "/" + productData.DataRecord.ItemID + "/" + lang + "/" + imgnameext;
                    productData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/fimageurl", newimageurl);
                    productData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/fimagepath", newImageFileName);
                    productData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp + "]/hidden/fimageref", imageref);
                    imgList.Add(newImageFileName);
                }
                lp += 1;
            }

            objCtrl.Update(productData.DataLangRecord);
            objCtrl.Update(productData.DataRecord);

            // remove any deleted images.
            var fl = Directory.GetFiles(productImgFolder);

            foreach (var f in fl)
            {
                if (!imgList.Contains(f))
                {
                    Utils.DeleteSysFile(f);
                }
            }

            // sort other language
            foreach (var l in DnnUtils.GetCultureCodeList())
            {
                if (l != lang)
                {
                    var strXml = "";
                    var pData  = new ProductData(productid, l);
                    var lp3    = 1;
                    foreach (var langimg in pData.Imgs)
                    {
                        var imgref  = langimg.GetXmlProperty("genxml/hidden/imageref");
                        var strNode = pData.DataLangRecord.GetXmlNode("genxml/imgs/genxml[./hidden/fimageref='" + imgref + "']");
                        if (strNode == "")
                        {
                            // create missing ref and get xml. (May misalign images alts)
                            pData.DataLangRecord.SetXmlProperty("genxml/imgs/genxml[" + lp3 + "]/hidden/fimageref", imgref);
                            strNode = pData.DataLangRecord.GetXmlNode("genxml/imgs/genxml[./hidden/fimageref='" + imgref + "']");
                        }
                        strXml += "<genxml>" + strNode + "</genxml>";
                        lp3    += 1;
                    }
                    strXml = "<imgs>" + strXml + "</imgs>";
                    pData.DataLangRecord.RemoveXmlNode("genxml/imgs");
                    pData.DataLangRecord.AddXmlNode(strXml, "imgs", "genxml");
                    objCtrl.Update(pData.DataLangRecord);
                }
            }

            RemoveProductDataCache(PortalSettings.Current.PortalId, productid);
        }
Esempio n. 39
0
        private String CopyAllCatXref(HttpContext context,Boolean moverecords = false)
        {
            var strOut = NBrightBuyUtils.GetResxMessage("general_fail");
            try
            {
                var settings = GetAjaxFields(context);
                var strFilter = " and XrefItemId = {Settings:itemid} ";

                strFilter = Utils.ReplaceSettingTokens(strFilter, settings);

                var newcatid = "";
                if (settings.ContainsKey("selectedcatid")) newcatid = settings["selectedcatid"];

                if (Utils.IsNumeric(newcatid) && settings.ContainsKey("itemid"))
                {
                    var objCtrl = new NBrightBuyController();
                    var objList = objCtrl.GetList(PortalSettings.Current.PortalId, -1, "CATXREF", strFilter);

                    foreach (var obj in objList)
                    {
                        var strGuid = newcatid + "x" + obj.ParentItemId.ToString("");
                        var nbi = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATXREF", strGuid);
                        if (nbi == null)
                        {
                            if (!moverecords) obj.ItemID = -1;
                            obj.XrefItemId = Convert.ToInt32(newcatid);
                            obj.GUIDKey = strGuid;
                            obj.XMLData = null;
                            obj.TextData = null;
                            obj.Lang = null;
                            objCtrl.Update(obj);
                            //add all cascade xref
                            var objGrpCtrl = new GrpCatController(_lang, true);
                            var parentcats = objGrpCtrl.GetCategory(Convert.ToInt32(newcatid));
                            foreach (var p in parentcats.Parents)
                            {
                                strGuid = p.ToString("") + "x" + obj.ParentItemId.ToString("");
                                nbi = objCtrl.GetByGuidKey(PortalSettings.Current.PortalId, -1, "CATCASCADE", strGuid);
                                if (nbi == null)
                                {
                                    obj.XrefItemId = p;
                                    obj.TypeCode = "CATCASCADE";
                                    obj.GUIDKey = strGuid;
                                    objCtrl.Update(obj);
                                }
                            }
                        }
                    }

                    if (moverecords) DeleteAllCatXref(context);

                    strOut = NBrightBuyUtils.GetResxMessage();
                }

            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
            return strOut;
        }
Esempio n. 40
0
        public void Save()
        {
            var objCtrl = new NBrightBuyController();

            objCtrl.Update(DataRecord);
        }
Esempio n. 41
0
 public void SetDefaultCategory(int categoryid)
 {
     var objCtrl = new NBrightBuyController();
     DataRecord.SetXmlProperty("genxml/defaultcatid", categoryid.ToString());
     objCtrl.Update(DataRecord);
 }
        private String SaveData(HttpContext context)
        {
            try
            {
                var objCtrl = new NBrightBuyController();

                //get uploaded params
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                SetContextLangauge(ajaxInfo); // Ajax breaks context with DNN, so reset the context language to match the client.

                var itemid = ajaxInfo.GetXmlProperty("genxml/hidden/itemid");
                var lang = ajaxInfo.GetXmlProperty("genxml/hidden/editlang");
                if (lang == "") lang = ajaxInfo.GetXmlProperty("genxml/hidden/lang");
                if (lang == "") lang = _lang;

                if (Utils.IsNumeric(itemid))
                {
                    // get DB record
                    var nbi = objCtrl.Get(Convert.ToInt32(itemid));
                    if (nbi != null)
                    {
                        // get data passed back by ajax
                        var strIn = HttpUtility.UrlDecode(Utils.RequestParam(context, "inputxml"));
                        // update record with ajax data
                        nbi.UpdateAjax(strIn);
                        nbi.GUIDKey = nbi.GetXmlProperty("genxml/textbox/code");
                        objCtrl.Update(nbi);

                        // do langauge record
                        nbi = objCtrl.GetDataLang(Convert.ToInt32(itemid), lang);
                        nbi.UpdateAjax(strIn);
                        objCtrl.Update(nbi);

                        DataCache.ClearCache(); // clear ALL cache, the usagelimit may need to be reset.

                    }
                }
                return "";

            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
Esempio n. 43
0
        public void Save()
        {
            foreach (var model in Models)
            {
                var qty = DataRecord.GetXmlPropertyDouble("genxml/models/genxml[" + model.ItemID.ToString("") + "]/textbox/txtqtyremaining");
                var minqty = DataRecord.GetXmlPropertyDouble("genxml/models/genxml[" + model.ItemID.ToString("") + "]/textbox/txtqtyminstock");
                var currentstatus = DataRecord.GetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/dropdownlist/modelstatus");
                var activatestock = DataRecord.GetXmlPropertyBool("genxml/models/genxml[" + model.ItemID.ToString("") + "]/checkbox/chkstockon");
                if (activatestock && currentstatus != "040" && currentstatus != "050")
                {
                    if (qty > 0) DataRecord.SetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/dropdownlist/modelstatus", "010");
                    if (minqty == qty) DataRecord.SetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/dropdownlist/modelstatus", "020");
                    if (qty <= 0 && minqty < qty) DataRecord.SetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/dropdownlist/modelstatus", "030");
                }
                else
                {
                    // stock not activate so set status to available
                    DataRecord.SetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/dropdownlist/modelstatus", "010");
                }

                if (DataRecord.GetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/hidden/modelid") == "") DataRecord.SetXmlProperty("genxml/models/genxml[" + model.ItemID.ToString("") + "]/hidden/modelid", Utils.GetUniqueKey());
            }

            // calcs what the import and guidkey should be.
            SetGuidKey();

            DataRecord.ModuleId = -1; // moduleid of product always set to -1 (Portal Wide)
            DataLangRecord.ModuleId = -1; // moduleid of product always set to -1 (Portal Wide)

            var objCtrl = new NBrightBuyController();
            var productid = objCtrl.Update(DataRecord);
            DataLangRecord.ParentItemId = productid;
            var plangid = objCtrl.Update(DataLangRecord);

            // reload data so it's upto date with new ids
            DataRecord = objCtrl.Get(productid);
            DataLangRecord = objCtrl.Get(plangid);

            NBrightBuyUtils.ProcessEventProvider(EventActions.AfterProductSave, DataRecord);
        }
Esempio n. 44
0
        public static void RemoveAllXref(string itemId)
        {
            if (Utils.IsNumeric(itemId))
            {
                var xrefList = new List<string>();
                xrefList.Add("prdimg");
                xrefList.Add("prdxref");
                xrefList.Add("prddoc");
                xrefList.Add("prdopt");

                foreach (var xrefName in xrefList)
                {
                    var objCtrl = new NBrightBuyController();
                    var objPInfo = objCtrl.Get(Convert.ToInt32(itemId));
                    if (objPInfo != null)
                    {
                        var xrefIdList = objPInfo.GetXrefList(xrefName);
                        foreach (var xrefid in xrefIdList)
                        {
                            if (Utils.IsNumeric(xrefid))
                            {
                                var objRef = objCtrl.Get(Convert.ToInt32(xrefid));
                                if (objRef != null)
                                {
                                    objRef.RemoveXref(xrefName, itemId);
                                    objCtrl.Update(objRef);
                                }
                            }
                            objPInfo.RemoveXref(xrefName, xrefid);
                            objCtrl.Update(objPInfo);
                        }

                    }
                }
            }
        }