Esempio n. 1
0
        /// <summary>
        /// GameSheets
        /// 将事件实体查询出来并填充到数据中
        /// </summary>
        /// <param name="DictDataItem"></param>
        /// <param name="ItemId"></param>
        /// <returns></returns>
        public Dictionary <String, Object> GetDictDataItemsByGameSheets(Dictionary <String, Object> DictDataItem, Int32 ItemId, BasePage Context)
        {
            var DataItem = Playngo_ClientZone_GameSheet.FindByKeyForEdit(ItemId);

            if (DataItem != null && DataItem.ID > 0)
            {
                //循环输出所有的固定项
                foreach (var Field in Playngo_ClientZone_GameSheet.Meta.Fields)
                {
                    DictDataItem.Add(Field.ColumnName, DataItem[Field.ColumnName]);
                }

                //移除累赘的字典项
                DictDataItem = Common.RemoveDictionary(DictDataItem, "Options");
                DictDataItem = Common.RemoveDictionary(DictDataItem, "Files");

                TemplateFormat xf = new TemplateFormat(Context);

                DictDataItem = Common.UpdateDictionary(DictDataItem, "Image", xf.ViewLinkUrl(xf.ViewItemSettingT <string>(DataItem, "Image", ""), "", Context));
                DictDataItem = Common.UpdateDictionary(DictDataItem, "Summary", xf.ViewItemSettingT <string>(DataItem, "Summary", ""));
                DictDataItem = Common.UpdateDictionary(DictDataItem, "Url", xf.GoUrl(DataItem));
                DictDataItem = Common.UpdateDictionary(DictDataItem, "ReleaseDateStr", String.Format("{0} {1}{2},{3}", DataItem.ReleaseDate.ToString("MMM"), DataItem.ReleaseDate.Day, xf.GetDaySuffix(DataItem.ReleaseDate.Day), DataItem.ReleaseDate.ToString("yyyy")));
            }
            return(DictDataItem);
        }
Esempio n. 2
0
        /// <summary>
        /// DownloadFiles
        /// 将事件实体查询出来并填充到数据中
        /// </summary>
        /// <param name="DictDataItem"></param>
        /// <param name="ItemId"></param>
        /// <returns></returns>
        public Dictionary <String, Object> GetDictDataItemsByDownloadFiles(Dictionary <String, Object> DictDataItem, Int32 ItemId, BasePage Context)
        {
            var DataItem = Playngo_ClientZone_DownloadFile.FindByKeyForEdit(ItemId);

            if (DataItem != null && DataItem.ID > 0)
            {
                //循环输出所有的固定项
                foreach (var Field in Playngo_ClientZone_DownloadFile.Meta.Fields)
                {
                    DictDataItem.Add(Field.ColumnName, DataItem[Field.ColumnName]);
                }

                //移除累赘的字典项
                DictDataItem = Common.RemoveDictionary(DictDataItem, "Options");

                TemplateFormat xf = new TemplateFormat(Context);


                String DownloadUrl = String.Format("{0}Resource_Service.aspx?ModuleId={1}&Token={2}&TabId={3}&PortalId={4}&language={5}&FileId={6}",
                                                   Context.ModulePath,
                                                   Context.Settings_ModuleID,
                                                   "DownloadFile",
                                                   Context.Settings_TabID,
                                                   Context.PortalId,
                                                   Context.language,
                                                   DataItem.ID);

                DictDataItem = Common.UpdateDictionary(DictDataItem, "Image", xf.ViewLinkUrl(xf.ViewItemSettingT <string>(DataItem, "Image", ""), "", Context));
                DictDataItem = Common.UpdateDictionary(DictDataItem, "Summary", xf.ViewItemSettingT <string>(DataItem, "Summary", ""));
                DictDataItem = Common.UpdateDictionary(DictDataItem, "Url", Context.FullPortalUrl(DownloadUrl));
                DictDataItem = Common.UpdateDictionary(DictDataItem, "ReleaseDateStr", String.Format("{0} {1}{2},{3}", DataItem.ReleaseDate.ToString("MMM"), DataItem.ReleaseDate.Day, xf.GetDaySuffix(DataItem.ReleaseDate.Day), DataItem.ReleaseDate.ToString("yyyy")));
            }
            return(DictDataItem);
        }
