Esempio n. 1
0
 private void AddDummyRecords(ImportFile importFile)
 {
     foreach (var item in GetDummyRecords(importFile))
     {
         importFile.RepairOrders.Add(item);
     }
 }
Esempio n. 2
0
 internal void MarkFileImported(ImportFile file)
 {
     if (!_Model.InDemo)
     {
         _Addin.MarkFileImported(file);
     }
 }
Esempio n. 3
0
        // get dummy records
        private Collection <RepairOrder> GetDummyRecords(ImportFile importFile)
        {
            int j     = _Model.MaxPreview == 0 ? 50 : _Model.MaxPreview;
            var items = new Collection <RepairOrder>();

            for (int i = 0; i < j; i++)
            {
                Thread.Sleep(100);
                var item = new RepairOrder(
                    importFile,
                    60932,
                    string.Format("Lorem ipsum dolor sit amet {0:000}", i + 1),
                    67661,
                    "Y",
                    5,
                    (i + 1),
                    "Ea",
                    "USD",
                    100003628
                    );
                item.SerialNumber = "EM1234567";
                items.Add(item);
            }
            importFile._LoadedAll = true;
            importFile.RefreshStatus();
            return(items);
        }
Esempio n. 4
0
 internal RepairOrder(
     ImportFile file,
     decimal serviceRequestId,
     string problemDescription,
     decimal inventoryItemID,
     string approvalRequiredFlag,
     decimal typeID,
     decimal quantity,
     string unit,
     string currency,
     decimal? resourceID
     )
 {
     _File = file;
     _serviceRequestId = serviceRequestId;
     ProblemDescription = problemDescription;
     InventoryItemId = inventoryItemID;
     ApprovalRequiredFlag = approvalRequiredFlag;
     RepairTypeId = typeID;
     Quantity = quantity;
     UnitOfMeasure = unit;
     Currency = currency;
     ResourceId = resourceID;
     _Status = ImportStatus.New;
 }
Esempio n. 5
0
        private void SwitchFile(ListView aList, RoutedEventArgs e)
        {
            ImportFile importFile = aList.SelectedItem as ImportFile;

            if (aList.SelectedIndex == -1)
            {
                return;
            }
            if (FileIsNotCurrent())
            {
                return;
            }
            if (_LastSelectionTime.ElapsedMilliseconds < 400)
            {
                aList.SelectedIndex         = _PreviousIndex;
                _Model.CurrentFile          = _PreviousFile;
                importFileList.SelectedItem = _PreviousFile;
                repairOrderList.ItemsSource = _PreviousFile.RepairOrders;
            }
            else
            {
                _PreviousIndex              = aList.SelectedIndex;
                _PreviousFile               = _Model.CurrentFile;
                _Model.CurrentFile          = importFile;
                importFileList.SelectedItem = importFile;
                repairOrderList.ItemsSource = importFile.RepairOrders;
                importFile._ShowAll         = false;
                _Model.loadFile(importFile);
                _LastSelectionTime.Restart();
            }
            e.Handled = true;
        }
Esempio n. 6
0
 internal RepairOrder(
     ImportFile file,
     decimal serviceRequestId,
     string problemDescription,
     decimal inventoryItemID,
     string approvalRequiredFlag,
     decimal typeID,
     decimal quantity,
     string unit,
     string currency,
     decimal?resourceID
     )
 {
     _File                = file;
     _serviceRequestId    = serviceRequestId;
     ProblemDescription   = problemDescription;
     InventoryItemId      = inventoryItemID;
     ApprovalRequiredFlag = approvalRequiredFlag;
     RepairTypeId         = typeID;
     Quantity             = quantity;
     UnitOfMeasure        = unit;
     Currency             = currency;
     ResourceId           = resourceID;
     _Status              = ImportStatus.New;
 }
Esempio n. 7
0
 // get a dummy file
 internal ImportFile GetDummyFile()
 {
     string name = string.Format("Repair_Orders_{0:000}.csv", 2);
     var file = new ImportFile(this._Model, 2, name, name, name);
     AddDummyRecords(file);
     return file;
 }
