private void GNBListItem_MouseUp(object sender, RoutedEventArgs e) { ListViewItem listViewItem = sender as ListViewItem; if (listViewItem.IsSelected) { GNBPageInfo item = listViewItem.DataContext as GNBPageInfo; } }
private void GNBListViewItem_MouseDoubleClick(object sender, RoutedEventArgs e) { GNBPageInfo item = ((ListViewItem)sender).DataContext as GNBPageInfo; GNBEditWindow gnbEditWindow = new GNBEditWindow(item); gnbEditWindow.Owner = Application.Current.MainWindow; gnbEditWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; gnbEditWindow.ShowDialog(); }
private void GNBChangedStatusBar() { GNBPageInfo item = GNBPageInfoList_ListView.SelectedItem as GNBPageInfo; string status = string.Empty; if (item != null) { status = item.Name + " | " + item.Url; } StatusBarItemChange(status); }
public async Task <int> GnbCheck(ObservableCollection <GNBPageInfo> gnbPageInfoList) { int errorCount = 0; foreach (GNBPageInfo item in gnbPageInfoList) { if (item.IsChecked) { statusCode = -1; GNBPageInfo tmp = new GNBPageInfo(); tmp = item; try { await GnbCheck(tmp); } catch (Exception e) { status = false; errorCount++; item.HasGNB = null; exceptionName = e.GetType().Name + " : \r\n" + e.Message; } item.Status = status; if (statusCode == -1) { item.StatusReason = exceptionName; //item.Code = null; item.HasGNB = null; item.IsPCHub = null; item.IsMyBanner = null; item.IsCheckedA2S = null; } else { item.StatusReason = statusCode.ToString(); } } } return(errorCount); }
private void GNB_GameCode_Item_TextBlock_TargetUpdated(object sender, DataTransferEventArgs e) { TextBlock textBlock = sender as TextBlock; GNBPageInfo gnb = textBlock.DataContext as GNBPageInfo; gnb.IsChanged = true; if (textBlock.Text == string.Empty) { textBlock.ToolTip = textBlock.Tag + " > 비어있음"; textBlock.Tag = "비어있음"; } else { textBlock.ToolTip = textBlock.Tag + " > " + textBlock.Text; textBlock.Tag = textBlock.Text; } }
private void GNB_ListViewItem_CheckBox_Unchecked(object sender, RoutedEventArgs e) { CheckBox ckb = sender as CheckBox; GNBPageInfo item = ckb.DataContext as GNBPageInfo; }
public bool ImportToXLS(ObservableCollection <GNBPageInfo> gnbPageInfoList) { bool isSucceed = false; #region Using OleDB ObservableCollection <GNBPageInfo> tmpList = new ObservableCollection <GNBPageInfo>(); string Excel03ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'"; string Excel07ConString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'"; string fileName = string.Empty; string path = string.Empty; string fileExtension = string.Empty; string fileContents = string.Empty; string sheetName = string.Empty; System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Title = "XSL로 가져오기"; dialog.Filter = "XLS, XLSX (*.xls, *.xlsx) | *.xls;*.xlsx; | 모든 파일 (*.*) | *.*"; try { System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { fileName = dialog.SafeFileName; path = dialog.FileName; fileExtension = Path.GetExtension(path); //switch (fileExtension) //{ // case ".xls": //Excel 97-03 // { // fileContents = string.Format(Excel07ConString, path, false); // break; // } // case ".xlsx": //Excel 07 // { // fileContents = string.Format(Excel07ConString, path, false); // break; // } //} if (Environment.Is64BitOperatingSystem == true) { fileContents = string.Format(Excel07ConString, path, false); } else { fileContents = string.Format(Excel03ConString, path, false); } using (OleDbConnection con = new OleDbConnection(fileContents)) { using (OleDbCommand cmd = new OleDbCommand()) { cmd.Connection = con; con.Open(); DataTable dtExcelSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); sheetName = dtExcelSchema.Rows[0]["TABLE_NAME"].ToString(); con.Close(); } } using (OleDbConnection con = new OleDbConnection(fileContents)) { using (OleDbCommand cmd = new OleDbCommand()) { using (OleDbDataAdapter oda = new OleDbDataAdapter()) { DataTable dt = new DataTable(); cmd.CommandText = "SELECT * From [" + sheetName + "]"; cmd.Connection = con; con.Open(); oda.SelectCommand = cmd; oda.Fill(dt); con.Close(); int columnCount = dt.Columns.Count; foreach (DataRow row in dt.Rows) { GNBPageInfo tmp = new GNBPageInfo(); for (int i = 0; i < columnCount; i++) { switch (i) { case (1): { switch (row.ItemArray[1].ToString()) { case ("공통 페이지"): { tmp.Category = Category.Common; break; } case ("온라인 게임"): { tmp.Category = Category.PCOnline; break; } case ("모바일 게임"): { tmp.Category = Category.Mobile; break; } } break; } case (2): { tmp.Name = row.ItemArray[2].ToString(); break; } case (3): { tmp.Url = row.ItemArray[3].ToString(); break; } case (4): { tmp.Code = row.ItemArray[4].ToString(); break; } case (5): { tmp.HasGNB = row.ItemArray[5].ToString() == "" ? (bool?)null : Convert.ToBoolean(row.ItemArray[5].ToString()); break; } case (6): { tmp.IsPCHub = row.ItemArray[6].ToString() == "" ? (bool?)null : Convert.ToBoolean(row.ItemArray[6].ToString()); break; } case (7): { tmp.IsMyBanner = row.ItemArray[7].ToString() == "" ? (bool?)null : Convert.ToBoolean(row.ItemArray[7].ToString()); break; } case (8): { tmp.IsCheckedA2S = row.ItemArray[8].ToString() == "" ? (bool?)null : Convert.ToBoolean(row.ItemArray[8].ToString()); break; } } } tmpList.Add(tmp); } gnbPageInfoList.Clear(); foreach (GNBPageInfo item in tmpList) { gnbPageInfoList.Add(item); } } } } } } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } #endregion #region Using Excel //GNBPageInfo tmp = new GNBPageInfo(); //string fileName = "GNBInfoList" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + @".xls"; //string path = Directory.GetCurrentDirectory() + @"\" + fileName; //Excel.Application excelApp = null; //Excel.Workbook workBook = null; //Excel.Worksheet workSheet = null; //Excel.Range range = null; //int rCnt = 0; // 열 갯수 //int cCnt = 0; // 행 갯수 //try //{ // excelApp = new Excel.Application(); // workBook = excelApp.Workbooks.Open(path, 0, true, 5, Missing.Value, Missing.Value, false, Missing.Value, Missing.Value, true, false, Missing.Value, false, false, false); // workSheet = (Excel.Worksheet)workBook.Worksheets.get_Item(1); // range = workSheet.UsedRange; // for (rCnt = 2; rCnt <= range.Rows.Count; rCnt++) // { // for (cCnt = 1; cCnt <= range.Columns.Count; cCnt++) // { // string value = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2; ; // switch (cCnt) // { // case (2): // { // switch ((string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2) // { // case ("공통 페이지"): // { // tmp.Category = Category.Common; // break; // } // case ("온라인 게임"): // { // tmp.Category = Category.PCOnline; // break; // } // case ("모바일 게임"): // { // tmp.Category = Category.Mobile; // break; // } // case (""): // { // tmp.Category = Category.None; // break; // } // } // break; // } // case (3): // { // tmp.Name = value; // break; // } // case (4): // { // tmp.Url = value; // break; // } // case (5): // { // tmp.Code = value; // break; // } // case (6): // { // tmp.HasGNB = value == null ? (bool?)null : Convert.ToBoolean(value); // break; // } // case (7): // { // tmp.IsPCHub = value == null ? (bool?)null : Convert.ToBoolean(value); // break; // } // case (8): // { // tmp.IsMyBanner = value == null ? (bool?)null : Convert.ToBoolean(value); // break; // } // case (9): // { // tmp.IsCheckedA2S = value == null ? (bool?)null : Convert.ToBoolean(value); // break; // } // } // } // gnbPageInfoList.Add(tmp); // } // isSucceed = true; // MessageBox.Show("불러오기에 성공하였습니다.", "Import To XLS", MessageBoxButton.OK, MessageBoxImage.Information); //} //catch (COMException) //{ // isSucceed = false; // MessageBox.Show("Excel이 설치되어 있지 않아 불러오기에 실패했습니다.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); //} //catch (Exception e) //{ // isSucceed = false; // MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); //} //finally //{ // // Clean up // ReleaseExcelObject(workSheet); // ReleaseExcelObject(workBook); // ReleaseExcelObject(excelApp); //} #endregion return(isSucceed); }
private bool DoImport(ObservableCollection <GNBPageInfo> gnbPageInfoList, string fileExtension) { bool isSucceed = false; string separator = string.Empty; string fileName = string.Empty; string path = string.Empty; if (fileExtension == "txt") { separator = "\t"; } else if (fileExtension == "csv") { separator = ","; } else { separator = ";"; } System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Title = fileExtension.ToUpper() + "로 가져오기"; dialog.Filter = fileExtension.ToUpper() + " (*." + fileExtension + ") | *." + fileExtension + "; | 모든 파일 (*.*) | *.*"; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { fileName = dialog.SafeFileName; path = dialog.FileName; try { FileStream fileStream = new FileStream(path, FileMode.Open); StreamReader streamReader = new StreamReader(fileStream, Encoding.UTF8, false); string fileContents = string.Empty; string[] list = null; string[] properties = null; fileContents = streamReader.ReadToEnd(); if (string.IsNullOrEmpty(fileContents) == false) { list = fileContents.Split('\n'); for (int i = 1; i < list.Length - 1; i++) { list[i] = list[i].Replace("\r", ""); GNBPageInfo tmp = new GNBPageInfo(); properties = list[i].Split(Convert.ToChar(separator)); if (properties[1] == "공통 페이지") { tmp.Category = Category.Common; } else if (properties[1] == "온라인 게임") { tmp.Category = Category.PCOnline; } else if (properties[1] == "모바일 게임") { tmp.Category = Category.Mobile; } else { tmp.Category = Category.Common; } tmp.Name = properties[2]; tmp.Url = properties[3]; tmp.Code = properties[4]; tmp.HasGNB = properties[5] == "" ? (bool?)null : Convert.ToBoolean(properties[5]); tmp.IsPCHub = properties[6] == "" ? (bool?)null : Convert.ToBoolean(properties[6]); tmp.IsMyBanner = properties[7] == "" ? (bool?)null : Convert.ToBoolean(properties[7]); tmp.IsCheckedA2S = properties[8] == "" ? (bool?)null : Convert.ToBoolean(properties[8]); gnbPageInfoList.Add(tmp); } } } catch (Exception e) { MessageBox.Show(e.Message + e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } return(isSucceed); }
public void GetGNBList(ObservableCollection <GNBPageInfo> gnbPageInfoList) { gnbPageInfoList.Clear(); try { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(path); XmlNodeList xmlNodeList = xmlDoc.SelectNodes("//GNBList/GNBPage"); foreach (XmlNode item in xmlNodeList) { GNBPageInfo gnbPageInfo = new GNBPageInfo(); if (Category.Common.ToString() == item.SelectSingleNode("Category").InnerText) { gnbPageInfo.Category = Category.Common; } else if (Category.PCOnline.ToString() == item.SelectSingleNode("Category").InnerText) { gnbPageInfo.Category = Category.PCOnline; } else if (Category.Mobile.ToString() == item.SelectSingleNode("Category").InnerText) { gnbPageInfo.Category = Category.Mobile; } else { gnbPageInfo.Category = Category.None; } gnbPageInfo.Name = item.SelectSingleNode("Name").InnerText; gnbPageInfo.Url = item.SelectSingleNode("URL").InnerText; gnbPageInfo.Code = item.SelectSingleNode("Code").InnerText; if (item.SelectSingleNode("HasGNB").InnerText == "null") { gnbPageInfo.HasGNB = null; } else { gnbPageInfo.HasGNB = Convert.ToBoolean(item.SelectSingleNode("HasGNB").InnerText); } if (item.SelectSingleNode("IsPCHub").InnerText == "null") { gnbPageInfo.IsPCHub = null; } else { gnbPageInfo.IsPCHub = Convert.ToBoolean(item.SelectSingleNode("IsPCHub").InnerText); } if (item.SelectSingleNode("IsMyBanner").InnerText == "null") { gnbPageInfo.IsMyBanner = null; } else { gnbPageInfo.IsMyBanner = Convert.ToBoolean(item.SelectSingleNode("IsMyBanner").InnerText); } if (item.SelectSingleNode("IsCheckedA2S").InnerText == "null") { gnbPageInfo.IsCheckedA2S = null; } else { gnbPageInfo.IsCheckedA2S = Convert.ToBoolean(item.SelectSingleNode("IsCheckedA2S").InnerText); } gnbPageInfoList.Add(gnbPageInfo); } } catch (Exception e) { MessageBox.Show(e.Message + e.Data, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public GNBEditWindow(GNBPageInfo item) { tmp.Clone(item); gnbPageInfo = item; InitializeComponent(); }
private async Task <GNBPageInfo> GnbCheck(GNBPageInfo gnbPageInfo) { try { HtmlDocument doc = await WebDocumentParser(gnbPageInfo.Url, gnbPageInfo.Name); if (doc != null) { bool isCheckedA2S = false; HtmlNodeCollection nodeCol = doc.DocumentNode.SelectNodes("//script"); if (nodeCol != null) { foreach (HtmlNode node in nodeCol) { if (node.Attributes["src"] != null) { if (node.Attributes["src"].Value.Contains("gnb.min.js") || node.Attributes["src"].Value.Contains("gnb.js")) { gnbPageInfo.HasGNB = true; if (node.Attributes["data-gamecode"] != null) { if (gnbPageInfo.Code != node.Attributes["data-gamecode"].Value) { gnbPageInfo.Code = node.Attributes["data-gamecode"].Value; } } if (node.Attributes["data-ispchub"] != null) { if (node.Attributes["data-ispchub"].Value == "true") { gnbPageInfo.IsPCHub = true; } else if ((node.Attributes["data-ispchub"].Value == "false")) { gnbPageInfo.IsPCHub = false; } } else { gnbPageInfo.IsPCHub = true; } if (node.Attributes["data-ismybanner"] != null) { if (node.Attributes["data-ismybanner"].Value == "true") { gnbPageInfo.IsMyBanner = true; } else if ((node.Attributes["data-ismybanner"].Value == "false")) { gnbPageInfo.IsMyBanner = false; } } else { gnbPageInfo.IsMyBanner = true; } } else if (node.Attributes["src"].Value.Contains("ngb_head.js") || node.Attributes["src"].Value.Contains("playlog.min.js") || node.Attributes["src"].Value.Contains("playlog.mobile.min.js")) { isCheckedA2S = true; } else if (node.Attributes["src"].Value.Contains("adjustPath.js")) { HtmlDocument subDoc = await WebDocumentParser(@"http://help.nexon.com" + node.Attributes["src"].Value, gnbPageInfo.Name); string[] sprits = subDoc.DocumentNode.InnerHtml.Split(' '); foreach (string item in sprits) { bool?isPCHub = null; bool?isMyBanner = null; if (item.Contains("gnb.min.js") || item.Contains("gnb.js")) { gnbPageInfo.HasGNB = true; } else if (item.Contains("data-gamecode")) { if (System.Text.RegularExpressions.Regex.IsMatch(item, @"\D")) { if (gnbPageInfo.Code != System.Text.RegularExpressions.Regex.Replace(item, @"\D", "")) { gnbPageInfo.Code = System.Text.RegularExpressions.Regex.Replace(item, @"\D", ""); } } } else if (item.Contains("data-ispchub'")) { if (item.Contains("true")) { gnbPageInfo.IsPCHub = true; isPCHub = true; } else if (item.Contains("false")) { gnbPageInfo.IsPCHub = false; isPCHub = true; } } else if (item.Contains("data-ismybanner")) { if (item.Contains("true")) { gnbPageInfo.IsMyBanner = true; isMyBanner = true; } else if (item.Contains("false")) { gnbPageInfo.IsMyBanner = false; isMyBanner = false; } } if (isPCHub == null) { gnbPageInfo.IsPCHub = true; } if (isMyBanner == null) { gnbPageInfo.IsMyBanner = true; } } } } } if (gnbPageInfo.HasGNB != true) { //gnbPageInfo.Code = null; gnbPageInfo.HasGNB = false; gnbPageInfo.IsPCHub = false; gnbPageInfo.IsMyBanner = false; } gnbPageInfo.IsCheckedA2S = isCheckedA2S; } } } catch { throw; } return(gnbPageInfo); }