Esempio n. 3
0
        public void Execute(BasePage Context)
        {
            Int32 FileId = WebHelper.GetIntParam(Context.Request, "FileId", 0);

            if (FileId > 0)
            {
                var FileItem = Playngo_ClientZone_DownloadFile.FindByKeyForEdit(FileId);
                if (FileItem != null && FileItem.ID > 0 && !String.IsNullOrEmpty(FileItem.Options))
                {
                    if (Context.IsPreRoleView(FileItem.Per_AllUsers, FileItem.Per_Roles) && Context.IsPreJurisdictionView(FileItem.Per_AllJurisdictions, FileItem.Per_Jurisdictions))
                    {
                        var FileItemOptions = ConvertTo.Deserialize <List <KeyValueEntity> >(FileItem.Options);
                        if (FileItemOptions != null)
                        {
                            TemplateFormat           xf         = new TemplateFormat(Context);
                            Playngo_ClientZone_Files Multimedia = new Playngo_ClientZone_Files();
                            String UploadFile = xf.GetFilePath(xf.ViewItemSettingT <String>(FileItem.Options, "UploadFile", ""), Context, out Multimedia);
                            if (!String.IsNullOrEmpty(UploadFile))
                            {
                                UploadFile = Context.Server.MapPath(UploadFile);
                                if (File.Exists(UploadFile))
                                {
                                    String FileName = String.Format("{0}.{1}", Multimedia.Name, Multimedia.FileExtension);
                                    //FileSystemUtils.DownloadFile(UploadFile,String.Format("{0}_{1}{2}", FileItem.Title, FileItem.Version,  Path.GetExtension(UploadFile)));
                                    //FileSystemUtils.DownloadFile(UploadFile);

                                    FileManager file = new FileManager();

                                    file.WriteFileToResponse(new System.IO.FileInfo(UploadFile), ContentDisposition.Attachment);
                                    IsResponseWrite = false;
                                }
                            }
                            else
                            {
                                //当前文件找不到
                            }
                        }
                        else
                        {
                            //没有添加文件
                        }
                    }
                    else
                    {
                        //没有权限下载
                    }
                }
                else
                {
                    ResponseString = "没找到数据怎么搞";
                }
            }
            else
            {
                ResponseString = "传过来的文件编号都不对";
            }
        }
        public void Execute(BasePage Context)
        {
            var FileList = new List <Playngo_ClientZone_DownloadFile>();


            //将文件列表取出
            String FileIds = WebHelper.GetStringParam(Context.Request, "FileIds", "");

            if (!String.IsNullOrEmpty(FileIds))
            {
                FileIds = FileIds.Trim(',');
                if (!String.IsNullOrEmpty(FileIds))
                {
                    FileList = Playngo_ClientZone_DownloadFile.FindAllByIds(FileIds);
                }
            }

            //待打包的文件路径
            var FilePathList = new List <String>();

            if (FileList != null && FileList.Count > 0)
            {
                //将文件的路径收集着
                foreach (var FileItem in FileList)
                {
                    if (FileItem != null && FileItem.ID > 0 && !String.IsNullOrEmpty(FileItem.Options))
                    {
                        if (Context.IsPreRoleView(FileItem.Per_AllUsers, FileItem.Per_Roles) && Context.IsPreJurisdictionView(FileItem.Per_AllJurisdictions, FileItem.Per_Jurisdictions))
                        {
                            var FileItemOptions = ConvertTo.Deserialize <List <KeyValueEntity> >(FileItem.Options);
                            if (FileItemOptions != null)
                            {
                                TemplateFormat xf         = new TemplateFormat(Context);
                                String         UploadFile = xf.GetFilePath(xf.ViewItemSettingT <String>(FileItem.Options, "UploadFile", ""), Context);
                                if (!String.IsNullOrEmpty(UploadFile))
                                {
                                    UploadFile = Context.Server.MapPath(UploadFile);
                                    if (File.Exists(UploadFile) && !FilePathList.Exists(r => r.ToLower() == UploadFile.ToLower()))
                                    {
                                        FilePathList.Add(UploadFile);
                                    }
                                }
                            }
                        }
                        else
                        {
                            //没有权限下载
                        }
                    }
                }


                if (FilePathList != null && FilePathList.Count > 0)
                {
                    //整理压缩包文件路径等信息
                    String   ZipPath = Context.Server.MapPath(String.Format("{0}ClientZone/temporary/download-{1}files-{2}.zip", Context.PortalSettings.HomeDirectory, FilePathList.Count, DateTime.Now.ToString("yyyyMMdd-Hms")));
                    FileInfo ZipFile = new FileInfo(ZipPath);
                    if (!ZipFile.Directory.Exists)
                    {
                        ZipFile.Directory.Create();
                    }
                    else
                    {
                        //清楚很多天前的文件
                        FileSystemUtils.ClearFiles(ZipFile.Directory, 1);
                    }

                    //创建压缩包
                    FileSystemUtils.CreateZipFiles(FilePathList, ZipPath);


                    //将压缩好的文件列表下载
                    FileSystemUtils.DownloadFile(ZipPath, Path.GetFileName(ZipPath));
                }
                else
                {
                    IsResponseWrite = true;
                    ResponseString  = "No files found.";
                }
            }
        }
Esempio n. 5
0
        public void Execute(BasePage Context)
        {
            JavaScriptSerializer        jsSerializer = new JavaScriptSerializer();
            Dictionary <String, Object> jsonPictures = new Dictionary <string, Object>();


            TemplateFormat xf = new TemplateFormat();
            QueryParam     qp = new QueryParam();


            qp.PageIndex = WebHelper.GetIntParam(Context.Request, "PageIndex", 1);
            qp.PageSize  = WebHelper.GetIntParam(Context.Request, "PageSize", xf.ViewSettingT <Int32>("General.GameSheets.Pagings", 12));

            //排序的规则
            Int32 Sort = WebHelper.GetIntParam(Context.Request, "Sort", 0);

            if (Sort == (Int32)EnumSortQueryByGame.GameName_DESC)
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.Title;
                qp.OrderType = 1;
            }
            else if (Sort == (Int32)EnumSortQueryByGame.GameName_ASC)
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.Title;
                qp.OrderType = 0;
            }
            else if (Sort == (Int32)EnumSortQueryByGame.GameID_DESC)
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.GameID;
                qp.OrderType = 1;
            }
            else if (Sort == (Int32)EnumSortQueryByGame.GameID_ASC)
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.GameID;
                qp.OrderType = 0;
            }
            else if (Sort == (Int32)EnumSortQueryByGame.ReleaseDate_DESC)
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.ReleaseDate;
                qp.OrderType = 1;
            }
            else if (Sort == (Int32)EnumSortQueryByGame.ReleaseDate_ASC)
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.ReleaseDate;
                qp.OrderType = 0;
            }
            else
            {
                qp.Orderfld  = Playngo_ClientZone_GameSheet._.ID;
                qp.OrderType = 1;
            }


            //查询语句
            qp = CreateQueryParam(qp, Context);

            //权限筛选
            qp = CreateQueryByRoles(qp, Context);

            //区域筛选
            qp = CreateQueryByJurisdictions(qp, Context);

            //游戏分类筛选
            qp = CreateQueryByGameGategorys(qp, Context);



            int RecordCount = 0;
            List <Playngo_ClientZone_GameSheet> GameSheetList = Playngo_ClientZone_GameSheet.FindAll(qp, out RecordCount);


            //配置值
            XmlFormat xmlFormat      = new XmlFormat(Context.Server.MapPath(String.Format("{0}Resource/xml/Config.Setting.GameSheets.xml", Context.ModulePath)));
            var       XmlItemSetting = xmlFormat.ToList <SettingEntity>();


            List <Dictionary <String, Object> > DictFiles = new List <Dictionary <string, object> >();

            foreach (var GameSheetItem in GameSheetList)
            {
                int index = GameSheetList.IndexOf(GameSheetItem); //index 为索引值

                Dictionary <String, Object> jsonDict = new Dictionary <String, Object>();



                //循环输出所有的固定项
                foreach (var Field in Playngo_ClientZone_GameSheet.Meta.Fields)
                {
                    jsonDict.Add(Field.ColumnName, GameSheetItem[Field.ColumnName]);
                }


                if (XmlItemSetting != null && XmlItemSetting.Count > 0)
                {
                    var ItemSettings = ConvertTo.Deserialize <List <KeyValueEntity> >(GameSheetItem.Options);
                    foreach (var ItemSetting in XmlItemSetting)
                    {
                        jsonDict = Common.UpdateDictionary(jsonDict, ItemSetting.Name, xf.ViewItemSetting(GameSheetItem, ItemSetting.Name, ItemSetting.DefaultValue));
                    }
                }


                jsonDict = Common.UpdateDictionary(jsonDict, "ReleaseDateString", GameSheetItem.ReleaseDate.ToShortDateString());
                jsonDict = Common.UpdateDictionary(jsonDict, "Image", xf.ViewLinkUrl(xf.ViewItemSettingT <string>(GameSheetItem, "Image", ""), "", Context));

                jsonDict = Common.UpdateDictionary(jsonDict, "Url", xf.GoUrl(GameSheetItem));
                //未来日期出现Coming Soon
                jsonDict = Common.UpdateDictionary(jsonDict, "ComingSoonDisplay", GameSheetItem.ReleaseDate > xUserTime.LocalTime());


                Int32 NotifyStatus = (Int32)EnumNotificationStatus.None;
                if (GameSheetItem.NotifyInclude == 1) //&& GameSheetItem.StartTime >= xUserTime.LocalTime().AddDays(-xf.ViewSettingT<Int32>("General.ExpiryTimeNotification", 7)))
                {
                    NotifyStatus = GameSheetItem.NotifyStatus;
                }


                jsonDict = Common.UpdateDictionary(jsonDict, "NotificationStatus", EnumHelper.GetEnumTextVal(NotifyStatus, typeof(EnumNotificationStatus)));
                jsonDict = Common.UpdateDictionary(jsonDict, "NotificationStatusClass", EnumHelper.GetEnumTextVal(NotifyStatus, typeof(EnumNotificationStatus)).ToLower());


                DictFiles.Add(jsonDict);
            }

            jsonPictures.Add("data", DictFiles);
            jsonPictures.Add("Pages", qp.Pages);
            jsonPictures.Add("RecordCount", RecordCount);

            //转换数据为json

            ResponseString = jsSerializer.Serialize(jsonPictures);
        }