Esempio n. 8
0
        // get a dummy file
        internal ImportFile GetDummyFile()
        {
            string name = string.Format("Repair_Orders_{0:000}.csv", 2);
            var    file = new ImportFile(this._Model, 2, name, name, name);

            AddDummyRecords(file);
            return(file);
        }
 // initialize control
 private void InitializeControl(Proxy proxy)
 {
     _Model = new BulkImportViewModel(proxy, this);
     _DefaultFile = new ImportFile(_Model, 0, string.Empty, string.Empty, string.Empty);
     _LastSelectionTime = new Stopwatch();
     _LastSelectionTime.Restart();
     _PreviousIndex = -1;
     _PreviousFile = _DefaultFile;
     this.Loaded += MainWindow_Loaded;
 }
 // initialize control
 private void InitializeControl(Proxy proxy)
 {
     _Model             = new BulkImportViewModel(proxy, this);
     _DefaultFile       = new ImportFile(_Model, 0, string.Empty, string.Empty, string.Empty);
     _LastSelectionTime = new Stopwatch();
     _LastSelectionTime.Restart();
     _PreviousIndex = -1;
     _PreviousFile  = _DefaultFile;
     this.Loaded   += MainWindow_Loaded;
 }
Esempio n. 11
0
 private bool AlreadyPresent(ImportFile file)
 {
     foreach (var f in ImportFileList)
     {
         if (f.FileId == file.FileId)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 12
0
        // load the file
        internal Collection <RepairOrder> LoadFile(ImportFile importFile)
        {
            var items = new Collection <RepairOrder>();

            if (_Model.InDesignMode || _Model.InDemo)
            {
                items = GetDummyRecords(importFile);
                if (_Model.InDemo && importFile.FileId % 7 == 0)
                {
                    importFile._JobStatus = ImportFile.JobStatus.ParseError;
                    items.Clear();
                }
            }
            else if (!_Model.InDesignMode && null != _Addin)
            {
                items = importFile.Parse(new MemoryStream(_Addin._rnSrv.getFileData(_Model.RntIncidentId, importFile.FileId)));
            }
            return(items);
        }
 void MainWindow_Loaded(object sender, RoutedEventArgs e)
 {
     this.DataContext = _Model;
     if (_Model.IsRecordLoaded || _Model.InDesignMode)
     {
         _Model.Render(true);
     }
     if (_Model.InDesignMode)
     {
         importFileList.SelectedIndex = 1;
         ImportFile importFile = _Model._Proxy.GetDummyFile();
         importFile._ShowAll         = false;
         repairOrderList.ItemsSource = importFile.RepairOrders;
         _Model.CurrentFile          = importFile;
         importFile.IsImportEnabled  = true;
         _Model.InDemo = true;
         importFile.SelectAll();
         _Model._Filter        = "Search";
         fileFilter.Foreground = Brushes.Gray;
         _Model.IsRunning      = true;
     }
 }
Esempio n. 14
0
 internal void MarkFileImported(ImportFile file)
 {
     if (!_Model.InDemo)
     {
         _Addin.MarkFileImported(file);
     }
 }
Esempio n. 15
0
 private void AddDummyRecords(ImportFile importFile)
 {
     foreach (var item in GetDummyRecords(importFile))
     {
         importFile.RepairOrders.Add(item);
     }
 }
Esempio n. 16
0
     // get dummy records
 private Collection<RepairOrder> GetDummyRecords(ImportFile importFile)
 {
     int j = _Model.MaxPreview == 0 ? 50 : _Model.MaxPreview;
     var items = new Collection<RepairOrder>();
     for (int i = 0; i < j; i++)
     {
         Thread.Sleep(100);
         var item = new RepairOrder(
                 importFile,
                 60932,
                 string.Format("Lorem ipsum dolor sit amet {0:000}", i + 1),
                 67661,
                 "Y",
                 5,
                 (i+1),
                 "Ea",
                 "USD",
                 100003628
             );
         item.SerialNumber = "EM1234567";
         items.Add(item);
     }
     importFile._LoadedAll = true;
     importFile.RefreshStatus();
     return items;
 }
Esempio n. 17
0
     // load the file
 internal Collection<RepairOrder> LoadFile(ImportFile importFile)
 {
     var items = new Collection<RepairOrder>();
     if (_Model.InDesignMode || _Model.InDemo)
     {
         items = GetDummyRecords(importFile);
         if (_Model.InDemo && importFile.FileId % 7 == 0)
         {
             importFile._JobStatus = ImportFile.JobStatus.ParseError;
             items.Clear();
         }
     }
     else if (!_Model.InDesignMode && null != _Addin)
     {
         items = importFile.Parse(new MemoryStream(_Addin._rnSrv.getFileData(_Model.RntIncidentId, importFile.FileId)));
     }
     return items;
 }
 private void SwitchFile(ListView aList, RoutedEventArgs e)
 {
     ImportFile importFile = aList.SelectedItem as ImportFile;
     if (aList.SelectedIndex == -1) return;
     if (FileIsNotCurrent()) return;
     if (_LastSelectionTime.ElapsedMilliseconds < 400)
     {
         aList.SelectedIndex = _PreviousIndex;
         _Model.CurrentFile = _PreviousFile;
         importFileList.SelectedItem = _PreviousFile;
         repairOrderList.ItemsSource = _PreviousFile.RepairOrders;
     }
     else
     {
         _PreviousIndex = aList.SelectedIndex;
         _PreviousFile = _Model.CurrentFile;
         _Model.CurrentFile = importFile;
         importFileList.SelectedItem = importFile;
         repairOrderList.ItemsSource = importFile.RepairOrders;
         importFile._ShowAll = false;
         _Model.loadFile(importFile);
         _LastSelectionTime.Restart();
     }
     e.Handled = true;
 }
 private bool AlreadyPresent(ImportFile file)
 {
     foreach (var f in ImportFileList)
     {
         if (f.FileId == file.FileId)
             return true;
     }
     return false;
 }
Esempio n. 20
0
 internal void MarkFileImported(ImportFile importFile)
 {
     int id = importFile.FileId;
     IFAttachInc2 attach = null;
     if (null != _Incident && null != _Incident.FAttach2)
     {
         foreach (var f in _Incident.FAttach2)
         {
             if (f.ID == id)
             {
                 attach = f;
                 break;
             }
         }
     }
     if (null == attach) return;
     // update the description of an incident's attachment
     Incident incident = new Incident();
     incident.ID = new ID();
     incident.ID.id = _Incident.ID;
     incident.ID.idSpecified = true;
     FileAttachmentIncident file = new FileAttachmentIncident();
     file.ID = new ID();
     file.ID.id = id;
     file.ID.idSpecified = true;
     file.action = ActionEnum.update;
     file.actionSpecified = true;
     file.Private = attach.Private;
     file.PrivateSpecified = true;
     bool updated;
     switch (importFile.StatusCode)
     {
         case 70:
         case 75:
             file.Description = importFile.Description +  string.Format("{{{0:00}}}", importFile.StatusCode);
             updated = true;
             break;
         default:
             updated = false;
             break;
     }
     if (updated)
     {
         incident.FileAttachments = new FileAttachmentIncident[1] { file };
         try
         {
             _rnSrv.updateObject(new RNObject[1] { incident });
         }
         catch (Exception ex)
         {
             _Model._Proxy.NoticeLog(String.Format("EBS Bulk Import failed to update the description of file {0}, id {1}",
                 importFile.Name, id), ex.Message);
         }
     }
 }
Esempio n. 21
0
     // get the import files
 internal Collection<ImportFile> GetImportFileList()
 {
     Collection<ImportFile> result = new Collection<ImportFile>();
     if (_Model.InDesignMode)
     {
         for (int i = 1; i < 50; i++)
         {
             string name = string.Format("Repair_Orders_{0:000}.csv", i);
             ImportFile file;
             file = new ImportFile(_Model, i, name, name, name);
             switch (i)
             {
                 case 1:
                     file._JobStatus = ImportFile.JobStatus.Load;
                     break;
                 case 2:
                     file._JobStatus = ImportFile.JobStatus.Loaded;
                     AddDummyRecords(file);
                     break;
                 case 3:
                     file._JobStatus = ImportFile.JobStatus.ParseError;
                     break;
                 case 4:
                     file._JobStatus = ImportFile.JobStatus.Loading;
                     break;
                 case 5:
                     file._JobStatus = ImportFile.JobStatus.Importing;
                     file.ProgressPercent = 50;
                     break;
                 case 6:
                     file._JobStatus = ImportFile.JobStatus.Done;
                     file.ProgressPercent = 100;
                     break;
                 case 7:
                     file._JobStatus = ImportFile.JobStatus.DoneError;
                     file.ProgressPercent = 100;
                     break;
                 case 8:
                     file._JobStatus = ImportFile.JobStatus.AllDone;
                     file.ProgressPercent = 100;
                     break;
                 case 9:
                     file._JobStatus = ImportFile.JobStatus.AllDoneError;
                     file.ProgressPercent = 100;
                     break;
                 default:
                     break;
             }
             file.RefreshStatus();
             result.Add(file);
         }
     }
     else if (_Model.InDemo)
     {
         for (int i = 1; i <= 50; i++)
         {
             string name = string.Format("Repair_Orders_{0:000}.csv", i);
             string description = name;
             if (i % 5 == 0) description += " {70}";
             if (i % 7 == 0) description += " {75}";
             var file = new ImportFile(_Model, i, name, name, description);
             result.Add(file);
         }
     }
     else if (null != _Addin && null != _Addin._Incident)
     {
         foreach (var f in _Addin._Incident.FAttach2)
         {
             if (isValid(f))
             {
                 string name = String.IsNullOrWhiteSpace(f.Name) ? f.UserFName : f.Name;
                 var impf = new ImportFile(_Model, f.ID, f.UserFName,
                     name,  
                     f.Descr );
                 result.Add(impf);
             }
         }
     }
     return result;
 }
Esempio n. 22
0
        internal void MarkFileImported(ImportFile importFile)
        {
            int          id     = importFile.FileId;
            IFAttachInc2 attach = null;

            if (null != _Incident && null != _Incident.FAttach2)
            {
                foreach (var f in _Incident.FAttach2)
                {
                    if (f.ID == id)
                    {
                        attach = f;
                        break;
                    }
                }
            }
            if (null == attach)
            {
                return;
            }
            // update the description of an incident's attachment
            Incident incident = new Incident();

            incident.ID             = new ID();
            incident.ID.id          = _Incident.ID;
            incident.ID.idSpecified = true;
            FileAttachmentIncident file = new FileAttachmentIncident();

            file.ID               = new ID();
            file.ID.id            = id;
            file.ID.idSpecified   = true;
            file.action           = ActionEnum.update;
            file.actionSpecified  = true;
            file.Private          = attach.Private;
            file.PrivateSpecified = true;
            bool updated;

            switch (importFile.StatusCode)
            {
            case 70:
            case 75:
                file.Description = importFile.Description + string.Format("{{{0:00}}}", importFile.StatusCode);
                updated          = true;
                break;

            default:
                updated = false;
                break;
            }
            if (updated)
            {
                incident.FileAttachments = new FileAttachmentIncident[1] {
                    file
                };
                try
                {
                    _rnSrv.updateObject(new RNObject[1] {
                        incident
                    });
                }
                catch (Exception ex)
                {
                    _Model._Proxy.NoticeLog(String.Format("EBS Bulk Import failed to update the description of file {0}, id {1}",
                                                          importFile.Name, id), ex.Message);
                }
            }
        }
Esempio n. 23
0
 // load the file
 internal void loadFile(ImportFile importFile)
 {
     importFile.Load();
 }
Esempio n. 24
0
        // get the import files
        internal Collection <ImportFile> GetImportFileList()
        {
            Collection <ImportFile> result = new Collection <ImportFile>();

            if (_Model.InDesignMode)
            {
                for (int i = 1; i < 50; i++)
                {
                    string     name = string.Format("Repair_Orders_{0:000}.csv", i);
                    ImportFile file;
                    file = new ImportFile(_Model, i, name, name, name);
                    switch (i)
                    {
                    case 1:
                        file._JobStatus = ImportFile.JobStatus.Load;
                        break;

                    case 2:
                        file._JobStatus = ImportFile.JobStatus.Loaded;
                        AddDummyRecords(file);
                        break;

                    case 3:
                        file._JobStatus = ImportFile.JobStatus.ParseError;
                        break;

                    case 4:
                        file._JobStatus = ImportFile.JobStatus.Loading;
                        break;

                    case 5:
                        file._JobStatus      = ImportFile.JobStatus.Importing;
                        file.ProgressPercent = 50;
                        break;

                    case 6:
                        file._JobStatus      = ImportFile.JobStatus.Done;
                        file.ProgressPercent = 100;
                        break;

                    case 7:
                        file._JobStatus      = ImportFile.JobStatus.DoneError;
                        file.ProgressPercent = 100;
                        break;

                    case 8:
                        file._JobStatus      = ImportFile.JobStatus.AllDone;
                        file.ProgressPercent = 100;
                        break;

                    case 9:
                        file._JobStatus      = ImportFile.JobStatus.AllDoneError;
                        file.ProgressPercent = 100;
                        break;

                    default:
                        break;
                    }
                    file.RefreshStatus();
                    result.Add(file);
                }
            }
            else if (_Model.InDemo)
            {
                for (int i = 1; i <= 50; i++)
                {
                    string name        = string.Format("Repair_Orders_{0:000}.csv", i);
                    string description = name;
                    if (i % 5 == 0)
                    {
                        description += " {70}";
                    }
                    if (i % 7 == 0)
                    {
                        description += " {75}";
                    }
                    var file = new ImportFile(_Model, i, name, name, description);
                    result.Add(file);
                }
            }
            else if (null != _Addin && null != _Addin._Incident)
            {
                foreach (var f in _Addin._Incident.FAttach2)
                {
                    if (isValid(f))
                    {
                        string name = String.IsNullOrWhiteSpace(f.Name) ? f.UserFName : f.Name;
                        var    impf = new ImportFile(_Model, f.ID, f.UserFName,
                                                     name,
                                                     f.Descr);
                        result.Add(impf);
                    }
                }
            }
            return(result);
        }
     // load the file
 internal void loadFile(ImportFile importFile)
 {
     importFile.Load();
 }