//code cu gen random ad all in config file public void SetTrueFalseAD(string pathFile) { try { foreach (string s in CTLConfig._GenAd) { entyconfigfile enty = new entyconfigfile(pathFile); enty.loadValuFromFile(); enty.SetvalueKey(s, "false"); } //setamazon entyconfigfile entyama = new entyconfigfile(pathFile); entyama.loadValuFromFile(); entyama.SetvalueKey("ad3", "true"); Random ran = new Random(); int CountTrue = ran.Next(1, CTLConfig._GenAd.Count); for (int i = 0; i < CountTrue; i++) { Random ran1 = new Random(); int index = ran1.Next(0, CTLConfig._GenAd.Count); entyconfigfile enty = new entyconfigfile(pathFile); enty.loadValuFromFile(); enty.SetvalueKey(CTLConfig._GenAd[index], "true"); } } catch (Exception ex) { CTLError.WriteError("loi SetTrueFalseAD " + pathFile, ex.Message); MessageBox.Show("Loi " + pathFile + ex.Message); } }
public void SetValueFile(string pathFile) { try { FileInfo FileSource = new FileInfo(pathFile); foreach (string s in CTLConfig._Gentypead) { FileInfo f = new FileInfo(Path.Combine(CTLConfig._pathfilelocal, s.Trim() + FileSource.Name.Split('.')[0])); if (f.Exists) { StreamReader read = new StreamReader(f.FullName); List <string> temp = new List <string>(); while (!read.EndOfStream) { string str = read.ReadLine(); if (str != string.Empty) { temp.Add(str); } } Random ran = new Random(); int index = ran.Next(0, temp.Count); entyconfigfile enty = new entyconfigfile(pathFile); enty.loadValuFromFile(); enty.SetvalueKey(s, temp[index]); } } } catch (Exception ex) { CTLError.WriteError("loi SetValueFile " + pathFile, ex.Message); MessageBox.Show("Loi " + pathFile + ex.Message); } }
private void listEditorfile_SelectedIndexChanged(object sender, EventArgs e) { FileInfo fselect = new FileInfo(listEditorfile.Items[listEditorfile.SelectedIndex].ToString()); entyconfigfile enty = GetxmlConfigfile(fselect); if (enty != null) { } }
private void listEditorfile_SelectedIndexChanged(object sender, EventArgs e) { flowLayoutPanel1.Controls.Clear(); FileInfo fselect = new FileInfo(listEditorfile.Items[listEditorfile.SelectedIndex].ToString()); entyconfigfile enty = new entyconfigfile(fselect.FullName); enty.loadValuFromFile(); UsrFileConfig user = new UsrFileConfig(enty); flowLayoutPanel1.Controls.Add(user); user.loadcontrol(); }
public entyconfigfile GetxmlConfigfile(FileInfo f) { try { entyconfigfile enty = new entyconfigfile(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(f.FullName); XmlElement node1 = xmlDoc.SelectSingleNode("/app/ad1") as XmlElement; enty.ad1_ggban = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad1") as XmlElement; enty.ad1_ggban = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad2") as XmlElement; enty.ad2_ggfull = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad3") as XmlElement; enty.ad3_amaz = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad4") as XmlElement; enty.ad4_adcolony = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad5") as XmlElement; enty.ad5_unity = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad6") as XmlElement; enty.ad6_revmob = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad7") as XmlElement; enty.ad7_vungle = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/ad8") as XmlElement; enty.ad8_suppersonic = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/gbanner") as XmlElement; enty.gbanner = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/gful") as XmlElement; enty.gful = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/amazon") as XmlElement; enty.amazon = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/adcolonyAppID") as XmlElement; enty.adcolonyAppID = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/adcolonyZoneID") as XmlElement; enty.adcolonyZoneID = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/unityid") as XmlElement; enty.unityid = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/revmobid") as XmlElement; enty.revmobid = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/vungleid") as XmlElement; enty.vungleid = node1.InnerText; node1 = xmlDoc.SelectSingleNode("/app/sonicid") as XmlElement; enty.sonicid = node1.InnerText; return(enty); } catch (Exception exception) { CTLError.WriteError("GetxmlConfigfile ", exception.Message); return(null); } }
public void GenAndUpload() { try { //DirectoryInfo dsource = new DirectoryInfo(CTLConfig._pathfilelocal); //code cu GenFrom file txt //foreach(FileInfo f in dsource.GetFiles("*.txt")) //{ // //set ID APP // SetValueFile(f.FullName); // //set ads // SetTrueFalseAD(f.FullName); // FTPHelper ftphelper = new FTPHelper(CTLConfig._user, CTLConfig._pass, CTLConfig._pathftp); // ftphelper.UploadFile(f.FullName); //} //end //code moi genfromfile xml FileInfo filegenxml = new FileInfo(Path.Combine(Application.StartupPath, "ConfigADS.xml")); if (filegenxml.Exists) { XmlDocument doc = new XmlDocument(); doc.Load(Application.StartupPath + @"\ConfigADS.xml"); XmlNode nodeList = doc.SelectSingleNode("/GenADS"); if (nodeList != null) { foreach (XmlNode node in nodeList.ChildNodes) { string[] OnAds = node.Attributes["OnAds"].Value.Split(','); string[] RanAds = node.Attributes["RanAds"].Value.Split(','); FileInfo fileUpload = new FileInfo(Path.Combine(CTLConfig._pathfilelocal, node.Name + ".txt")); if (!fileUpload.Exists) { continue; } entyconfigfile enty = new entyconfigfile(fileUpload.FullName); enty.loadValuFromFile(); enty.SetFalseALLAd(); foreach (string str in OnAds) { enty.SetvalueKey(str, "true"); } Random ran = new Random(); foreach (string str in RanAds) { enty.SetvalueKey(str, ran.Next(0, 3) > 0 ? "true" : "false"); } FTPHelper ftphelper = new FTPHelper(CTLConfig._user, CTLConfig._pass, CTLConfig._pathftp); ftphelper.UploadFile(fileUpload.FullName); } } } else { CTLError.WriteError("KO ton tai file ConfigADS.xml ", "Loi gen ads"); } } catch (Exception ex) { CTLError.WriteError("loi GenAndUpload ", ex.Message); MessageBox.Show("Loi " + ex.Message); } }
public void SetValue() { try { if (txtpathfileSetkey.Text == string.Empty) { MessageBox.Show("vui long chon Path File"); return; } DirectoryInfo dparent = new DirectoryInfo(txtpathfileSetkey.Text); if (checkSetparentKey.Checked) { foreach (FileInfo f in dparent.GetFiles(txtfilename.Text)) { if (f.Exists) { entyconfigfile enty = new entyconfigfile(f.FullName); enty.loadValuFromFile(); enty.SetvalueKey(txtKeySet.Text, txtValukey.Text); } } } int CountKey = 0; List <string> listkey = new List <string>(); if (checksetfromfile.Checked) { StreamReader read = new StreamReader(txtfromfile.Text); while (!read.EndOfStream) { string readline = read.ReadLine(); if (readline.Trim() != string.Empty) { listkey.Add(readline); } } } foreach (DirectoryInfo dsource in dparent.GetDirectories()) { foreach (FileInfo f in dsource.GetFiles(txtfilename.Text)) { if (f.Exists) { string valuekey = txtValukey.Text; if (checksetfromfile.Checked) { if (listkey.Count > CountKey) { valuekey = listkey[CountKey++]; } else { valuekey = listkey[CountKey - 1]; } } entyconfigfile enty = new entyconfigfile(f.FullName); enty.loadValuFromFile(); enty.SetvalueKey(txtKeySet.Text, valuekey); } } } labthongbao.Text = "Set Value Thanh Cong"; } catch (Exception ex) { CTLError.WriteError("loi SetValue tab3 ", ex.Message); labthongbao.Text = "Loi " + ex.Message; return; } }