Beispiel #1
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);
        }
Beispiel #2
0
        // import the repair order
        internal bool Import(RepairOrder repairOrder)
        {
            if (_Model.InDemo)
            {
                Thread.Sleep(1000);
                if (repairOrder.Quantity % 10 == 0 && repairOrder._File.FileId % 10 == 0)
                {
                    return(false);
                }
                return(true);
            }
            var ro = new Accelerator.EBS.SharedServices.RepairOrder();

            ro.Quantity           = repairOrder.Quantity;
            ro.UnitOfMeasure      = repairOrder.UnitOfMeasure;
            ro.ApprovalRequired   = repairOrder.ApprovalRequiredFlag;
            ro.Currency           = repairOrder.Currency;
            ro.ResourceID         = _Model.EbsOwnerId;
            ro.ProblemDescription = repairOrder.ProblemDescription;
            ro.ServiceRequestID   = _Model.EbsSrId;
            ro.SerialNumber       = repairOrder.SerialNumber;
            if (ro.ValidateSerialNumber(_Model.EbsContactOrgId, _Model.RntIncidentId, _Model.RntContactId))
            {
                ro.Create(_Model.RntIncidentId, _Model.RntContactId);
            }
            else
            {
                NoticeLog(string.Format("EBS Bulk Import cannot create a repair order because the serial number {0} is not valid", repairOrder.SerialNumber), null);
                return(false);
            }

            if (String.IsNullOrWhiteSpace(ro.RepairNumber))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        private void updateSelected(RoutedEventArgs e, object sender)
        {
            if (null == _Model.CurrentFile)
            {
                return;
            }
            DataGrid dg = sender as DataGrid;

            if (null == dg)
            {
                return;
            }
            if (!_Model.CurrentFile.IsImportEnabled)
            {
                return;
            }
            var col = dg.CurrentCell.Column;

            if (null == col)
            {
                return;
            }
            if (!((string)col.Header == "Selected"))
            {
                return;
            }
            RepairOrder item = dg.CurrentItem as RepairOrder;

            if (null == item)
            {
                return;
            }
            if (RepairOrder.ImportStatus.New != item.Status)
            {
                return;
            }
            item.Selected = !item.Selected;
            e.Handled     = true;
        }
Beispiel #4
0
     // parse the CSV file
 internal Collection<RepairOrder> Parse(Stream stream)
 {
     var items = new Collection<RepairOrder>();
     int max = _MaxPreview;
     int ret = max;
     if (_ShowAll | 0 == max)
     {
         max = 0;
     }
     else
     {
         max = _MaxPreview + 1;
     }
     CSV file = new CSV(stream, 
         hasHeaders: true, charDelimiter:',', charQuote:'"', charEscapeQuote:'\\', fileEncoding:Encoding.UTF8, maxRecords:max, name:Title);
     DataTable table = file.ToDataTable();
     if (null == table)
     {
         _Proxy.NoticeLog(string.Format("EBS Bulk Import cannot parse file {0} id {1}. Cannot create data table.", 
             Title, FileId), null);
         _JobStatus = JobStatus.ParseError;
         stream.Dispose();
         items.Clear();
         return items;
     }
     stream.Dispose();
     DataRowCollection rows = table.Rows;
     int rowCount = rows.Count;
     ret = rowCount;
     if (0 == rowCount || (rowCount <= _MaxPreview) || (0 == max))
     {
         _LoadedAll = true;
         IsShowAllEnabled = false;
     }
     else if (rowCount == (_MaxPreview + 1))
     {
         _LoadedAll = false;
         IsShowAllEnabled = true;
         ret = rowCount - 1;
     }
     else
     {
         _LoadedAll = false;
         IsShowAllEnabled = true;
     }
     int i = 0;
     foreach (DataRow row in rows)
     {
         if (++i > ret)
         {
             break;
         }
         var item = new RepairOrder(
                 this,
                 this._Model.EbsSrId,
                 Convert.ToString(row.Field<object>("PROBLEM_DESCRIPTION")),
                 0,
                 Convert.ToString(row.Field<object>("APPROVAL_REQUIRED_FLAG")),
                 Convert.ToDecimal(row.Field<object>("REPAIR_TYPE_ID")),
                 Convert.ToDecimal(row.Field<object>("QUANTITY")),
                 Convert.ToString(row.Field<object>("UNIT_OF_MEASURE")),
                 Convert.ToString(row.Field<object>("CURRENCY_CODE")),
                 0
             );
         item.SerialNumber = Convert.ToString(row.Field<object>("SERIAL_NUMBER"));                
         items.Add(item);
     }
     return items;
 }
Beispiel #5
0
        // parse the CSV file
        internal Collection <RepairOrder> Parse(Stream stream)
        {
            var items = new Collection <RepairOrder>();
            int max   = _MaxPreview;
            int ret   = max;

            if (_ShowAll | 0 == max)
            {
                max = 0;
            }
            else
            {
                max = _MaxPreview + 1;
            }
            CSV file = new CSV(stream,
                               hasHeaders: true, charDelimiter: ',', charQuote: '"', charEscapeQuote: '\\', fileEncoding: Encoding.UTF8, maxRecords: max, name: Title);
            DataTable table = file.ToDataTable();

            if (null == table)
            {
                _Proxy.NoticeLog(string.Format("EBS Bulk Import cannot parse file {0} id {1}. Cannot create data table.",
                                               Title, FileId), null);
                _JobStatus = JobStatus.ParseError;
                stream.Dispose();
                items.Clear();
                return(items);
            }
            stream.Dispose();
            DataRowCollection rows = table.Rows;
            int rowCount           = rows.Count;

            ret = rowCount;
            if (0 == rowCount || (rowCount <= _MaxPreview) || (0 == max))
            {
                _LoadedAll       = true;
                IsShowAllEnabled = false;
            }
            else if (rowCount == (_MaxPreview + 1))
            {
                _LoadedAll       = false;
                IsShowAllEnabled = true;
                ret = rowCount - 1;
            }
            else
            {
                _LoadedAll       = false;
                IsShowAllEnabled = true;
            }
            int i = 0;

            foreach (DataRow row in rows)
            {
                if (++i > ret)
                {
                    break;
                }
                var item = new RepairOrder(
                    this,
                    this._Model.EbsSrId,
                    Convert.ToString(row.Field <object>("PROBLEM_DESCRIPTION")),
                    0,
                    Convert.ToString(row.Field <object>("APPROVAL_REQUIRED_FLAG")),
                    Convert.ToDecimal(row.Field <object>("REPAIR_TYPE_ID")),
                    Convert.ToDecimal(row.Field <object>("QUANTITY")),
                    Convert.ToString(row.Field <object>("UNIT_OF_MEASURE")),
                    Convert.ToString(row.Field <object>("CURRENCY_CODE")),
                    0
                    );
                item.SerialNumber = Convert.ToString(row.Field <object>("SERIAL_NUMBER"));
                items.Add(item);
            }
            return(items);
        }