private void ButtonBase_OnClick(object sender, RoutedEventArgs routedEventArgs) { if (currentUser == "user1") { if (currentPassword == passwords[0]) { var newForm = new User1_NewTasks(); newForm.Show(); Close(); } else { MessageBox.Show("Incorrect password"); } } else if ((currentUser == "user2" && currentPassword == passwords[1]) || (currentUser == "user3" && currentPassword == passwords[2]) || (currentUser == "user4" && currentPassword == passwords[3])) { var newForm = new User234_InProgress(currentUser); newForm.Show(); XmlTransformer xmlTranformer = new XmlTransformer(); Close(); } else { MessageBox.Show("Incorrect credentails"); } }
private void FetchMails_onClick(object sender, RoutedEventArgs e) { listView.Items.Clear(); Mail mail = new Mail(); List <Mail> listItems = mail.fetch("user1"); Dictionary <string, KeyValuePair <int, int> > sync = new Dictionary <string, KeyValuePair <int, int> >(); foreach (var item in listItems) { listView.Items.Add(item); if (sync.Count == 0 || !sync.ContainsKey(item.ID)) //zliczaj maile które przysz³y { sync.Add(item.ID, new KeyValuePair <int, int>(/*employeesIncluded*/ 3, 0)); } sync[item.ID] = new KeyValuePair <int, int>(sync[item.ID].Key, sync[item.ID].Value + 1); } foreach (var v in sync) { if (v.Value.Key == v.Value.Value) //sprawdzaj iloœæ maili { List <Mail> mails = new List <Mail>(); //kontener na maile które chcemy zebraæ foreach (var m in listItems) { if (m.ID == v.Key) { mails.Add(m); m.downloadAttachment(m.Attachment, m.Content); //pobierz nag³owek } } //scalanie xmli string[] att = new string[mails.Count]; for (int i = 0; i < mails.Count; i++) { att[i] = mails[i].Attachment; } XmlTransformer.MergeXmls(att); } } }
public static void ExcelToXML(string pathToExcel) { var excelFile = new FileInfo(pathToExcel); var xmlDoc = new XmlDocument(); XmlNode rootNode = xmlDoc.CreateElement("orders"); xmlDoc.AppendChild(rootNode); using (var excel = new ExcelPackage(excelFile)) { foreach (var worksheet in excel.Workbook.Worksheets) { var orderNode = xmlDoc.CreateElement("order"); rootNode.AppendChild(orderNode); var orderNumber = worksheet.Cells["G2"].Value.ToString(); var status = (string)worksheet.Cells["H2"].Value.ToString(); var clientId = (string)worksheet.Cells["I2"].Value.ToString(); var clientName = (string)worksheet.Cells["J2"].Value.ToString(); var clientSurname = (string)worksheet.Cells["K2"].Value.ToString(); XmlTransformer.AddOrderInformation(xmlDoc, orderNode, orderNumber, status, clientId, clientName, clientSurname); var orderColumn = "A"; var orderIndex = 1; do { orderIndex++; try { var cellValue = worksheet.Cells[orderColumn + orderIndex].Value.ToString(); } catch (Exception e) { break; } var type = (string)worksheet.Cells["B" + orderIndex].Value.ToString(); var detail = (string)worksheet.Cells["C" + orderIndex].Value.ToString(); var amount = (string)worksheet.Cells["D" + orderIndex].Value.ToString(); var product_status = (string)worksheet.Cells["E" + orderIndex].ToString(); var productNode = xmlDoc.CreateElement("order"); var typeNode = xmlDoc.CreateElement("type"); typeNode.InnerText = type; var detailNode = xmlDoc.CreateElement("detail"); detailNode.InnerText = detail; var amountNode = xmlDoc.CreateElement("type"); amountNode.InnerText = amount; var productStatusNode = xmlDoc.CreateElement("type"); productStatusNode.InnerText = product_status; productNode.AppendChild(typeNode); productNode.AppendChild(detailNode); productNode.AppendChild(amountNode); productNode.AppendChild(productStatusNode); XmlTransformer.AddProduct(xmlDoc, orderNode, productNode); } while (true); } } String orderPath = "..\\..\\xmls_result\\excel_order.xml"; xmlDoc.Save(orderPath); XmlTransformer.DivideOrders(orderPath); }