Ejemplo n.º 1
0
        public static string ProcessCommand(string paramCmd, HttpContext context)
        {
            var strOut = "CLIENT - ERROR!! - No Security rights for current user!";

            if (NBrightBuyUtils.CheckManagerRights())
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                var userId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/userid");

                switch (paramCmd)
                {
                case "product_admin_getlist":
                    strOut = ProductFunctions.ProductAdminList(context);
                    break;

                case "product_admin_getdetail":
                    strOut = ProductFunctions.ProductAdminDetail(context);
                    break;

                case "product_admin_save":
                    strOut = ProductFunctions.ProductAdminSave(context);
                    break;

                case "product_admin_selectlist":
                    strOut = ProductFunctions.ProductAdminList(context);
                    break;

                case "product_moveproductadmin":
                    strOut = ProductFunctions.MoveProductAdmin(context);
                    break;
                }
            }
            return(strOut);
        }
Ejemplo n.º 2
0
 public static String ClientAdminSave(HttpContext context)
 {
     try
     {
         if (NBrightBuyUtils.CheckManagerRights())
         {
             var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
             var userId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/userid");
             if (userId > 0)
             {
                 var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                 if (clientData.Exists)
                 {
                     clientData.Update(ajaxInfo);
                     clientData.Save();
                     return("");
                 }
             }
         }
         return("");
     }
     catch (Exception ex)
     {
         return(ex.ToString());
     }
 }
