public static String Js(String files, Boolean debug)
        {
            String name     = HelperService.CalculateMD5Hash(files);
            String path     = @"/cache/script/js/";
            String FilePath = path + name + ".js";

            if (!HelperService.DirExists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            JavaScriptBundle js = new JavaScriptBundle();

            foreach (string fl in files.Split(','))
            {
                if (File.Exists(HttpContext.Current.Server.MapPath(fl)))
                {
                    js.Add(fl);
                }
            }
            if (debug == true)
            {
                return(js.ForceRelease().ForceDebug().Render(FilePath));
            }
            else
            {
                return(js.ForceRelease().Render(FilePath));
            }
        }
        public Boolean clearLocked <t>(int id, bool ajax)
        {
            dynamic item = ActiveRecordBase <t> .Find(id);

            bool result = false;

            if (item.GetType().GetMethod("editing") != null)
            {
                HelperService.writelog("Releasing editor from item ", item.editing.nid, item.id);
                item.editing = null;
                ActiveRecordMediator <dynamic> .Save(item);

                result = true;
            }
            return(result);
        }
Exemplo n.º 3
0
        public static String Js(string files)
        {
            String name     = CalculateMD5Hash(files);
            String path     = @"/cache/script/js/";
            String FilePath = path + name + ".js";

            if (!HelperService.DirExists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            JavaScriptBundle js = new JavaScriptBundle();

            foreach (string fl in files.Split(','))
            {
                js.Add(fl);
            }
            return(js.ForceRelease().Render(FilePath));
        }
        //This is a generic set of methods that will first check the object has a property
        //then if it does set it to null if the user is not actively editing it
        public Boolean clearConnections <t>()
        {
            t[] items = ActiveRecordBase <t> .FindAll();

            bool result = false;

            foreach (dynamic item in items)
            {
                if (item.GetType().GetProperty("editing") != null)
                {
                    if (isActive(item.editing))
                    {
                        HelperService.writelog("Releasing editor from item ", item.editing, item.id);
                        item.editing = null;
                        ActiveRecordMediator <dynamic> .Save(item);

                        result = true;
                    }
                }
            }
            return(result);
        }
        public string getShapeLatLng_json_str(int id, bool showOnlyEncoded)
        {
            if (showOnlyEncoded == null)
            {
                showOnlyEncoded = true;
            }
            string     gem       = "";
            geometrics geometric = ActiveRecordBase <geometrics> .Find(id);

            if (geometric.boundary != null)
            {
                SqlGeography spatial = geometrics.AsGeography(geometric.boundary);
                string       sp_type = spatial.STGeometryType().ToString().ToUpper();
                switch (sp_type)
                {
                case "POINT":
                    gem = outputRawPoint(spatial);
                    break;

                case "LINESTRING":
                    gem = outputRawLineString(spatial);
                    break;

                case "POLYGON":
                    gem = outputRawPolygon(spatial);
                    break;

                case "MULTIPOINT":
                    break;

                case "MULTILINESTRING":
                    break;

                case "MULTIPOLYGON":
                    break;
                }
            }
            String shape = "";

            shape += @"
                {";
            String shapeOptions = "";

            shapeOptions += @"       ""name"":""" + geometric.name + @""",";
            //shapeOptions += (showOnlyEncoded ? @"      ""latlng_str"":""" + gem + @"""," : "");
            // shapeOptions += @"       ""encoded"":""" + (geometric.encoded!=null? HelperService.EscapeForJson(geometric.encoded) : "") + @""",";
            if (geometric.children.Count > 0)
            {
                String obj = "";
                foreach (geometrics child in geometric.children)
                {
                    obj += (child.encoded != null ? (obj == "" ? "" : ",") + @"""" + HelperService.EscapeForJson(child.encoded) + @"""" : "");
                }

                shapeOptions += @"       ""encoded"":[" + obj + @"],";
            }
            else
            {
                shapeOptions += @"       ""encoded"":""" + (geometric.encoded != null ? HelperService.EscapeForJson(geometric.encoded) : "") + @""",";
            }



            shapeOptions += (geometric.style.Count > 0 ? @"      ""style"":" + geometric.style[0].style_obj + @"," : "");
            shapeOptions += @"      ""type"":""" + (geometric.default_type != null?geometric.default_type.name:"polygon") + @"""";

            shape += shapeOptions;
            shape += @"
                }";
            return(shape);
        }