コード例 #1
0
 public byte[] InformerImageError(CoCEnum.CoCFmtReq type, string langid = null)
 {
     return((this._cocInformer != null) ?
            this._cocInformer.ErrorImageInformer(type, langid) :
            new byte[0]
            );
 }
コード例 #2
0
            private Image _GetTemplateImage(CoCEnum.CoCFmtReq type)
            {
                Image tmplImage = (Image)((type == CoCEnum.CoCFmtReq.Clan) ?
                                          Properties.Resources.bgClanTemplate :
                                          Properties.Resources.bgMemberTemplate
                                          );

                ((Bitmap)tmplImage).MakeTransparent(Color.Transparent);
                return(tmplImage);
            }
コード例 #3
0
ファイル: CoCMedia.cs プロジェクト: PetersSharp/stCoCServer
            public static string _GetMediaUrl(CoCEnum.CoCFmtReq type, CoCEnum.CoCBadgeType size, string imgId)
            {
                CoCMediaSetInfo cms = null;

                if ((cms = CoCMediaSet.GetMediaSet(type)) == null)
                {
                    return(null);
                }
                return(string.Format(
                           Properties.Settings.Default.CoCLocalMediaURL,
                           cms.mpath[0],
                           cms.mpath[1],
                           cms.mdir,
                           cms.msize[(int)size].ToString(),
                           ((string.IsNullOrWhiteSpace(imgId)) ? "" : imgId + ".png")
                           ));
            }
コード例 #4
0
 public byte[] ErrorImageInformer(CoCEnum.CoCFmtReq type, string langid = null)
 {
     try
     {
         CultureInfo ci = stNet.stWebServerUtil.HttpUtil.GetHttpClientLanguage(langid, null);
         return(this._GraphSaveToMemStream(
                    (Image)((type == CoCEnum.CoCFmtReq.Clan) ?
                            Properties.Resources.ResourceManager.GetObject("bgTemplate500Error500x100", ci) :
                            ((type == CoCEnum.CoCFmtReq.Auth) ?
                             Properties.Resources.ResourceManager.GetObject("bgTemplate404MembrsError300x180", ci) :
                             Properties.Resources.ResourceManager.GetObject("bgTemplate500Error300x180", ci)
                            ))
                    ));
     }
     catch (Exception)
     {
         return(new byte[0]);
     }
 }
コード例 #5
0
ファイル: CoCMedia.cs プロジェクト: PetersSharp/stCoCServer
            // mediaPath - TODO: variable parent _assetspath

            public static CoCMediaSetInfo GetMediaSet(CoCEnum.CoCFmtReq mediaid)
            {
                switch (mediaid)
                {
                case CoCEnum.CoCFmtReq.Leagues:
                {
                    return(new CoCMediaSetInfo()
                        {
                            msize = CoCMediaSet.sizeLigue,
                            mpath = CoCMediaSet.mediaPath,
                            mdir = CoCEnum.CoCFmtReq.Leagues.ToString().ToLowerInvariant()
                        });
                }

                case CoCEnum.CoCFmtReq.Clan:
                case CoCEnum.CoCFmtReq.Warlog:
                case CoCEnum.CoCFmtReq.Badges:
                {
                    return(new CoCMediaSetInfo()
                        {
                            msize = CoCMediaSet.sizeBadge,
                            mpath = CoCMediaSet.mediaPath,
                            mdir = CoCEnum.CoCFmtReq.Badges.ToString().ToLowerInvariant()
                        });
                }

                case CoCEnum.CoCFmtReq.Flags:
                {
                    return(new CoCMediaSetInfo()
                        {
                            msize = CoCMediaSet.sizeFlags,
                            mpath = CoCMediaSet.mediaPath,
                            mdir = CoCEnum.CoCFmtReq.Flags.ToString().ToLowerInvariant()
                        });
                }

                default:
                {
                    return(null);
                }
                }
            }
コード例 #6
0
        public byte[] InformerImageGet(DataRow dr, CoCEnum.CoCFmtReq type, int idx, string cacheid, string langid = null, bool iscached = true)
        {
            if (this._cocInformer == null)
            {
                return(new byte[0]);
            }
            byte[] bytes   = null;
            string imgid   = this._cocInformer.GetResourceId(type, idx),
                   cacheId = imgid + cacheid;

            if ((iscached) && (stCore.stCache.GetCacheObject <byte[]>(cacheId, out bytes)))
            {
                return(bytes);
            }
            bytes = this._cocInformer.CreateCacheInformer(dr, type, idx, imgid, langid);
            if (iscached)
            {
                stCore.stCache.SetCacheObject <byte[]>(cacheId, bytes, this.UpdateNextTime);
            }
            return(bytes);
        }
