Пример #1
0
        public void ImportWebModificationsPartTwo(IEnumerable <Webmodrecord> webmodrecords)
        {
            foreach (var webmodrecord in webmodrecords.OrderBy(a => a.screenname))
            {
                var criteria = new Webmodlistcriteria()
                {
                    screenname = webmodrecord.screenname, functionname = webmodrecord.functionname, recordcountlimit = 1
                };
                if (string.IsNullOrEmpty(webmodrecord.profile) && string.IsNullOrEmpty(webmodrecord.@operator))
                {
                    criteria.level = "c";
                }
                if (!string.IsNullOrEmpty(webmodrecord.profile))
                {
                    criteria.level   = "p";
                    criteria.profile = webmodrecord.profile;
                }
                if (!string.IsNullOrEmpty(webmodrecord.@operator))
                {
                    criteria.level     = "o";
                    criteria.@operator = webmodrecord.@operator;
                }

                var list = this._assharedentryRepository.GetWebModificationList(criteria);
                if (list?.webmodlistresults.Count > 0)
                {
                    var firstRecord     = list.webmodlistresults.First();
                    var newExtendRecord = this._assharedentryRepository.WebModificationRead(new Webmodcriteria {
                        webmodRowID = firstRecord.webmodRowID
                    });
                    newExtendRecord.settingvalue = webmodrecord.settingvalue;
                    this._assharedentryRepository.WebModificationUpdate(newExtendRecord);
                    continue;
                }
                webmodrecord.rowpointer  = string.Empty;
                webmodrecord.webmodRowID = string.Empty;
                this._assharedentryRepository.WebModificationCreate(webmodrecord);
            }
        }
Пример #2
0
 public Webmodlistresults GetActiveWebModification(Webmodlistcriteria webmodlistcriteria)
 {
     return(this.adapter.GetActiveWebModification(webmodlistcriteria));
 }
Пример #3
0
        public IEnumerable <Webmodrecord> ImportWebModificationsPartOne(byte[] zipFile)
        {
            var user         = this._pvUserRepository.Get(this._tokenObject.Cono, this._tokenObject.Oper.StripOffDomain(), 1, "webmodificationaccesslevel");
            var allowCompany = user.webmodificationaccesslevel.ToLower() == "c";
            var allowProfile = allowCompany || user.webmodificationaccesslevel.ToLower() == "p";
            var allowUser    = allowCompany || allowProfile || user.webmodificationaccesslevel.ToLower() == "u";

            if (!allowUser)
            {
                ErrorReportingHelper.ReportErrors("special.saapa.import.denied");
            }

            var importObjectString = ZipClass.Decompress(zipFile);
            var webmodRecords      = JsonConvert.DeserializeObject <IEnumerable <Webmodrecord> >(importObjectString);
            var importWebMods      = webmodRecords as Webmodrecord[] ?? webmodRecords.ToArray();

            foreach (var webmodrecord in importWebMods)
            {
                webmodrecord.cono = this._tokenObject.Cono;
                if (allowCompany && string.IsNullOrEmpty(webmodrecord.profile) &&
                    string.IsNullOrEmpty(webmodrecord.@operator))
                {
                    continue;
                }
                if (allowProfile)
                {
                    if (string.IsNullOrEmpty(webmodrecord.profile) && string.IsNullOrEmpty(webmodrecord.@operator))
                    {
                        webmodrecord.@operator    = this.CheckUser(webmodrecord.@operator);
                        webmodrecord.errorMessage = "special.saapa.import.defaultoperatorset";

                        continue;
                    }
                    if (!string.IsNullOrEmpty(webmodrecord.profile))
                    {
                        var profile = this.CheckProfle(webmodrecord.profile);
                        if (profile == Noprofile)
                        {
                            webmodrecord.errorMessage = "special.saapa.import.noprofile";
                            webmodrecord.profile      = string.Empty;
                            webmodrecord.profile      = this.CheckUser(webmodrecord.@operator);
                        }

                        if (profile != webmodrecord.profile)
                        {
                            webmodrecord.errorMessage = "special.saapa.import.profileset";
                        }

                        webmodrecord.profile = this.CheckProfle(webmodrecord.profile);
                        continue;
                    }
                    var oper = this.CheckUser(webmodrecord.@operator);
                    if (oper != webmodrecord.@operator)
                    {
                        webmodrecord.errorMessage = "special.saapa.import.defaultoperatorset";
                    }
                    webmodrecord.@operator = oper;
                    continue;
                }
                webmodrecord.profile = string.Empty;
                var operAlllowUser = this.CheckUser(webmodrecord.@operator);
                if (operAlllowUser != webmodrecord.@operator)
                {
                    webmodrecord.errorMessage = "special.saapa.import.defaultoperatorset";
                }
                webmodrecord.@operator = operAlllowUser;
            }

            foreach (var webmodrecord in importWebMods)

            {
                var criteria = new Webmodlistcriteria()
                {
                    screenname = webmodrecord.screenname, functionname = webmodrecord.functionname, recordcountlimit = 1
                };
                if (string.IsNullOrEmpty(webmodrecord.profile) && string.IsNullOrEmpty(webmodrecord.@operator))
                {
                    criteria.level = "c";
                }
                if (!string.IsNullOrEmpty(webmodrecord.profile))
                {
                    criteria.level   = "p";
                    criteria.profile = webmodrecord.profile;
                }
                if (!string.IsNullOrEmpty(webmodrecord.@operator))
                {
                    criteria.level     = "o";
                    criteria.@operator = webmodrecord.@operator;
                }

                webmodrecord.willOverwrite = this._assharedentryRepository.GetWebModificationList(criteria).webmodlistresults.Any();
            }
            return(importWebMods);
        }