Пример #1
0
        public PatchAgent()
        {
            InitializeComponent();

            Int32[] Widths = new Int32[(Int32)EField.Max]
            {
                650,
                50
            };

            AgentFields = new System.Windows.Forms.ColumnHeader[(Int32)EField.Max];
            for (Int32 i = 0; i < (Int32)EField.Max; ++i)
            {
                AgentFields[i]       = new System.Windows.Forms.ColumnHeader();
                AgentFields[i].Text  = ((EField)i).ToString();
                AgentFields[i].Width = Widths[i];
            }

            lvUpdateList.Columns.AddRange(AgentFields);
            //lvUpdateList.Location = new System.Drawing.Point(13, 39);
            //lvUpdateList.Size = new System.Drawing.Size(989, 677);
            lvUpdateList.UseCompatibleStateImageBehavior = false;
            lvUpdateList.FullRowSelect      = true;
            lvUpdateList.ListViewItemSorter = new ListViewItemComparer(lvUpdateList.Sorting, 0);

            btnLogout.Enabled = false;
            btnSub.Enabled    = false;
            btnAdd.Enabled    = false;
            btnDel.Enabled    = false;
            btnUpdate.Enabled = false;
            btnReset.Enabled  = false;

            try
            {
                _Option = new COptionJson <SOption>("Option.ini", false);

                tbID.Text = _Option.Data.ID;
                tbPW.Text = _Option.Data.PW;

                _Net = new CAgent(_Option.Data.DataFileName, _Option.Data.DataPath, new CNamePort(_Option.Data.MasterNamePort), Link, LinkFail, UnLink, DataCallback);

                lbFullData.ColumnWidth = Width;
                foreach (var i in _Net.GetData().Files)
                {
                    lbFullData.Items.Add(i.Key);
                }

                SetVersion(_Net.GetData().Version);
                timerNet.Enabled = true;
            }
            catch (Exception Exception_)
            {
                Log(Exception_.ToString());
            }
        }
Пример #2
0
        public GameClientTest()
        {
            InitializeComponent();

            try
            {
                var SetupJson = (JsonDataObject)JsonParser.Parse(File.ReadAllText("Option.ini"));

                _Auto    = SetupJson["Auto"].GetBool();
                ServerNo = SetupJson["ServerNo"].GetInt32();
                var ServerInfo = ((JsonDataObject)(((JsonDataArray)SetupJson["Servers"])[ServerNo]));

                StartNum  = ServerInfo["StartNum"].GetUInt32();
                ClientCnt = ServerInfo["ClientCnt"].GetInt32();
                if (ClientCnt <= 0)
                {
                    throw new Exception("Invalid ClientCnt");
                }

                DataPath = ServerInfo["DataPath"].GetString();
                IP       = ServerInfo["IP"].GetString();
                Port     = ServerInfo["Port"].GetUInt16();

                ID = ServerInfo["ID"].GetString();
                PW = ServerInfo["PW"].GetString();

                TimerNet.Enabled = true;

                if (_Auto)
                {
                    btnLoginUID.Enabled = false;
                }

                btnDisconnect.Enabled = false;

                _Net = new rso.game.CClient(
                    Link, LinkFail, UnLink, Recv, LinkSoft, UnLinkSoft,
                    Check, CheckFail,
                    new SVersion(0, 0));
                if (_Net == null)
                {
                    return;
                }

                _Binder = new CClientBinder(_Net);

                _Clients = new SClient[ClientCnt];

                for (TPeerCnt i = 0; i < ClientCnt; ++i)
                {
                    _Clients[i] = new SClient(i);
                    _Clients[i].Initialize();
                }

                _Binder.AddSendProto <SGameProtoNetCs>((Int32)EProtoNetCs.GameProto);

                _Binder.AddRecvProto((Int32)EProtoNetSc.GameProto, GameProtoNetSc);

                TimerNet.Enabled = true;
                _Graphics        = this.CreateGraphics();
            }
            catch (Exception Exception_)
            {
                _Log(Exception_.ToString());
                return;
            }
        }