Ejemplo n.º 3
0
        public String CategoryAdminDetail(HttpContext context, int catid, string editLangCurrent)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    EditLangCurrent = editLangCurrent;
                    var ajaxInfo       = NBrightBuyUtils.GetAjaxInfo(context);
                    var strOut         = "";
                    var selecteditemid = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
                    if (catid > 0)
                    {
                        selecteditemid = catid;
                    }
                    if (Utils.IsNumeric(selecteditemid))
                    {
                        var themeFolder   = ajaxInfo.GetXmlProperty("genxml/hidden/themefolder");
                        var razortemplate = ajaxInfo.GetXmlProperty("genxml/hidden/razortemplate");
                        var portalId      = PortalSettings.Current.PortalId;

                        var passSettings = ajaxInfo.ToDictionary();
                        foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                        {
                            if (passSettings.ContainsKey(s.Key))
                            {
                                passSettings[s.Key] = s.Value;
                            }
                            else
                            {
                                passSettings.Add(s.Key, s.Value);
                            }
                        }

                        if (selecteditemid <= 0)
                        {
                            return("");
                        }

                        if (themeFolder == "")
                        {
                            themeFolder = StoreSettings.Current.ThemeFolder;
                        }

                        var objCtrl = new NBrightBuyController();
                        var info    = objCtrl.GetData(Convert.ToInt32(selecteditemid), EntityTypeCode + "LANG", EditLangCurrent, true);

                        strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", info, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    }
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 4
0
        private string DownloadSystemFile(string paramCmd, HttpContext context)
        {
            var strOut = "";

            lock (lockobjectDownloadSystemFile)
            {
                var fname   = Utils.RequestQueryStringParam(context, "filename");
                var filekey = Utils.RequestQueryStringParam(context, "key");
                if (filekey != "")
                {
                    var uData = new UserData();
                    if (uData.HasPurchasedDocByKey(filekey))
                    {
                        fname = uData.GetPurchasedFileName(filekey);
                    }
                    fname = StoreSettings.Current.FolderDocuments + "/" + fname;
                }
                if (fname != "")
                {
                    strOut = fname; // return this is error.
                    var downloadname = Utils.RequestQueryStringParam(context, "downloadname");
                    var userid       = Utils.RequestQueryStringParam(context, "userid");
                    var fpath        = HttpContext.Current.Server.MapPath(fname);
                    if (downloadname == "")
                    {
                        downloadname = Path.GetFileName(fname);
                    }
                    try
                    {
                        if (fpath.ToLower().Contains("\\secure"))
                        {
                            if (NBrightBuyUtils.CheckManagerRights() || UserController.Instance.GetCurrentUserInfo().UserID.ToString() == userid)
                            {
                                Utils.ForceDocDownload(fpath, downloadname, context.Response);
                            }
                        }
                        else
                        {
                            Utils.ForceDocDownload(fpath, downloadname, context.Response);
                        }
                    }
                    catch (Exception ex)
                    {
                        // ignore, robots can cause error on thread abort.
                        //Exceptions.LogException(ex);
                        Logging.Debug($"XmlConnector.ProcessRequest exception for {paramCmd} which is ignored because bots tend to cause these on thread abort: {ex.Message}.");
                    }
                }
            }
            return(strOut);
        }
Ejemplo n.º 5
0
        public String CategoryGroupFilters(HttpContext context, string editLangCurrent)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    EditLangCurrent = editLangCurrent;
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);
                    var strOut   = "";
                    var catid    = ajaxInfo.GetXmlPropertyInt("genxml/hidden/selectedcatid");
                    if (catid > 0)
                    {
                        var themeFolder   = "config";
                        var razortemplate = "Admin_CategoryFilterGroups.cshtml";

                        var passSettings = ajaxInfo.ToDictionary();
                        foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                        {
                            if (passSettings.ContainsKey(s.Key))
                            {
                                passSettings[s.Key] = s.Value;
                            }
                            else
                            {
                                passSettings.Add(s.Key, s.Value);
                            }
                        }

                        var objCtrl = new NBrightBuyController();
                        var info    = objCtrl.GetData(catid, EntityTypeCode + "LANG", EditLangCurrent, true);

                        strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", info, TemplateRelPath, themeFolder, Utils.GetCurrentCulture(), passSettings);
                    }
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 6
0
        private static String OrderAdminRemoveInvoice(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);
                    var itemId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                    if (itemId > 0)
                    {
                        var ordData = new OrderData(itemId);
                        if (ordData != null)
                        {
                            // save relitive path also
                            if (File.Exists(ordData.PurchaseInfo.GetXmlProperty("genxml/hidden/invoicefilepath")))
                            {
                                File.Delete(ordData.PurchaseInfo.GetXmlProperty("genxml/hidden/invoicefilepath"));
                            }


                            ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilepath", "");
                            ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilename", "");
                            ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefileext", "");
                            ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilerelpath", "");
                            ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicedownloadname", "");
                            ordData.AddAuditMessage(NBrightBuyUtils.ResourceKey("OrderAdmin.cmdDeleteInvoice"), "invremove", UserController.Instance.GetCurrentUserInfo().Username, "False");

                            ordData.Save();
                        }
                    }

                    return("");
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 7
0
        public static String ClientAdminDetail(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    var settings = NBrightBuyUtils.GetAjaxDictionary(context);
                    var strOut   = "";

                    if (!settings.ContainsKey("themefolder"))
                    {
                        settings.Add("themefolder", "");
                    }
                    if (!settings.ContainsKey("razortemplate"))
                    {
                        settings.Add("razortemplate", "");
                    }
                    if (!settings.ContainsKey("portalid"))
                    {
                        settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                    }
                    if (!settings.ContainsKey("selecteditemid"))
                    {
                        settings.Add("selecteditemid", "");
                    }

                    var themeFolder    = settings["themefolder"];
                    var selecteditemid = settings["selecteditemid"];
                    if (selecteditemid == "")
                    {
                        if (!settings.ContainsKey("userid"))
                        {
                            settings.Add("userid", "");
                        }
                        selecteditemid = settings["userid"];
                    }
                    var razortemplate = settings["razortemplate"];
                    var portalId      = Convert.ToInt32(settings["portalid"]);

                    var passSettings = settings;
                    foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                    {
                        if (passSettings.ContainsKey(s.Key))
                        {
                            passSettings[s.Key] = s.Value;
                        }
                        else
                        {
                            passSettings.Add(s.Key, s.Value);
                        }
                    }

                    if (!Utils.IsNumeric(selecteditemid))
                    {
                        return("");
                    }

                    if (themeFolder == "")
                    {
                        themeFolder = StoreSettings.Current.ThemeFolder;
                        if (settings.ContainsKey("themefolder"))
                        {
                            themeFolder = settings["themefolder"];
                        }
                    }

                    var clientData = new ClientData(portalId, Convert.ToInt32(selecteditemid));
                    strOut = NBrightBuyUtils.RazorTemplRender(razortemplate, 0, "", clientData, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings);
                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 8
0
        public static string ProcessCommand(string paramCmd, HttpContext context)
        {
            var strOut = "CLIENT - ERROR!! - No Security rights for current user!";

            if (NBrightBuyUtils.CheckManagerRights())
            {
                var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
                var userId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/userid");

                switch (paramCmd)
                {
                case "client.admin_getlist":
                    strOut = ClientFunctions.ClientAdminList(context);
                    break;

                case "client.admin_getdetail":
                    strOut = ClientFunctions.ClientAdminDetail(context);
                    break;

                case "client.admin_save":
                    strOut = ClientFunctions.ClientAdminSave(context);
                    break;

                case "client.discountcodes":
                    //strOut = ClientFunctions.GetClientDiscountCodes(context);
                    break;

                case "client.adddiscountcode":
                    AddClientDiscountCodes(context);
                    strOut = ClientFunctions.ClientAdminDetail(context);
                    break;

                case "client.vouchercodes":
                    //strOut = ClientFunctions.GetClientVoucherCodes(context);
                    break;

                case "client.addvouchercode":
                    AddClientVoucherCodes(context);
                    strOut = ClientFunctions.ClientAdminDetail(context);
                    break;

                case "client.unlockuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.UnlockUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.deleteuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.DeleteUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.restoreuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.RestoreUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.removeuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.RemoveUser();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.validateuser":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.AuthoriseClient();
                            clientData.AddClientEditorRole();
                            if (StoreSettings.Current.Get("resetpasswordonclientvalidate") == "True")
                            {
                                clientData.ResetPassword();
                            }
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.unauthoriseuser":
                    if (userId > 0 && UserController.Instance.GetCurrentUserInfo()?.UserID != userId)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.UnAuthoriseClient();
                            clientData.RemoveClientEditorRole();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.resetpass":
                    if (userId > 0)
                    {
                        var clientData = new ClientData(PortalSettings.Current.PortalId, userId);
                        if (clientData.Exists)
                        {
                            clientData.ResetPassword();
                            strOut = ClientFunctions.ClientAdminDetail(context);
                        }
                    }
                    break;

                case "client.createorder":
                    var cart = new CartData(PortalSettings.Current.PortalId);
                    cart.UserId   = userId;
                    cart.EditMode = "C";
                    cart.Save();
                    strOut = DnnUtils.GetResourceString("/DesktopModules/NBright/NBrightBuy/App_LocalResources/", "General.Processing");
                    break;
                }
            }
            return(strOut);
        }
Ejemplo n.º 9
0
        public static String ClientAdminList(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    var settings = NBrightBuyUtils.GetAjaxDictionary(context);

                    var paging = true;

                    if (UserController.Instance.GetCurrentUserInfo().UserID <= 0)
                    {
                        return("");
                    }

                    var strOut = "";

                    if (!settings.ContainsKey("themefolder"))
                    {
                        settings.Add("themefolder", "");
                    }
                    if (!settings.ContainsKey("userid"))
                    {
                        settings.Add("userid", "-1");
                    }
                    if (!settings.ContainsKey("razortemplate"))
                    {
                        settings.Add("razortemplate", "");
                    }
                    if (!settings.ContainsKey("returnlimit"))
                    {
                        settings.Add("returnlimit", "0");
                    }
                    if (!settings.ContainsKey("pagenumber"))
                    {
                        settings.Add("pagenumber", "0");
                    }
                    if (!settings.ContainsKey("pagesize"))
                    {
                        settings.Add("pagesize", "0");
                    }
                    if (!settings.ContainsKey("searchtext"))
                    {
                        settings.Add("searchtext", "");
                    }
                    if (!settings.ContainsKey("dtesearchdatefrom"))
                    {
                        settings.Add("dtesearchdatefrom", "");
                    }
                    if (!settings.ContainsKey("dtesearchdateto"))
                    {
                        settings.Add("dtesearchdateto", "");
                    }
                    if (!settings.ContainsKey("searchorderstatus"))
                    {
                        settings.Add("searchorderstatus", "");
                    }
                    if (!settings.ContainsKey("portalid"))
                    {
                        settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                    }
                    if (!Utils.IsNumeric(settings["userid"]))
                    {
                        settings["pagenumber"] = "1";
                    }
                    if (!Utils.IsNumeric(settings["pagenumber"]))
                    {
                        settings["pagenumber"] = "1";
                    }
                    if (!Utils.IsNumeric(settings["pagesize"]))
                    {
                        settings["pagesize"] = "20";
                    }
                    if (!Utils.IsNumeric(settings["returnlimit"]))
                    {
                        settings["returnlimit"] = "50";
                    }

                    var themeFolder   = settings["themefolder"];
                    var razortemplate = settings["razortemplate"];
                    var returnLimit   = Convert.ToInt32(settings["returnlimit"]);
                    var pageNumber    = Convert.ToInt32(settings["pagenumber"]);
                    var pageSize      = Convert.ToInt32(settings["pagesize"]);
                    var portalId      = Convert.ToInt32(settings["portalid"]);
                    var userid        = settings["userid"];

                    var searchText = settings["searchtext"];

                    var recordCount = 0;

                    if (themeFolder == "")
                    {
                        themeFolder = StoreSettings.Current.ThemeFolder;
                        if (settings.ContainsKey("themefolder"))
                        {
                            themeFolder = settings["themefolder"];
                        }
                    }

                    var objCtrl = new NBrightBuyController();

                    if (paging) // get record count for paging
                    {
                        if (pageNumber == 0)
                        {
                            pageNumber = 1;
                        }
                        if (pageSize == 0)
                        {
                            pageSize = 20;
                        }

                        // get only entity type required
                        recordCount = objCtrl.GetDnnUsersCount(portalId, "%" + searchText + "%");
                    }

                    var list = objCtrl.GetDnnUsers(portalId, "%" + searchText + "%", 0, pageNumber, pageSize, recordCount);

                    var passSettings = settings;
                    foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                    {
                        if (passSettings.ContainsKey(s.Key))
                        {
                            passSettings[s.Key] = s.Value;
                        }
                        else
                        {
                            passSettings.Add(s.Key, s.Value);
                        }
                    }

                    strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings);

                    // add paging if needed
                    if (paging && (recordCount > pageSize))
                    {
                        var pg = new NBrightCore.controls.PagingCtrl();
                        strOut += pg.RenderPager(recordCount, pageSize, pageNumber);
                    }

                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 10
0
        public String CategorySave(HttpContext context, string editLangCurrent)
        {
            if (NBrightBuyUtils.CheckManagerRights())
            {
                EditLangCurrent = editLangCurrent;
                var ajaxInfo     = NBrightBuyUtils.GetAjaxFields(context);
                var parentitemid = ajaxInfo.GetXmlPropertyInt("genxml/dropdownlist/ddlparentcatid");
                var catid        = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                if (catid > 0)
                {
                    if (parentitemid != catid)
                    {
                        var catData = new CategoryData(catid, EditLangCurrent);

                        // check we've not put a category under it's child
                        if (!IsParentInChildren(catData, parentitemid))
                        {
                            var catDirectList   = catData.GetDirectArticles();
                            var oldparentitemId = catData.ParentItemId;
                            if (parentitemid != oldparentitemId)
                            {
                                // remove articles for category, so we realign the cascade records.
                                foreach (var p in catDirectList)
                                {
                                    var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang);
                                    prdData.RemoveCategory(catData.CategoryId);
                                }
                            }

                            catData.Update(ajaxInfo);

                            // the base category ref cannot have language dependant refs, we therefore just use a unique key
                            var catref = catData.DataRecord.GetXmlProperty("genxml/textbox/txtcategoryref");
                            if (catref == "")
                            {
                                if (catData.DataRecord.GUIDKey == "")
                                {
                                    catref = Utils.GetUniqueKey().ToLower();
                                    catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catref);
                                    catData.DataRecord.GUIDKey = catref;
                                }
                                else
                                {
                                    catData.DataRecord.SetXmlProperty("genxml/textbox/txtcategoryref", catData.DataRecord.GUIDKey);
                                }
                            }
                            catData.Save();
                            CategoryUtils.ValidateLangaugeRef(PortalSettings.Current.PortalId, catid); // do validate so we update all refs and children refs
                            NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);

                            if (parentitemid != oldparentitemId)
                            {
                                // all all articles for category. so we realign the cascade records.
                                foreach (var p in catDirectList)
                                {
                                    var prdData = new ProductData(p.ParentItemId, p.PortalId, p.Lang);
                                    prdData.AddCategory(catData.CategoryId);
                                }
                            }
                        }
                    }
                }
                DataCache.ClearCache();
                NBrightBuyUtils.RemoveModCachePortalWide(PortalSettings.Current.PortalId);
            }
            return("");
        }