コード例 #7
0
            private Image _CreateTemplateImage(DataRow row, CoCEnum.CoCFmtReq type)
            {
                int    x, y;
                SizeF  gSize = new SizeF();
                string pathImgLogo;

                Image tmplImage = this._GetTemplateImage(type);

                // Trick about libgdiplus.so in Mono (*nix)
                // libgdiplus not support image more 32bpp (PixelFormat32bppARGB)
                // see http://bugzilla.ximian.com/show_bug.cgi?id=80693
                //
                switch (type)
                {
                case CoCEnum.CoCFmtReq.Clan:
                {
                    if (this._ismono)
                    {
                        pathImgLogo = Path.Combine(
                            this._imgdir,
                            CoCInformer.ImageDefaultBadges
                            );
                    }
                    else
                    {
                        pathImgLogo = Path.Combine(
                            this._imgdir,
                            "badges",
                            "70",
                            Path.GetFileNameWithoutExtension(Convert.ToString(row["ico"], CultureInfo.InvariantCulture)) + ".png"
                            );
                    }
                    break;
                }

                default:
                {
                    pathImgLogo = Path.Combine(
                        this._imgdir,
                        "leagues",
                        "36",
                        Path.GetFileNameWithoutExtension(Convert.ToString(row["ico"], CultureInfo.InvariantCulture)) + ".png"
                        );
                    break;
                }
                }
                try
                {
                    if (File.Exists(pathImgLogo))
                    {
                        try
                        {
                            this._GraphImage(
                                tmplImage,
                                pathImgLogo,
                                ((type == CoCEnum.CoCFmtReq.Clan) ? 5 : 5),
                                ((type == CoCEnum.CoCFmtReq.Clan) ? 5 : 5)
                                );
                        }
                        catch (Exception e)
                        {
                            throw e;
                        }
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }
                }
                catch (NotSupportedException)
                {
                    using (Image imgLogo = (Image)((type == CoCEnum.CoCFmtReq.Clan) ?
                                                   Properties.Resources.bgDefaultBage :
                                                   Properties.Resources.bgDefaultLeague
                                                   ))
                    {
                        this._GraphImage(
                            tmplImage,
                            imgLogo,
                            ((type == CoCEnum.CoCFmtReq.Clan) ? 5 : 5),
                            ((type == CoCEnum.CoCFmtReq.Clan) ? 5 : 5)
                            );
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
                foreach (InformerItems item in ((type == CoCEnum.CoCFmtReq.Clan) ? this._ClanFields : this._MembersFields))
                {
                    string text = Convert.ToString(row[item.name], CultureInfo.InvariantCulture);
                    if (!string.IsNullOrWhiteSpace(text))
                    {
                        x     = ((item.isAppendWidth) ? ((int)gSize.Width + item.x) : item.x);
                        y     = (((item.isAppendHeight) ? ((int)gSize.Height + item.y) : item.y) - (int)((this._ismono) ? 2 : 0));
                        gSize = _GraphText(tmplImage, item.text + text, item.font, item.fontsz, item.clr, x, y);
                    }
                }
                return(tmplImage);
            }
コード例 #8
0
 public string GetResourceId(CoCEnum.CoCFmtReq type, int idx)
 {
     return(((type == CoCEnum.CoCFmtReq.Clan) ? CoCInformer.ResourceClanTmpl : CoCInformer.ResourceMembersTmpl) + idx.ToString());
 }
コード例 #9
0
            public byte[] CreateCacheInformer(DataRow dr, CoCEnum.CoCFmtReq type, int idx, string imgid = null, string langid = null, int width = 0, int height = 0)
            {
                if (
                    (idx < 0) ||
                    ((bool)(type == CoCEnum.CoCFmtReq.Clan) ? (idx > 25) : (idx > 15))
                    )
                {
                    return(this._ErrorImageInternal(
                               ((type == CoCEnum.CoCFmtReq.Clan) ? "bgTemplate404Error500x100" : "bgTemplate404Error300x180"),
                               langid
                               ));
                }
                if (string.IsNullOrWhiteSpace(imgid))
                {
                    imgid = this.GetResourceId(type, idx);
                }

                width = ((width == 0) ?
                         ((type == CoCEnum.CoCFmtReq.Clan) ? 500 : 300) : width);
                height = ((height == 0) ?
                          ((type == CoCEnum.CoCFmtReq.Clan) ? 100 : 180) : height);

                try
                {
                    using (Image tmplImage = this._CreateTemplateImage(dr, type))
                    {
                        using (Image bgImage = (Image)Properties.Resources.ResourceManager.GetObject(imgid))
                        {
                            using (Graphics drawGraph = Graphics.FromImage(bgImage))
                            {
                                drawGraph.DrawImage(tmplImage, 0, 0, width, height);
                                drawGraph.Flush();
                                return(this._GraphSaveToMemStream(bgImage));
                            }
                        }
                    }
                }
#if DEBUG_ImgException1
                catch (NotSupportedException e)
                {
                    stCore.stConsole.WriteHeader("[CreateCacheInformer] NotSupportedException: " + e.Message + Environment.NewLine + e.ToString());
#else
                catch (NotSupportedException)
                {
#endif
                    return(this._ErrorImageInternal(
                               ((type == CoCEnum.CoCFmtReq.Clan) ? "bgTemplate500NoSupportError500x100" : "bgTemplate500NoSupportError300x180"),
                               langid
                               ));
                }
                catch (Exception e)
                {
#if DEBUG_ImgException2
                    stCore.stConsole.WriteHeader("[CreateCacheInformer] Exception: " + e.Message + Environment.NewLine + e.ToString());
#endif

                    if (this._parent.isLogEnable)
                    {
                        this._parent._ilog.LogError(
                            string.Format(
                                Properties.Resources.CoCInformerError,
                                e.Message
                                )
                            );
                    }
                    return(this._ErrorImageInternal(
                               ((type == CoCEnum.CoCFmtReq.Clan) ? "bgTemplate500Error500x100" : "bgTemplate500Error300x180"),
                               langid
                               ));
                }
            }
コード例 #10
0
 public void NotifyEvent(CoCEnum.CoCFmtReq typeId, DataTable dt)
 {
     this._cocNotifier.Event(typeId, dt);
 }
コード例 #11
0
            public void Event(CoCEnum.CoCFmtReq typeId, DataTable dt)
            {
                switch (typeId)
                {
                case CoCEnum.CoCFmtReq.Clan:
                {
                    this._notifyTable.ForEach(notify =>
                        {
                            if (
                                (notify.TableId == typeId) &&
                                (!string.IsNullOrWhiteSpace(notify.NameField))
                                )
                            {
                                if (this._EventCheckRow(dt.Rows[0], notify.NameField))
                                {
                                    this._EventToTable(notify.EventId, "name", notify.NameField, dt.Rows[0]);
                                }
                            }
                        });
                    if ((this._parent._isInformerStatic) && (this._parent._cocInformer != null))
                    {
                        try
                        {
                            this._parent._cocInformer.CreateClanInformerAll(dt.Rows[0]);
                        }
#if DEBUG
                        catch (Exception e)
                        {
                            if (this._parent.isLogEnable)
                            {
                                this._parent._ilog.LogError(
                                    string.Format(
                                        Properties.Resources.CoCInformerError,
                                        e.Message
                                        )
                                    );
                            }
#else
                        catch (Exception)
                        {
#endif
                        }
                    }
                    break;
                }

                case CoCEnum.CoCFmtReq.Warlog:
                {
                    foreach (DataRow addedRow in dt.Select(null, null, DataViewRowState.Added))
                    {
                        this._EventToTable(
                            CoCEnum.EventNotify.WarClanEnd,
                            new string[] { "opname", "optag", "cdestruct", "opdestruct", "result", "members" },
                            addedRow
                            );
                    }
                    break;
                }

                case CoCEnum.CoCFmtReq.Members:
                {
                    foreach (DataRow addedRow in dt.Select(null, null, DataViewRowState.Added))
                    {
                        if (this._EventFilterMemberTag(addedRow))
                        {
                            continue;
                        }
                        this._EventToTable(CoCEnum.EventNotify.MemberNew, "nik", "level", addedRow, true);
                    }
                    foreach (DataRow updateRow in dt.Select(null, null, DataViewRowState.ModifiedCurrent))
                    {
                        if (this._EventFilterMemberTag(updateRow))
                        {
                            continue;
                        }
                        this._notifyTable.ForEach(notify =>
                            {
                                if (
                                    (notify.TableId == typeId) &&
                                    (!string.IsNullOrWhiteSpace(notify.NameField))
                                    )
                                {
                                    switch (notify.EventId)
                                    {
                                    case CoCEnum.EventNotify.MemberNew:
                                        {
                                            break;
                                        }

                                    case CoCEnum.EventNotify.MemberExit:
                                        {
                                            Int64 status = (Int64)updateRow["status", DataRowVersion.Current];
                                            if (status == 0)
                                            {
                                                this._EventToTable(notify.EventId, "nik", notify.NameField, updateRow, true);

                                                // stDokuWiki.AuthManager.DokuAuthManager
                                                // is enable, delete exiting user
                                                if (this._parent._cocDWAuth != null)
                                                {
                                                    this._parent.DokuWikiAuthDel(
                                                        Convert.ToString(updateRow["nik"], CultureInfo.InvariantCulture)
                                                        );
                                                }
                                            }
                                            break;
                                        }

                                    default:
                                        {
                                            if (this._EventCheckRow(updateRow, notify.NameField))
                                            {
                                                this._EventToTable(notify.EventId, "nik", notify.NameField, updateRow);
                                            }
                                            break;
                                        }
                                    }
                                }
                            });
                    }
                    break;
                }
                }
                if (this._data.Rows.Count > 0)
                {
                    this._rssString = this._EventRssToString();
                    this._EventSseSend(this._DataSseSend);

                    // stDokuWiki.AuthManager.DokuAuthManager
                    // save user table
                    if (
                        (typeId == CoCEnum.CoCFmtReq.Members) &&
                        (this._parent._cocDWAuth != null)
                        )
                    {
                        this._parent.DokuWikiAuthSave();
                    }
                }
            }