Example #1
0
        public ActionResult UpdatePocket(string pocketData)
        {
            PocketModel pocketModel = JsonConvert.DeserializeObject <PocketModel>(pocketData);

            pocketModel.pocketInfo.UpdatedBy = SessionManager.UserId;

            ServiceInputObject serviceInputsForUpdation = new ServiceInputObject
            {
                baseURL        = ConfigSettings.WebApiBaseAddress,
                controllerName = "Pocket",
                methodName     = "PutPocketDetail"
            };
            int returnValue = ServiceMethods.GeneratePutRequestIntDestinationEntity <PocketInfoEntities>(pocketModel.pocketInfo, serviceInputsForUpdation);


            return(Json("Data Successfully Updated"));
        }
Example #2
0
        private static PocketModel GetBestPocket(UnturnedPlayer player)
        {
            var permissions = player.GetPermissions().Select(a => a.Name).Where(p => p.ToLower().StartsWith($"{Conf.PermissionPrefix}.") && !p.Equals($"{Conf.PermissionPrefix}.", StringComparison.InvariantCultureIgnoreCase));
            var enumerable  = permissions as string[] ?? permissions.ToArray();

            if (enumerable.Length == 0)
            {
                return(null);
            }
            var bestPocket = new PocketModel(0, 0);

            foreach (var pocket in enumerable)
            {
                var pocketSplit = pocket.Split('.');
                if (pocketSplit.Length != 3)
                {
                    Logger.LogError("[RFPocketResizer] Error: PermissionPrefix must not contain '.'");
                    Logger.LogError($"[RFPocketResizer] Invalid permission format: {pocket}");
                    Logger.LogError("[RFPocketResizer] Correct format: 'permPrefix'.'width'.'height'");
                    continue;
                }
                try
                {
                    byte.TryParse(pocketSplit[1], out var w);
                    byte.TryParse(pocketSplit[2], out var h);
                    if (w * h > bestPocket.Width * bestPocket.Height)
                    {
                        bestPocket = new PocketModel(w, h);
                    }
                }
                catch (Exception ex)
                {
                    bestPocket = new PocketModel(5, 3);

                    Logger.LogError("[RFPocketResizer] Error: " + ex);
                }
            }
#if DEBUG
            Logger.LogWarning($"[RFPocketResizer] Player: {player.CharacterName}");
            Logger.LogWarning("[RFPocketResizer] Found Permissions: " + string.Join(", ", enumerable.ToArray()));
            Logger.LogWarning($"[RFPocketResizer] Pocket size taken: {bestPocket.Width} × {bestPocket.Height}");
#endif
            return(bestPocket);
        }
Example #3
0
        public ActionResult CreatePocket()
        {
            PocketModel pocketModel = new PocketModel();

            pocketModel.pocketInfo = new PocketInfoEntities();

            pocketModel.pocketInfo.PocketVillageMappingList = new List <PocketVillageMappingEntities>();
            PocketVillageMappingEntities villageMappingEntities = new PocketVillageMappingEntities();

            pocketModel.pocketInfo.PocketVillageMappingList.Add(villageMappingEntities);

            pocketModel.pocketInfo.PocketCropMappingList = new List <PocketCropMappingEntities>();
            pocketModel.pocketInfo.PocketCropMappingList.Add(new PocketCropMappingEntities());

            pocketModel.pocketInfo.PocketFertilizerMappingList = new List <PocketFertilizerMappingEntities>();
            pocketModel.pocketInfo.PocketFertilizerMappingList.Add(new PocketFertilizerMappingEntities());

            pocketModel.ActionType = ActionTypeEnum.Insert;
            return(View(pocketModel));
        }
Example #4
0
        public ActionResult SelectedPocketForUpdate(int id)
        {
            ServiceInputObject serviceInputsForDocType = new ServiceInputObject
            {
                baseURL        = ConfigSettings.WebApiBaseAddress,
                controllerName = "Pocket",
                methodName     = "GetPocketDetailForUpdate",
                parameterValue = Convert.ToString(id)
            };
            PocketInfoEntities pocketDetail = new PocketInfoEntities();

            pocketDetail = ServiceMethods.GenerateGatRequest <PocketInfoEntities>(serviceInputsForDocType);

            PocketModel pocketModel = new PocketModel();

            pocketModel.pocketInfo     = pocketDetail;
            pocketModel.isInDetailMode = false;
            pocketModel.ActionType     = ActionTypeEnum.Update;

            return(View("CreatePocket", pocketModel));
        }