Ejemplo n.º 11
0
        private static String OrderAdminSave(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);
                    var itemId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                    if (itemId > 0)
                    {
                        var ordData = new OrderData(itemId);
                        if (ordData != null)
                        {
                            var newStatusOrder = ajaxInfo.GetXmlProperty("genxml/dropdownlist/orderstatus");
                            if (ordData.OrderStatus != newStatusOrder)
                            {
                                ordData.OrderStatus = newStatusOrder;
                            }

                            ordData.PurchaseInfo.SetXmlProperty("genxml/textbox/shippingdate", ajaxInfo.GetXmlProperty("genxml/textbox/shippingdate"), TypeCode.DateTime);
                            ordData.PurchaseInfo.SetXmlProperty("genxml/textbox/trackingcode", ajaxInfo.GetXmlProperty("genxml/textbox/trackingcode"));

                            // do audit notes
                            if (ajaxInfo.GetXmlProperty("genxml/textbox/auditnotes") != "")
                            {
                                ordData.AddAuditMessage(ajaxInfo.GetXmlProperty("genxml/textbox/auditnotes"), "notes", UserController.Instance.GetCurrentUserInfo().Username, "False");
                            }

                            // save relitive path also
                            if (ajaxInfo.GetXmlProperty("genxml/hidden/optionfilelist") != "")
                            {
                                var fname = Path.GetFileName(ajaxInfo.GetXmlProperty("genxml/hidden/optionfilelist"));

                                if (File.Exists(StoreSettings.Current.FolderTempMapPath.TrimEnd('\\') + "\\" + fname))
                                {
                                    var newfname = Utils.GetUniqueKey();
                                    // save relitive path also
                                    if (File.Exists(ordData.PurchaseInfo.GetXmlProperty("genxml/hidden/invoicefilepath")))
                                    {
                                        File.Delete(StoreSettings.Current.FolderUploadsMapPath.TrimEnd('\\') + "\\" + newfname);
                                    }

                                    File.Copy(StoreSettings.Current.FolderTempMapPath.TrimEnd('\\') + "\\" + fname, StoreSettings.Current.FolderUploadsMapPath.TrimEnd('\\') + "\\" + newfname);
                                    File.Delete(StoreSettings.Current.FolderTempMapPath.TrimEnd('\\') + "\\" + fname);

                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilepath", StoreSettings.Current.FolderUploadsMapPath.TrimEnd('\\') + "\\" + newfname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilename", newfname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoiceuploadname", fname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefileext", Path.GetExtension(fname));
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilerelpath", StoreSettings.Current.FolderUploads + "/" + newfname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicedownloadname", "NBS" + ordData.OrderNumber + Path.GetExtension(fname));
                                }
                            }



                            ordData.Save();
                        }
                    }

                    return("");
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 12
0
        public static string ProcessCommand(string paramCmd, HttpContext context, string editlang = "")
        {
            var strOut   = "PROPERTY - ERROR!! - No Security rights or function command.";
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);

            UiLang = ajaxInfo.GetXmlProperty("genxml/hidden/uilang");
            if (UiLang == "")
            {
                UiLang = EditLangCurrent;
            }
            var userId = ajaxInfo.GetXmlPropertyInt("genxml/hidden/userid");

            EntityTypeCode = ajaxInfo.GetXmlProperty("genxml/hidden/entitytypecode");
            if (EntityTypeCode == "")
            {
                EntityTypeCode = "CAT";                       // default to category
            }
            UiLang          = NBrightBuyUtils.GetUILang(ajaxInfo);
            EditLangCurrent = editlang;
            if (EditLangCurrent == "")
            {
                EditLangCurrent = NBrightBuyUtils.GetEditLang(ajaxInfo);
            }

            if (!paramCmd.ToLower().Contains("save"))
            {
                // pickup nextlang, indicates if we are changing languages. (Don't use if saving data, only for getting next language.)
                EditLangCurrent = NBrightBuyUtils.GetNextLang(ajaxInfo, EditLangCurrent);
            }

            switch (paramCmd)
            {
            case "property_admin_getlist":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategoryAdminList(context, "property", EditLangCurrent);
                break;

            case "property_admin_getdetail":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategoryAdminDetail(context, 0, EditLangCurrent);
                break;

            case "property_admin_addnew":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategoryAdminAddNew(context, "property");
                break;

            case "property_admin_savelist":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategoryAdminSaveList(context);
                break;

            case "property_admin_save":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategorySave(context, EditLangCurrent);
                break;

            case "property_admin_saveexit":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategorySave(context, EditLangCurrent);
                break;

            case "property_admin_movecategory":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.MoveCategoryAdmin(context, "property");
                break;

            case "property_admin_delete":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.DeleteCategory(context, "property");
                break;

            case "property_updateimages":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.UpdateCategoryImages(context, EditLangCurrent);
                break;

            case "property_getproductselectlist":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = ProductFunctions.ProductAdminList(context, true, EditLangCurrent, "", true);
                break;

            case "property_selectchangehidden":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryFunctions.CategoryHidden(context);
                break;

            case "property_categoryproductlist":
                strOut = CategoryFunctions.GetCategoryProductList(context, EditLangCurrent);
                break;

            case "property_removeimage":
                strOut = CategoryFunctions.RemoveCategoryImage(context, EditLangCurrent);
                break;

            case "property_displayproductselect":
                strOut = CategoryFunctions.CategoryProductSelect(context, EditLangCurrent);
                break;

            case "property_selectcatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CategoryFunctions.SelectCatXref(context, EditLangCurrent);
                }
                break;

            case "property_deletecatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CategoryFunctions.DeleteCatXref(context);
                }
                break;

            case "property_deleteallcatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CategoryFunctions.DeleteAllCatXref(context, EditLangCurrent);
                }
                break;
            }
            return(strOut);
        }
