Exemple #1
0
        public Form1(bool auto, bool audio)
        {
            InitializeComponent();
            ScrapLog    = new LogData();
            FileReadLog = new LogData();
            FileSaveLog = new LogData();
            CompareLog  = new LogData();
            request     = new Scrap();
            response    = new Response();

            ExcelDataFromServer = new ExcelData();
            ExcelDataFromFile   = new ExcelData();
            ReadLog();
            richTextBox_Log.SelectionStart = richTextBox_Log.Text.Length;
            richTextBox_Log.ScrollToCaret();
            richTextBox_Log.AppendText($"[{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")}] - " +
                                       "Programos paleidimas - [");
            richTextBox_Log.AppendText("Atlikta", Color.Green);
            richTextBox_Log.AppendText("]\n");
            SaveLog();
            if (auto)
            {
                checkBox_Auto.Checked = true;
                Auto = auto;
            }

            Audio = !audio;
            Text  = VersionLabel;
        }
Exemple #2
0
        public void UpdateData(ExcelData newData, BackgroundWorker bw)
        {
            NeedToBeUpdated = new List <ExcelLicencija>();
            bw.ReportProgress(10);
            //Update changed records
            for (var i = 0; i < Data.Count; i++)
            {
                var newLicencija = newData.Data.Find(x => x.Spaudo_Nr == Data[i].Spaudo_Nr);
                if (newLicencija != null)
                {
                    if (!newLicencija.Equals(Data[i]))
                    {
                        Data[i] = newLicencija;
                    }
                }
                else
                {
                    NeedToBeUpdated.Add(Data[i]);
                }
            }

            bw.ReportProgress(40);

            //Add new records
            newData.Data.ForEach(x =>
            {
                if (!Data.Contains(x))
                {
                    Data.Add(x);
                }
            });

            bw.ReportProgress(60);
            //Update NeedToBeUpdated
            for (var i = 0; i < NeedToBeUpdated.Count; i++)
            {
                var scrap        = new Scrap();
                var newLicencija = new ExcelLicencija(scrap.RequestRecord(NeedToBeUpdated[i].Spaudo_Nr.Trim()));
                if (newLicencija != null)
                {
                    Data[Data.IndexOf(NeedToBeUpdated[i])] = newLicencija;
                }
                bw.ReportProgress(i * 40 / NeedToBeUpdated.Count + 60);
            }

            NeedToBeUpdated = new List <ExcelLicencija>();

            //Negaliojančių licencijų panaikinimas
            Data = Data.FindAll(x => x.Licencijos_būsena == "Aktyvi").ToList();

            bw.ReportProgress(100);
        }