Example #5
0
        public ActionResult Init(FormCollection collection)
        {
            JsonMessage jm = new JsonMessage();

            string SourceUrl = collection["source"];

            Uri uriResult;

            if (Uri.TryCreate(SourceUrl, UriKind.Absolute, out uriResult) && uriResult.Scheme == Uri.UriSchemeHttp)
            {
                PocketModel result = null;

                SessionManager sm = new SessionManager();

                Guid Id = Guid.NewGuid();

                string ServerFolderPath     = Server.MapPath("/");
                string AllPocketsFolderPath = ConfigurationManager.AppSettings["PocketPath"];
                if (!String.IsNullOrEmpty(AllPocketsFolderPath))
                {
                    AllPocketsFolderPath = ServerFolderPath + AllPocketsFolderPath;
                }
                string ServerDomainName = Request.Url.Authority;
                string messagefrom      = ConfigurationManager.AppSettings["DefaultMessageFrom"];
                string messageto        = "";
                result = new PocketModel(Id, SourceUrl, AllPocketsFolderPath, ServerDomainName, ServerFolderPath, messagefrom, messageto);

                sm.Set("pocketModel", result);

                jm.Object = result.CurrentProjectLink;
                jm.Result = true;
            }
            else
            {
                jm.Result  = false;
                jm.Message = "Адрес сайта-образца определeн как некорректный: " + SourceUrl;
            }

            return(Json(jm));
        }
Example #6
0
        public ActionResult Index()
        {
            string ContentType = MimeMapping.GetMimeMapping(Request.Path).ToLower();

            if ((ContentType == "application/octet-stream" ||
                 ContentType == "text/html")
                &&
                ((Request.AcceptTypes.Length == 1 && Request.AcceptTypes[0] == "*/*") ||
                 Request.AcceptTypes.Any(r => r.ToLower() == "text/html") ||
                 Request.AcceptTypes.Any(r => r.ToLower() == "text/plain") ||
                 Request.AcceptTypes.Any(r => r.ToLower() == "application/xhtml+xml") ||
                 Request.AcceptTypes.Any(r => r.ToLower() == "application/xml")))
            {
                NameValueCollection qscoll = HttpUtility.ParseQueryString(HttpContext.Request.Url.Query);
                if (qscoll.Count > 0)
                {
                    string source = qscoll["source"];
                    string id     = qscoll["id"];
                    if (source != null && id != null)
                    {
                        if (Pocket == null || id.ToLower() != Pocket.Id.ToString().ToLower())
                        {
                            SessionManager sm = new SessionManager();

                            string ServerFolderPath     = Server.MapPath("/");
                            string AllPocketsFolderPath = ConfigurationManager.AppSettings["PocketPath"];
                            if (!String.IsNullOrEmpty(AllPocketsFolderPath))
                            {
                                AllPocketsFolderPath = ServerFolderPath + AllPocketsFolderPath;
                            }
                            string      ServerDomainName = Request.Url.Authority;
                            PocketModel result           = new PocketModel(new Guid(id), source, AllPocketsFolderPath, ServerDomainName, ServerFolderPath, "", "");

                            sm.Set("pocketModel", result);

                            return(Redirect("/"));//плохое решение - лучше бы как-то удалять параметры
                        }
                    }
                }
                if (Pocket == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                string content = Pocket.GetContent(Request.Url, false);

                foreach (var ControlName in SharedControls)
                {
                    string template = RenderRazorViewToString(ControlName.Value, "");
                    content = content.Replace("@" + ControlName.Key, template);
                }

                return(Content(content));
            }
            else if (ContentType == "application/javascript" || ContentType == "text/css")
            {
                string content = "";
                if (Pocket != null)
                {
                    content = Pocket.GetContent(Request.Url, true);
                }
                return(new FileContentResult(Encoding.UTF8.GetBytes(content), ContentType));
            }
            else
            {
                Stream Stream = new MemoryStream();
                if (Pocket != null)
                {
                    Stream = Pocket.GetSourceFileStream(Request.Url);
                }
                return(new FileStreamResult(Stream, ContentType));
            }
        }