Exemple #1
0
        private void TranslateZoneList()
        {
            foreach (var zone in this.ZoneList)
            {
                var place = (
                    from x in XIVDB.Instance.PlacenameList.AsParallel()
                    where
                    string.Equals(x.NameEn, zone.Name, StringComparison.InvariantCultureIgnoreCase)
                    select
                    x).FirstOrDefault();

                if (place != null)
                {
                    zone.Name   = place.Name;
                    zone.IDonDB = place.ID;
                }
                else
                {
                    var area = (
                        from x in XIVDB.Instance.AreaList.AsParallel()
                        where
                        string.Equals(x.NameEn, zone.Name, StringComparison.InvariantCultureIgnoreCase)
                        select
                        x).FirstOrDefault();

                    if (area != null)
                    {
                        zone.Name   = area.Name;
                        zone.IDonDB = area.ID;
                    }
                }
            }

            AppLogger.Trace($"zone list translated.");
        }
        private void _WebSocket_OnMessage(object sender, MessageEventArgs e)
        {
            _lastReceivedTime = DateTime.UtcNow;

            if (e.IsBinary)
            {
                string data = GZipDecompresser.Decompress(e.RawData);

                var pingMessage = JsonConvert.DeserializeObject <PingMessageV1>(data);
                if (pingMessage.IsPing())
                {
                    AppLogger.Trace($"WebSocket received data, ping={pingMessage.ts}");
                    string pongData = $"{{\"op\":\"pong\", \"ts\":{pingMessage.ts}}}";
                    _WebSocket.Send(pongData);
                    AppLogger.Trace($"WebSocket repied data, pong={pingMessage.ts}");
                }
                else
                {
                    dynamic json = JToken.Parse(data);
                    string  op   = json.op;
                    if (String.Equals(op, "auth"))
                    {
                        var response = JsonConvert.DeserializeObject <WebSocketV1AuthResponse>(data);

                        OnAuthenticationReceived?.Invoke(response);
                    }
                    else
                    {
                        var response = JsonConvert.DeserializeObject <DataResponseType>(data);

                        OnDataReceived?.Invoke(response);
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// XIVDBのスキルリストとFFXIVプラグインのスキルリストをマージする
        /// </summary>
        private void MergeSkillList()
        {
            if (!this.isMergedSkillList)
            {
                if (this.skillList.Any() &&
                    XIVDB.Instance.ActionList.Any())
                {
                    foreach (var action in XIVDB.Instance.ActionList)
                    {
                        var skill = new Skill()
                        {
                            ID   = action.Key,
                            Name = action.Value.Name
                        };

                        this.skillList[action.Key] = skill;
                    }

                    this.isMergedSkillList = true;
                    AppLogger.Trace("XIVDB action list merged.");
                }
            }

            // FFXIVプラグインにスキルリストを反映する
            this.LoadSkillToFFXIVPlugin();
        }
Exemple #4
0
        private void LoadZoneList()
        {
            if (this.zoneList.Any())
            {
                return;
            }

            if (this.plugin == null)
            {
                return;
            }

            var newList = new List <Zone>();

            var asm = this.plugin.GetType().Assembly;

            var language      = "EN";
            var resourcesName = $"FFXIV_ACT_Plugin.Resources.ZoneList_{language.ToUpper()}.txt";

            using (var st = asm.GetManifestResourceStream(resourcesName))
            {
                if (st == null)
                {
                    return;
                }

                using (var sr = new StreamReader(st))
                {
                    while (!sr.EndOfStream)
                    {
                        var line = sr.ReadLine();
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var values = line.Split('|');
                            if (values.Length >= 2)
                            {
                                var zone = new Zone()
                                {
                                    ID   = int.Parse(values[0]),
                                    Name = values[1].Trim()
                                };

                                newList.Add(zone);
                            }
                        }
                    }
                }

                AppLogger.Trace("zone list loaded.");

                // ユーザで任意に追加したゾーンを読み込む
                this.LoadZoneListAdded(newList);

                // 新しいゾーンリストをセットする
                this.zoneList = newList;

                // ゾーンリストを翻訳する
                this.TranslateZoneList();
            }
        }
Exemple #5
0
        private void LoadZoneListAdded(
            List <Zone> baseZoneList)
        {
            try
            {
                var dir  = XIVDB.Instance.ResourcesDirectory;
                var file = Path.Combine(dir, "Zones.csv");

                if (!File.Exists(file))
                {
                    return;
                }

                var isLoaded = false;
                using (var parser = new TextFieldParser(file, new UTF8Encoding(false))
                {
                    TextFieldType = FieldType.Delimited,
                    Delimiters = new[] { "," },
                    HasFieldsEnclosedInQuotes = true,
                    TrimWhiteSpace = true,
                    CommentTokens = new[] { "#" },
                })
                {
                    while (!parser.EndOfData)
                    {
                        var values = parser.ReadFields();

                        if (values.Length >= 2)
                        {
                            var newZone = new Zone()
                            {
                                ID            = int.Parse(values[0]),
                                Name          = values[1].Trim(),
                                IsAddedByUser = true,
                            };

                            if (!baseZoneList.Any(x =>
                                                  x.ID == newZone.ID))
                            {
                                baseZoneList.Add(newZone);
                            }

                            isLoaded = true;
                        }
                    }
                }

                if (isLoaded)
                {
                    AppLogger.Trace($"custom zone list loaded. {file}");
                }
            }
            catch (Exception ex)
            {
                AppLogger.Trace(ex, "error on load additional zone list.");
            }
        }
        /// <summary>
        /// Return a new instance of SmtpClient initializate with the values for the company smtpClient specifies in smtpClientType
        /// </summary>
        /// <param name="smtpClientType">smtpClient company type</param>
        /// <returns></returns>
        public static SmtpClientType GetSmtpClientType(string smtpClientType)
        {
            switch (smtpClientType.ToLower())
            {
            case "gmail":
                return(SmtpClientType.Gmail);

            default:
                AppLogger.Trace(String.Format("stmpClientType '{0}' not supported", smtpClientType));
                return(SmtpClientType.Unknown);
            }
        }
Exemple #7
0
        private void LoadSkillList()
        {
            if (this.skillList.Any())
            {
                return;
            }

            if (this.plugin == null)
            {
                return;
            }

            var asm = this.plugin.GetType().Assembly;

            var language      = this.FFXIVLocale.ToString().Replace("JA", "JP");
            var resourcesName = $"FFXIV_ACT_Plugin.Resources.SkillList_{language.ToUpper()}.txt";

            using (var st = asm.GetManifestResourceStream(resourcesName))
            {
                if (st == null)
                {
                    return;
                }

                var newList = new Dictionary <int, Skill>();

                using (var sr = new StreamReader(st))
                {
                    while (!sr.EndOfStream)
                    {
                        var line = sr.ReadLine();
                        if (!string.IsNullOrWhiteSpace(line))
                        {
                            var values = line.Split('|');
                            if (values.Length >= 2)
                            {
                                var skill = new Skill()
                                {
                                    ID   = int.Parse(values[0], NumberStyles.HexNumber),
                                    Name = values[1].Trim()
                                };

                                newList.Add(skill.ID, skill);
                            }
                        }
                    }
                }

                this.skillList = newList;
                AppLogger.Trace("skill list loaded.");
            }
        }
Exemple #8
0
        /// <summary>
        /// XIVDBのBuff(Status)リストとFFXIVプラグインのBuffリストをマージする
        /// </summary>
        private void MergeBuffList()
        {
            if (this.isMergedBuffList)
            {
                return;
            }

            if (!XIVDB.Instance.BuffList.Any())
            {
                return;
            }

            if (this.plugin == null)
            {
                return;
            }

            var t   = (this.plugin as object).GetType().Module.Assembly.GetType("FFXIV_ACT_Plugin.Resources.BuffList");
            var obj = t.GetField(
                "_instance",
                BindingFlags.NonPublic | BindingFlags.Static)
                      .GetValue(null);

            var list = obj.GetType().GetField(
                "_BuffList",
                BindingFlags.NonPublic | BindingFlags.Instance)
                       .GetValue(obj);

            var pluginList = list as SortedDictionary <int, string>;

            foreach (var entry in XIVDB.Instance.BuffList)
            {
                if (!pluginList.ContainsKey(entry.Key))
                {
                    pluginList[entry.Key] = entry.Value.Name;
                    Debug.WriteLine(entry.ToString());
                }
            }

            if (XIVDB.Instance.BuffList.Any())
            {
                AppLogger.Trace("XIVDB Status list -> FFXIV Plugin");
            }

            this.isMergedBuffList = true;
        }
Exemple #9
0
        private void AttachScanMemory()
        {
            if (this.plugin == null)
            {
                return;
            }

            FieldInfo fi;

            if (this.pluginMemory == null)
            {
                fi = this.plugin?.GetType().GetField(
                    "_Memory",
                    BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                this.pluginMemory = fi?.GetValue(this.plugin);
            }

            if (this.pluginMemory == null)
            {
                return;
            }

            if (this.pluginConfig == null)
            {
                fi = this?.pluginMemory?.GetType().GetField(
                    "_config",
                    BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                this.pluginConfig = fi?.GetValue(this.pluginMemory);
            }

            if (this.pluginConfig == null)
            {
                return;
            }

            if (this.pluginScancombat == null)
            {
                fi = this.pluginConfig?.GetType().GetField(
                    "ScanCombatants",
                    BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
                this.pluginScancombat = fi?.GetValue(this.pluginConfig);

                AppLogger.Trace("attached ffxiv plugin ScanCombatants.");
            }
        }
        private void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            double elapsedSecond = (DateTime.UtcNow - _lastReceivedTime).TotalSeconds;

            AppLogger.Trace($"WebSocket received data {elapsedSecond.ToString("0.00")} sec ago");

            if (elapsedSecond > RECONNECT_WAIT_SECOND && elapsedSecond <= RENEW_WAIT_SECOND)
            {
                AppLogger.Info("WebSocket reconnecting...");
                _WebSocket.Close();
                _WebSocket.Connect();
            }
            else if (elapsedSecond > RENEW_WAIT_SECOND)
            {
                AppLogger.Info("WebSocket re-initialize...");
                Disconnect();
                UninitializeWebSocket();
                InitializeWebSocket();
                Connect();
            }
        }
Exemple #11
0
        private void LoadSkillToFFXIVPlugin()
        {
            if (this.isLoadedSkillToFFXIV)
            {
                return;
            }

            if (this.plugin == null)
            {
                return;
            }

            var t   = (this.plugin as object).GetType().Module.Assembly.GetType("FFXIV_ACT_Plugin.Resources.SkillList");
            var obj = t.GetField(
                "_instance",
                BindingFlags.NonPublic | BindingFlags.Static)
                      .GetValue(null);

            var list = obj.GetType().GetField(
                "_SkillList",
                BindingFlags.NonPublic | BindingFlags.Instance)
                       .GetValue(obj);

            var pluginSkillList = list as SortedDictionary <int, string>;

            foreach (var entry in XIVDB.Instance.ActionList)
            {
                if (!pluginSkillList.ContainsKey(entry.Key))
                {
                    pluginSkillList[entry.Key] = entry.Value.Name;
                }
            }

            if (XIVDB.Instance.ActionList.Any())
            {
                this.isLoadedSkillToFFXIV = true;
                AppLogger.Trace("XIVDB action list -> FFXIV Plugin");
            }
        }
Exemple #12
0
        private void AttachPlugin()
        {
            if (this.plugin != null ||
                ActGlobals.oFormActMain == null)
            {
                return;
            }

            var ffxivPlugin = (
                from x in ActGlobals.oFormActMain.ActPlugins
                where
                x.pluginFile.Name.ToUpper().Contains("FFXIV_ACT_Plugin".ToUpper()) &&
                x.lblPluginStatus.Text.ToUpper().Contains("FFXIV Plugin Started.".ToUpper())
                select
                x.pluginObj).FirstOrDefault();

            if (ffxivPlugin != null)
            {
                this.plugin = ffxivPlugin;
                AppLogger.Trace("attached ffxiv plugin.");
            }
        }
Exemple #13
0
 public IActionResult Index(FileUpload File)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (File != null && File.File != null)
             {
                 FileProcessor processor = new FileProcessor();
                 Tuple <bool, List <FileDiagnostics> > result = processor.ProcessFile(File.File.OpenReadStream(), File.File.FileName);
                 if (result != null)
                 {
                     if (result.Item1)
                     {
                         ViewData["Uploaded"] = result.Item1;
                     }
                     else
                     {
                         foreach (FileDiagnostics fd in result.Item2)
                         {
                             AppLogger.Trace(fd.Message + "- Row.No:" + fd.RowNo);
                         }
                         return(BadRequest(result.Item2));
                     }
                 }
                 else
                 {
                     return(Error());
                 }
             }
         }
     }
     catch (Exception ex)
     {
         AppLogger.Log(ex);
     }
     return(View());
 }
Exemple #14
0
        private void _WebSocket_OnMessage(object sender, MessageEventArgs e)
        {
            _lastReceivedTime = DateTime.UtcNow;

            if (e.IsBinary)
            {
                string data = GZipDecompresser.Decompress(e.RawData);

                var pingMessage = JsonConvert.DeserializeObject <PingMessage>(data);
                if (pingMessage != null && pingMessage.ping != 0)
                {
                    AppLogger.Trace($"WebSocekt received data, ping={pingMessage.ping}");
                    string pongData = $"{{\"pong\":{pingMessage.ping}}}";
                    _WebSocket.Send(pongData);
                    AppLogger.Trace($"WebSocket replied data, pong={pingMessage.ping}");
                }
                else
                {
                    var response = JsonConvert.DeserializeObject <DataResponseType>(data);

                    OnResponseReceived?.Invoke(response);
                }
            }
        }
Exemple #15
0
        /// <summary>
        /// Constructor - read in the configuration file
        /// </summary>
        public Startup()
        {
            logger.Trace("Initializing Startup");

            logger.Trace("Loading config.json and env. variables");
            // Read in the configuration file
            var config = new Configuration()
                         .AddJsonFile("config.json")
                         .AddEnvironmentVariables();

            // WebConfiguration is a single instance version of the config.json
            // file.  This sets it up.
            logger.Trace("Initializing WebConfiguration");
            WebConfiguration.Instance.SetConfiguration(config);
        }
Exemple #16
0
 public IActionResult Index()
 {
     logger.Trace("GET Index()");
     return(View());
 }
Exemple #17
0
        public IActionResult Index()
        {
            logger.Trace("{0} {1}", Request.Method, Request.Path.Value);

            return(View());
        }