예제 #1
0
        public bool ProcessData(Description description)
        {
            this.IsWorking = true;
            string         temporaryReturn = "";
            WorkerProperty wp = new WorkerProperty();

            RepackData(description, wp);

            IWorkerModel workerModel = new WorkerModel();

            workerModel = CreateEntity(collectionDescriptionDataBase);

            SqlDataAccess sqliteDataAccess = new SqlDataAccess();

            if (CheckCode(workerModel.Code, workerModel.Value, sqliteDataAccess))
            {
                Console.WriteLine("Podatak se cuva . . . ");
                AddDataToTable(workerModel, collectionDescriptionDataBase.dataSet, sqliteDataAccess);
                temporaryReturn += "Worker ID:" + IdWorkera + Environment.NewLine;
                Console.WriteLine("Podatak sacuvan");
            }
            else
            {
                temporaryReturn += "Worker ID:" + IdWorkera + Environment.NewLine;
                Console.WriteLine("Podatak odbacen!");
                string test = "[" + DateTime.Now.ToString() + "] - " + "Podatak odbacen" + workerModel.Code + " - " + workerModel.Value;
                Logger.WriteToLogFile(test, @"C:\Users\ASUS\Desktop\MarkoTaticProjekatRES\Project3_rees_pr13_pr15\logger.txt");
            }

            Console.WriteLine(temporaryReturn);
            this.IsWorking = false;
            return(true);
        }
예제 #2
0
        public bool RepackData(Description description, WorkerProperty wp)
        {
            if (description.dataSet == 1)
            {
                collectionDescription1.dataSet = description.dataSet;
                collectionDescription1.id      = description.id;

                for (int i = 0; i < description.items.Count; i++)
                {
                    wp.code        = description.items[i].code;
                    wp.workerValue = description.items[i].value;

                    workerProperties1.Add(wp);
                }

                historicalCollection1.items       = workerProperties1;
                collectionDescription1.listaItema = historicalCollection1;

                collectionDescriptionDataBase = collectionDescription1;
                return(true);
            }
            if (description.dataSet == 2)
            {
                collectionDescription2.dataSet = description.dataSet;
                collectionDescription2.id      = description.id;

                for (int i = 0; i < description.items.Count; i++)
                {
                    wp.code        = description.items[i].code;
                    wp.workerValue = description.items[i].value;

                    workerProperties2.Add(wp);
                }

                historicalCollection2.items       = workerProperties2;
                collectionDescription2.listaItema = historicalCollection2;

                collectionDescriptionDataBase = collectionDescription2;
                return(true);
            }
            if (description.dataSet == 3)
            {
                collectionDescription3.dataSet = description.dataSet;
                collectionDescription3.id      = description.id;

                for (int i = 0; i < description.items.Count; i++)
                {
                    wp.code        = description.items[i].code;
                    wp.workerValue = description.items[i].value;

                    workerProperties3.Add(wp);
                }

                historicalCollection3.items       = workerProperties3;
                collectionDescription3.listaItema = historicalCollection3;

                collectionDescriptionDataBase = collectionDescription3;
                return(true);
            }
            if (description.dataSet == 4)
            {
                collectionDescription4.dataSet = description.dataSet;
                collectionDescription4.id      = description.id;

                for (int i = 0; i < description.items.Count; i++)
                {
                    wp.code        = description.items[i].code;
                    wp.workerValue = description.items[i].value;

                    workerProperties4.Add(wp);
                }

                historicalCollection4.items       = workerProperties4;
                collectionDescription4.listaItema = historicalCollection4;

                collectionDescriptionDataBase = collectionDescription4;
                return(true);
            }

            return(false);
        }