Ejemplo n.º 1
0
        public bool Process()
        {
            Debug.WriteLine("start LoadMissionResultEntry");
            WorksheetEntry sheet = GetWorksheet("Mission");

            if (sheet == null)
            {
                _finishCallback(false);
                return(false);
            }

            var list = Query(sheet);

            lock (((ICollection)_missionResultLog).SyncRoot)
            {
                foreach (var row in list)
                {
                    var it = new LogData.MissionResultInfo(row);
                    it.MemberID = _memberId;
                    it.Number   = _missionResultLog.Count + 1;
                    _missionResultLog.Add(it);
                }
            }
            _finishCallback(true);
            return(true);
        }
Ejemplo n.º 2
0
 public AddMissionResultEntry(SpreadSheetWrapper wrapper, LogData.MissionResultInfo info
                              , LogStore.LogStore.LogUploadCompleted finishCallback)
 {
     _wrapper        = wrapper;
     _info           = info;
     _memberId       = info.MemberID;
     _finishCallback = finishCallback;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 遠征結果の追加
        /// </summary>
        /// <param name="info">遠征結果</param>
        public void AddMissionResult(LogData.MissionResultInfo info)
        {
            if (info == null)
            {
                Debug.WriteLine("invalid MissionResult(null)");
                return;
            }

            lock (((ICollection)_missionLog).SyncRoot)
            {
                info.Number = _missionLog.Count + 1;
                _missionLog.Add(info);
            }
            _logStore.AddMissionResult(info, (bool bSucceeded) =>
            {
                if (!(Properties.Settings.Default.SuppressSuceedWriteLog && bSucceeded))
                {
                    UpdateStatusMessage("遠征結果の書き込みに{0}しました", bSucceeded ? "成功" : "失敗");
                }
            });
            _vlvMissionResult.UpdateList();
        }
Ejemplo n.º 4
0
        public override bool LoadMissionResult(string MemberID, IList <LogData.MissionResultInfo> missionLog,
                                               LogDownloadCompleted finishCallback)
        {
            string file = GetFilePath(MemberID, mission_filename);

            if (file == null)
            {
                finishCallback(false);
                return(false);
            }

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

            using (TextFieldParser parser = new TextFieldParser(file,
                                                                System.Text.Encoding.UTF8))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");

                lock (((ICollection)missionLog).SyncRoot)
                {
                    while (!parser.EndOfData)
                    {
                        string[] row  = parser.ReadFields();
                        var      info = new LogData.MissionResultInfo(row);
                        info.Number   = missionLog.Count + 1;
                        info.MemberID = MemberID;
                        missionLog.Add(info);
                    }
                }
            }
            finishCallback(true);
            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 遠征結果のログ情報を生成
        /// </summary>
        /// <param name="JSON"></param>
        /// <param name="shipList"></param>
        /// <returns></returns>
        public LogData.MissionResultInfo CreateResult(string JSON, MemberData.Ship shipList, MemberData.Basic basicData)
        {
//            var json = DynamicJson.Parse(JSON);
            var json = JsonConvert.DeserializeObject <KCB.api_req_mission.Result>(JSON);

            if ((int)json.api_result != 1)
            {
                return(null);
            }

            var result = json.api_data;

            if (result == null)
            {
                return(null);
            }

            LogData.MissionResultInfo res = new LogData.MissionResultInfo();
            res.MemberID  = basicData.MemberID;
            res.AreaName  = result.api_maparea_name;
            res.QuestName = result.api_quest_name;
            res.Date      = DateTime.Now;
            res.Succeeded = (int)result.api_clear_result;

            //失敗したとき、api_get_material = -1で帰ってくる
//            Type typMaterial = result.api_get_material.GetType();
//            if (typMaterial != typeof(Codeplex.Data.DynamicJson))
//            if(result.api_get_material is Codeplex.Data.DynamicJson)
//                res.Material = new LogData.Material((double[])result.api_get_material);

            if (result.api_get_material is Newtonsoft.Json.Linq.JArray)
            {
                res.Material = new LogData.Material((Newtonsoft.Json.Linq.JArray)result.api_get_material);
            }
            else
            {
                res.Material = new LogData.Material();
            }

            if (result.api_useitem_flag[0] != 0)
            {
                res.Item.Add(
                    string.Format("{0}x{1}", itemName((int)result.api_useitem_flag[0]
                                                      , result.api_get_item1.api_useitem_name),
                                  (int)result.api_get_item1.api_useitem_count)
                    );
            }

            if (result.api_useitem_flag[1] != 0)
            {
                res.Item.Add(
                    string.Format("{0}x{1}", itemName((int)result.api_useitem_flag[1]
                                                      , result.api_get_item2.api_useitem_name),
                                  (int)result.api_get_item2.api_useitem_count)
                    );
            }

//            double[] ships = (double[]) result.api_ship_id;
//            for (int n = 1; n < ships.Count(); n++)
            for (int n = 1; n < result.api_ship_id.Count(); n++)
            {
                var it = shipList.GetShip(result.api_ship_id[n]);
                res.Member.Add(string.Format("{0}({1}Lv{2})", it.ShipName, it.ShipType, it.Level));
                Debug.WriteLine("Member:" + res.Member.Last());
            }

            Debug.WriteLine("result:" + res.ToString());

            return(res);
        }
Ejemplo n.º 6
0
        public override bool LoadMissionResult(string MemberID, IList<LogData.MissionResultInfo> missionLog,
            LogDownloadCompleted finishCallback)
        {
            string file = GetFilePath(MemberID, mission_filename);
            if (file == null)
            {
                finishCallback(false);
                return false;
            }

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

            using (TextFieldParser parser = new TextFieldParser(file,
                System.Text.Encoding.UTF8))
            {
                parser.TextFieldType = FieldType.Delimited;
                parser.SetDelimiters(",");

                lock (((ICollection)missionLog).SyncRoot)
                {
                    while (!parser.EndOfData)
                    {
                        string[] row = parser.ReadFields();
                        var info = new LogData.MissionResultInfo(row);
                        info.Number = missionLog.Count + 1;
                        info.MemberID = MemberID;
                        missionLog.Add(info);
                    }
                }
            }
            finishCallback(true);
            return true;
        }
Ejemplo n.º 7
0
 public virtual bool AddMissionResult(LogData.MissionResultInfo info, LogUploadCompleted finishCallback)
 {
     finishCallback(true); return(true);
 }
Ejemplo n.º 8
0
 public override bool AddMissionResult(LogData.MissionResultInfo info, LogUploadCompleted finishCallback)
 {
     _jobq.Add(new GSpread.Job.CreateIfNotExistSheet(info.MemberID, _wrapper));
     _jobq.Add(new GSpread.Job.AddMissionResultEntry(_wrapper, info, finishCallback));
     return(true);
 }
Ejemplo n.º 9
0
        /// <summary>
        /// 遠征結果のログ情報を生成
        /// </summary>
        /// <param name="JSON"></param>
        /// <param name="shipList"></param>
        /// <returns></returns>
        public LogData.MissionResultInfo CreateResult(string JSON, MemberData.Ship shipList,MemberData.Basic basicData)
        {
//            var json = DynamicJson.Parse(JSON);
            var json = JsonConvert.DeserializeObject<KCB.api_req_mission.Result>(JSON);
            if ((int)json.api_result != 1)
                return null;

            var result = json.api_data;
            if (result == null)
                return null;

            LogData.MissionResultInfo res = new LogData.MissionResultInfo();
            res.MemberID = basicData.MemberID;
            res.AreaName = result.api_maparea_name;
            res.QuestName = result.api_quest_name;
            res.Date = DateTime.Now;
            res.Succeeded = (int)result.api_clear_result;

            //失敗したとき、api_get_material = -1で帰ってくる
//            Type typMaterial = result.api_get_material.GetType();
//            if (typMaterial != typeof(Codeplex.Data.DynamicJson))
//            if(result.api_get_material is Codeplex.Data.DynamicJson)
//                res.Material = new LogData.Material((double[])result.api_get_material);

            if (result.api_get_material is Newtonsoft.Json.Linq.JArray)
                res.Material = new LogData.Material((Newtonsoft.Json.Linq.JArray)result.api_get_material);
            else
                res.Material = new LogData.Material();

            if (result.api_useitem_flag[0] != 0)
            {
                res.Item.Add(
                    string.Format("{0}x{1}", itemName((int)result.api_useitem_flag[0]
                       , result.api_get_item1.api_useitem_name),
                    (int)result.api_get_item1.api_useitem_count)
                );
            }

            if (result.api_useitem_flag[1] != 0)
            {
                res.Item.Add(
                    string.Format("{0}x{1}", itemName((int)result.api_useitem_flag[1]
                     , result.api_get_item2.api_useitem_name),
                    (int)result.api_get_item2.api_useitem_count)
                );
            }

//            double[] ships = (double[]) result.api_ship_id;
//            for (int n = 1; n < ships.Count(); n++)
            for (int n = 1; n < result.api_ship_id.Count(); n++)
            {
                var it = shipList.GetShip(result.api_ship_id[n]);
                res.Member.Add(string.Format("{0}({1}Lv{2})", it.ShipName, it.ShipType, it.Level));
                Debug.WriteLine("Member:" + res.Member.Last());
            }

            Debug.WriteLine("result:" + res.ToString());

            return res;


        }