Exemplo n.º 1
0
        public void Export()
        {
            var env                = GetEnviroment();
            var aircraftCore       = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore   = new ItemsRelationsDataAccess(env);
            var componentCore      = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);
            var mpdCore            = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);
            var aircraftFlightCore = new AircraftFlightCore(env, env.Loader, env.NewLoader, null, null, componentCore, null, aircraftCore);
            var calc               = new Calculator(env, componentCore, aircraftFlightCore, aircraftCore);

            aircraftCore.LoadAllAircrafts();
            var aircraft = aircraftCore.GetAircraftById(2316);
            var mpds     = mpdCore.GetMaintenanceDirectives(aircraft);

            int q  = 0;
            var ds = ExcelToDataTableUsingExcelDataReader(@"D:\MPD.xlsx");

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    var mpd = mpds.FirstOrDefault(i => i.TaskNumberCheck == row[0].ToString());
                    if (mpd == null)
                    {
                        continue;
                    }

                    var record = new DirectiveRecord
                    {
                        Parent       = mpd,
                        ParentId     = mpd.ItemId,
                        OnLifelength = new Lifelength(),
                    };

                    if (int.TryParse(row[2].ToString(), out var hour))
                    {
                        record.OnLifelength.Hours = hour;
                    }
                    if (int.TryParse(row[3].ToString(), out var cycle))
                    {
                        record.OnLifelength.Cycles = cycle;
                    }
                    if (DateTime.TryParse(row[4].ToString(), out var date))
                    {
                        record.RecordDate = date;
                    }

                    var res = calc.GetFlightLifelengthOnStartOfDay(aircraft, date);

                    if ((hour > 0 || cycle > 0) && date != DateTime.MinValue)
                    {
                        record.OnLifelength.Days = res.Days;
                        //Trace.WriteLine(row[0].ToString());
                        env.NewKeeper.Save(record);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Test()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var mpdCore          = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            aircraftCore.LoadAllAircrafts();
            var aircraftFrom = aircraftCore.GetAircraftById(2336);
            //var aircraftTo = aircraftCore.GetAircraftById(2347);

            var mpdsFrom = mpdCore.GetMaintenanceDirectives(aircraftFrom);

            //var mpdsTo = mpdCore.GetMaintenanceDirectives(aircraftTo);

            foreach (var maintenanceDirective in mpdsFrom.Where(i => i.IsOperatorTask))
            {
                maintenanceDirective.IsOperatorTask = false;
                env.Keeper.Save(maintenanceDirective);
                Trace.WriteLine($"{maintenanceDirective.TaskNumberCheck}");
                //var find = mpdsTo.FirstOrDefault(i => i.TaskNumberCheck.TrimEnd() == maintenanceDirective.TaskNumberCheck.TrimEnd());
                //if (find == null)
                //	continue;
                //Trace.WriteLine($"{maintenanceDirective.TaskNumberCheck} - {find?.TaskNumberCheck ?? "N/A"}");
                //Trace.WriteLine(maintenanceDirective.Kits.Count);
                //Trace.WriteLine("------------------------");

                //find.KitsApplicable = true;
                //env.Keeper.Save(find);

                //foreach (var accessoryRequired in find.Kits)
                //{
                //	env.Keeper.Delete(accessoryRequired);
                //}

                //foreach (var rec in maintenanceDirective.Kits)
                //{
                //	var newRec = rec.GetCopyUnsaved();
                //	newRec.ParentId = find.ItemId;
                //	env.Keeper.Save(newRec);
                //}
            }
        }
Exemplo n.º 3
0
        public void ImportMaintenanceDirectives757TotalFinish()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore,
                                                     itemRelationCore);
            var mpdCore = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var ds = ExcelToDataTableUsingExcelDataReader(@"D:\111\737\task.xlsx");

            aircraftCore.LoadAllAircrafts();
            var aircraft = aircraftCore.GetAircraftById(2335);

            var mpds = mpdCore.GetMaintenanceDirectives(aircraft);

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (string.IsNullOrEmpty(row[0].ToString()))
                    {
                        continue;
                    }

                    var taskCards = row[2].ToString().Split(new string[] { "\n" }, StringSplitOptions.None);

                    foreach (var card in taskCards)
                    {
                        var finds = mpds
                                    .Where(i => i.TaskCardNumber.ToLower().Trim().Equals(card.ToLower().Trim()))
                                    .OrderBy(i => i.PerformanceRecords.Count > 0)
                                    .ToList();

                        foreach (var mpd in finds)
                        {
                            mpd.TaskNumberCheck = row[0].ToString();
                            env.NewKeeper.Save(mpd);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void ImportTaskCard()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, null);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var maintenanceCore  = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var aircraft = env.NewLoader.GetObject <AircraftDTO, Aircraft>(new Filter("ItemId", 2340));

            var mpdList = maintenanceCore.GetMaintenanceDirectives(aircraft);

            var d     = new DirectoryInfo(@"D:\MPD\All Task Cards for UP-B6703");
            var files = d.GetFiles();

            foreach (var mpd in mpdList)
            {
                var file = files.FirstOrDefault(f => f.Name.Replace(".pdf", "") == mpd.TaskCardNumber);
                if (file != null)
                {
                    var _fileData    = UsefulMethods.GetByteArrayFromFile(file.FullName);
                    var attachedFile = new AttachedFile
                    {
                        FileData = _fileData,
                        FileName = file.Name,
                        FileSize = _fileData.Length
                    };
                    mpd.TaskCardNumberFile = attachedFile;
                    env.NewKeeper.Save(mpd);
                }
                else
                {
                    Trace.WriteLine(mpd.TaskNumberCheck);
                }
            }
        }