Пример #3
0
        public UInt64 Export <TProto>(string SheetName_, string TargetDir_, string[] ColumnNames_) where TProto : SProto, new()
        {
            try
            {
                try
                {
                    _Worksheet = (Worksheet)_Workbook.Worksheets.get_Item(SheetName_);
                }
                catch
                {
                    throw new Exception(string.Format("FileName[{0}] SheetName[{1}] does not exist at FileName[{2}]", _FileName, SheetName_, _FileName));
                }

                object[,] _UsedRangeData = _Worksheet.UsedRange.Value;
                if (_UsedRangeData == null)
                {
                    throw new Exception(string.Format("FileName[{0}] SheetName[{1}] is empty", _FileName, SheetName_));
                }

                var RowCnt = _UsedRangeData.GetLength(0);

                if (RowCnt <= _RowOffset)
                {
                    throw new Exception(string.Format("RowCnt[{0}] <= RowOffset[{0}]", RowCnt.ToString(), _RowOffset.ToString()));
                }

                var ColCnt = _UsedRangeData.GetLength(1);

                // Read Column Names ////////////////////////////////////////
                // 엑셀 컬럼을 순서대로 읽고 Value로 Index를 부여
                var ColumnIndices = new Dictionary <string, Int32>();
                for (Int32 c = 0; c < ColCnt; ++c)
                {
                    string ColumnName = "";

                    if (_UsedRangeData[1 + _RowOffset, c + 1] != null)
                    {
                        ColumnName = _UsedRangeData[1 + _RowOffset, c + 1].ToString();
                    }

                    if (ColumnName.Length == 0)
                    {
                        continue;
                    }

                    if (ColumnIndices.ContainsKey(ColumnName))
                    {
                        throw new Exception(string.Format("Column is duplicated FileName[{0}] SheetName[{1}] ColumnNum[{2}] ColumnName[{3}]", _FileName, SheetName_, c.ToString(), ColumnName));
                    }

                    ColumnIndices.Add(ColumnName, c);
                }


                var ExportExcelIndices = new List <Int32>(); // Export 할 컬럼의 엑셀에서의 인덱스 모음.
                foreach (var i in ColumnNames_)
                {
                    if (!ColumnIndices.ContainsKey(i))
                    {
                        throw new Exception(string.Format("Column can not be found FileName[{0}] SheetName[{1}] ColumnName[{2}]", _FileName, SheetName_, i));
                    }

                    ExportExcelIndices.Add(ColumnIndices[i]);
                }

                var Proto    = new TProto();
                var SetFuncs = new List <TSetFunc>();

                foreach (var i in Proto.StdName().Split(new char[] { ',' }))
                {
                    switch (i)
                    {
                    case "bool":
                        SetFuncs.Add((CStream Stream_, string Data_) =>
                        {
                            try
                            {
                                Stream_.Push(bool.Parse(Data_) ? true : false);
                            }
                            catch
                            {
                                Stream_.Push(Int32.Parse(Data_) != 0 ? true : false);
                            }
                        });
                        break;

                    case "int8":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(SByte.Parse(Data_)); });
                        break;

                    case "uint8":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(Byte.Parse(Data_)); });
                        break;

                    case "int16":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(Int16.Parse(Data_)); });
                        break;

                    case "uint16":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(UInt16.Parse(Data_)); });
                        break;

                    case "int32":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(Int32.Parse(Data_)); });
                        break;

                    case "uint32":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(UInt32.Parse(Data_)); });
                        break;

                    case "int64":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(Int64.Parse(Data_)); });
                        break;

                    case "uint64":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(UInt64.Parse(Data_)); });
                        break;

                    case "float":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(float.Parse(Data_)); });
                        break;

                    case "double":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(double.Parse(Data_)); });
                        break;

                    case "string":
                    case "wstring":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(Data_); });
                        break;

                    case "time_point":
                        SetFuncs.Add((CStream Stream_, string Data_) => { Stream_.Push(new TimePoint(Int64.Parse(Data_))); });
                        break;

                    default:     // enum 으로 간주
                        SetFuncs.Add((CStream Stream_, string Data_) => { _EnumValue.PushToStream(i, Data_, Stream_); });
                        break;
                    }
                }

                if (SetFuncs.Count != ExportExcelIndices.Count)
                {
                    throw new Exception(string.Format("FileName[{0}] SheetName[{1}] Proto MemberCount[{2}] does not match export ColumnCount[{3}]", _FileName, SheetName_, SetFuncs.Count, ExportExcelIndices.Count));
                }

                var DataStream = new CStream();
                DataStream.Push(RowCnt - 1 - _RowOffset);

                for (Int32 r = 1 + _RowOffset; r < RowCnt; ++r)
                {
                    for (Int32 i = 0; i < ExportExcelIndices.Count; ++i)
                    {
                        string CellData = "";

                        if (_UsedRangeData[r + 1, ExportExcelIndices[i] + 1] != null)
                        {
                            CellData = _UsedRangeData[r + 1, ExportExcelIndices[i] + 1].ToString();
                        }

                        try
                        {
                            SetFuncs[i](DataStream, CellData);
                        }
                        catch (Exception Exception_)
                        {
                            throw new Exception(string.Format("Parse Error FileName[{0}] SheetName[{1}] Row[{2}] Column[{3}] Msg[{4}]", _FileName, SheetName_, r.ToString(), ExportExcelIndices[i].ToString(), Exception_.ToString()));
                        }
                    }
                }

                DataStream.SaveFile(Path.Combine(TargetDir_, SheetName_ + "." + _TargetExtension));
                DisposeWorksheet();

                return(DataStream.CheckSum());
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Пример #4
0
        public void ExportEnum(string SheetName_, string ColumnName_, string TargetDir_, string TargetFile_, string EnumFrameFormat_)
        {
            try
            {
                try
                {
                    _Worksheet = (Worksheet)_Workbook.Worksheets.get_Item(SheetName_);
                }
                catch
                {
                    throw new Exception(string.Format("FileName[{0}] SheetName[{1}] does not exist at FileName[{2}]", _FileName, SheetName_, _FileName));
                }

                object[,] _UsedRangeData = _Worksheet.UsedRange.Value;
                if (_UsedRangeData == null)
                {
                    throw new Exception(string.Format("FileName[{0}] SheetName[{1}] is empty", _FileName, SheetName_));
                }

                var RowCnt = _UsedRangeData.GetLength(0);
                var ColCnt = _UsedRangeData.GetLength(1);

                // Read Column Names ////////////////////////////////////////
                // 엑셀 컬럼을 순서대로 읽고 Value로 Index를 부여
                Int32 ColumnIndex = -1;
                for (Int32 c = 0; c < ColCnt; ++c)
                {
                    if (_UsedRangeData[1, c + 1] != null)
                    {
                        if (_UsedRangeData[1, c + 1].ToString() == ColumnName_)
                        {
                            ColumnIndex = c;
                            break;
                        }
                    }
                }

                if (ColumnIndex == -1)
                {
                    throw new Exception(string.Format("Column is not found FileName[{0}] SheetName[{1}] ColumnName[{2}]", _FileName, SheetName_, ColumnName_));
                }

                string Content = "";

                for (Int32 r = 1; r < RowCnt; ++r)
                {
                    string CellData = "";

                    if (_UsedRangeData[r + 1, ColumnIndex + 1] != null)
                    {
                        CellData = _UsedRangeData[r + 1, ColumnIndex + 1].ToString();
                    }

                    try
                    {
                        if (r > 1)
                        {
                            Content += ",\n";
                        }

                        Content += CellData;
                    }
                    catch (Exception Exception_)
                    {
                        throw new Exception(string.Format("Parse Error FileName[{0}] SheetName[{1}] Row[{2}] Column[{3}] Msg[{4}]", _FileName, SheetName_, r.ToString(), ColumnIndex.ToString(), Exception_.ToString()));
                    }
                }

                Directory.CreateDirectory(TargetDir_);
                File.WriteAllText(Path.GetFullPath(Path.Combine(TargetDir_, TargetFile_)), string.Format(EnumFrameFormat_, Content));
                DisposeWorksheet();
            }
            catch
            {
                Dispose();
                throw;
            }
        }