Пример #1
0
        public async Task <LinkResponseInfo> GetLink(LinkKind kind, string fileId)
        {
            // LinkKind is View or Edit

            var client = new HttpClient();

            client.DefaultRequestHeaders.Authorization
                = new AuthenticationHeaderValue(Bearer, AccessToken);

            var request = string.Format(RequestLink, fileId);
            var uri     = new Uri(RootUrl + request);

            var requestJson = JsonConvert.SerializeObject(
                new RequestLinkInfo
            {
                Type = kind.ToString().ToLower()
            });

            var content = new StringContent(
                requestJson,
                Encoding.UTF8,
                "application/json");

            var response = await client.PostAsync(uri, content);

            var result = JsonConvert.DeserializeObject <LinkResponseInfo>(
                await response.Content.ReadAsStringAsync());

            return(result);
        }
Пример #2
0
        public LinkInfo(Uri baseUri, string url, LinkKind kind)
        {
            Contract.Requires(Uri.IsWellFormedUriString(
                                  url, UriKind.RelativeOrAbsolute));

            Kind = kind;

            Uri uri;

            if (Uri.IsWellFormedUriString(url, UriKind.Absolute))
            {
                uri = new Uri(url);
            }
            else
            {
                uri = new Uri(baseUri, url);
            }

            if (kind == LinkKind.HTML)
            {
                Uri = uri;
            }
            else
            {
                Uri = new Uri(uri.GetLeftPart(UriPartial.Path));
            }
        }
Пример #3
0
        public PdfLink MakeLink(Rectangle rect, string destination, LinkKind linkType)
        {
            PdfLink link = new PdfLink(doc.NextObjectId(), rect);

            this.objects.Add(link);

            if (linkType == LinkKind.External)
            {
                if (destination.EndsWith(".pdf"))
                { // FileSpec
                    PdfFileSpec fileSpec = new PdfFileSpec(doc.NextObjectId(), destination);
                    this.objects.Add(fileSpec);
                    PdfGoToRemote gotoR = new PdfGoToRemote(fileSpec, doc.NextObjectId());
                    this.objects.Add(gotoR);
                    link.SetAction(gotoR);
                }
                else
                { // URI
                    PdfUri uri = new PdfUri(destination);
                    link.SetAction(uri);
                }
            }
            else
            {
                PdfObjectReference goToReference = GetGoToReference(destination);
                PdfInternalLink    internalLink  = new PdfInternalLink(goToReference);
                link.SetAction(internalLink);
            }
            return(link);
        }
Пример #4
0
 public Link(LinkKind linkKind, GameObject mediaCondition, GameObject mediaAction, string[] description)
 {
     this.linkKind       = linkKind;
     this.mediaCondition = mediaCondition;
     this.mediaAction    = mediaAction;
     this.description    = description;
 }
Пример #5
0
        public IActionResult LinkCategoryList()
        {
            IList <LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);

            Core.Admin.WriteLogActions("查看友情链接分类列表页面;");
            return(View(list));
        }
Пример #6
0
        public IActionResult EditLinkKind(LinkKind model)
        {
            if (model.Id <= 0)
            {
                tip.Message = "错误参数传递!";
                return(Json(tip));
            }
            LinkKind oldentity = LinkKind.Find(LinkKind._.Id == model.Id);

            if (oldentity == null)
            {
                tip.Message = "系统找不到本记录!";
                return(Json(tip));
            }
            if (string.IsNullOrEmpty(model.KindName))
            {
                tip.Message = "友情链接分类名称不能为空!";
                return(Json(tip));
            }
            model.Update();
            tip.Status  = JsonTip.SUCCESS;
            tip.Message = "编辑友情链接分类成功";
            Core.Admin.WriteLogActions("编辑友情链接分类(" + model.Id + ");");
            return(Json(tip));
        }
Пример #7
0
 public NonSponsoredLink(string url, string description, DateTime lastCrawl, LinkKind kind)
 {
     Url         = url;
     Description = description;
     Impressions = 0;
     LastCrawl   = lastCrawl;
     Kind        = kind;
 }
Пример #8
0
        public IActionResult AddLink()
        {
            IList <LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);

            ViewBag.ListKinds = list;
            Core.Admin.WriteLogActions("查看添加友情链接页面;");
            return(View());
        }
Пример #9
0
        public IActionResult AddLinkKind(LinkKind model)
        {
            if (string.IsNullOrEmpty(model.KindName))
            {
                tip.Message = "广告分类名称不能为空!";
                return(Json(tip));
            }

            model.Insert();
            tip.Status  = JsonTip.SUCCESS;
            tip.Message = "添加友情链接分类成功";
            Core.Admin.WriteLogActions("添加友情链接分类(" + model.Id + ");");
            return(Json(tip));
        }
Пример #10
0
 public Link(string id1, string id2, LinkStatus status, LinkKind kind, long timestamp)
 {
     if (String.CompareOrdinal(id1, id2) < 0)
     {
         Id1 = id1;
         Id2 = id2;
     }
     else
     {
         Id1 = id2;
         Id2 = id1;
     }
     Status = status;
     Kind = kind;
     Timestamp = timestamp;
 }
Пример #11
0
 public Link(string id1, string id2, LinkStatus status, LinkKind kind, long timestamp)
 {
     if (String.CompareOrdinal(id1, id2) < 0)
     {
         Id1 = id1;
         Id2 = id2;
     }
     else
     {
         Id1 = id2;
         Id2 = id1;
     }
     Status    = status;
     Kind      = kind;
     Timestamp = timestamp;
 }
Пример #12
0
        public IActionResult EditLink(int id)
        {
            IList <LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);

            ViewBag.ListKinds = list;

            Link entity = Link.Find(Link._.Id == id);

            if (entity == null)
            {
                return(EchoTipPage("系统找不到本记录!"));
            }

            Core.Admin.WriteLogActions("查看/编辑友情链接(" + id + ");");

            return(View(entity));
        }
Пример #13
0
        public JsonResult DelLinkKind(int id)
        {
            LinkKind entity = LinkKind.Find(LinkKind._.Id == id);

            if (entity == null)
            {
                tip.Message = "系统找不到本友情链接分类!";
                return(Json(tip));
            }
            //删除下属友情链接
            IList <Link> list = Link.FindAll(Link._.KId == entity.Id, null, null, 0, 0);

            if (list != null && list.Count > 0)
            {
                list.Delete();
            }
            Core.Admin.WriteLogActions("删除友情链接分类(id:" + entity.Id + ");");
            entity.Delete();
            tip.Status  = JsonTip.SUCCESS;
            tip.Message = "删除友情链接分类成功";
            return(Json(tip));
        }
Пример #14
0
 public Link(string id1, string id2, LinkStatus status, LinkKind kind)
     : this(id1, id2, status, kind, CurrentTimeMillis())
 {
 }
Пример #15
0
 public Link(string id1, string id2, LinkStatus status, LinkKind kind)
     : this(id1, id2, status, kind, CurrentTimeMillis())
 {
 }
Пример #16
0
 private bool isArmyNavigableTo(LinkKind kind, Military military)
 {
     return GlobalVariables.LandArmyCanGoDownWater ||
         ((kind == LinkKind.Land && military.Kind.Type != MilitaryType.水军) || (kind == LinkKind.Water && military.Kind.Type == MilitaryType.水军) || kind == LinkKind.Both);
 }
Пример #17
0
        private Troop BuildTroopForTransfer(Military military, Architecture destination, LinkKind linkkind)
        {
            if (linkkind == LinkKind.None)
            {
                return null;
            }
            if (!this.isArmyNavigableTo(linkkind, military))
            {
                return null;
            }
            if (this.Persons.Count == 0) return null;
            TroopList list = new TroopList();
            this.Persons.ClearSelected();
            if ((military.Scales > 5) && (military.Morale >= 80) && (military.Combativity >= 80) && (military.InjuryQuantity < military.Kind.MinScale) && !military.IsFewScaleNeedRetreat)
            {
                PersonList list2;
                Military military2 = military;
                if ((military2.FollowedLeader != null) && this.Persons.HasGameObject(military2.FollowedLeader) && military2.FollowedLeader.WaitForFeiZi == null && military2.FollowedLeader.LocationTroop == null)
                {
                    list2 = new PersonList();
                    list2.Add(military2.FollowedLeader);
                    military2.FollowedLeader.Selected = true;
                    Point? nullable = this.GetRandomStartingPosition(military2);
                    if (!nullable.HasValue)
                    {
                        return null;
                    }

                    Troop troop = this.CreateTroop(list2, military2.FollowedLeader, military2, -1, nullable.Value);
                    troop.WillArchitecture = destination;
                    Legion legion = this.BelongedFaction.GetLegion(destination);
                    if (legion == null)
                    {
                        legion = this.CreateOffensiveLegion(destination);
                    }
                    legion.AddTroop(troop);
                    return troop;
                }
                if ((((military2.Leader != null) && (military2.LeaderExperience >= 10)) && (((military2.Leader.Strength >= 80) || (military2.Leader.Command >= 80)) || military2.Leader.HasLeaderValidTitle))
                    && this.Persons.HasGameObject(military2.Leader) && military2.Leader.WaitForFeiZi == null && military2.Leader.LocationTroop == null)
                {
                    list2 = new PersonList();
                    list2.Add(military2.Leader);
                    military2.Leader.Selected = true;
                    Point? nullable = this.GetRandomStartingPosition(military2);
                    if (!nullable.HasValue)
                    {
                        return null;
                    }
                    Troop troop = this.CreateTroop(list2, military2.Leader, military2, -1, nullable.Value);
                    troop.WillArchitecture = destination;
                    Legion legion = this.BelongedFaction.GetLegion(destination);
                    if (legion == null)
                    {
                        legion = this.CreateOffensiveLegion(destination);
                    }
                    legion.AddTroop(troop);
                    return troop;
                }
                GameObjectList sortedList = this.Persons.GetList() as GameObjectList;
                sortedList.PropertyName = "FightingForce";
                sortedList.IsNumber = true;
                sortedList.SmallToBig = true;
                sortedList.ReSort();
                foreach (Person person in sortedList)
                {
                    if (!person.Selected && person.WaitForFeiZi == null && person.LocationTroop == null)
                    {
                        list2 = new PersonList();
                        list2.Add(person);
                        person.Selected = true;
                        Point? nullable = this.GetRandomStartingPosition(military2);
                        if (!nullable.HasValue)
                        {
                            break;
                        }
                        Troop troop = this.CreateTroop(list2, person, military2, -1, nullable.Value);
                        troop.WillArchitecture = destination;
                        Legion legion = this.BelongedFaction.GetLegion(destination);
                        if (legion == null)
                        {
                            legion = this.CreateOffensiveLegion(destination);
                        }
                        legion.AddTroop(troop);
                        return troop;
                    }
                }
            }
            return null;
        }
Пример #18
0
 private Troop BuildOffensiveTroop(Architecture destination, LinkKind linkkind, bool offensive)
 {
     Troop troop;
     if (linkkind == LinkKind.None)
     {
         return null;
     }
     TroopList list = new TroopList();
     this.Persons.ClearSelected();
     //Label_0309:
     foreach (Military military in this.Militaries.GetRandomList())
     {
         if (military.Scales < military.RetreatScale * 1.5) continue;
         if (military.IsTransport) continue; //never deal with transports in this function
         switch (linkkind)
         {
             case LinkKind.Land:
                 {
                     if (military.Kind.Type != MilitaryType.水军)
                     {
                         break;
                     }
                     continue;
                 }
             case LinkKind.Water:
                 {
                     //if ((military.Kind.Type == MilitaryType.水军) || (this.ValueWater && (!offensive || ((military.Quantity >= 0x1f40) && (GameObject.Random(military.Kind.Merit) <= 0)))))
                     if (GlobalVariables.LandArmyCanGoDownWater)
                     {
                         if (!offensive || (military.KindID != 28 && !military.IsTransport))
                         {
                             break;
                         }
                     }
                     else
                     {
                         if (military.Kind.Type == MilitaryType.水军)
                         {
                             break;
                         }
                     }
                     continue;
                 }
         }
         if ((((military.Scales > 5) && (military.Morale >= 80)) && (military.Combativity >= 80)) && (military.InjuryQuantity < military.Kind.MinScale)
             && (!offensive ||
             (military.Merit > 0)
             )) //do not use transport teams to attack
         {
             TroopList candidates = this.AISelectPersonIntoTroop(this, military);
             foreach (Troop t in candidates)
             {
                 list.Add(t);
             }
         }
     }
     if (list.Count > 0)
     {
         list.IsNumber = true;
         list.PropertyName = "SimulatingFightingForce";
         list.ReSort();
         foreach (Troop troop2 in list.GetList())
         {
             bool personAlreadyOut = false;
             foreach (Person p in troop2.Candidates)
             {
                 if (p.LocationTroop != null)
                 {
                     personAlreadyOut = true;
                     break;
                 }
             }
             bool militaryOut = true;
             foreach (Military m in this.Militaries)
             {
                 if (troop2.Army == m)
                 {
                     militaryOut = false;
                     break;
                 }
             }
             if (personAlreadyOut) continue;
             if (militaryOut) continue;
             if (troop2.FightingForce < 10000 && offensive)
             {
                 break;
             }
             Point? nullable = this.GetRandomStartingPosition(troop2);
             if (!nullable.HasValue)
             {
                 break;
             }
             Person leader = troop2.Candidates[0] as Person;
             PersonList candidates = this.SelectSubOfficersToTroop(troop2);
             troop = this.CreateTroop(candidates, leader, troop2.Army, -1, nullable.Value);
             troop.WillArchitecture = destination;
             Legion legion = this.BelongedFaction.GetLegion(destination);
             if (legion == null)
             {
                 legion = this.CreateOffensiveLegion(destination);
             }
             legion.AddTroop(troop);
             this.PostCreateTroop(troop, false);
         }
     }
     foreach (Troop t in list)
     {
         t.Destroy(true, false);
     }
     return null;
 }
Пример #19
0
        /**
         * render page into PDF
         *
         * @param page page to render
         */

        public void RenderPage(Page page)
        {
            BodyAreaContainer body;
            AreaContainer     before, after, start, end;

            currentStream = this.pdfCreator.MakeContentStream();
            body          = page.getBody();
            before        = page.getBefore();
            after         = page.getAfter();
            start         = page.getStart();
            end           = page.getEnd();

            this.currentFontName      = "";
            this.currentFontSize      = 0;
            this.currentLetterSpacing = Single.NaN;

            currentStream.BeginTextObject();

            RenderBodyAreaContainer(body);

            if (before != null)
            {
                RenderAreaContainer(before);
            }

            if (after != null)
            {
                RenderAreaContainer(after);
            }

            if (start != null)
            {
                RenderAreaContainer(start);
            }

            if (end != null)
            {
                RenderAreaContainer(end);
            }
            CloseText();

            // Bug fix for issue 1823
            this.currentLetterSpacing = Single.NaN;

            float w = page.getWidth();
            float h = page.GetHeight();

            currentStream.EndTextObject();

            var idList = new System.Collections.Generic.List <string>();

            foreach (string id in page.getIDList())
            {
                idList.Add(id);
            }

            currentPage = this.pdfCreator.MakePage(
                this.pdfResources, currentStream,
                Convert.ToInt32(Math.Round(w / 1000)),
                Convert.ToInt32(Math.Round(h / 1000)), idList.ToArray());

            if (page.hasLinks() || currentAnnotList != null)
            {
                if (currentAnnotList == null)
                {
                    currentAnnotList = this.pdfCreator.MakeAnnotList();
                }
                currentPage.SetAnnotList(currentAnnotList);

                ArrayList lsets = page.getLinkSets();
                foreach (LinkSet linkSet in lsets)
                {
                    linkSet.align();
                    String    dest     = linkSet.getDest();
                    LinkKind  linkType = linkSet.getLinkType();
                    ArrayList rsets    = linkSet.getRects();
                    foreach (LinkedRectangle lrect in rsets)
                    {
                        currentAnnotList.Add(
                            this.pdfCreator.MakeLink(lrect.getRectangle(),
                                                     dest, linkType).GetReference());
                    }
                }
                currentAnnotList = null;
            }
            else
            {
                // just to be on the safe side
                currentAnnotList = null;
            }

            // ensures that color is properly reset for blocks that carry over pages
            this.currentFill = null;
        }
Пример #20
0
 private Troop BuildOffensiveTroop(Architecture destination, LinkKind linkkind, bool offensive)
 {
     Troop troop;
     if (linkkind == LinkKind.None)
     {
         return null;
     }
     TroopList list = new TroopList();
     this.Persons.ClearSelected();
 //Label_0309:
     foreach (Military military in this.Militaries.GetRandomList())
     {
         switch (linkkind)
         {
             case LinkKind.Land:
             {
                 if (military.Kind.Type != MilitaryType.水军)
                 {
                     break;
                 }
                 continue;
             }
             case LinkKind.Water:
             {
                 if ((military.Kind.Type == MilitaryType.水军) || (this.ValueWater && (!offensive || ((military.Quantity >= 0x1f40) && (GameObject.Random(military.Kind.Merit) <= 0)))))
                 {
                     break;
                 }
                 continue;
             }
         }
         if ((((military.Scales >= 3) && (military.Morale >= 80)) && (military.Combativity >= 80)) && (military.InjuryQuantity < military.Kind.MinScale))
         {
             PersonList list2;
             Military military2 = military;
             if ((linkkind == LinkKind.Water) && (military.Kind.Type != MilitaryType.水军))
             {
                 Military military3 = Military.SimCreate(base.Scenario, this, base.Scenario.GameCommonData.AllMilitaryKinds.GetMilitaryKind(0x1c));
                 military3.SetShelledMilitary(military);
                 military2 = military3;
             }
             if ((military2.FollowedLeader != null) && this.Persons.HasGameObject(military2.FollowedLeader))
             {
                 list2 = new PersonList();
                 list2.Add(military2.FollowedLeader);
                 military2.FollowedLeader.Selected = true;
                 troop = Troop.CreateSimulateTroop(list2, military2, this.Position);
                 list.Add(troop);
                 //goto Label_0309;
                 continue;
             }
             if ((((military2.Leader != null) && (military2.LeaderExperience >= 200)) && (((military2.Leader.Strength >= 80) || (military2.Leader.Command >= 80)) || military2.Leader.HasLeaderValidCombatTitle)) && this.Persons.HasGameObject(military2.Leader))
             {
                 list2 = new PersonList();
                 list2.Add(military2.Leader);
                 military2.Leader.Selected = true;
                 troop = Troop.CreateSimulateTroop(list2, military2, this.Position);
                 list.Add(troop);
                 //goto Label_0309;
                 continue;
             }
             foreach (Person person in this.Persons)
             {
                 if (!person.Selected && (person.Command >= 40))
                 {
                     list2 = new PersonList();
                     list2.Add(person);
                     troop = Troop.CreateSimulateTroop(list2, military2, this.Position);
                     list.Add(troop);
                 }
             }
         }
     }
     if (list.Count > 0)
     {
         list.IsNumber = true;
         list.PropertyName = "SimulatingFightingForce";
         list.ReSort();
         foreach (Troop troop2 in list.GetList())
         {
             if (troop2.FightingForce < 0x2710)
             {
                 break;
             }
             Point? nullable = this.GetCampaignPosition(troop2, destination.ArchitectureArea.Area, true);
             if (!nullable.HasValue)
             {
                 break;
             }
             Person leader = troop2.Persons[0] as Person;
             this.AddPersonToTroop(troop2);
             troop = this.CreateTroop(troop2.Persons, leader, troop2.Army, -1, nullable.Value);
             troop.WillArchitecture = destination;
             Legion legion = this.BelongedFaction.GetLegion(destination);
             if (legion == null)
             {
                 legion = this.CreateOffensiveLegion(destination);
             }
             legion.AddTroop(troop);
             this.PostCreateTroop(troop, false);
             return troop;
         }
     }
     return null;
 }
Пример #21
0
        public static bool IsLink(this string url,
            Uri baseUri, LinkKind kind, UriFilter filter = UriFilter.None)
        {
            Contract.Requires(baseUri.IsBaseUri());

            if (string.IsNullOrWhiteSpace(url))
                return false;

            url = url.Trim().ToLower();

            if (!Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                return false;

            if (url.StartsWith("#"))
                return false;

            Uri uri;

            if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri))
                return false;

            if (!uri.IsAbsoluteUri)
            {
                if (!Uri.TryCreate(baseUri, uri, out uri))
                    return false;
            }

            if (uri.Scheme != "http")
                return false;

            switch (filter)
            {
                case UriFilter.LocalPath:
                    if (!baseUri.IsBaseOf(uri))
                        return false;
                    break;
                case UriFilter.Authority:
                    if (uri.Authority != baseUri.Authority)
                        return false;
                    break;
            }

            if (kind == LinkKind.HTML)
                return true;

            if (!string.IsNullOrWhiteSpace(uri.Query))
                return false;

            string localPath;

            try
            {
                localPath = Path.GetFileName(uri.LocalPath);
            }
            catch
            {
                return false;
            }

            switch (Path.GetExtension(localPath))
            {
                case ".jpg":
                case ".jpeg":
                case ".png":
                case ".gif":
                case ".bmp":
                case ".tiff":
                    return true;
                default:
                    return false;
            }
        }