Exemplo n.º 5
0
        public void ImportMaintenanceDirectives757Total()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);
            var mpdCore          = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var ds = ExcelToDataTableUsingExcelDataReader(@"D:\111\737\task.xlsx");

            aircraftCore.LoadAllAircrafts();
            var aircraft = aircraftCore.GetAircraftById(2335);

            var bd  = componentCore.GetAicraftBaseComponents(aircraft.ItemId, BaseComponentType.Frame.ItemId).FirstOrDefault();
            var ata = env.NewLoader.GetObjectListAll <ATAChapterDTO, AtaChapter>();

            var mpds = mpdCore.GetMaintenanceDirectives(aircraft);

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (string.IsNullOrEmpty(row[0].ToString()))
                    {
                        continue;
                    }

                    MaintenanceDirective find;
                    var finds = mpds
                                .Where(i => i.TaskNumberCheck.ToLower().Trim().Equals(row[0].ToString().ToLower().Trim()))
                                .OrderBy(i => i.PerformanceRecords.Count > 0)
                                .ToList();

                    //Такой колхоз сделан потому что бывает что mpd две с одинаковым названием
                    var flag = false;


                    find = finds.FirstOrDefault();

                    MaintenanceDirective mpd;

                    if (find != null)
                    {
                        mpd = find;
                        finds.Remove(find);
                    }
                    else
                    {
                        mpd = new MaintenanceDirective()
                        {
                            ParentBaseComponent = bd,
                            HiddenRemarks       = "NEW",
                        };
                        flag = true;
                    }

                    Setup757Total(mpd, row, ata, flag);


                    var taskCards = row[2].ToString().Split(new string[] { "\n" }, StringSplitOptions.None);
                    var counter   = 1;
                    if (taskCards.Count() > 1)
                    {
                        foreach (var taskCard in taskCards)
                        {
                            if (string.IsNullOrEmpty(taskCard))
                            {
                                continue;
                            }


                            if (counter == 1)
                            {
                                mpd.TaskNumberCheck = $"{row[0]} ({counter})";
                                mpd.TaskCardNumber  = taskCard;

                                env.Keeper.Save(mpd);
                                counter++;
                            }
                            else
                            {
                                var mpdExist = finds.FirstOrDefault();
                                if (mpdExist != null)
                                {
                                    Setup757Total(mpdExist, row, ata, flag);
                                    mpdExist.TaskNumberCheck = $"{row[0]} ({counter})";
                                    mpdExist.TaskCardNumber  = taskCard;

                                    env.Keeper.Save(mpdExist);
                                    finds.Remove(mpdExist);
                                }
                                else
                                {
                                    var newMpd = mpd.GetCopyUnsaved();
                                    Setup757Total(newMpd, row, ata, flag);
                                    newMpd.ParentBaseComponent = bd;
                                    newMpd.TaskNumberCheck     = $"{row[0]} ({counter})";
                                    newMpd.TaskCardNumber      = taskCard;

                                    env.Keeper.Save(newMpd);

                                    foreach (var record in mpd.PerformanceRecords)
                                    {
                                        var newRec = record.GetCopyUnsaved();
                                        newRec.ParentId = newMpd.ItemId;
                                        env.Keeper.Save(newRec);
                                    }
                                }
                                counter++;
                            }
                        }
                    }
                    else
                    {
                        mpd.TaskCardNumber = row[2].ToString();
                        env.Keeper.Save(mpd);
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void ImportMaintenanceDirectives757()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);
            var mpdCore          = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var ds = ExcelToDataTableUsingExcelDataReader(@"D:\111\737\zip.xlsx");

            aircraftCore.LoadAllAircrafts();
            var aircraft = aircraftCore.GetAircraftById(2335);

            var bd  = componentCore.GetAicraftBaseComponents(aircraft.ItemId, BaseComponentType.Frame.ItemId).FirstOrDefault();
            var ata = env.NewLoader.GetObjectListAll <ATAChapterDTO, AtaChapter>();

            var mpds = mpdCore.GetMaintenanceDirectives(aircraft);

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (string.IsNullOrEmpty(row[0].ToString()))
                    {
                        continue;
                    }

                    MaintenanceDirective find = mpds.FirstOrDefault(i => i.TaskNumberCheck.ToLower().Trim().Equals(row[0].ToString().ToLower().Trim()));

                    //Такой колхоз сделан потому что бывает что mpd две с одинаковым названием
                    var flag = false;


                    MaintenanceDirective mpd;

                    if (find != null)
                    {
                        mpd = find;
                    }
                    else
                    {
                        mpd = new MaintenanceDirective()
                        {
                            ParentBaseComponent = bd,
                            HiddenRemarks       = "NEW",
                        };
                        flag = true;
                    }


                    mpd.TaskNumberCheck   = row[0].ToString();
                    mpd.MaintenanceManual = row[1].ToString();


                    #region SYSTEMS AND POWERPLANT MAINTENA

                    //mpd.Program = MaintenanceDirectiveProgramType.SystemsAndPowerPlants;
                    //mpd.MpdRef = "SYSTEMS AND POWERPLANT MAINTENA";

                    //if (!string.IsNullOrEmpty(row[2].ToString()))
                    //{
                    //    int res;
                    //    if (int.TryParse(row[2].ToString(), out res))
                    //        mpd.Category = MpdCategory.GetItemById(res);
                    //}

                    //mpd.Zone = row[6].ToString().Replace("\n", " ");
                    //mpd.Access = row[7].ToString().Replace("\n", " ");

                    //if (!string.IsNullOrEmpty(row[10].ToString()))
                    //{
                    //    double mhr;
                    //    if (double.TryParse(row[10].ToString(), out mhr))
                    //        mpd.ManHours = mhr;
                    //}

                    //var apl = row[8].ToString();
                    //if (apl.Contains("ALL"))
                    //{
                    //    mpd.IsApplicability = true;
                    //}

                    //mpd.Description = row[11].ToString();

                    #endregion

                    #region STRUCTURAL MAINTENANCE REQUIREM

                    //mpd.Program = MaintenanceDirectiveProgramType.StructuresMaintenance;
                    //mpd.MpdRef = "STRUCTURAL MAINTENANCE REQUIREM";

                    //if (!string.IsNullOrEmpty(row[9].ToString()))
                    //{
                    //    double mhr;
                    //    if (double.TryParse(row[9].ToString(), out mhr))
                    //        mpd.ManHours = mhr;
                    //}

                    //if (!string.IsNullOrEmpty(row[2].ToString()))
                    //    mpd.ProgramIndicator = MaintenanceDirectiveProgramIndicator.Items
                    //        .FirstOrDefault(i => i.ShortName.Contains(row[2].ToString()));

                    //mpd.Zone = row[3].ToString().Replace("\n", " ");
                    //mpd.Access = row[4].ToString().Replace("\n", " ");

                    //var apl = row[7].ToString();
                    //if (apl.Contains("ALL"))
                    //{
                    //    mpd.IsApplicability = true;
                    //}

                    //mpd.Description = row[10].ToString();

                    #endregion

                    #region ZONAL INSPECTION PROGRAM

                    //mpd.Program = MaintenanceDirectiveProgramType.ZonalInspection;
                    //mpd.MpdRef = "ZONAL INSPECTION PROGRAM";

                    //if (!string.IsNullOrEmpty(row[8].ToString()))
                    //{
                    //    double mhr;
                    //    if (double.TryParse(row[8].ToString(), out mhr))
                    //        mpd.ManHours = mhr;
                    //}

                    //mpd.Zone = row[2].ToString().Replace("\n", " ");
                    //mpd.Access = row[3].ToString().Replace("\n", " ");

                    //var apl = row[6].ToString();
                    //if (apl.Contains("ALL"))
                    //{
                    //    mpd.IsApplicability = true;
                    //}

                    //mpd.Description = row[9].ToString();

                    #endregion

                    if (flag)
                    {
                        mpd.HiddenRemarks = "NEW";
                    }

                    if (mpd.TaskNumberCheck.Length > 2)
                    {
                        var shortName = mpd.TaskNumberCheck.Substring(0, 2);
                        mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(shortName));
                    }

                    mpd.MPDTaskNumber           = "D626A001";
                    mpd.IsOperatorTask          = false;
                    mpd.MpdRevisionDate         = new DateTime(2019, 2, 15);
                    mpd.Threshold.EffectiveDate = new DateTime(2018, 8, 23);
                    mpd.ScheduleRevisionDate    = new DateTime(2018, 8, 23);
                    mpd.ScheduleRevisionNum     = "0";
                    mpd.ScheduleRef             = "SC-C014-MP";
                    env.Keeper.Save(mpd);
                }
            }
        }
