Exemple #1
0
        private void import(object param)
        {
            ImportBase  import      = null;
            ImportParam importParam = (ImportParam)param;

            switch (importParam.ImportType)
            {
            case ImportType.Country:
                import = new ImportCountry(importParam.FileName, (ICountryService)importParam.Service[0]);
                break;

            case ImportType.Region:
                import =
                    new ImportRegion(importParam.FileName, (ICountryService)importParam.Service[0],
                                     (IRegionService)importParam.Service[1]);
                break;

            case ImportType.Store:
                import =
                    new ImportStore(importParam.FileName, (ICountryService)importParam.Service[0],
                                    (IRegionService)importParam.Service[1], (IStoreService)importParam.Service[2]);
                break;

            case ImportType.World:
                import = new ImportWorld(importParam.FileName, (IStoreService)importParam.Service[0]);
                break;

            case ImportType.HWGR:
                import = new ImportHWGRdb(importParam.FileName, (IStoreService)importParam.Service[0]);
                break;

            case ImportType.WGR:
                import = new ImportWGRdb2(importParam.FileName, (IStoreService)importParam.Service[0]);
                break;

            case ImportType.WorkingDays:
                import = new ImportYearlyWorkingDays(importParam.FileName, (ICountryService)importParam.Service[0]);
                break;

            case ImportType.Feast:
                import = new ImportFeasts(importParam.FileName, (ICountryService)importParam.Service[0]);
                break;

            case ImportType.Employee:
                import = new ImportEmployee(importParam.FileName, (IEmployeeService)importParam.Service[0]);
                break;

            case ImportType.LongTimeAbsence:
                import = new ImportLongTimeAbsence(importParam.FileName, (IEmployeeService)importParam.Service[0]);
                break;

            case ImportType.Absence:
                import =
                    new ImportAbsence(importParam.FileName,
                                      ((ICountryService)importParam.Service[0]).AbsenceService);
                break;

            case ImportType.TimePlanning:
                import =
                    new ImportTime(importParam.FileName,
                                   ((IEmployeeService)importParam.Service[0]).EmployeeTimeService,
                                   ImportTimeType.Planning);
                break;

            case ImportType.TimeRecording:
                import =
                    new ImportTime(importParam.FileName,
                                   ((IEmployeeService)importParam.Service[0]).EmployeeTimeService,
                                   ImportTimeType.Recording);
                break;

            case ImportType.ActualBusinessVolume:
                import = new ImportBusinessVolume((IStoreService)importParam.Service[0], BusinessVolumeType.Actual);
                break;

            case ImportType.TargetBusinessVolume:
                import = new ImportBusinessVolume((IStoreService)importParam.Service[0], BusinessVolumeType.Target);
                break;

            case ImportType.CashRegisterReceipt:
                import =
                    new ImportBusinessVolume((IStoreService)importParam.Service[0],
                                             BusinessVolumeType.CashRegisterReceipt);
                break;

            default:
                throw new NotSupported();
            }
            try
            {
                if (import != null)
                {
                    import.OnAllComplete         += OnAllComplete;
                    import.OnAllProgressChanged  += OnAllProgressChanged;
                    import.OnMessage             += OnMessage;
                    import.OnTaskComplete        += OnTaskComplete;
                    import.OnTaskProgressChanged += OnTaskProgressChanged;
                    import.Run();
                }
                else
                {
                    if (OnAllComplete != null)
                    {
                        OnAllComplete(this, new CompleteEventArgs(true));
                    }
                }
            }
            catch (Exception ex)
            {
                if (OnMessage != null)
                {
                    OnMessage(this, new MessageEventArgs(ex.Message));
                }
                if (OnAllComplete != null)
                {
                    OnAllComplete(this, new CompleteEventArgs(false));
                }
            }
        }
Exemple #2
0
 private void import(object param)
 {
     ImportBase import = null;
     ImportParam importParam = (ImportParam) param;
     switch (importParam.ImportType)
     {
         case ImportType.Country:
             import = new ImportCountry(importParam.FileName, (ICountryService) importParam.Service[0]);
             break;
         case ImportType.Region:
             import =
                 new ImportRegion(importParam.FileName, (ICountryService) importParam.Service[0],
                                  (IRegionService) importParam.Service[1]);
             break;
         case ImportType.Store:
             import =
                 new ImportStore(importParam.FileName, (ICountryService) importParam.Service[0],
                                 (IRegionService) importParam.Service[1], (IStoreService) importParam.Service[2]);
             break;
         case ImportType.World:
             import = new ImportWorld(importParam.FileName, (IStoreService) importParam.Service[0]);
             break;
         case ImportType.HWGR:
             import = new ImportHWGRdb(importParam.FileName, (IStoreService) importParam.Service[0]);
             break;
         case ImportType.WGR:
             import = new ImportWGRdb2(importParam.FileName, (IStoreService) importParam.Service[0]);
             break;
         case ImportType.WorkingDays:
             import = new ImportYearlyWorkingDays(importParam.FileName, (ICountryService) importParam.Service[0]);
             break;
         case ImportType.Feast:
             import = new ImportFeasts(importParam.FileName, (ICountryService) importParam.Service[0]);
             break;
         case ImportType.Employee:
             import = new ImportEmployee(importParam.FileName, (IEmployeeService) importParam.Service[0]);
             break;
         case ImportType.LongTimeAbsence:
             import = new ImportLongTimeAbsence(importParam.FileName, (IEmployeeService) importParam.Service[0]);
             break;
         case ImportType.Absence:
             import =
                 new ImportAbsence(importParam.FileName,
                                   ((ICountryService) importParam.Service[0]).AbsenceService);
             break;
         case ImportType.TimePlanning:
             import =
                 new ImportTime(importParam.FileName,
                                ((IEmployeeService) importParam.Service[0]).EmployeeTimeService,
                                ImportTimeType.Planning);
             break;
         case ImportType.TimeRecording:
             import =
                 new ImportTime(importParam.FileName,
                                ((IEmployeeService) importParam.Service[0]).EmployeeTimeService,
                                ImportTimeType.Recording);
             break;
         case ImportType.ActualBusinessVolume:
             import = new ImportBusinessVolume((IStoreService) importParam.Service[0], BusinessVolumeType.Actual);
             break;
         case ImportType.TargetBusinessVolume:
             import = new ImportBusinessVolume((IStoreService) importParam.Service[0], BusinessVolumeType.Target);
             break;
         case ImportType.CashRegisterReceipt:
             import =
                 new ImportBusinessVolume((IStoreService) importParam.Service[0],
                                          BusinessVolumeType.CashRegisterReceipt);
             break;
         default:
             throw new NotSupported();
     }
     try
     {
         if (import != null)
         {
             import.OnAllComplete += OnAllComplete;
             import.OnAllProgressChanged += OnAllProgressChanged;
             import.OnMessage += OnMessage;
             import.OnTaskComplete += OnTaskComplete;
             import.OnTaskProgressChanged += OnTaskProgressChanged;
             import.Run();
         }
         else
         {
             if (OnAllComplete != null)
             {
                 OnAllComplete(this, new CompleteEventArgs(true));
             }
         }
     }
     catch (Exception ex)
     {
         if (OnMessage != null)
         {
             OnMessage(this, new MessageEventArgs(ex.Message));
         }
         if (OnAllComplete != null)
         {
             OnAllComplete(this, new CompleteEventArgs(false));
         }
     }
 }