public ActionResult GetFile(string path, string type)
        {
            var pathtemp = Server.MapPath("~\\Upload\\" + path);

            var picture = new List <string>()
            {
                ".JPEG", ".TIFF", ".PNG", ".GIF", ".JPG"
            };

            var video = new List <string>()
            {
                ".MP4", ".WEBM", ".OGG"
            };

            var           data     = new List <DataGroupModel>();
            List <string> typeList = null;

            if (Directory.Exists(pathtemp))
            {
                switch (type)
                {
                case "picture":
                    typeList = picture;
                    break;

                case "video":
                    typeList = video;
                    break;
                }
                DirectoryInfo curFolder = new DirectoryInfo(pathtemp);
                foreach (FileInfo file in curFolder.GetFiles())
                {
                    var typeFile = file.Extension.ToUpper();
                    var da       = new DataGroupModel()
                    {
                        text = file.Name,
                        href = "\\Upload\\" + path + "\\" + file.Name
                    };



                    if (typeList == null)
                    {
                        data.Add(da);
                    }
                    else if (typeList.Contains(typeFile))
                    {
                        data.Add(da);
                    }
                }
            }



            return(Json(JsonConvert.SerializeObject(data,
                                                    Formatting.Indented,
                                                    new JsonSerializerSettings {
                DefaultValueHandling = DefaultValueHandling.Ignore
            })));
        }
        /// <summary>
        /// This is the call back function to process the grouped data structure
        /// </summary>
        /// <param name="records"></param>
        /// <param name="dataGroupModel"></param>
        private void CreateDataGroupModel(object records, DataGroupModel dataGroupModel)
        {
            TestDataListModel list = new TestDataListModel();

            list.Records.AddRange(records as IEnumerable <TestDataModel>);
            dataGroupModel.GridRows = Google.Protobuf.WellKnownTypes.Any.Pack(list);
        }
Exemple #3
0
        private static List <DataGroupModel> AddFunctionsGroup(System.Collections.IEnumerable groups, DataGroupModelCallBack callBack)
        {
            var groupModelList = new List <DataGroupModel>();

            foreach (AggregateFunctionsGroup group in groups)
            {
                DataGroupModel groupModel = new DataGroupModel()
                {
                    GridGroupModel = CreateTelerikGroupModel(group)
                };

                if (group.HasSubgroups)
                {
                    groupModel.SubGroups.AddRange(AddFunctionsGroup(group.Items, callBack));
                }
                else
                {
                    callBack(group.Items, groupModel);
                }

                groupModelList.Add(groupModel);
            }

            return(groupModelList);
        }
 /// <summary>
 /// Call back function to process the grouped data
 /// </summary>
 /// <param name="dataGroupModel"></param>
 /// <returns></returns>
 private IEnumerable <object> UnpackProtoList(DataGroupModel dataGroupModel)
 {
     if (dataGroupModel.GridRows == null)
     {
         return(null);
     }
     else
     {
         var gridData = dataGroupModel.GridRows.Unpack <TestDataListModel>();
         return(gridData.Records.ToList());
     }
 }
        public List <DataGroupModel> GetFolder(string path)
        {
            var           pathtemp    = Server.MapPath("~\\Upload\\" + path);
            DirectoryInfo curFolder   = new DirectoryInfo(pathtemp);
            var           childFolder = curFolder.GetDirectories();

            if (childFolder.Length > 0)
            {
                var result = new List <DataGroupModel>();
                foreach (var fol in childFolder)
                {
                    var f = new DataGroupModel()
                    {
                        text = fol.Name,
                        href = path + "\\" + fol.Name
                    };
                    f.nodes = GetFolder(f.href);
                    result.Add(f);
                }
                return(result);
            }
            return(null);
        }
Exemple #6
0
 public List<DataGroupModel> GetFolder(string path)
 {
     var pathtemp = Server.MapPath("~\\Upload\\" + path);
     DirectoryInfo curFolder = new DirectoryInfo(pathtemp);
     var childFolder = curFolder.GetDirectories();
     if (childFolder.Length > 0)
     {
         var result = new List<DataGroupModel>();
         foreach (var fol in childFolder)
         {
             var f = new DataGroupModel()
             {
                 text = fol.Name,
                 href = path + "\\" + fol.Name
             };
             f.nodes = GetFolder(f.href);
             result.Add(f);
         }
         return result;
     }
     return null;
 }
Exemple #7
0
        public ActionResult GetFile(string path, string type)
        {
            var pathtemp = Server.MapPath("~\\Upload\\" + path);

            var picture = new List<string>()
            {
                ".JPEG",".TIFF",".PNG",".GIF",".JPG"
            };

            var video = new List<string>()
            {
                ".MP4",".WEBM",".OGG"
            };

            var data = new List<DataGroupModel>();
            List<string> typeList = null;
            if (Directory.Exists(pathtemp))
            {
                switch (type)
                {
                    case "picture":
                        typeList = picture;
                        break;
                    case "video":
                        typeList = video;
                        break;
                }
                DirectoryInfo curFolder = new DirectoryInfo(pathtemp);
                foreach (FileInfo file in curFolder.GetFiles())
                {

                    var typeFile = file.Extension.ToUpper();
                    var da = new DataGroupModel()
                    {
                        text = file.Name,
                        href = "\\Upload\\" + path + "\\" + file.Name
                    };

                    if (typeList == null )
                    {
                        data.Add(da);
                    }else if (typeList.Contains(typeFile))
                    {
                        data.Add(da);
                    }

                }
            }

            return Json(JsonConvert.SerializeObject(data,
                Formatting.Indented,
                new JsonSerializerSettings { DefaultValueHandling = DefaultValueHandling.Ignore }));
        }