Exemplo n.º 7
0
        public void ImportMaintenanceDirectives37XX()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);
            var mpdCore          = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var ds = ExcelToDataTableUsingExcelDataReader(@"D:\123\mpd.xlsx");

            aircraftCore.LoadAllAircrafts();
            var aircraft = aircraftCore.GetAircraftById(2334);

            var bd  = componentCore.GetAicraftBaseComponents(aircraft.ItemId, BaseComponentType.Frame.ItemId).FirstOrDefault();
            var ata = env.NewLoader.GetObjectListAll <ATAChapterDTO, AtaChapter>();

            var mpds = mpdCore.GetMaintenanceDirectives(aircraft);


            foreach (DataTable table in ds.Tables)
            {
                foreach (var row in table.Rows.OfType <DataRow>().GroupBy(i => i[1]))
                //foreach (DataRow row in table.Rows)
                {
                    #region Добавление Mpd TaskNumber(Appendix B - Old to New XRef)

                    //int counter = 1;
                    //var find = mpds.FirstOrDefault(i => i.TaskNumberCheck.ToLower().Trim().Equals(row.Key.ToString().ToLower()));
                    //if (find != null)
                    //{
                    //	foreach (var dataRow in row)
                    //	{
                    //		if (counter == 1)
                    //		{
                    //			if (row.Count() > 1)
                    //				find.TaskNumberCheck = $"{row.Key} ({counter})";

                    //			find.MpdOldTaskCard = dataRow[2].ToString();
                    //			find.TaskCardNumber = dataRow[3].ToString();
                    //			env.Keeper.Save(find);
                    //			counter++;
                    //		}
                    //		else
                    //		{

                    //			MaintenanceDirective mpd = find.GetCopyUnsaved();
                    //			mpd.ParentBaseComponent = bd;
                    //			mpd.TaskNumberCheck = $"{row.Key} ({counter})";
                    //			mpd.MpdOldTaskCard = dataRow[2].ToString();
                    //			mpd.TaskCardNumber = dataRow[3].ToString();
                    //			env.Keeper.Save(mpd);
                    //			counter++;

                    //		}
                    //	}
                    //}


                    #endregion


                    //var find = mpds.FirstOrDefault(i =>
                    //i.TaskNumberCheck.ToLower().Trim().Equals(row[0].ToString().ToLower()));

                    //MaintenanceDirective mpd;

                    //if (find != null)
                    //	mpd = find;
                    //else
                    //	mpd = new MaintenanceDirective()
                    //	{
                    //		ParentBaseComponent = bd,
                    //		HiddenRemarks = "NEW",
                    //	};

                    #region Основное добавление(Appendix G - ISIP)

                    //mpd.Program = MaintenanceDirectiveProgramType.ISIP;
                    //mpd.MpdRef = "Appendix G - ISIP";

                    //mpd.TaskNumberCheck = row[0].ToString();
                    //mpd.Zone = row[4].ToString();
                    //mpd.Access = row[3].ToString();
                    //mpd.Description = row[8].ToString();

                    //if (mpd.TaskNumberCheck.Length > 2)
                    //{
                    //	var shortName = mpd.TaskNumberCheck.Substring(1, 2);
                    //	mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(shortName));

                    //}
                    //mpd.MPDTaskNumber = "D6-38278";
                    //mpd.IsOperatorTask = false;
                    //mpd.MpdRevisionDate = new DateTime(2018, 9, 25);
                    //mpd.Threshold.EffectiveDate = new DateTime(2018, 10, 1);
                    //mpd.ScheduleRevisionDate = new DateTime(2018, 10, 1);
                    //mpd.ScheduleRevisionNum = "1";
                    //mpd.ScheduleRef = "SC-C011-MP";


                    #endregion

                    #region Основное добавление(Section 6 Systems и Section 7 Structures)

                    //mpd.Program = MaintenanceDirectiveProgramType.SystemsMaintenance;
                    //mpd.MpdRef = "Section 6 Systems";

                    //mpd.Program = MaintenanceDirectiveProgramType.StructuralInspection;
                    //mpd.MpdRef = "Section 7 Structures";

                    //mpd.TaskNumberCheck = row[0].ToString();
                    //mpd.MRB = row[1].ToString();
                    //mpd.Zone = row[4].ToString();
                    //mpd.Access = row[3].ToString();
                    //mpd.Description = row[8].ToString();

                    //var apl = row[5].ToString();
                    //if (apl.Contains("ALL"))
                    //{
                    //	mpd.IsApplicability = true;
                    //}
                    //else if (apl == "(1)")
                    //{
                    //	mpd.IsApplicability = true;
                    //	mpd.Applicability = apl;
                    //}


                    //if (mpd.TaskNumberCheck.Length > 2)
                    //{
                    //	var shortName = mpd.TaskNumberCheck.Substring(1, 2);
                    //	mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(shortName));

                    //}
                    //mpd.MPDTaskNumber = "D6-38278";
                    //mpd.IsOperatorTask = false;
                    //mpd.MpdRevisionDate = new DateTime(2018, 9, 25);
                    //mpd.Threshold.EffectiveDate = new DateTime(2018, 10, 1);
                    //mpd.ScheduleRevisionDate = new DateTime(2018, 10, 1);
                    //mpd.ScheduleRevisionNum = "1";
                    //mpd.ScheduleRef = "SC-C011-MP";


                    #endregion

                    //env.Keeper.Save(mpd);
                }
            }
        }
Exemplo n.º 8
0
        public void Test()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, null);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var maintenanceCore  = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);

            var aircraft = env.NewLoader.GetObject <AircraftDTO, Aircraft>(new Filter("ItemId", 2348));

            var mpdList = maintenanceCore.GetMaintenanceDirectives(aircraft);

            var bd = componentCore.GetAicraftBaseComponents(2348, BaseComponentType.Frame.ItemId).FirstOrDefault();

            var d     = new DirectoryInfo(@"H:\TaskCard\ALL for Yevhenij");
            var files = d.GetFiles();

            var ds = ExcelToDataTableUsingExcelDataReader(@"H:\Card.xlsx");

            var dict = new Dictionary <string, List <DataRow> >();

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (!dict.ContainsKey(row[1].ToString()))
                    {
                        dict.Add(row[1].ToString(), new List <DataRow> {
                            row
                        });
                    }
                    else
                    {
                        dict[row[1].ToString()].Add(row);
                    }
                }
            }

            foreach (var mpd in mpdList)
            {
                int counter     = 1;
                var description = mpd.Description;

                if (mpd.Program.ItemId == MaintenanceDirectiveProgramType.StructuresMaintenance.ItemId || mpd.Program.ItemId == MaintenanceDirectiveProgramType.SystemsAndPowerPlants.ItemId ||
                    mpd.Program.ItemId == MaintenanceDirectiveProgramType.ZonalInspection.ItemId)
                {
                    if (!dict.ContainsKey(mpd.TaskNumberCheck))
                    {
                        Trace.WriteLine(mpd.TaskNumberCheck);
                        continue;
                    }

                    foreach (var row in dict[mpd.TaskNumberCheck])
                    {
                        if (counter == 1)
                        {
                            mpd.TaskCardNumber = row[0].ToString();

                            var file = files.FirstOrDefault(f => f.Name.Replace(".pdf", "") == mpd.TaskCardNumber);
                            if (file != null)
                            {
                                var _fileData    = UsefulMethods.GetByteArrayFromFile(file.FullName);
                                var attachedFile = new AttachedFile
                                {
                                    FileData = _fileData,
                                    FileName = file.Name,
                                    FileSize = _fileData.Length
                                };

                                mpd.Description       += $" / TaskCard : {row[2]}";
                                mpd.TaskCardNumberFile = attachedFile;
                            }

                            if (dict[mpd.TaskNumberCheck].Count > 1)
                            {
                                mpd.TaskNumberCheck += $" ({counter})";
                            }

                            env.NewKeeper.Save(mpd);
                            counter++;
                        }
                        else
                        {
                            var newMpd = mpd.GetCopyUnsaved();
                            newMpd.TaskCardNumber     = row[0].ToString();
                            newMpd.TaskCardNumberFile = null;

                            var file = files.FirstOrDefault(f => f.Name.Replace(".pdf", "") == newMpd.TaskCardNumber);
                            if (file != null)
                            {
                                var _fileData    = UsefulMethods.GetByteArrayFromFile(file.FullName);
                                var attachedFile = new AttachedFile
                                {
                                    FileData = _fileData,
                                    FileName = file.Name,
                                    FileSize = _fileData.Length
                                };

                                newMpd.TaskCardNumberFile = attachedFile;
                                newMpd.Description        = $"{description} / TaskCard : {row[2]}";
                            }

                            newMpd.TaskNumberCheck     = $"{row[1]} ({counter})";
                            newMpd.ParentBaseComponent = bd;
                            env.NewKeeper.Save(newMpd);
                            counter++;
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void CopyAircraft()
        {
            var env              = GetEnviroment();
            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);
            var directiveCore    = new DirectiveCore(env.NewKeeper, env.NewLoader, env.Keeper, env.Loader, itemRelationCore);
            var maintenanceCore  = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var newBaseComponent     = new List <BaseComponent>();
            var newComponents        = new List <Entities.General.Accessory.Component>();
            var directives           = new List <Directive>();
            var maintenanceDirective = new List <MaintenanceDirective>();

            //Грузим ВС, делаем с него копию и сохраняем
            var aircrafts   = env.NewLoader.GetObject <AircraftDTO, Aircraft>(new Filter("ItemId", 2346), true);
            var newAircraft = aircrafts.GetCopyUnsaved();

            //newAircraft.RegistrationNumber += "- COPY";

            env.NewKeeper.Save(newAircraft);

            //Грузим базовые агрегаты ВС, делаем с копии и сохраняем
            var baseComponents = new BaseComponentCollection(componentCore.GetAicraftBaseComponents(aircrafts.ItemId));

            LoadDocuments(baseComponents, env);

            foreach (var baseComponent in baseComponents)
            {
                var newComponent = (BaseComponent)baseComponent.GetCopyUnsaved();
                newComponent.ParentAircraftId = newAircraft.ItemId;


                env.NewKeeper.Save(newComponent);
                newBaseComponent.Add(newComponent);

                foreach (var transferRecord in baseComponent.TransferRecords)
                {
                    var newTransferRecord = transferRecord.GetCopyUnsaved();
                    if (newTransferRecord.DestinationObjectType == SmartCoreType.Aircraft)
                    {
                        newTransferRecord.DestinationObjectId = newAircraft.ItemId;
                    }
                    newTransferRecord.ParentId = newComponent.ItemId;

                    env.NewKeeper.Save(newTransferRecord);
                }

                foreach (var componentDirective in baseComponent.ComponentDirectives)
                {
                    var newcomponentDirective = componentDirective.GetCopyUnsaved();

                    newcomponentDirective.ComponentId = newComponent.ItemId;
                    env.NewKeeper.Save(newcomponentDirective);
                }
            }

            //Грузим агрегаты ВС, делаем с копии и сохраняем
            var components = componentCore.GetComponents(aircrafts.ItemId);

            foreach (var component in components)
            {
                var newComponent = component.GetCopyUnsaved();
                newComponent.ParentAircraftId = newAircraft.ItemId;

                env.NewKeeper.Save(newComponent);
                newComponents.Add(newComponent);

                foreach (var transferRecord in component.TransferRecords)
                {
                    var newTransferRecord = transferRecord.GetCopyUnsaved();

                    if (newTransferRecord.DestinationObjectType == SmartCoreType.BaseComponent)
                    {
                        newTransferRecord.DestinationObjectId = newBaseComponent.FirstOrDefault(b => b.SerialNumber == ((BaseComponent)newTransferRecord.DestinationObject).SerialNumber).ItemId;
                    }
                    newTransferRecord.ParentId = newComponent.ItemId;

                    env.NewKeeper.Save(newTransferRecord);
                }

                foreach (var componentDirective in component.ComponentDirectives)
                {
                    var newcomponentDirective = componentDirective.GetCopyUnsaved();

                    newcomponentDirective.ComponentId = newComponent.ItemId;
                    env.NewKeeper.Save(newcomponentDirective);
                }
            }

            //Грузим директивы ВС, делаем с копии и сохраняем
            directives.Clear();
            directives.AddRange(directiveCore.GetDirectives(aircrafts, DirectiveType.All));
            foreach (var directive in directives)
            {
                var newDirective = directive.GetCopyUnsaved();
                newDirective.ParentBaseComponent = newBaseComponent.FirstOrDefault(b => b.SerialNumber == newDirective.ParentBaseComponent.SerialNumber);


                newDirective.PerformanceRecords.Clear();
                newDirective.CategoriesRecords.Clear();

                env.NewKeeper.Save(newDirective);
            }

            //Грузим MPD ВС, делаем с копии и сохраняем
            maintenanceDirective.Clear();
            maintenanceDirective.AddRange(maintenanceCore.GetMaintenanceDirectives(aircrafts));
            foreach (var directive in maintenanceDirective)
            {
                var newDirective = directive.GetCopyUnsaved();
                if (directive.ParentBaseComponent != null)
                {
                    newDirective.ParentBaseComponent = newBaseComponent.FirstOrDefault(b => b.SerialNumber == directive.ParentBaseComponent.SerialNumber);
                }

                newDirective.PerformanceRecords.Clear();
                newDirective.CategoriesRecords.Clear();

                env.NewKeeper.Save(newDirective);
            }
        }
Exemplo n.º 10
0
        /* public static Presenters Presenters
         * {
         *   get { return presenters; }
         * }*/

        static Program()
        {
            var exePath = Path.GetDirectoryName(Application.ExecutablePath);
            var path    = Path.Combine(exePath, "AppSettings.json");
            var json    = File.ReadAllText(path);

            GlobalObjects.Config = JsonConvert.DeserializeObject <JObject>(json);

            AuditContext auditContext = null;

            try
            {
                auditContext = new AuditContext((string)GlobalObjects.Config["ConnectionStrings"]["Audit"]);
            }
            catch {}
            GlobalObjects.AuditRepository = new AuditRepository(auditContext);
            GlobalObjects.AuditContext    = auditContext;

            var environment = DbTypes.CasEnvironment = new CasEnvironment();

            environment.AuditRepository = GlobalObjects.AuditRepository;
            environment.ApiProvider     = new ApiProvider((string)GlobalObjects.Config["ConnectionStrings"]["ScatTest"]);

            var nonRoutineJobDataAccess      = new NonRoutineJobDataAccess(environment.Loader, environment.Keeper);
            var itemsRelationsDataAccess     = new ItemsRelationsDataAccess(environment);
            var filesDataAccess              = new FilesDataAccess(environment.NewLoader);
            var workPackageRecordsDataAccess = new WorkPackageRecordsDataAccess(environment);


            var storeService              = new StoreCore(environment);
            var aircraftService           = new AircraftsCore(environment.Loader, environment.NewKeeper, environment.NewLoader);
            var compontntService          = new ComponentCore(environment, environment.Loader, environment.NewLoader, environment.NewKeeper, aircraftService, itemsRelationsDataAccess);
            var averageUtilizationService = new AverageUtilizationCore(aircraftService, storeService, compontntService);
            var directiveService          = new DirectiveCore(environment.NewKeeper, environment.NewLoader, environment.Keeper, environment.Loader, itemsRelationsDataAccess);
            var aircraftFlightService     = new AircraftFlightCore(environment, environment.Loader, environment.NewLoader, directiveService, environment.Manipulator, compontntService, environment.NewKeeper, aircraftService);
            var flightTrackService        = new FlightTrackCore(environment.NewLoader, environment.Loader, environment);
            var calculator                 = new Calculator(environment, compontntService, aircraftFlightService, aircraftService);
            var mtopCalculator             = new MTOPCalculator(calculator, aircraftService, averageUtilizationService);
            var planOpsCalculator          = new PlanOpsCalculator(environment.NewLoader, environment.NewKeeper, aircraftService, flightTrackService);
            var performanceCalculator      = new PerformanceCalculator(calculator, averageUtilizationService, mtopCalculator);
            var packageService             = new PackagesCore(environment, environment.NewKeeper, environment.Loader, aircraftService, compontntService);
            var purchaseService            = new PurchaseCore(environment, environment.NewLoader, environment.Loader, packageService, environment.NewKeeper, performanceCalculator);
            var calcStockService           = new StockCalculator(environment, environment.NewLoader, compontntService);
            var documentService            = new DocumentCore(environment, environment.NewLoader, environment.Loader, aircraftService, environment.NewKeeper, compontntService);
            var maintenanceService         = new MaintenanceCore(environment, environment.NewLoader, environment.NewKeeper, itemsRelationsDataAccess, aircraftService);
            var maintenanceCheckCalculator = new MaintenanceCheckCalculator(calculator, averageUtilizationService, performanceCalculator);
            var analystService             = new AnalystCore(compontntService, maintenanceService, directiveService, maintenanceCheckCalculator, performanceCalculator);
            var discrepanciesService       = new DiscrepanciesCore(environment.Loader, environment.NewLoader, directiveService, aircraftFlightService);
            var kitsService                = new KitsCore(environment, environment.Loader, environment.NewKeeper, compontntService, nonRoutineJobDataAccess);
            var smsService                 = new SMSCore(environment.Manipulator);
            var personelService            = new PersonnelCore(environment);
            var transferRecordCore         = new TransferRecordCore(environment.NewLoader, environment.NewKeeper, compontntService, aircraftService, calculator, storeService, filesDataAccess);
            var bindedItemsService         = new BindedItemsCore(compontntService, directiveService, maintenanceService);
            var performanceService         = new PerformanceCore(environment.NewKeeper, environment.Keeper, calculator, bindedItemsService);
            var workPackageService         = new WorkPackageCore(environment, environment.NewLoader, maintenanceService, environment.NewKeeper, calculator, compontntService, aircraftService, nonRoutineJobDataAccess, directiveService, filesDataAccess, performanceCalculator, performanceService, bindedItemsService, workPackageRecordsDataAccess, mtopCalculator, averageUtilizationService);
            var nonRoutineJobService       = new NonRoutineJobCore(environment, workPackageService, nonRoutineJobDataAccess, environment.NewLoader);
            var auditService               = new AuditCore(environment, environment.Loader, environment.NewLoader, environment.NewKeeper, calculator, performanceCalculator, performanceService);

            DbTypes.AircraftsCore = aircraftService;

            GlobalObjects.CasEnvironment             = environment;
            GlobalObjects.PackageCore                = packageService;
            GlobalObjects.PurchaseCore               = purchaseService;
            GlobalObjects.ComponentCore              = compontntService;
            GlobalObjects.AnalystCore                = analystService;
            GlobalObjects.StockCalculator            = calcStockService;
            GlobalObjects.DocumentCore               = documentService;
            GlobalObjects.AuditCore                  = auditService;
            GlobalObjects.MaintenanceCore            = maintenanceService;
            GlobalObjects.WorkPackageCore            = workPackageService;
            GlobalObjects.NonRoutineJobCore          = nonRoutineJobService;
            GlobalObjects.DirectiveCore              = directiveService;
            GlobalObjects.AircraftFlightsCore        = aircraftFlightService;
            GlobalObjects.DiscrepanciesCore          = discrepanciesService;
            GlobalObjects.KitsCore                   = kitsService;
            GlobalObjects.SmsCore                    = smsService;
            GlobalObjects.PersonnelCore              = personelService;
            GlobalObjects.TransferRecordCore         = transferRecordCore;
            GlobalObjects.AircraftsCore              = aircraftService;
            GlobalObjects.ItemsRelationsDataAccess   = itemsRelationsDataAccess;
            GlobalObjects.StoreCore                  = storeService;
            GlobalObjects.BindedItemsCore            = bindedItemsService;
            GlobalObjects.AverageUtilizationCore     = averageUtilizationService;
            GlobalObjects.MaintenanceCheckCalculator = maintenanceCheckCalculator;
            GlobalObjects.MTOPCalculator             = mtopCalculator;
            GlobalObjects.PerformanceCalculator      = performanceCalculator;
            GlobalObjects.PlanOpsCalculator          = planOpsCalculator;
            GlobalObjects.PerformanceCore            = performanceService;
            GlobalObjects.FlightTrackCore            = flightTrackService;

            environment.SetAircraftCore(aircraftService);
            environment.Calculator = calculator;
            environment.Manipulator.PurchaseService    = GlobalObjects.PurchaseCore;
            environment.Manipulator.MaintenanceCore    = GlobalObjects.MaintenanceCore;
            environment.Manipulator.WorkPackageCore    = GlobalObjects.WorkPackageCore;
            environment.Manipulator.AircraftFlightCore = GlobalObjects.AircraftFlightsCore;
            environment.Manipulator.ComponentCore      = GlobalObjects.ComponentCore;
            environment.Manipulator.AircraftsCore      = GlobalObjects.AircraftsCore;
            environment.Manipulator.BindedItemCore     = GlobalObjects.BindedItemsCore;

            InitLoadingVariants();
            InitializePresenters();
        }
Exemplo n.º 11
0
        public void GetBindedItemsForMpd()
        {
            const int aircraftId = 2316;            // Воздушное судно 4LimaTest

            //инициализация core - ов
            var enviroment     = GetEnviroment();
            var itemRelationDA = new ItemsRelationsDataAccess(enviroment);
            var airctaftCore   = new AircraftsCore(enviroment.Loader, enviroment.NewKeeper, enviroment.NewLoader);

            airctaftCore.LoadAllAircrafts();
            var componentCore   = new ComponentCore(enviroment, enviroment.Loader, enviroment.NewLoader, enviroment.NewKeeper, airctaftCore, itemRelationDA);
            var directiveCore   = new DirectiveCore(enviroment.NewKeeper, enviroment.NewLoader, enviroment.Keeper, enviroment.Loader, itemRelationDA);
            var maintenanceCore = new MaintenanceCore(enviroment, enviroment.NewLoader, enviroment.NewKeeper, itemRelationDA, null);
            var bindedItemCore  = new BindedItemsCore(componentCore, directiveCore, maintenanceCore);

            //Загрузка базового компонента для того что бы привязать его к mpd и ad
            var baseDetail = enviroment.BaseComponents.FirstOrDefault(x => x.ParentAircraftId == aircraftId);
            var detail     = componentCore.GetComponents(baseDetail).FirstOrDefault();

            var mpd = new MaintenanceDirective {
                ParentBaseComponent = baseDetail
            };
            var dd = new ComponentDirective {
                ComponentId = detail.ItemId, Remarks = "DDTest"
            };
            var ad = new Directive {
                ParentBaseComponent = baseDetail, Remarks = "ADTest"
            };

            enviroment.NewKeeper.Save(dd);
            enviroment.NewKeeper.Save(ad);
            enviroment.NewKeeper.Save(mpd);

            mpd.ItemRelations.Add(new ItemsRelation
            {
                FirstItemId      = mpd.ItemId,
                FirtsItemTypeId  = mpd.SmartCoreObjectType.ItemId,
                SecondItemId     = dd.ItemId,
                SecondItemTypeId = dd.SmartCoreObjectType.ItemId,
                RelationTypeId   = WorkItemsRelationType.CalculationAffect
            });

            mpd.ItemRelations.Add(new ItemsRelation
            {
                FirstItemId      = mpd.ItemId,
                FirtsItemTypeId  = mpd.SmartCoreObjectType.ItemId,
                SecondItemId     = ad.ItemId,
                SecondItemTypeId = ad.SmartCoreObjectType.ItemId,
                RelationTypeId   = WorkItemsRelationType.CalculationAffect
            });

            foreach (var itemRelation in mpd.ItemRelations)
            {
                enviroment.NewKeeper.Save(itemRelation);
            }


            var bindedItemsADOnly = bindedItemCore.GetBindedItemsFor(aircraftId, new[] { mpd }, new [] { SmartCoreType.Directive.ItemId });
            var bindedItemsDDOnly = bindedItemCore.GetBindedItemsFor(aircraftId, new[] { mpd }, new [] { SmartCoreType.ComponentDirective.ItemId });
            var bindedItemsAll    = bindedItemCore.GetBindedItemsFor(aircraftId, new[] { mpd });


            foreach (var itemRelation in mpd.ItemRelations)
            {
                enviroment.NewKeeper.Delete(itemRelation);
            }

            enviroment.NewKeeper.Delete(mpd);
            enviroment.NewKeeper.Delete(dd);
            enviroment.NewKeeper.Delete(ad);


            Assert.IsTrue(bindedItemsADOnly[mpd].Count == 1);
            var forCheckAd = (Directive)bindedItemsADOnly[mpd].Single();

            Assert.AreEqual(forCheckAd.Remarks, ad.Remarks);

            Assert.IsTrue(bindedItemsDDOnly[mpd].Count == 1);
            var forCheckDd = (ComponentDirective)bindedItemsDDOnly[mpd].Single();

            Assert.AreEqual(forCheckDd.Remarks, dd.Remarks);

            Assert.IsTrue(bindedItemsAll[mpd].Count == 2);
        }
Exemplo n.º 12
0
        public void ImportMaintenanceDirectives()
        {
            var env = GetEnviroment();

            var aircraftCore     = new AircraftsCore(env.Loader, env.NewKeeper, env.NewLoader);
            var itemRelationCore = new ItemsRelationsDataAccess(env);
            var componentCore    = new ComponentCore(env, env.Loader, env.NewLoader, env.NewKeeper, aircraftCore, itemRelationCore);
            var mpdCore          = new MaintenanceCore(env, env.NewLoader, env.NewKeeper, itemRelationCore, aircraftCore);

            var ds = ExcelToDataTableUsingExcelDataReader(@"H:\SCIAWL.xlsx");

            var bd  = componentCore.GetAicraftBaseComponents(2348, BaseComponentType.Frame.ItemId).FirstOrDefault();
            var ata = env.NewLoader.GetObjectListAll <ATAChapterDTO, AtaChapter>();

            aircraftCore.LoadAllAircrafts();
            var aircraft = aircraftCore.GetAircraftById(2348);

            var mpds = mpdCore.GetMaintenanceDirectives(aircraft);

            MaintenanceDirective savedMpd = null;

            foreach (DataTable table in ds.Tables)
            {
                foreach (DataRow row in table.Rows)
                {
                    if (string.IsNullOrEmpty(row[0].ToString()))
                    {
                        continue;
                    }

                    var find = mpds.FirstOrDefault(i => i.TaskNumberCheck.ToLower().Equals(row[0].ToString().ToLower()));
                    if (find != null)
                    {
                        if (find.MaintenanceManual != row[1].ToString())
                        {
                            find.HiddenRemarks    += $"| AMM |";
                            find.MaintenanceManual = row[1].ToString();
                        }

                        find.Program = MaintenanceDirectiveProgramType.SpecialCompliance;

                        //if (!string.IsNullOrEmpty(row[3].ToString()))
                        //{
                        //	var value = row[3].ToString();
                        //	if (value.Contains("SYSTEMS AND POWERPLANT"))
                        //	{
                        //		if (find.Program.ItemId != MaintenanceDirectiveProgramType.SystemsAndPowerPlants.ItemId)
                        //		{
                        //			find.HiddenRemarks += $"| Program |";
                        //			find.Program = MaintenanceDirectiveProgramType.SystemsAndPowerPlants;
                        //		}
                        //	}
                        //	else if (value.Contains("STRUCTURAL"))
                        //	{
                        //		if (find.Program.ItemId != MaintenanceDirectiveProgramType.StructuresMaintenance.ItemId)
                        //		{
                        //			find.HiddenRemarks += $"| Program |";
                        //			find.Program = MaintenanceDirectiveProgramType.StructuresMaintenance;
                        //		}
                        //	}
                        //	else if(value.Contains("ZONAL"))
                        //	{
                        //		if (find.Program.ItemId != MaintenanceDirectiveProgramType.ZonalInspection.ItemId)
                        //		{
                        //			find.HiddenRemarks += $"| Program |";
                        //			find.Program = MaintenanceDirectiveProgramType.ZonalInspection;
                        //		}
                        //	}
                        //}

                        if (!string.IsNullOrEmpty(row[4].ToString()))
                        {
                            var category = MpdCategory.GetItemById(Convert.ToInt32(row[4].ToString()[0]));
                            if (category != null && find.Category.ItemId != category.ItemId)
                            {
                                find.HiddenRemarks += $"| Category |";
                                find.Category       = category;
                            }
                        }

                        if (!string.IsNullOrEmpty(row[5].ToString()))
                        {
                            var programIndicator = MaintenanceDirectiveProgramIndicator.Items.FirstOrDefault(i => i.ShortName.Contains(row[5].ToString()));
                            if (programIndicator != null && find.ProgramIndicator.ItemId != programIndicator.ItemId)
                            {
                                find.HiddenRemarks   += $"| ProgramIndicator |";
                                find.ProgramIndicator = programIndicator;
                            }
                        }

                        if (!string.IsNullOrEmpty(row[6].ToString()))
                        {
                            var workType = MaintenanceDirectiveTaskType.Items.FirstOrDefault(i => i.ShortName.Contains(row[6].ToString()));
                            if (workType != null && find.WorkType.ItemId != workType.ItemId)
                            {
                                find.HiddenRemarks += $"| WorkType |";
                                find.WorkType       = workType;
                            }
                        }

                        if (find.Zone != row[22].ToString())
                        {
                            find.HiddenRemarks += $"| Zone |";
                            find.Zone           = row[22].ToString().Replace("\n", " ");
                        }

                        if (find.Access != row[23].ToString())
                        {
                            find.HiddenRemarks += $"| Access |";
                            find.Access         = row[23].ToString().Replace("\n", " ");
                        }

                        if (find.Applicability != row[24].ToString())
                        {
                            find.HiddenRemarks += $"| Applicability |";
                            find.Applicability  = row[24].ToString();
                        }

                        if (!string.IsNullOrEmpty(row[26].ToString()))
                        {
                            var value = Convert.ToDouble(row[26].ToString());
                            if (find.ManHours != value)
                            {
                                find.HiddenRemarks += $"| ManHours |";
                                find.ManHours       = value;
                            }
                        }

                        if (find.Description != row[27].ToString())
                        {
                            find.HiddenRemarks += $"| Description |";
                            find.Description    = row[27].ToString();
                        }

                        if (find.Description != row[2].ToString())
                        {
                            find.HiddenRemarks += $"| Remarks |";
                            find.Remarks        = row[2].ToString();
                        }

                        if (find.Description != row[28].ToString())
                        {
                            find.HiddenRemarks += $"| Doc No |";
                            find.MPDTaskNumber  = row[28].ToString();
                        }

                        if (find.Description != row[28].ToString())
                        {
                            find.HiddenRemarks += $"| Workarea |";
                            find.Workarea       = row[29].ToString();
                        }


                        if (!string.IsNullOrEmpty(row[7].ToString()) && row[7].ToString() != "N/A")
                        {
                            var value = row[7].ToString();
                            find.Threshold.FirstPerformanceSinceNew.Hours = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[8].ToString()) && row[8].ToString() != "N/A")
                        {
                            var value = row[8].ToString();
                            find.Threshold.FirstPerformanceSinceNew.Cycles = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[9].ToString()) && row[9].ToString() != "N/A")
                        {
                            find.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Days;
                            var value = row[9].ToString();
                            find.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[10].ToString()) && row[10].ToString() != "N/A")
                        {
                            find.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Months;
                            var value = row[10].ToString();
                            find.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[11].ToString()) && row[11].ToString() != "N/A")
                        {
                            find.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Years;
                            var value = row[11].ToString();
                            find.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value);
                        }

                        ///////////////////////////////////////////////////////////////////////////////
                        if (!string.IsNullOrEmpty(row[15].ToString()) && row[15].ToString() != "N/A")
                        {
                            var value = row[15].ToString();
                            find.Threshold.RepeatInterval.Hours = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[16].ToString()) && row[16].ToString() != "N/A")
                        {
                            var value = row[16].ToString();
                            find.Threshold.RepeatInterval.Cycles = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[17].ToString()) && row[17].ToString() != "N/A")
                        {
                            find.Threshold.RepeatInterval.CalendarType = CalendarTypes.Days;
                            var value = row[17].ToString();
                            find.Threshold.RepeatInterval.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[18].ToString()) && row[18].ToString() != "N/A")
                        {
                            find.Threshold.RepeatInterval.CalendarType = CalendarTypes.Months;
                            var value = row[18].ToString();
                            find.Threshold.RepeatInterval.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[19].ToString()) && row[19].ToString() != "N/A")
                        {
                            find.Threshold.RepeatInterval.CalendarType = CalendarTypes.Years;
                            var value = row[19].ToString();
                            find.Threshold.RepeatInterval.CalendarValue = int.Parse(value);
                        }


                        env.NewKeeper.Save(find);
                    }
                    else
                    {
                        var newMpd = new MaintenanceDirective
                        {
                            ParentBaseComponent = bd,
                            HiddenRemarks       = "NEW",
                        };

                        newMpd.TaskNumberCheck   = row[0].ToString();
                        newMpd.MaintenanceManual = row[1].ToString();

                        newMpd.Program = MaintenanceDirectiveProgramType.SpecialCompliance;

                        //if (!string.IsNullOrEmpty(row[3].ToString()))
                        //{
                        //	var value = row[3].ToString();
                        //	if(value.Contains("SYSTEMS AND POWERPLANT"))
                        //		newMpd.Program = MaintenanceDirectiveProgramType.SystemsAndPowerPlants;
                        //	else if (value.Contains("STRUCTURAL"))
                        //		newMpd.Program = MaintenanceDirectiveProgramType.StructuresMaintenance;
                        //	else if (value.Contains("ZONAL"))
                        //		newMpd.Program = MaintenanceDirectiveProgramType.ZonalInspection;
                        //}


                        if (!string.IsNullOrEmpty(row[4].ToString()))
                        {
                            newMpd.Category = MpdCategory.GetItemById(Convert.ToInt32(row[4].ToString()));
                        }

                        if (!string.IsNullOrEmpty(row[5].ToString()))
                        {
                            newMpd.ProgramIndicator = MaintenanceDirectiveProgramIndicator.Items.FirstOrDefault(i => i.ShortName.Contains(row[5].ToString()));
                        }

                        if (!string.IsNullOrEmpty(row[6].ToString()))
                        {
                            newMpd.WorkType = MaintenanceDirectiveTaskType.Items.FirstOrDefault(i => i.ShortName.Contains(row[6].ToString()));
                        }

                        newMpd.Zone          = row[22].ToString().Replace("\n", " ");
                        newMpd.Access        = row[23].ToString().Replace("\n", " ");
                        newMpd.Applicability = row[24].ToString();

                        if (!string.IsNullOrEmpty(row[26].ToString()))
                        {
                            newMpd.ManHours = Convert.ToDouble(row[26].ToString());
                        }

                        newMpd.Remarks       = row[2].ToString();
                        newMpd.Description   = row[27].ToString();
                        newMpd.MPDTaskNumber = row[28].ToString();
                        newMpd.Workarea      = row[29].ToString();

                        if (newMpd.TaskNumberCheck.Length > 2)
                        {
                            newMpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(newMpd.TaskNumberCheck.Substring(0, 2)));
                        }


                        newMpd.Threshold = new MaintenanceDirectiveThreshold();
                        ///////////////////////////////////////////////////////////////////////////////
                        if (!string.IsNullOrEmpty(row[7].ToString()) && row[7].ToString() != "N/A")
                        {
                            var value = row[7].ToString();
                            newMpd.Threshold.FirstPerformanceSinceNew.Hours = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[8].ToString()) && row[8].ToString() != "N/A")
                        {
                            var value = row[8].ToString();
                            newMpd.Threshold.FirstPerformanceSinceNew.Cycles = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[9].ToString()) && row[9].ToString() != "N/A")
                        {
                            newMpd.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Days;
                            var value = row[9].ToString();
                            newMpd.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[10].ToString()) && row[10].ToString() != "N/A")
                        {
                            newMpd.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Months;
                            var value = row[10].ToString();
                            newMpd.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[11].ToString()) && row[11].ToString() != "N/A")
                        {
                            newMpd.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Years;
                            var value = row[11].ToString();
                            newMpd.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value);
                        }

                        ///////////////////////////////////////////////////////////////////////////////
                        if (!string.IsNullOrEmpty(row[15].ToString()) && row[15].ToString() != "N/A")
                        {
                            var value = row[15].ToString();
                            newMpd.Threshold.RepeatInterval.Hours = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[16].ToString()) && row[16].ToString() != "N/A")
                        {
                            var value = row[16].ToString();
                            newMpd.Threshold.RepeatInterval.Cycles = int.Parse(value);
                        }

                        if (!string.IsNullOrEmpty(row[17].ToString()) && row[17].ToString() != "N/A")
                        {
                            newMpd.Threshold.RepeatInterval.CalendarType = CalendarTypes.Days;
                            var value = row[17].ToString();
                            newMpd.Threshold.RepeatInterval.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[18].ToString()) && row[18].ToString() != "N/A")
                        {
                            newMpd.Threshold.RepeatInterval.CalendarType = CalendarTypes.Months;
                            var value = row[18].ToString();
                            newMpd.Threshold.RepeatInterval.CalendarValue = int.Parse(value);
                        }
                        else if (!string.IsNullOrEmpty(row[19].ToString()) && row[19].ToString() != "N/A")
                        {
                            newMpd.Threshold.RepeatInterval.CalendarType = CalendarTypes.Years;
                            var value = row[19].ToString();
                            newMpd.Threshold.RepeatInterval.CalendarValue = int.Parse(value);
                        }

                        env.NewKeeper.Save(newMpd);
                    }


                    #region UP-B3

                    //var newMpd = new MaintenanceDirective();
                    //newMpd.TaskNumberCheck = row[0].ToString();
                    //newMpd.Description = row[6].ToString();
                    //newMpd.Applicability = row[5].ToString();

                    //newMpd.WorkType = MaintenanceDirectiveTaskType.Items.FirstOrDefault(i => i.ShortName.Contains(row[2].ToString()));


                    //newMpd.MPDTaskNumber = "D626A011-9-03";
                    //newMpd.ParentBaseComponent = bd;
                    //newMpd.Program = MaintenanceDirectiveProgramType.CertificationMaintenanceRequirement;
                    //newMpd.MpdRevisionDate = new DateTime(2017, 9, 1);

                    //if (newMpd.TaskNumberCheck.Length > 2)
                    //	newMpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(newMpd.TaskNumberCheck.Substring(0, 2)));
                    //env.Keeper.Save(newMpd);


                    //env.Keeper.Save(newMpd);

                    //DateTime d = new DateTime();

                    //if(DateTime.TryParse(row[4].ToString(), out d))
                    //	newMpd.MpdRevisionDate = d;

                    //
                    //
                    //if (newMpd.TaskNumberCheck.Length > 2)
                    //newMpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(newMpd.TaskNumberCheck.Substring(0, 2)));

                    //newMpd.Threshold = new MaintenanceDirectiveThreshold();
                    //if (!string.IsNullOrEmpty(row[6].ToString()))
                    //{
                    //	newMpd.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Days;
                    //	var value = row[6].ToString();
                    //	newMpd.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}
                    //else if (!string.IsNullOrEmpty(row[7].ToString()))
                    //{
                    //	newMpd.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Months;
                    //	var value = row[7].ToString();
                    //	newMpd.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}
                    //else if (!string.IsNullOrEmpty(row[8].ToString()))
                    //{
                    //	newMpd.Threshold.FirstPerformanceSinceNew.CalendarType = CalendarTypes.Years;
                    //	var value = row[8].ToString();
                    //	newMpd.Threshold.FirstPerformanceSinceNew.CalendarValue = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}

                    //if (!string.IsNullOrEmpty(row[9].ToString()))
                    //{
                    //	var value = row[9].ToString();
                    //	newMpd.Threshold.FirstPerformanceSinceNew.Days = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}

                    //if (!string.IsNullOrEmpty(row[10].ToString()))
                    //{
                    //	var value = row[10].ToString();
                    //	newMpd.Threshold.FirstPerformanceSinceNew.Cycles = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}


                    //if (!string.IsNullOrEmpty(row[11].ToString()))
                    //{
                    //	newMpd.Threshold.RepeatInterval.CalendarType = CalendarTypes.Days;
                    //	var value = row[11].ToString();
                    //	newMpd.Threshold.RepeatInterval.CalendarValue = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}
                    //else if (!string.IsNullOrEmpty(row[12].ToString()))
                    //{
                    //	newMpd.Threshold.RepeatInterval.CalendarType = CalendarTypes.Months;
                    //	var value = row[12].ToString();
                    //	newMpd.Threshold.RepeatInterval.CalendarValue = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}
                    //else if (!string.IsNullOrEmpty(row[13].ToString()))
                    //{
                    //	newMpd.Threshold.RepeatInterval.CalendarType = CalendarTypes.Years;
                    //	var value = row[13].ToString();
                    //	newMpd.Threshold.RepeatInterval.CalendarValue = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}

                    //if (!string.IsNullOrEmpty(row[14].ToString()))
                    //{
                    //	var value = row[14].ToString();
                    //	newMpd.Threshold.RepeatInterval.Days = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}

                    //if (!string.IsNullOrEmpty(row[15].ToString()))
                    //{
                    //	var value = row[15].ToString();
                    //	newMpd.Threshold.RepeatInterval.Cycles = int.Parse(value.Remove(value.IndexOf(' ')));
                    //}

                    //env.Keeper.Save(newMpd);

                    #endregion

                    #region UP-B6703

                    //if (row[0].ToString().Length == 0)
                    //{
                    //	savedMpd.Zone += $" {row[1]}";
                    //	savedMpd.Access += $" {row[4]}";
                    //	savedMpd.Description += $" {row[2]}";

                    //	env.Keeper.Save(savedMpd);
                    //}
                    //else
                    //{
                    //	var mpd = new MaintenanceDirective();

                    //	var taskNumberCheck = row[0].ToString().Split();
                    //	var zone = row[1].ToString().Split();
                    //	var access = row[4].ToString().Split();

                    //	mpd.TaskNumberCheck = string.Join(" ", taskNumberCheck);
                    //	mpd.TaskCardNumber = row[0].ToString();
                    //	//mpd.TaskCardNumber = row[5].ToString();//690-694 756-802
                    //	mpd.Zone = string.Join(" ", zone);
                    //	mpd.Access = string.Join(" ", access);
                    //	mpd.Description = row[2].ToString();
                    //	//mpd.Description = $"{row[5]} {row[2]}";//669-689

                    //	if (mpd.TaskNumberCheck.Length > 2)
                    //		mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(mpd.TaskNumberCheck.Substring(0, 2)));


                    //	mpd.ParentBaseComponent = bd;
                    //	env.Keeper.Save(mpd);
                    //	savedMpd = mpd;
                    //}


                    #endregion

                    #region LY - FLG


                    //mpd.TaskNumberCheck = row[0].ToString();
                    //mpd.TaskCardNumber = row[0].ToString();
                    //mpd.Zone = row[1].ToString();
                    //mpd.Description = row[2].ToString();

                    //if(table.Columns.Count > 3)
                    //	mpd.Access = row[3].ToString();

                    //if(mpd.TaskNumberCheck.Length > 2)
                    //	mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(mpd.TaskNumberCheck.Substring(0, 2)));

                    #endregion

                    #region LY - AZV

                    //if (row[0].ToString().Length == 0)
                    //{
                    //	savedMpd.TaskCardNumber += $" {row[2]}";
                    //	savedMpd.Zone += $" {row[3]}";
                    //	savedMpd.Access += $" {row[4]}";
                    //	savedMpd.Description += $" {row[6]}";

                    //	env.Keeper.Save(savedMpd);
                    //}
                    //else
                    //{
                    //	var mpd = new MaintenanceDirective();

                    //	mpd.TaskNumberCheck = row[0].ToString();

                    //	var maintenanceManual = row[1].ToString().Split();
                    //	var cardNumber = row[2].ToString().Split();
                    //	var zone = row[3].ToString().Split();
                    //	var access = row[4].ToString().Split();


                    //	mpd.MaintenanceManual = string.Join(" ", maintenanceManual);
                    //	mpd.TaskCardNumber = string.Join(" ", cardNumber);
                    //	mpd.Zone = string.Join(" ", zone);
                    //	mpd.Access = string.Join(" ", access);

                    //	//mpd.Description = $"{row[5]} {row[6]}";//271 - 294

                    //	mpd.Description = row[6].ToString();
                    //	if (!string.IsNullOrEmpty(row[5].ToString()))
                    //		mpd.ManHours = Convert.ToDouble(row[5].ToString());

                    //	if(mpd.TaskNumberCheck.Length > 2)
                    //		mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(mpd.TaskNumberCheck.Substring(0, 2)));


                    //	mpd.ParentBaseComponent = bd;
                    //	env.Keeper.Save(mpd);
                    //	savedMpd = mpd;
                    //}

                    #endregion

                    #region CRJ

                    //if (row[0].ToString().Length == 0)
                    //	continue;

                    //var mpd = new MaintenanceDirective();

                    //var taskNumberCheck = row[1].ToString().Split();
                    //var taskCardNumber = row[0].ToString().Split();
                    //var access = row[3].ToString().Split();

                    //mpd.TaskNumberCheck = string.Join(" ", taskNumberCheck);
                    //mpd.TaskCardNumber = string.Join(" ", taskCardNumber);
                    //mpd.Description = row[2].ToString();
                    //mpd.Access = string.Join(" ", access);

                    //double q;
                    //if (!string.IsNullOrEmpty(row[4].ToString()) && double.TryParse(row[4].ToString(), out q))
                    //	mpd.ManHours = Convert.ToDouble(row[4].ToString());

                    //mpd.Remarks = $"{row[5]} {row[6]}";

                    //if(mpd.TaskNumberCheck.Length > 2)
                    //	mpd.ATAChapter = ata.FirstOrDefault(a => a.ShortName.Equals(mpd.TaskNumberCheck.Substring(0, 2)));

                    //mpd.ParentBaseComponent = bd;
                    //env.Keeper.Save(mpd);

                    #endregion
                }
            }
        }