Ejemplo n.º 13
0
        private static String OrderAdminSave(HttpContext context)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    var ajaxInfo = NBrightBuyUtils.GetAjaxInfo(context);
                    var itemId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/itemid");
                    if (itemId > 0)
                    {
                        var ordData = new OrderData(itemId);
                        if (ordData != null)
                        {
                            var newStatusOrder = ajaxInfo.GetXmlProperty("genxml/dropdownlist/orderstatus");
                            if (ordData.OrderStatus != newStatusOrder)
                            {
                                ordData.OrderStatus = newStatusOrder;
                            }

                            ordData.PurchaseInfo.SetXmlProperty("genxml/textbox/shippingdate", ajaxInfo.GetXmlProperty("genxml/textbox/shippingdate"), TypeCode.DateTime);
                            ordData.PurchaseInfo.SetXmlProperty("genxml/textbox/trackingcode", ajaxInfo.GetXmlProperty("genxml/textbox/trackingcode"));

                            // do audit notes
                            if (ajaxInfo.GetXmlProperty("genxml/textbox/auditnotes") != "")
                            {
                                ordData.AddAuditMessage(ajaxInfo.GetXmlProperty("genxml/textbox/auditnotes"), "notes", UserController.Instance.GetCurrentUserInfo().Username, "False");
                            }

                            // save relitive path also
                            if (ajaxInfo.GetXmlProperty("genxml/hidden/optionfilelist") != "")
                            {
                                var fname = Path.GetFileName(ajaxInfo.GetXmlProperty("genxml/hidden/optionfilelist"));

                                var ext = Path.GetExtension(fname);
                                fname = DnnUtils.Encrypt(fname, StoreSettings.Current.Get("adminpin"));
                                foreach (char c in System.IO.Path.GetInvalidFileNameChars())
                                {
                                    fname = fname.Replace(c, '_');
                                }
                                fname = ext + "-" + fname; // add extension to front, so it cannot be servered but we can add to order data.

                                if (File.Exists(StoreSettings.Current.FolderTempMapPath.TrimEnd('\\') + "\\" + fname))
                                {
                                    var newfname = "secure" + Utils.GetUniqueKey();
                                    // save relitive path also
                                    if (File.Exists(ordData.PurchaseInfo.GetXmlProperty("genxml/hidden/invoicefilepath")))
                                    {
                                        File.Delete(StoreSettings.Current.FolderUploadsMapPath.TrimEnd('\\') + "\\" + newfname);
                                    }

                                    File.Copy(StoreSettings.Current.FolderTempMapPath.TrimEnd('\\') + "\\" + fname, StoreSettings.Current.FolderUploadsMapPath.TrimEnd('\\') + "\\" + newfname);
                                    File.Delete(StoreSettings.Current.FolderTempMapPath.TrimEnd('\\') + "\\" + fname);

                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilepath", StoreSettings.Current.FolderUploadsMapPath.TrimEnd('\\') + "\\" + newfname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilename", newfname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoiceuploadname", fname);

                                    var ext2     = "";
                                    var extSplit = fname.Split('-');
                                    if (extSplit.Count() > 0)
                                    {
                                        ext2 = extSplit[0];                       // we add the extension to the front of upload for IIS default security in serving file.
                                    }
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefileext", ext2);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicefilerelpath", StoreSettings.Current.FolderUploads + "/" + newfname);
                                    ordData.PurchaseInfo.SetXmlProperty("genxml/hidden/invoicedownloadname", "OS" + ordData.OrderNumber + ext2);
                                }
                            }

                            ordData.Save();

                            //Remove cached dashboard template
                            var cachekey = "nbrightbuydashboard*" + PortalSettings.Current.PortalId.ToString();
                            Utils.RemoveCache(cachekey);
                        }
                    }

                    return("");
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }
Ejemplo n.º 14
0
        public string ProcessCommand(string paramCmd, HttpContext context, string editlang = "")
        {
            var strOut   = "CATEGORY - ERROR!! - No Security rights or function command.";
            var ajaxInfo = NBrightBuyUtils.GetAjaxFields(context);
            var userId   = ajaxInfo.GetXmlPropertyInt("genxml/hidden/userid");

            EntityTypeCode = ajaxInfo.GetXmlProperty("genxml/hidden/entitytypecode");
            if (EntityTypeCode == "")
            {
                EntityTypeCode = "CATEGORY";                       // default to category
            }
            EditLangCurrent = NBrightBuyUtils.GetEditLang(ajaxInfo, Utils.GetCurrentCulture());

            if (!paramCmd.ToLower().Contains("save"))
            {
                // pickup nextlang, indicates if we are changing languages. (Don't use if saving data, only for getting next language.)
                EditLangCurrent = NBrightBuyUtils.GetNextLang(ajaxInfo, EditLangCurrent);
            }

            switch (paramCmd)
            {
            case "category_admin_getlist":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryAdminList(context, "", EditLangCurrent);
                break;

            case "category_admin_getdetail":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryAdminDetail(context, 0, EditLangCurrent);
                break;

            case "category_admin_addnew":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryAdminAddNew(context);
                break;

            case "category_admin_savelist":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryAdminSaveList(context);
                break;

            case "category_admin_save":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategorySave(context, EditLangCurrent);
                break;

            case "category_admin_saveexit":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategorySave(context, EditLangCurrent);
                break;

            case "category_admin_movecategory":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = MoveCategoryAdmin(context);
                break;

            case "category_admin_delete":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = DeleteCategory(context);
                break;

            case "category_updateimages":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = UpdateCategoryImages(context, EditLangCurrent);
                break;

            case "category_getproductselectlist":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                var productFunctions = new ProductFunctions();
                strOut = productFunctions.ProductAdminList(context, true, EditLangCurrent, "", true);
                break;

            case "category_selectchangehidden":
                if (!NBrightBuyUtils.CheckManagerRights())
                {
                    break;
                }
                strOut = CategoryHidden(context);
                break;

            case "category_categoryproductlist":
                strOut = GetCategoryProductList(context, EditLangCurrent);
                break;

            case "category_removeimage":
                strOut = RemoveCategoryImage(context, EditLangCurrent);
                break;

            case "category_displayproductselect":
                strOut = CategoryProductSelect(context, EditLangCurrent);
                break;

            case "category_selectcatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = SelectCatXref(context, EditLangCurrent);
                }
                break;

            case "category_deletecatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = DeleteCatXref(context);
                }
                break;

            case "category_deleteallcatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = DeleteAllCatXref(context, EditLangCurrent);
                }
                break;

            case "category_copyallcatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CopyAllCatXref(context);
                }
                break;

            case "category_moveallcatxref":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CopyAllCatXref(context, true);
                }
                break;

            case "category_cattaxupdate":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CatTaxUpdate(context, EditLangCurrent);
                }
                break;

            case "category_addgroupfilter":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = AddGroupFilter(context, EditLangCurrent);
                }
                break;

            case "category_removegroupfilter":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = RemoveGroupFilter(context, EditLangCurrent);
                }
                break;

            case "category_categorygroupfilter":
                if (NBrightBuyUtils.CheckRights())
                {
                    strOut = CategoryGroupFilters(context, EditLangCurrent);
                }
                break;
            }
            return(strOut);
        }
