Exemplo n.º 1
0
        private void workerLoad_DoWork(object sender, DoWorkEventArgs e)
        {
            xmlLineCheckIns = new List <XmlLineCheckInModel>();
            XDocument xmlDocument = XDocument.Load(xml);

            foreach (XElement xmlElement in xmlDocument.Element("LineCheckIns").Elements("LineCheckIn"))
            {
                XmlLineCheckInModel xmlLineCheckIn = new XmlLineCheckInModel();
                xmlLineCheckIn.CardId   = xmlElement.Element("CardId").Value;
                xmlLineCheckIn.WorkAt   = xmlElement.Element("WorkAt").Value;
                xmlLineCheckIn.LineTime = xmlElement.Element("LineTime").Value;
                xmlLineCheckIns.Add(xmlLineCheckIn);
            }

            foreach (string line in lines)
            {
                string lineNumber = Regex.Match(line, @"\d+").Value;
                //if (String.IsNullOrEmpty(lineNumber) == false)
                //{
                //    lineAfters.Add("SEWING LINE " + lineNumber + "A");
                //    lineAfters.Add("SEWING LINE " + lineNumber + "B");
                //}
                //else
                //{
                //    lineAfters.Add(line);
                //}
                sources.AddRange(SourceController.Get(line, date));
            }
            //lineAfters = lineAfters.Distinct().ToList();
            lineAfters = lines.Distinct().ToList();
        }
Exemplo n.º 2
0
        private void workerLoad_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            foreach (PersonalModel personal in personalLines)
            {
                XmlLineCheckInModel  xmlLineCheckIn = xmlLineCheckIns.Where(x => x.CardId == personal.CardId).LastOrDefault();
                LineCheckInViewModel lineCheckIn    = new LineCheckInViewModel();
                lineCheckIn.CardId     = personal.CardId;
                lineCheckIn.WorkerId   = personal.WorkerId;
                lineCheckIn.Name       = personal.Name;
                lineCheckIn.Department = personal.Department;
                lineCheckIn.Position   = personal.Position;
                lineCheckIn.HiredDate  = personal.HiredDate;
                if (xmlLineCheckIn != null)
                {
                    lineCheckIn.WorkAt        = xmlLineCheckIn.WorkAt;
                    lineCheckIn.IsLineCheckIn = true;
                    lineCheckIn.LineTime      = xmlLineCheckIn.LineTime;
                }
                List <SourceModel> sourceWorkers = sources.Where(s => s.CardId == personal.CardId).ToList();
                if (sourceWorkers.Count() > 0)
                {
                    lineCheckIn.IsTerminalCheckIn = true;
                    foreach (SourceModel source in sourceWorkers)
                    {
                        lineCheckIn.TerminalTime += source.Time.Substring(0, 2) + ":" + source.Time.Substring(2, 2) + " | ";
                    }
                }

                lineCheckIns.Add(lineCheckIn);
            }

            for (int i = 0; i <= lineAfters.Count - 1; i++)
            {
                ColumnDefinition cd = new ColumnDefinition();
                cd.Width = new GridLength(1, GridUnitType.Star);
                gridShowButton.ColumnDefinitions.Add(cd);

                string lineAfter    = lineAfters[i];
                Button btnLineAfter = new Button();
                Grid.SetColumn(btnLineAfter, i);
                btnLineAfter.Margin     = new Thickness(1, 0, 1, 0);
                btnLineAfter.Content    = lineAfter;
                btnLineAfter.ToolTip    = lineAfter;
                btnLineAfter.FontSize   = 12;
                btnLineAfter.Background = Brushes.LightGray;
                btnLineAfter.FontWeight = FontWeights.Bold;
                btnLineAfter.Click     += new RoutedEventHandler(btnLineAfter_Click);
                gridShowButton.Children.Add(btnLineAfter);
            }

            dgCheckInList.ItemsSource = null;
            dgCheckInList.ItemsSource = lineCheckIns;
        }