public async Task <ActionResult <Setting> > AddNewSetting(Setting Newsetting)
        {
            var Setting = await _settingService.AddSetting(Newsetting);

            if (Setting == null)
            {
                return(NotFound());
            }

            return(Ok(Setting));
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();

            if (string.IsNullOrEmpty(txtFolderName.Text))
            {
                errorProvider1.SetError(txtFolderName, "Folder name cannot be empty");
                return;
            }

            if (string.IsNullOrEmpty(txtPatterns.Text))
            {
                errorProvider1.SetError(txtPatterns, "Folder patterns cannot be empty");
                return;
            }

            var isEdit     = this.FolderSettingModel != null;
            var originName = isEdit ? this.FolderSettingModel.FolderName : null;

            this.FolderSettingModel = new DbFolderSetting()
            {
                FolderName = txtFolderName.Text.Trim(),
                Patterns   = txtPatterns.Text.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries)
            };

            if (isEdit)
            {
                SettingService.EditSetting(originName, FolderSettingModel);
            }
            else
            {
                SettingService.AddSetting(this.FolderSettingModel);
            }

            this.IsSaved = true;
            this.Close();
        }
Пример #3
0
        private void getJsonByObName(string fileName, string Obfilename, bool teamB = false)
        {
            string jsonFileName = lolReplayPath + "\\db\\" + fileName + ".json";

            Debug.WriteLine(jsonFileName);

            /*
             * TODO :: 若json不存在,则重新从网络抓取。 参考 Lol\LolService.cs  GetDataById() 函数。需要COOKIE。
             *      预览方式:http://lol.qq.com 登录QQ ,然后 直接访问 http://api.pallas.tgp.qq.com/core/tcall?callback=getGameDetailCallback&dtag=profile&p=%5B%5B4%2C%7B%22area_id%22%3A%221%22%2C%22game_id%22%3A%221917183753%22%7D%5D%5D&t=1458284672949
             *      参数说明:原参数为:tcall?callback=getGameDetailCallback&dtag=profile&p=[[4,{"area_id":"7","game_id":"897455227"}]]&t=1458284672949 ,其中p参数为重点,area_id为大区ID,即OB文件1_1111111.ob中的_线前部分,后面是game_id。
             *      可以根据现有的OB文件,更改 http://api.pallas.tgp.qq.com/core/tcall?callback=getGameDetailCallback&dtag=profile&p=%5B%5B4%2C%7B%22area_id%22%3A%221%22%2C%22game_id%22%3A%221917183753%22%7D%5D%5D&t=1458284672949 对应的area_id、game_id的参数,浏览器打开访问即可。(这里p参数为URL编码后的形式)
             *      若使用LolService.cs,则参考LolService.cs的 GetJsonResponse函数中 request.Headers.Add(HttpRequestHeader.Cookie, settingService.GetValueByName("lolCookie")); 这部分代码。
             */

            if (!File.Exists(jsonFileName))
            {
                /*
                 *  TO_DO: (v) 加入try-catch,不然cookie過期或是沒cookie之類的程式就crash了。還要加個UI讓user log in不然沒cookie,該class就無法作用。
                 *  最後是將這段code移到正確位置,暫時放在這裡是因為比較好測試,只要按下撥放鍵,就能在output看到輸出。要把output出來的資訊正確接到view上。
                 */
                MyRepository <Battle>       battleRepository       = new MyRepository <Battle>();
                MyRepository <Record>       recordRepository       = new MyRepository <Record>();
                MyRepository <ChampionInfo> championInfoRepository = new MyRepository <ChampionInfo>();
                MyRepository <SnapShot>     snapShotRepository     = new MyRepository <SnapShot>();
                MyRepository <Setting>      settingRepository      = new MyRepository <Setting>();

                SettingService settingService = new SettingService(settingRepository);

                Setting setting = new Setting();
                setting.Name  = "lolCookie";
                setting.Value = "pgv_pvi=2140056576; pgv_si=s8457872384; pgv_pvid=899159065; pgv_info=pgvReferrer=&ssid=s157361622; ptisp=cn; ptui_loginuin=00886929001668; pt2gguin=o2144651473; uin=o2144651473; skey=@Tw9l7VgET; RK=+mW3u7R2Wy; ptcz=60f35fa5e7def4af02c5e9b9838713e31fbdaf713af04eec539e7ab9d9d4c164; IED_LOG_INFO=uin*2144651473|nick*a514514772%20|time*1460039631";

                /*
                 * "pgv_pvi=2501693440; pgv_si=s6959702016; pgv_pvid=932930068; pgv_info=pgvReferrer=&ssid=s8234311070; ptisp=cn; ptui_loginuin=00886929001668; pt2gguin=o2144651473; uin=o2144651473; skey=@jDNBIyes1; RK=+mW3u7R2Wy; ptcz=fe9dc9d80a764c7517a31e00f8875751328c7c88449a92898b5f58688efd01bd; IED_LOG_INFO=uin*2144651473|nick*a514514772%20|time*1460035654"
                 * "pgv_pvi=2140056576; pgv_si=s8457872384; pgv_pvid=899159065; pgv_info=pgvReferrer=&ssid=s157361622; ptisp=cn; ptui_loginuin=00886929001668; pt2gguin=o2144651473; uin=o2144651473; skey=@Tw9l7VgET; RK=+mW3u7R2Wy; ptcz=60f35fa5e7def4af02c5e9b9838713e31fbdaf713af04eec539e7ab9d9d4c164; IED_LOG_INFO=uin*2144651473|nick*a514514772%20|time*1460039631"
                 */
                string[] ID     = Obfilename.Split('_');
                int      areaID = Int32.Parse(ID[0]);
                int      gameID = Int32.Parse(ID[1]);
                Battle   test;
                try
                {
                    settingService.AddSetting(setting);
                    LolDataSpider spider = new LolDataSpider(battleRepository, recordRepository, championInfoRepository, snapShotRepository, settingService);
                    test = spider.GetDataById(gameID, areaID, jsonFileName);

                    /*Debug.WriteLine(test.GameId);
                     * Debug.WriteLine(test.Duration);
                     * Debug.WriteLine(test.BattleType);*/
                }
                catch
                {
                    Debug.WriteLine("There is something wrong, please check again.");

                    /*
                     *  TO_DO : 輸出一些簡單的說明,協助使用者登入QQ後取得cookie。
                     *
                     */
                    string value       = "cookie~~~";
                    string explanation = "In order to acquite game information, we need your cookie after log in QQ.\nPlease follow these steps : \n1. open your browser and go to the website : http://lol.qq.com/comm-htdocs/pay/new_index.htm?t=lol or any website which you can log in QQ";
                    if (InputBox("type in cookie", /*explanation*/ "test", ref value) == DialogResult.OK)
                    {
                        Debug.WriteLine(value);
                    }
                }
            }
            int anotherCounter = 0;

            if (teamB)
            {
                anotherCounter = 5;
            }
            if (File.Exists(jsonFileName))
            {
                using (StreamReader r = new StreamReader(jsonFileName))
                {
                    string json = r.ReadToEnd();
                    Debug.Write(json);
                    List <Record> perTeam = JsonConvert.DeserializeObject <List <Record> >(json);

                    lvwBooks.AddRow("", "", "", "", ""); // empty

                    // Add icons to the sub-items.
                    for (int i = tmp_cnt; i < lvwBooks.Items.Count; i++)
                    {
                        // Set the main item's image index.
                        string ChampionName = championtable.getNameFromID(perTeam[0 + anotherCounter].ChampionId) + ".png";
                        lvwBooks.Items[i].ImageIndex = SearchImageFromList(ChampionName);
                        lvwBooks.Items[i].Group      = lvwBooks.Groups[tmp_cnt / 2];

                        for (int c = 1; c < lvwBooks.Columns.Count; c++)
                        {
                            ChampionName = championtable.getNameFromID(perTeam[c + anotherCounter].ChampionId) + ".png";
                            lvwBooks.AddIconToSubitem(i, c, SearchImageFromList(ChampionName));
                        }
                    }
                    tmp_cnt++;
                }
            }
        }