Ejemplo n.º 15
0
        public static String ProductAdminList(Dictionary <string, string> settings, bool paging = true)
        {
            try
            {
                if (NBrightBuyUtils.CheckManagerRights())
                {
                    if (UserController.Instance.GetCurrentUserInfo().UserID <= 0)
                    {
                        return("");
                    }

                    var strOut = "";

                    if (!settings.ContainsKey("themefolder"))
                    {
                        settings.Add("themefolder", "");
                    }
                    if (!settings.ContainsKey("razortemplate"))
                    {
                        settings.Add("razortemplate", "");
                    }
                    if (!settings.ContainsKey("header"))
                    {
                        settings.Add("header", "");
                    }
                    if (!settings.ContainsKey("body"))
                    {
                        settings.Add("body", "");
                    }
                    if (!settings.ContainsKey("footer"))
                    {
                        settings.Add("footer", "");
                    }
                    if (!settings.ContainsKey("filter"))
                    {
                        settings.Add("filter", "");
                    }
                    if (!settings.ContainsKey("orderby"))
                    {
                        settings.Add("orderby", "");
                    }
                    if (!settings.ContainsKey("returnlimit"))
                    {
                        settings.Add("returnlimit", "0");
                    }
                    if (!settings.ContainsKey("pagenumber"))
                    {
                        settings.Add("pagenumber", "0");
                    }
                    if (!settings.ContainsKey("pagesize"))
                    {
                        settings.Add("pagesize", "0");
                    }
                    if (!settings.ContainsKey("searchtext"))
                    {
                        settings.Add("searchtext", "");
                    }
                    if (!settings.ContainsKey("searchcategory"))
                    {
                        settings.Add("searchcategory", "");
                    }
                    if (!settings.ContainsKey("cascade"))
                    {
                        settings.Add("cascade", "False");
                    }

                    if (!settings.ContainsKey("portalid"))
                    {
                        settings.Add("portalid", PortalSettings.Current.PortalId.ToString(""));                                    // aways make sure we have portalid in settings
                    }
                    // select a specific entity data type for the product (used by plugins)
                    if (!settings.ContainsKey("entitytypecode"))
                    {
                        settings.Add("entitytypecode", "PRD");
                    }
                    if (!settings.ContainsKey("entitytypecodelang"))
                    {
                        settings.Add("entitytypecodelang", "PRDLANG");
                    }
                    var entitytypecodelang = settings["entitytypecodelang"];
                    var entitytypecode     = settings["entitytypecode"];

                    var themeFolder   = settings["themefolder"];
                    var header        = settings["header"];
                    var body          = settings["body"];
                    var footer        = settings["footer"];
                    var filter        = settings["filter"];
                    var orderby       = settings["orderby"];
                    var returnLimit   = Convert.ToInt32(settings["returnlimit"]);
                    var pageNumber    = Convert.ToInt32(settings["pagenumber"]);
                    var pageSize      = Convert.ToInt32(settings["pagesize"]);
                    var cascade       = Convert.ToBoolean(settings["cascade"]);
                    var razortemplate = settings["razortemplate"];
                    var portalId      = Convert.ToInt32(settings["portalid"]);

                    var searchText     = settings["searchtext"];
                    var searchCategory = settings["searchcategory"];

                    if (searchText != "")
                    {
                        filter += " and (NB3.[ProductName] like '%" + searchText + "%' or NB3.[ProductRef] like '%" + searchText + "%' or NB3.[Summary] like '%" + searchText + "%' ) ";
                    }

                    if (Utils.IsNumeric(searchCategory))
                    {
                        if (orderby == "{bycategoryproduct}")
                        {
                            orderby += searchCategory;
                        }
                        var objQual = DotNetNuke.Data.DataProvider.Instance().ObjectQualifier;
                        var dbOwner = DotNetNuke.Data.DataProvider.Instance().DatabaseOwner;
                        if (!cascade)
                        {
                            filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") ";
                        }
                        else
                        {
                            filter += " and NB1.[ItemId] in (select parentitemid from " + dbOwner + "[" + objQual + "NBrightBuy] where (typecode = 'CATXREF' and XrefItemId = " + searchCategory + ") or (typecode = 'CATCASCADE' and XrefItemId = " + searchCategory + ")) ";
                        }
                    }
                    else
                    {
                        if (orderby == "{bycategoryproduct}")
                        {
                            orderby = " order by NB3.productname ";
                        }
                    }

                    // logic for client list of products
                    if (NBrightBuyUtils.IsClientOnly())
                    {
                        filter += " and NB1.ItemId in (select ParentItemId from dbo.[NBrightBuy] as NBclient where NBclient.TypeCode = 'USERPRDXREF' and NBclient.UserId = " + UserController.Instance.GetCurrentUserInfo().UserID.ToString("") + ") ";
                    }

                    var recordCount = 0;

                    if (themeFolder == "")
                    {
                        themeFolder = StoreSettings.Current.ThemeFolder;
                        if (settings.ContainsKey("themefolder"))
                        {
                            themeFolder = settings["themefolder"];
                        }
                    }


                    var objCtrl = new NBrightBuyController();

                    if (paging) // get record count for paging
                    {
                        if (pageNumber == 0)
                        {
                            pageNumber = 1;
                        }
                        if (pageSize == 0)
                        {
                            pageSize = 20;
                        }

                        // get only entity type required
                        recordCount = objCtrl.GetListCount(PortalSettings.Current.PortalId, -1, entitytypecode, filter, entitytypecodelang, Utils.GetCurrentCulture());
                    }

                    // get selected entitytypecode.
                    var list = objCtrl.GetDataList(PortalSettings.Current.PortalId, -1, entitytypecode, entitytypecodelang, Utils.GetCurrentCulture(), filter, orderby, StoreSettings.Current.DebugMode, "", returnLimit, pageNumber, pageSize, recordCount);

                    var passSettings = settings;
                    foreach (var s in StoreSettings.Current.Settings()) // copy store setting, otherwise we get a byRef assignement
                    {
                        if (passSettings.ContainsKey(s.Key))
                        {
                            passSettings[s.Key] = s.Value;
                        }
                        else
                        {
                            passSettings.Add(s.Key, s.Value);
                        }
                    }

                    strOut = NBrightBuyUtils.RazorTemplRenderList(razortemplate, 0, "", list, "/DesktopModules/NBright/NBrightBuy", themeFolder, Utils.GetCurrentCulture(), passSettings);

                    // add paging if needed
                    if (paging && (recordCount > pageSize))
                    {
                        var pg = new NBrightCore.controls.PagingCtrl();
                        strOut += pg.RenderPager(recordCount, pageSize, pageNumber);
                    }

                    return(strOut);
                }
                return("");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }