Exemple #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            var specialId = AuthRequest.GetQueryInt("specialId");

            if (specialId > 0)
            {
                _specialInfo = SpecialManager.GetSpecialInfo(SiteId, specialId);
            }

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

            if (_specialInfo != null)
            {
                TbTitle.Text     = _specialInfo.Title;
                TbUrl.Text       = _specialInfo.Url;
                PhUpload.Visible = false;
            }
            else
            {
                TbUrl.Text = $"@/special/{DateTime.Now:yyyy/MM/dd}/";
            }
        }
Exemple #2
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var specialInfo = (SpecialInfo)e.Item.DataItem;

            var ltlTitle   = (Literal)e.Item.FindControl("ltlTitle");
            var ltlUrl     = (Literal)e.Item.FindControl("ltlUrl");
            var ltlAddDate = (Literal)e.Item.FindControl("ltlAddDate");
            var ltlActions = (Literal)e.Item.FindControl("ltlActions");

            ltlTitle.Text   = $@"<a href=""{SpecialManager.GetSpecialUrl(SiteInfo, specialInfo.Url)}"" target=""_blank"">{specialInfo.Title}</a>";
            ltlUrl.Text     = specialInfo.Url;
            ltlAddDate.Text = specialInfo.AddDate.ToString("yyyy-MM-dd HH:mm");

            ltlActions.Text = $@"
<a class=""m-r-10"" href=""javascript:;"" onclick=""{ModalSpecialAdd.GetOpenWindowString(SiteId, specialInfo.Id)}"">编辑</a>
<a class=""m-r-10"" href=""javascript:;"" onclick=""{ModalSpecialUpload.GetOpenWindowString(SiteId, specialInfo.Id)}"">上传压缩包</a>
<a class=""m-r-10"" href=""{GetRedirectUrl(SiteId)}&specialId={specialInfo.Id}&download={true}"">下载压缩包</a>
<a class=""m-r-10"" onclick=""{AlertUtils.ConfirmDelete("删除专题", $"此操作将删除专题“{specialInfo.Title}”及相关文件,确认吗?", $"{GetRedirectUrl(SiteId)}&specialId={specialInfo.Id}&delete={true}")}"" href=""javascript:;"">删除</a>
";
        }
        public ActionResult Specials(AdminSpecialVM model)
        {
            _specialManager = SpecialManagerFactory.Create();

            if (ModelState.IsValid)
            {
                try
                {
                    var response = _specialManager.SaveSpecial(model.Special);

                    if (!response.Success)
                    {
                        return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                var response = _specialManager.GetAllSpecials();
                model.SetSpecialItems(response.Specials);

                return(View(model));
            }

            return(RedirectToAction("Specials"));
        }
Exemple #4
0
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId    = request.GetQueryInt("siteId");
                var specialId = request.GetQueryInt("specialId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(siteId,
                                                                     ConfigManager.SitePermissions.Specials))
                {
                    return(Unauthorized());
                }

                SpecialInfo specialInfo = null;
                if (specialId > 0)
                {
                    specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId);
                }

                return(Ok(new
                {
                    Value = specialInfo,
                    Guid = StringUtils.GetShortGuid(false),
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #5
0
        public static void CreateByAll(int siteId)
        {
            CreateTaskManager.ClearAllTask(siteId);

            var channelIdList = ChannelManager.GetChannelIdList(siteId);

            foreach (var channelId in channelIdList)
            {
                CreateChannel(siteId, channelId);
            }

            foreach (var channelId in channelIdList)
            {
                CreateAllContent(siteId, channelId);
            }

            foreach (var specialId in SpecialManager.GetAllSpecialIdList(siteId))
            {
                CreateSpecial(siteId, specialId);
            }

            foreach (var fileTemplateId in TemplateManager.GetAllFileTemplateIdList(siteId))
            {
                CreateFile(siteId, fileTemplateId);
            }
        }
        public IHttpActionResult Delete()
        {
            try
            {
                var request   = new AuthenticatedRequest();
                var siteId    = request.GetPostInt("siteId");
                var specialId = request.GetPostInt("specialId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(siteId,
                                                                     ConfigManager.SitePermissions.Specials))
                {
                    return(Unauthorized());
                }

                var siteInfo    = SiteManager.GetSiteInfo(siteId);
                var specialInfo = SpecialManager.DeleteSpecialInfo(siteInfo, specialId);

                request.AddSiteLog(siteId,
                                   "删除专题",
                                   $"专题名称:{specialInfo.Title}");

                var specialInfoList = DataProvider.SpecialDao.GetSpecialInfoList(siteId);

                return(Ok(new
                {
                    Value = specialInfoList
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
        public ActionResult Index()
        {
            //get managers
            ListingManager listingManager = ListingManagerFactory.Create();
            SpecialManager specialManager = SpecialManagerFactory.Create();

            //get responses
            ListingFeaturedResponse listingFeaturedResponse = listingManager.GetFeaturedListings();
            SpecialGetAllResponse   specialResponse         = specialManager.GetAllSpecials();

            //validate responses
            if (!listingFeaturedResponse.Success || !specialResponse.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{listingFeaturedResponse.Message} {specialResponse.Message}"));
            }
            else
            {
                //build vm
                HomeVM model = new HomeVM();

                model.SetFeaturedListingItems(listingFeaturedResponse.Listings);
                model.SetSpecialItems(specialResponse.Specials);

                return(View(model));
            }
        }
Exemple #8
0
        public void Insert(SpecialInfo specialInfo)
        {
            var sqlString = $@"INSERT INTO {TableName}
           ({nameof(SpecialInfo.SiteId)}, 
            {nameof(SpecialInfo.Title)}, 
            {nameof(SpecialInfo.Url)},
            {nameof(SpecialInfo.AddDate)})
     VALUES
           (@{nameof(SpecialInfo.SiteId)}, 
            @{nameof(SpecialInfo.Title)}, 
            @{nameof(SpecialInfo.Url)}, 
            @{nameof(SpecialInfo.AddDate)})";

            IDataParameter[] parameters =
            {
                GetParameter(nameof(specialInfo.SiteId),  DataType.Integer,  specialInfo.SiteId),
                GetParameter(nameof(specialInfo.Title),   DataType.VarChar,                  200,specialInfo.Title),
                GetParameter(nameof(specialInfo.Url),     DataType.VarChar,                  200,specialInfo.Url),
                GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate)
            };

            ExecuteNonQuery(sqlString, parameters);

            SpecialManager.RemoveCache(specialInfo.SiteId);
        }
    //private GameManager Gamecontroller;

    void Start()
    {
        test = GameObject.FindObjectOfType <SpecialManager> ();

        //GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
        //Gamecontroller = gameControllerObject.GetComponent<GameManager> ();
    }
Exemple #10
0
        public void RaisePropertyChangedEvent()
        {
            var sut        = new SpecialManager();
            var lineWorker = new LineWorker();

            Assert.PropertyChanged(sut, "AddStaff", () => sut.AddStaff(lineWorker));
        }
Exemple #11
0
        private static string GetTaskName(ECreateType createType, int siteId, int channelId, int contentId,
                                          int fileTemplateId, int specialId, out int pageCount)
        {
            pageCount = 0;
            var name = string.Empty;

            if (createType == ECreateType.Channel)
            {
                name = channelId == siteId ? "首页" : ChannelManager.GetChannelName(siteId, channelId);
                if (!string.IsNullOrEmpty(name))
                {
                    pageCount = 1;
                }
            }
            else if (createType == ECreateType.AllContent)
            {
                var siteInfo    = SiteManager.GetSiteInfo(siteId);
                var channelInfo = ChannelManager.GetChannelInfo(siteId, channelId);

                if (channelInfo != null)
                {
                    var count = ContentManager.GetCount(siteInfo, channelInfo, true);
                    if (count > 0)
                    {
                        pageCount = count;
                        name      = $"{channelInfo.ChannelName}下所有内容页,共 {pageCount} 项";
                    }
                }
            }
            else if (createType == ECreateType.Content)
            {
                var tuple = DataProvider.ContentDao.GetValue(ChannelManager.GetTableName(
                                                                 SiteManager.GetSiteInfo(siteId), channelId), contentId, ContentAttribute.Title);
                if (tuple != null)
                {
                    name      = tuple.Item2;
                    pageCount = 1;
                }
            }
            else if (createType == ECreateType.File)
            {
                name = TemplateManager.GetTemplateName(siteId, fileTemplateId);
                if (!string.IsNullOrEmpty(name))
                {
                    pageCount = 1;
                }
            }
            else if (createType == ECreateType.Special)
            {
                name = SpecialManager.GetTitle(siteId, specialId);
                if (!string.IsNullOrEmpty(name))
                {
                    pageCount = 1;
                }
            }
            return(name);
        }
Exemple #12
0
        public void Delete(int siteId, int specialId)
        {
            if (specialId <= 0) return;

            var sqlString = $"DELETE FROM {TableName} WHERE {nameof(SpecialInfo.Id)} = {specialId}";
            ExecuteNonQuery(sqlString);

            SpecialManager.RemoveCache(siteId);
        }
Exemple #13
0
    /*
     * Lifecycle events
     */

    void Awake()
    {
        _uuid                  = Guid.NewGuid();
        _rb                    = GetComponent <Rigidbody2D>();
        _puckHighlight         = GetComponentInChildren <PuckHighlight>();
        _trailRenderer         = GetComponentInChildren <TrailRenderer>();
        _special               = GetComponentInChildren <SpecialManager>();
        _triggerPuckZoom       = GetComponentInChildren <TriggerPuckZoom>();
        _trailRenderer.enabled = false;
    }
    // Use this for initialization
    void Start()
    {
        test            = GameObject.FindObjectOfType <SpecialManager> ();
        test.playernum += 1;
        if (isLocalPlayer)
        {
            return;
        }

        NotUs.GetComponent <MovementScript> ().enabled = false;
        NotUs.GetComponent <Gun> ().enabled            = false;
    }
        public ActionResult DeleteSpecial(int id)
        {
            _specialManager = SpecialManagerFactory.Create();

            var response = _specialManager.DeleteSpecial(id);

            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
            }

            return(RedirectToAction("Specials"));
        }
Exemple #16
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            var specialId = AuthRequest.GetQueryInt("specialId");
            var keyword   = AuthRequest.GetQueryString("keyword");

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

            TbKeyword.Text = keyword;

            if (specialId > 0)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["delete"]))
                {
                    var specialInfo = SpecialManager.DeleteSpecialInfo(SiteId, specialId);

                    AuthRequest.AddSiteLog(SiteId,
                                           "删除专题",
                                           $"专题名称:{specialInfo.Title}");

                    SuccessDeleteMessage();
                }
                else if (!string.IsNullOrEmpty(Request.QueryString["download"]))
                {
                    var specialInfo   = SpecialManager.GetSpecialInfo(SiteId, specialId);
                    var directoryPath = SpecialManager.GetSpecialDirectoryPath(SiteInfo, specialInfo.Url);
                    var zipFilePath   = SpecialManager.GetSpecialZipFilePath(directoryPath);
                    PageUtils.Download(Response, zipFilePath, $"{specialInfo.Title}.zip");
                    return;
                }
            }

            RptContents.DataSource = string.IsNullOrEmpty(keyword)
                ? DataProvider.SpecialDao.GetSpecialInfoList(SiteId)
                : DataProvider.SpecialDao.GetSpecialInfoList(SiteId, keyword);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAdd.Attributes.Add("onclick", ModalSpecialAdd.GetOpenWindowString(SiteId));
        }
        public ActionResult Specials()
        {
            _specialManager = SpecialManagerFactory.Create();
            var model    = new AdminSpecialVM();
            var response = _specialManager.GetAllSpecials();

            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message:{response.Message}"));
            }
            else
            {
                model.SetSpecialItems(response.Specials);
                return(View(model));
            }
        }
        private static async Task CreateSpecialAsync(int siteId, int specialId)
        {
            var siteInfo         = SiteManager.GetSiteInfo(siteId);
            var templateInfoList = SpecialManager.GetTemplateInfoList(siteInfo, specialId);

            foreach (var templateInfo in templateInfoList)
            {
                var pageInfo    = new PageInfo(siteId, 0, siteInfo, templateInfo, new Dictionary <string, object>());
                var contextInfo = new ContextInfo(pageInfo);
                var filePath    = PathUtility.MapPath(siteInfo, templateInfo.CreatedFileFullName);

                var contentBuilder = new StringBuilder(templateInfo.Content);
                Parser.Parse(pageInfo, contextInfo, contentBuilder, filePath, false);
                await GenerateFileAsync(filePath, pageInfo.TemplateInfo.Charset, contentBuilder);
            }
        }
        public IHttpActionResult GetConfig()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId    = request.GetQueryInt("siteId");
                var specialId = request.GetQueryInt("specialId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(siteId,
                                                                     ConfigManager.SitePermissions.Specials))
                {
                    return(Unauthorized());
                }

                var siteInfo    = SiteManager.GetSiteInfo(siteId);
                var specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId);

                if (specialInfo == null)
                {
                    return(BadRequest("专题不存在!"));
                }

                var specialUrl = PageUtility.ParseNavigationUrl(siteInfo, $"@/{StringUtils.TrimSlash(specialInfo.Url)}/", true);
                var filePath   = PathUtils.Combine(SpecialManager.GetSpecialDirectoryPath(siteInfo, specialInfo.Url), "index.html");
                var html       = FileUtils.ReadText(filePath, Encoding.UTF8);

                return(Ok(new
                {
                    Value = specialInfo,
                    SpecialUrl = specialUrl,
                    Html = html
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #20
0
        public void Update(SpecialInfo specialInfo)
        {
            var sqlString = $@"UPDATE {TableName} SET
                {nameof(SpecialInfo.SiteId)} = @{nameof(SpecialInfo.SiteId)},  
                {nameof(SpecialInfo.Title)} = @{nameof(SpecialInfo.Title)}, 
                {nameof(SpecialInfo.Url)} = @{nameof(SpecialInfo.Url)},
                {nameof(SpecialInfo.AddDate)} = @{nameof(SpecialInfo.AddDate)}
            WHERE {nameof(SpecialInfo.Id)} = @{nameof(SpecialInfo.Id)}";

            IDataParameter[] parameters =
            {
                GetParameter(nameof(specialInfo.SiteId),  DataType.Integer,  specialInfo.SiteId),
                GetParameter(nameof(specialInfo.Title),   DataType.VarChar,                   200,specialInfo.Title),
                GetParameter(nameof(specialInfo.Url),     DataType.VarChar,                   200,specialInfo.Url),
                GetParameter(nameof(specialInfo.AddDate), DataType.DateTime, specialInfo.AddDate),
                GetParameter(nameof(specialInfo.Id),      DataType.Integer,  specialInfo.Id)
            };

            ExecuteNonQuery(sqlString, parameters);

            SpecialManager.RemoveCache(specialInfo.SiteId);
        }
        public ActionResult Specials()
        {
            //get manager
            SpecialManager manager = SpecialManagerFactory.Create();

            //get response
            SpecialGetAllResponse response = manager.GetAllSpecials();

            //validate
            if (!response.Success)
            {
                return(new HttpStatusCodeResult(500, $"Error in cloud. Message: {response.Message}"));
            }
            else
            {
                //create vm
                SpecialListVM model = new SpecialListVM();
                model.SetSpecialItems(response.Specials);

                return(View(model));
            }
        }
Exemple #22
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            var specialId = AuthRequest.GetQueryInt("specialId");

            _specialInfo = SpecialManager.GetSpecialInfo(SiteId, specialId);

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

            LtlTitle.Text = _specialInfo.Title;
        }
        public IHttpActionResult Download()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId    = request.GetPostInt("siteId");
                var specialId = request.GetPostInt("specialId");

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(siteId,
                                                                     ConfigManager.SitePermissions.Specials))
                {
                    return(Unauthorized());
                }

                var siteInfo    = SiteManager.GetSiteInfo(siteId);
                var specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId);

                var directoryPath    = SpecialManager.GetSpecialDirectoryPath(siteInfo, specialInfo.Url);
                var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath);
                var zipFilePath      = SpecialManager.GetSpecialZipFilePath(specialInfo.Title, directoryPath);

                FileUtils.DeleteFileIfExists(zipFilePath);
                ZipUtils.CreateZip(zipFilePath, srcDirectoryPath);
                var url = SpecialManager.GetSpecialZipFileUrl(siteInfo, specialInfo);

                return(Ok(new
                {
                    Value = url
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #24
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            if (HifUpload.PostedFile == null || "" == HifUpload.PostedFile.FileName)
            {
                FailMessage("上传压缩包失败,请选择ZIP文件上传!");
                return;
            }

            var filePath = HifUpload.PostedFile.FileName;

            if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".zip"))
            {
                FailMessage("上传压缩包失败,必须上传ZIP文件!");
                return;
            }

            var directoryPath = SpecialManager.GetSpecialDirectoryPath(SiteInfo, _specialInfo.Url);

            DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);

            var zipFilePath = SpecialManager.GetSpecialZipFilePath(directoryPath);

            HifUpload.PostedFile.SaveAs(zipFilePath);
            var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath);

            ZipUtils.ExtractZip(zipFilePath, srcDirectoryPath);

            DirectoryUtils.Copy(srcDirectoryPath, directoryPath, true);

            LayerUtils.Close(Page);
        }
    void Start()
    {
        currentNbHuman = nbCreaturePerGroup;

        bool canFight = GameObject.FindGameObjectWithTag("CombatTerrain").GetComponent <CombatTerrainInfo>().bCanFightHere;

        if (!canFight)
        {
            gameObject.SetActive(false);
        }

        GameObject rollObj = GameObject.FindGameObjectWithTag("RollProbaManager");

        if (rollObj != null)
        {
            rollProbaManager = rollObj.GetComponent <RollProbaManager>();
        }

        discoveredTip = null;

        GameObject g = GameObject.FindGameObjectWithTag("ProtoManager");

        if (g != null)
        {
            protoScript = g.GetComponent <ProtoScript>();
        }

        specialManager = GameObject.FindGameObjectWithTag("SpecialManager").GetComponent <SpecialManager>();

        caravane = GameObject.FindGameObjectWithTag("Caravane").GetComponent <Caravane>();
        fighterMouvementManager = GameObject.FindGameObjectWithTag("FighterMouvementManager").GetComponent <FighterMouvementManager>();
        creaturePrefabManager   = GameObject.FindGameObjectWithTag("CreaturePrefabManager").GetComponent <CreaturePrefabManager>();



        float rand = Random.Range(0f, 1f);


        if ((rand < rollProbaManager.specialProba.probaFight || specialManager.iaBard.bardFollow) && protoScript == null && !isBossCombat)
        {
            if (specialManager.iaBard.bardFollow)
            {
                bSpecialFight = true;
                specialType   = SpecialType.Bard;
            }
            else
            {
                float rand2 = Random.Range(0f, 1f);

                if (rand2 < rollProbaManager.specialProba.bard)
                {
                    if (!specialManager.iaBard.endStory)
                    {
                        bSpecialFight = true;
                        specialType   = SpecialType.Bard;
                    }
                }
                else if (!specialManager.iaEd.isDead && rand2 < rollProbaManager.specialProba.ed)
                {
                    bSpecialFight = true;
                    specialType   = SpecialType.Ed;
                }
                else
                {
                    bSpecialFight = true;
                    specialType   = SpecialType.Slip;
                }
            }
        }


        InstantiateMonster();
        InstantiateHuman();


        monsterGroupFighter.groupLogic = logic.GetComponent <PlayerLogic>();

        /*
         *
         * bSpecialFight = true;
         *      specialType = SpecialType.Ed;
         * humanGroupFighter.groupLogic = specialManager.iaEd;
         * ((IAEd)(humanGroupFighter.groupLogic)).groupEd = (GroupEd) humanGroupFighter;
         *
         */


        if (bSpecialFight)
        {
            if (specialType == SpecialType.Bard)
            {
                humanGroupFighter.groupLogic = specialManager.iaBard;
                ((IABard)(humanGroupFighter.groupLogic)).groupBard = (GroupBard)humanGroupFighter;
                specialManager.iaBard.combatJustStarted            = true;
            }
            else if (specialType == SpecialType.Ed)
            {
                humanGroupFighter.groupLogic = specialManager.iaEd;
                ((IAEd)(humanGroupFighter.groupLogic)).groupEd = (GroupEd)humanGroupFighter;
            }
            else
            {
                humanGroupFighter.groupLogic = specialManager.iaSlip;
                ((IASlip)(humanGroupFighter.groupLogic)).groupSlip = (GroupSlip)humanGroupFighter;
            }
        }
        else
        {
            humanGroupFighter.groupLogic = logic.GetComponent <GroupIA>();
            ((GroupIA)humanGroupFighter.groupLogic).groupHumanFighter = (GroupHumanFighter)humanGroupFighter;
        }


        RollInitiative();

        bCombatStarted = false;

        Invoke("CanStartCombat", timeBeforeStartFight);

        //Play Music
        AkSoundEngine.SetSwitch("Tension", "T2", gameObject);
        AkSoundEngine.PostEvent("Play_FightMusic", gameObject);

        for (int i = 0; i < SceneManager.sceneCount; ++i)
        {
            if (SceneManager.GetSceneAt(i).name != "Menu" && SceneManager.GetSceneAt(i).name != "CARTE")
            {
                AkSoundEngine.PostEvent(SceneManager.GetSceneAt(i).name, gameObject);
            }
        }
    }
Exemple #26
0
        public IHttpActionResult Submit()
        {
            try
            {
                var request = new AuthenticatedRequest();

                var siteId       = request.GetPostInt("siteId");
                var guid         = request.GetPostString("guid");
                var specialId    = request.GetPostInt("specialId");
                var isEditOnly   = request.GetPostBool("isEditOnly");
                var isUploadOnly = request.GetPostBool("isUploadOnly");
                var title        = request.GetPostString("title");
                var url          = request.GetPostString("url");
                var fileNames    = TranslateUtils.StringCollectionToStringList(request.GetPostString("fileNames"));
                var siteInfo     = SiteManager.GetSiteInfo(siteId);

                if (!request.IsAdminLoggin ||
                    !request.AdminPermissionsImpl.HasSitePermissions(siteId,
                                                                     ConfigManager.SitePermissions.Specials))
                {
                    return(Unauthorized());
                }

                if (specialId > 0 && isEditOnly)
                {
                    var specialInfo      = SpecialManager.GetSpecialInfo(siteId, specialId);
                    var oldDirectoryPath = string.Empty;
                    var newDirectoryPath = string.Empty;

                    if (specialInfo.Title != title && DataProvider.SpecialDao.IsTitleExists(siteId, title))
                    {
                        return(BadRequest("专题修改失败,专题名称已存在!"));
                    }
                    if (specialInfo.Url != url)
                    {
                        if (DataProvider.SpecialDao.IsUrlExists(siteId, url))
                        {
                            return(BadRequest("专题修改失败,专题访问地址已存在!"));
                        }

                        oldDirectoryPath = SpecialManager.GetSpecialDirectoryPath(siteInfo, specialInfo.Url);
                        newDirectoryPath = SpecialManager.GetSpecialDirectoryPath(siteInfo, url);
                    }

                    specialInfo.Title = title;
                    specialInfo.Url   = url;
                    DataProvider.SpecialDao.Update(specialInfo);

                    if (oldDirectoryPath != newDirectoryPath)
                    {
                        DirectoryUtils.MoveDirectory(oldDirectoryPath, newDirectoryPath, true);
                    }
                }
                else if (specialId > 0 && isUploadOnly)
                {
                    var specialInfo = SpecialManager.GetSpecialInfo(siteId, specialId);

                    var directoryPath    = SpecialManager.GetSpecialDirectoryPath(siteInfo, specialInfo.Url);
                    var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath);
                    DirectoryUtils.CreateDirectoryIfNotExists(srcDirectoryPath);

                    var uploadDirectoryPath = PathUtils.GetTemporaryFilesPath(guid);
                    foreach (var filePath in DirectoryUtils.GetFilePaths(uploadDirectoryPath))
                    {
                        var fileName = PathUtils.GetFileName(filePath);
                        if (!StringUtils.ContainsIgnoreCase(fileNames, fileName))
                        {
                            continue;
                        }

                        if (EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath)))
                        {
                            ZipUtils.ExtractZip(filePath, srcDirectoryPath);
                        }
                        else
                        {
                            FileUtils.MoveFile(filePath, PathUtils.Combine(srcDirectoryPath, fileName), true);
                        }
                    }

                    DirectoryUtils.Copy(srcDirectoryPath, directoryPath);
                }
                else if (specialId == 0)
                {
                    if (DataProvider.SpecialDao.IsTitleExists(siteId, title))
                    {
                        return(BadRequest("专题添加失败,专题名称已存在!"));
                    }
                    if (DataProvider.SpecialDao.IsUrlExists(siteId, url))
                    {
                        return(BadRequest("专题添加失败,专题访问地址已存在!"));
                    }

                    var directoryPath    = SpecialManager.GetSpecialDirectoryPath(siteInfo, url);
                    var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath);
                    DirectoryUtils.CreateDirectoryIfNotExists(srcDirectoryPath);

                    var uploadDirectoryPath = PathUtils.GetTemporaryFilesPath(guid);
                    foreach (var filePath in DirectoryUtils.GetFilePaths(uploadDirectoryPath))
                    {
                        var fileName = PathUtils.GetFileName(filePath);
                        if (!StringUtils.ContainsIgnoreCase(fileNames, fileName))
                        {
                            continue;
                        }

                        if (EFileSystemTypeUtils.IsZip(PathUtils.GetExtension(filePath)))
                        {
                            ZipUtils.ExtractZip(filePath, srcDirectoryPath);
                        }
                        else
                        {
                            FileUtils.MoveFile(filePath, PathUtils.Combine(srcDirectoryPath, fileName), true);
                        }
                    }

                    DirectoryUtils.Copy(srcDirectoryPath, directoryPath);

                    specialId = DataProvider.SpecialDao.Insert(new SpecialInfo
                    {
                        Id      = 0,
                        SiteId  = siteId,
                        Title   = title,
                        Url     = url,
                        AddDate = DateTime.Now
                    });

                    request.AddSiteLog(siteId, "新建专题", $"专题名称:{title}");
                }

                CreateManager.CreateSpecial(siteId, specialId);

                return(Ok(new
                {
                    Value = specialId
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Exemple #27
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var title = TbTitle.Text;
            var url   = PathUtility.AddVirtualToPath(TbUrl.Text);

            if (_specialInfo != null)
            {
                var oldDirectoryPath = string.Empty;
                var newDirectoryPath = string.Empty;

                if (_specialInfo.Title != title && DataProvider.SpecialDao.IsTitleExists(SiteId, title))
                {
                    FailMessage("专题修改失败,专题名称已存在!");
                    return;
                }
                if (_specialInfo.Url != url)
                {
                    if (DataProvider.SpecialDao.IsUrlExists(SiteId, url))
                    {
                        FailMessage("专题修改失败,专题访问地址已存在!");
                        return;
                    }

                    oldDirectoryPath = SpecialManager.GetSpecialDirectoryPath(SiteInfo, _specialInfo.Url);
                    newDirectoryPath = SpecialManager.GetSpecialDirectoryPath(SiteInfo, url);
                }

                _specialInfo.Title = title;
                _specialInfo.Url   = url;
                DataProvider.SpecialDao.Update(_specialInfo);

                if (oldDirectoryPath != newDirectoryPath)
                {
                    DirectoryUtils.MoveDirectory(oldDirectoryPath, newDirectoryPath, true);
                }
            }
            else
            {
                if (HifUpload.PostedFile == null || "" == HifUpload.PostedFile.FileName)
                {
                    FailMessage("专题添加失败,请选择ZIP文件上传!");
                    return;
                }

                var filePath = HifUpload.PostedFile.FileName;
                if (!StringUtils.EqualsIgnoreCase(Path.GetExtension(filePath), ".zip"))
                {
                    FailMessage("专题添加失败,必须上传ZIP文件!");
                    return;
                }

                if (DataProvider.SpecialDao.IsTitleExists(SiteId, title))
                {
                    FailMessage("专题添加失败,专题名称已存在!");
                    return;
                }
                if (DataProvider.SpecialDao.IsUrlExists(SiteId, url))
                {
                    FailMessage("专题添加失败,专题访问地址已存在!");
                    return;
                }

                var directoryPath = SpecialManager.GetSpecialDirectoryPath(SiteInfo, url);
                DirectoryUtils.CreateDirectoryIfNotExists(directoryPath);

                var zipFilePath = SpecialManager.GetSpecialZipFilePath(directoryPath);

                HifUpload.PostedFile.SaveAs(zipFilePath);
                var srcDirectoryPath = SpecialManager.GetSpecialSrcDirectoryPath(directoryPath);
                ZipUtils.ExtractZip(zipFilePath, srcDirectoryPath);

                DirectoryUtils.Copy(srcDirectoryPath, directoryPath, true);
                //var htmlFiles = Directory.GetFiles(srcDirectoryPath, "*.html", SearchOption.AllDirectories);
                //foreach (var htmlFile in htmlFiles)
                //{
                //    CreateManager.CreateFile();
                //}

                var specialInfo = new SpecialInfo
                {
                    Title   = title,
                    Url     = url,
                    SiteId  = SiteId,
                    AddDate = DateTime.Now
                };

                DataProvider.SpecialDao.Insert(specialInfo);
            }

            LayerUtils.Close(Page);
        }