示例#1
0
        public void Add(Tabel tabel)
        {
            if (_list.Exists(item => item == tabel))
                return;

            _list.Add(tabel);
        }
示例#2
0
        public void StartImport()
        {
            TabelList tabelList = TabelList.GetInstance();

            string[] files = Directory.GetFiles(FilePath, "*.txt");

            foreach (var file in files)
            {
                string date = file.Split('_')[2].Split('.')[0];
                int month = Convert.ToInt32(string.Concat(date[0], date[1]));
                int year = Convert.ToInt32(string.Concat("20", date[2], date[3]));

                string[] lines = File.ReadAllLines(file);

                for (int i = 1; i < lines.Count(); i++)
                {
                    string[] fields = lines[i].Split(';');

                    for (int j = 2; j < fields.Count(); j++)
                    {
                        if ((fields[j] == "Я") || (fields[j] == "Я/Н"))
                        {
                            Tabel tabel = new Tabel(fields[0], new DateTime(year, month, j - 1));
                            tabel.Save();
                        }
                    }
                }

                File.Move(file, FilePath + @"\processed\" + DateTime.Today.ToShortDateString() + " " + Path.GetFileName(file));
            }
        }
示例#3
0
        protected override void loadFromSql()
        {
            DataTable dt = _provider.Select("Tabel");

            foreach (DataRow row in dt.Rows)
            {
                Tabel tabel = new Tabel(row);
                Add(tabel);
            }
        }
        public void StartImport()
        {
            try
            {
                using (ExcelDoc excel = new ExcelDoc(FilePath))
                {
                    int i = 7;

                    string curCell = "H" + i;
                    while (excel.getValue(curCell) != null)
                    {
                        curCell = "A" + i;
                        if ((excel.getValue(curCell) == null) ||
                            ((excel.getValue(curCell).ToString().ToUpper() != "AM") && (excel.getValue(curCell).ToString().ToUpper() != "АМ")))
                        {
                            curCell = "H" + i;
                            i++;
                            continue;
                        }

                        curCell = "H" + i;
                        string number = excel.getValue(curCell).ToString();

                        curCell = "D" + i;
                        DateTime dateBegin;
                        DateTime.TryParse(excel.getValue1(curCell).ToString(), out dateBegin);

                        curCell = "E" + i;
                        DateTime dateEnd;
                        DateTime.TryParse(excel.getValue1(curCell).ToString(), out dateEnd);

                        for (DateTime date = dateBegin; date <= dateEnd; date = date.AddDays(1))
                        {
                            Tabel tabel = new Tabel(number, date) { Comment = "businessTrip" };
                            tabel.Save();
                        }

                        curCell = "H" + i;
                        i++;
                    }
                }
            }
            catch (NullReferenceException ex)
            {
                LogManager.Logger.Error(ex, "Error in file {file}", FilePath);
            }
            catch (COMException ex)
            {
                LogManager.Logger.Error(ex, "Error in file {file}", FilePath);
            }
        }