Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, RepairOrder repairOrder)
        {
            if (id != repairOrder.Id)
            {
                return(NotFound());
            }

            if (!ModelState.IsValid)
            {
                var viewModel = await GetRepairOrderViewModelWithAllTools();

                viewModel.RepairOrder = repairOrder;

                return(View(viewModel));
            }

            try
            {
                _context.Update(repairOrder);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RepairOrderExists(repairOrder.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
 public ActionResult Create(RepairOrder repairOrder, FormCollection collection)
 {
     // TODO: Uncomment bottom redirect to go to unimplemented details views.
     db.Add(repairOrder);
     return(RedirectToAction("Index"));
     //return RedirectToAction("Details", new { id = repairOrder.Id });
 }
Exemplo n.º 3
0
        private void bw_LoadRODetails(object sender, DoWorkEventArgs e)
        {
            string      logMessage, logNote;
            string      repairNum = (string)e.Argument;
            RepairOrder ro        = new RepairOrder();

            try
            {
                ro       = ro.Lookup(repairNum, _logIncidentId, 0);
                e.Result = ro;
            }
            catch (Exception ex)
            {
                e.Cancel = true;
                bw_roList.CancelAsync();

                string message = ex.Message;
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                logMessage = "Error in loading Repair Order. Error: " + ex.Message;
                _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage);
                return;
            }
            if (ro.ErrorMessage != null)
            {
                e.Cancel   = true;
                logMessage = "Loading Repair Order is failed. RO Num = " + repairNum;
                logNote    = "Response shows error code when loading repair order. Response's error message: " + ro.ErrorMessage;
                _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                return;
            }
        }
Exemplo n.º 4
0
        public IHttpActionResult PutRepairOrder(int id, RepairOrder repairOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != repairOrder.ID)
            {
                return(BadRequest());
            }

            db.Entry(repairOrder).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RepairOrderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 5
0
        public async Task <InvokedResult> DeleteAsync(RepairOrder repairOrder)
        {
            DbContext.Set <RepairOrder>().Remove(repairOrder);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method which is invoked by the AddIn framework when the control is created.
        /// </summary>
        /// <param name="inDesignMode">Flag which indicates if the control is being drawn on the Workspace Designer. (Use this flag to determine if code should perform any logic on the workspace record)</param>
        /// <param name="RecordContext">The current workspace record context.</param>
        /// <returns>The control which implements the IWorkspaceComponent2 interface.</returns>
        public IWorkspaceComponent2 CreateControl(bool inDesignMode, IRecordContext RecordContext)
        {
            if (!ConfigurationSetting.configVerbPerfect)
            {
                if (!ConfigurationSetting.loginUserIsAdmin)
                {
                    MessageBox.Show("RepairOrderAddIn is not initialized properly. \nPlease contact your system administrator.\n You are now logged out.");
                    _gContext.Logout();
                }
                else // don't want to logout admin
                {
                    MessageBox.Show("RepairOrderAddIn is not loaded because of invalid configuration verb.");
                    return(new RepairOrderAddIn(inDesignMode, RecordContext, isEnabledEditing));
                }
            }

            _rContext = RecordContext;
            string logMessage, logNote;

            if (!inDesignMode && _rContext != null)
            {
                // Set config according to custom configuration verb
                ConfigurationSetting instance = ConfigurationSetting.Instance(_gContext);

                _usr = ConfigurationSetting.username;
                _pwd = ConfigurationSetting.password;
                _log = ConfigurationSetting.logWrap;
                _ebsDefaultSrOwnerId        = ConfigurationSetting.ebsDefaultSrOwnerId;
                RepairOrder.ServiceProvider = ConfigurationSetting.EBSProvider;
                RepairOrder.CreateURL       = ConfigurationSetting.CreateRepair_WSDL;
                RepairOrder.UpdateURL       = ConfigurationSetting.UpdateRepair_WSDL;
                //RepairOrder.LookupURL = ConfigurationSetting.LookupRepair_WSDL;
                //RepairOrder.ListLookupURL = ConfigurationSetting.LookupRepairList_WSDL;
                RepairOrder.ListURL              = ConfigurationSetting.RepairOrderList_WSDL;
                RepairOrder.ServiceUsername      = _usr;
                RepairOrder.ServicePassword      = _pwd;
                RepairOrder.ServiceClientTimeout = ConfigurationSetting.EBSServiceTimeout;
                RepairOrder.InitEBSProvider();
                logMessage = "Repair Order is initiated.";
                logNote    = "";
                _log.DebugLog(logMessage: logMessage, logNote: logNote);
            }

            /*
             * bool isEnabled = false;
             * if (isEnabledEditing == "true")
             * {
             *  isEnabled = true;
             * }*/
            _wsAddIn      = new RepairOrderAddIn(inDesignMode, _rContext, isEnabledEditing);
            _wsAddIn._log = _log;
            _wsAddIn._ebsDefaultSrOwnerId = _ebsDefaultSrOwnerId;
            if (_log != null)
            {
                logMessage = "Repair Order AddIn is setup.";
                logNote    = "";
                _log.DebugLog(logMessage: logMessage, logNote: logNote);
            }
            return(_wsAddIn);
        }
Exemplo n.º 7
0
        public async Task <InvokedResult> CreateRepairOrder(RepairOrder repairOrder)
        {
            DbContext.Set <RepairOrder>().Add(repairOrder);
            await DbContext.SaveChangesAsync();

            return(InvokedResult.SucceededResult);
        }
Exemplo n.º 8
0
        public void Add_Repair_Order_With_Service_Contracts()
        {
            var api = Credentials.GetAPI();

            var ro = new RepairOrder
            {
                CustomerNumber  = "4232734",
                VIN             = "JTHFF2C20B2515555",
                ServiceWriterID = "999",
                OdometerIn      = "40602",
                LineItems       = new List <LineItem> {
                    new LineItem {
                        LaborOpCode                   = "*",
                        ServiceLineNumber             = "1",
                        LineType                      = "A",
                        TransCode                     = "SC",
                        Comments                      = "Test",
                        ServiceType                   = "MR",
                        ServiceDepartmentKey          = "6",
                        ServiceContractSequenceNumber = "1"
                    }
                },
                TagNumber = string.Empty
            };

            var addRoResponse =
                api.AddRepairOrder(new AddRepairOrderRequest("CRMT", "BH1")
            {
                RO = ro
            });
        }
Exemplo n.º 9
0
        /// <summary>
        /// Записывает информацию о созданном заказе.
        /// </summary>
        /// <param name="token">Текущие токен.</param>
        /// <param name="order">Созданный заказ.</param>
        public void TrackNewOrder(SecurityToken token, RepairOrder order)
        {
            _logger.InfoFormat("Записываем в историю создание нового заказа {0} пользователем {1}", order.RepairOrderID,
                               token.LoginName);
            var timeLine = CreateTimeline(order.RepairOrderID, TimelineKindSet.StatusChanged);

            string engineerName = string.Empty;
            string managerName  = string.Empty;

            var user = GetUser(token, order.EngineerID);

            if (user != null)
            {
                engineerName = user.ToString();
            } //if

            user = GetUser(token, order.ManagerID);
            if (user != null)
            {
                managerName = user.ToString();
            } //if

            timeLine.Title = string.Format("Новый заказ назначен на менеджера \"{0}\" и инженера \"{1}\" пользователем \"{2}\"", managerName,
                                           engineerName, token.User);

            SaveOrderTimeline(timeLine);
        }
Exemplo n.º 10
0
        // добавление данных по заявке
        public void AppendOrder(RepairOrder order)
        {
            // создание новой заявки/заказа на ремонт
            RepairOrder newOrder = new RepairOrder {
                Client  = GetClients().ToList().Find(c => c.Id == order.Client.Id),
                Car     = _db.Cars.ToList().Find(c => c.Id == order.Car.Id),
                Worker  = order.Worker,
                IsReady = order.IsReady,
                DateOfTheApplication = order.DateOfTheApplication,
            };

            foreach (var value in order.Malfunctions)
            {
                Malfunction templValue = _db.Malfunctions.First(m => m.Id == value.Id);
                newOrder.Malfunctions.Add(templValue);
            }

            _db.RepairOrders.Add(newOrder);
            _db.SaveChanges();

            // изменяем статус работника - работает сейчас
            ChangeWorker(order.Worker, _db.WorkerStatuses.ToList()[0]);
            // добавляем клиенту дату обращения
            AppendClientDate(order.Client);

            ++_countOfOrders;
        }
        private void bw_LoadROList(object sender, DoWorkEventArgs e)
        {
            string logMessage, logNote;
            var    sr_id  = "";
            var    sr_num = "";
            IList <ICustomAttribute> customAttributes = incident.CustomAttributes;

            string[] incCustomAttrs = { "Accelerator$ebs_sr_id", "Accelerator$ebs_sr_num" };
            Dictionary <String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(customAttributes, incCustomAttrs, this._logIncidentId, 0);

            sr_id  = incCustomAttrsResults["Accelerator$ebs_sr_id"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_id"].ToString() : "";
            sr_num = incCustomAttrsResults["Accelerator$ebs_sr_num"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_num"].ToString() : "";

            //Check incident whether associated to a service request
            if (!String.IsNullOrWhiteSpace(sr_id))
            {
                //If incident is related to a SR
                //Lookup repair order by service request id
                RepairOrder ro = new RepairOrder();

                RepairOrder[] results = null;
                try
                {
                    results  = ro.LookupList(sr_id, sr_num, _logIncidentId, 0);
                    e.Result = results;
                }
                catch (Exception ex)
                {
                    e.Cancel = true;
                    bw_roList.CancelAsync();

                    string message = ex.Message;
                    MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    logMessage = "Error in loading Repair Order List. Error: " + ex.Message;
                    _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage);
                    return;
                }

                if (ro.ErrorMessage != null)
                {
                    e.Cancel   = true;
                    logMessage = "Loading Repair Order List is failed. SR ID = " + sr_id;
                    logNote    = "Response shows error code when loading repair order list. Response's error message: " + ro.ErrorMessage;
                    _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                    return;
                }
                else
                {
                    logMessage = "Loading Repair Order List Successfully. Current Service Request has " + results.Length + " Repair Order(s)";
                    logNote    = "";
                    _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                }
            }
            else
            {
                e.Result = null;
            }
        }
Exemplo n.º 12
0
        public ActionResult DeleteConfirmed(int id)
        {
            RepairOrder repairOrder = db.RepairOrders.Find(id);

            db.RepairOrders.Remove(repairOrder);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 13
0
 public void CreateRepairOrder(RepairOrder repairOrder)
 {
     using (FibrellaContext context = new FibrellaContext())
     {
         context.RepairOrders.Add(repairOrder);
         context.SaveChanges();
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Сохраняет в базе модель редактирования заказа.
        /// </summary>
        /// <param name="token">Токен безопасности.</param>
        /// <param name="model">Модель редактирования.</param>
        /// <param name="result">Результат корректности модели.</param>
        /// <returns>Модель пункта грида.</returns>
        public static RepairOrderGridItemModel SaveEditRepairOrderGridItemModel(SecurityToken token, RepairOrderEditModel model, JGridSaveModelResult result)
        {
            var entity = RemontinkaServer.Instance.EntitiesFacade.GetOrder(token, model.Id);

            RiseExceptionIfNotFound(entity, model.Id, "Заказ");

            var oldEntity = new RepairOrder();

            entity.CopyTo(oldEntity);

            if (ProjectRoleSet.UserHasRole(token.User.ProjectRoleID, ProjectRoleSet.Engineer))//Если пользователь инженер, тогда даем ему право изменять только статус заказа
            {
                entity.OrderStatusID  = model.RepairOrderStatusID;
                entity.Recommendation = model.Recommendation;
            } //if
            else
            {
                //TODO Сделать трекинг изменений в OrderTimeline
                entity.BranchID         = model.BranchID;
                entity.CallEventDate    = model.CallEventDate;
                entity.ClientAddress    = model.ClientAddress;
                entity.ClientEmail      = model.ClientEmail;
                entity.ClientFullName   = model.ClientFullName;
                entity.ClientPhone      = model.ClientPhone;
                entity.DateOfBeReady    = model.DateOfBeReady;
                entity.Defect           = model.Defect;
                entity.DeviceAppearance = model.DeviceAppearance;
                entity.DeviceModel      = model.DeviceModel;
                entity.DeviceSN         = model.DeviceSN;
                entity.DeviceTitle      = model.DeviceTitle;
                entity.DeviceTrademark  = model.DeviceTrademark;
                entity.EngineerID       = model.EngineerID;
                entity.GuidePrice       = model.GuidePrice;
                entity.IsUrgent         = model.IsUrgent;
                entity.IssueDate        = model.IssueDate;
                if (entity.IssueDate != null && entity.IssuerID == null)
                {
                    entity.IssuerID = token.User.UserID;
                } //if
                //entity.IssuerID = model.is
                entity.ManagerID      = model.ManagerID;
                entity.Notes          = model.Notes;
                entity.Options        = model.Options;
                entity.OrderKindID    = model.OrderKindID;
                entity.OrderStatusID  = model.RepairOrderStatusID;
                entity.PrePayment     = model.PrePayment;
                entity.Recommendation = model.Recommendation;
                entity.WarrantyTo     = model.WarrantyTo;
            } //else

            RemontinkaServer.Instance.EntitiesFacade.SaveRepairOrder(token, entity);
            entity = RemontinkaServer.Instance.EntitiesFacade.GetOrder(token, entity.RepairOrderID);
            RiseExceptionIfNotFound(entity, model.Id, "Заказ");

            RemontinkaServer.Instance.OrderTimelineManager.TrackOrderChange(token, oldEntity, entity);

            return(CreateItemModel(entity));
        }
Exemplo n.º 15
0
 public ActionResult Create(RepairOrder repairOrder)
 {
     if (ModelState.IsValid)
     {
         db.Add(repairOrder);
         return(RedirectToAction("Details", new { id = repairOrder.Id }));
     }
     return(View());
 }
Exemplo n.º 16
0
        public ActionResult Add()
        {
            ViewBag.EmployeeList = EmployeeService.FindNormalList();

            var model = new RepairOrder();

            model.RepairOn = DateTime.Now;
            return(View("Edit", model));
        }
Exemplo n.º 17
0
        public void Update(RepairOrder repairOrder)
        {
            /*var r = Get(repairOrder.Id);
             * db.SaveChanges();*/
            var entry = db.Entry(repairOrder);

            entry.State = EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Сохраняет модель создаваемого заказа в хранилище.
        /// </summary>
        /// <param name="token">Токен безопасности</param>
        /// <param name="model">Модель для сохранения.</param>
        /// <param name="result">Модель результата модели. </param>
        /// <returns>Созданный пункт грида.</returns>
        public static RepairOrderGridItemModel SaveCreateRepairOrderGridItemModel(SecurityToken token,
                                                                                  RepairOrderCreateModel model, JGridSaveModelResult result)
        {
            var entity = new RepairOrder();

            entity.BranchID         = model.BranchID;
            entity.CallEventDate    = model.CallEventDate;
            entity.ClientAddress    = model.ClientAddress;
            entity.ClientEmail      = model.ClientEmail;
            entity.ClientFullName   = model.ClientFullName;
            entity.ClientPhone      = model.ClientPhone;
            entity.DateOfBeReady    = model.DateOfBeReady;
            entity.Defect           = model.Defect;
            entity.DeviceAppearance = model.DeviceAppearance;
            entity.DeviceModel      = model.DeviceModel;
            entity.DeviceSN         = model.DeviceSN;
            entity.DeviceTitle      = model.DeviceTitle;
            entity.DeviceTrademark  = model.DeviceTrademark;
            entity.EngineerID       = model.EngineerID;
            entity.EventDate        = DateTime.Now;
            entity.GuidePrice       = model.GuidePrice;
            entity.IsUrgent         = model.IsUrgent;
            entity.IssueDate        = null;
            entity.IssuerID         = null;
            entity.ManagerID        = model.ManagerID;
            entity.Notes            = model.Notes;
            entity.Number           = model.Number;
            entity.Options          = model.Options;
            entity.OrderKindID      = model.OrderKindID;
            DataLayer.Entities.OrderStatus status;
            if (entity.EngineerID == null)
            {
                status =
                    RemontinkaServer.Instance.EntitiesFacade.GetOrderStatusByKind(token,
                                                                                  StatusKindSet.New.StatusKindID);
            } //if
            else
            {
                status =
                    RemontinkaServer.Instance.EntitiesFacade.GetOrderStatusByKind(token,
                                                                                  StatusKindSet.OnWork.StatusKindID);
            } //else

            entity.OrderStatusID  = status.OrderStatusID;
            entity.PrePayment     = model.PrePayment;
            entity.Recommendation = null;
            entity.WarrantyTo     = DateTime.Today;
            entity.AccessPassword = RemontinkaServer.Instance.CryptoService.GeneratePassword(6, 6);

            RemontinkaServer.Instance.EntitiesFacade.SaveRepairOrder(token, entity);
            var savedItem = RemontinkaServer.Instance.EntitiesFacade.GetOrder(token, entity.RepairOrderID);

            RemontinkaServer.Instance.OrderTimelineManager.TrackNewOrder(token, savedItem);

            return(CreateItemModel(savedItem));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 假数据
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        private PageResult <List <RepairOrder> > GetUserList(PageabledEventArgs args)
        {
            PageResult <List <RepairOrder> > pageResult = new PageResult <List <RepairOrder> >();

            List <RepairOrder> result = new List <RepairOrder>();

            for (int i = 0; i < 2000; i++)
            {
                var model = new RepairOrder()
                {
                    Adress = "石岩",
                    AppointmentDateTime = DateTime.Now,
                    Brand            = "电器",
                    City             = "ab",
                    Code             = "10001" + i,
                    CustomName       = "夏磊" + i,
                    Description      = "ab",
                    DoorToDoorAmount = 30,
                    Gender           = Gender.Men,
                    VisitingDateTime = DateTime.Now.AddDays(0.5),


                    IsMaintenanceSuccessed = true,
                    IsEabled          = true,
                    MaintenanceAmount = 600,

                    MaintenanceMaster = "张师傅",
                    CreateUserId      = 1,
                    CreateUserName    = "******",
                    CreateTime        = DateTime.Now,
                    Remark            = "此人是歌神",
                    Sort           = i + 1,
                    UpdateUserId   = 1,
                    UpdateUserName = "******",
                    UpdateTime     = DateTime.Now
                };
                if (i % 2 == 0)
                {
                    model.Gender = Gender.Men;
                }
                result.Add(model);
            }
            var count = result.Count();

            if (args != null)
            {
                if (!string.IsNullOrEmpty(args.Key))
                {
                    result = result.Where(exp => exp.Code.Contains(args.Key)).ToList();
                    count  = result.Count();
                }
            }
            pageResult.Data  = result.Skip((args.PageIndex - 1) * args.PageSize).Take(args.PageSize).ToList();
            pageResult.Total = count;
            return(pageResult);
        }
        /// <summary>
        /// 新建报修.
        /// </summary>
        /// /// <param name="order">传入数据.</param>
        /// <returns>Json.</returns>
        public ActionResult AddRepair(RepairOrder order)
        {
            // 自增列用法
            int orderId = Db.Insertable(order).ExecuteReturnIdentity();

            order.Id         = orderId;
            order.CreateTime = DateTime.Now.ToString();
            Db.Updateable(order).ExecuteCommand();
            return(Json(new { code = 200 }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
 public ActionResult Edit([Bind(Include = "Id,StartDate,EndDate,Status,Counter")] RepairOrder repairOrder)
 {
     if (ModelState.IsValid)
     {
         db.Entry(repairOrder).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(repairOrder));
 }
Exemplo n.º 22
0
        public IHttpActionResult GetRepairOrder(int id)
        {
            RepairOrder repairOrder = db.RepairOrders.Find(id);

            if (repairOrder == null)
            {
                return(NotFound());
            }

            return(Ok(repairOrder));
        }
        public void Update_Repair_Order_Lines()
        {
            // arrange
            var api = Credentials.GetAPI();

            var customer =
                api.FindCustomers(new CustomerSearchRequest(Credentials.EnterpriseCode, Credentials.DealerNumber) { LastName = "Smith" })
                    .CustomerSearchResult.First(c => c.Vehicles != null && c.Vehicles.Any());
            var vehicleVin = customer.Vehicles.First();

            var advisor =
                api.GetServiceAdvisors(new ServiceWritersTableRequest(Credentials.EnterpriseCode,
                    Credentials.DealerNumber)).First();

            var ro = new RepairOrder
            {
                CustomerNumber = customer.CustomerNumber,
                VIN = vehicleVin.Value,
                ServiceWriterID = advisor.ID,
                OdometerIn = "1",
                LineItems = new List<LineItem> { new LineItem { LaborOpCode = "*", ServiceLineNumber = "1", LineType = "A", TransCode = "CP", Comments = "Test", ServiceType = "MR" }},
                TagNumber = string.Empty
            };

            var addRoResponse =
                api.AddRepairOrder(new AddRepairOrderRequest(Credentials.EnterpriseCode, Credentials.DealerNumber)
                {
                    RO = ro
                });
            var roNumber = addRoResponse.RepairOrderNumber;

            var retreivedRo =
                api.FindOpenRepairOrders(new OpenRepairOrderLookup(Credentials.EnterpriseCode, Credentials.DealerNumber)
                {
                    RepairOrderNumber = roNumber
                }).First();
            // we need the op code line
            var detail = retreivedRo.Details.First(r => r.LineType == "A");

            // act
            var updateLineItemsRequest = new UpdateRepairOrderLinesRequest(Credentials.EnterpriseCode,
                Credentials.DealerNumber) { RepairOrderNumber = roNumber };
            var updateLineItem = new UpdateLineItem
            {
                ServiceLineNumber = Convert.ToInt32(detail.ServiceLineNumber),
                Technicians = new Technician[] { new Technician {  CauseStatement = "Test Cause"} }
            };
            updateLineItemsRequest.LineItems.Add(updateLineItem);
            var updateLineItemsResponse = api.UpdateRepairOrderLines(updateLineItemsRequest);

            // assert
            Assert.NotNull(updateLineItemsResponse);
            Assert.NotNull(updateLineItemsResponse.Success);
        }
 public void SetUp()
 {
     _service          = new RepairOrderServices();
     _emptyRepairOrder = new RepairOrder();
     _repairOrder      = new RepairOrder()
     {
         Id            = 1,
         StartDate     = DateTime.Today,
         CompletedData = DateTime.Today
     };
 }
Exemplo n.º 25
0
        /// <summary>
        /// Сохраняет в базе модель создания элемента.
        /// </summary>
        /// <param name="token">Токен безопасности.</param>
        /// <param name="model">Модель редактирования сущности для сохранения.</param>
        /// <param name="result">Результат с ошибками.</param>
        public override void SaveEditModel(SecurityToken token, RepairOrderEditModel model, SaveModelResult result)
        {
            var entity = ClientCore.Instance.DataStore.GetRepairOrder(model.Id);

            RiseExceptionIfNotFound(entity, model.Id, "Заказ");

            var oldEntity = new RepairOrder();

            entity.CopyTo(oldEntity);

            if (ProjectRoleSet.UserHasRole(token.User.ProjectRoleID, ProjectRoleSet.Engineer))
            {
                entity.OrderStatusIDGuid = model.RepairOrderStatusID;
            } //if
            else
            {
                //TODO Сделать трекинг изменений в OrderTimeline
                entity.BranchIDGuid          = model.BranchID;
                entity.CallEventDateDateTime = model.CallEventDate;
                entity.ClientAddress         = model.ClientAddress;
                entity.ClientEmail           = model.ClientEmail;
                entity.ClientFullName        = model.ClientFullName;
                entity.ClientPhone           = model.ClientPhone;
                entity.DateOfBeReadyDateTime = model.DateOfBeReady;
                entity.Defect            = model.Defect;
                entity.DeviceAppearance  = model.DeviceAppearance;
                entity.DeviceModel       = model.DeviceModel;
                entity.DeviceSN          = model.DeviceSN;
                entity.DeviceTitle       = model.DeviceTitle;
                entity.DeviceTrademark   = model.DeviceTrademark;
                entity.EngineerIDGuid    = model.EngineerID;
                entity.GuidePrice        = (double?)WpfUtils.StringToDecimal(model.GuidePrice);
                entity.IsUrgentBoolean   = model.IsUrgent;
                entity.IssueDateDateTime = model.IssueDate;
                if (entity.IssueDate != null && entity.IssuerID == null)
                {
                    entity.IssuerID = token.User.UserID;
                } //if

                entity.ManagerIDGuid      = model.ManagerID;
                entity.Notes              = model.Notes;
                entity.Options            = model.Options;
                entity.OrderKindIDGuid    = model.OrderKindID;
                entity.OrderStatusIDGuid  = model.RepairOrderStatusID;
                entity.PrePayment         = (double?)WpfUtils.StringToDecimal(model.PrePayment);
                entity.Recommendation     = model.Recommendation;
                entity.WarrantyToDateTime = model.WarrantyTo;
            } //else

            ClientCore.Instance.DataStore.SaveRepairOrder(entity);


            ClientCore.Instance.OrderTimelineManager.TrackOrderChange(token, oldEntity, entity);
        }
Exemplo n.º 26
0
        public RepairOrder GetRepairOrder(string searchString)
        {
            RepairOrder repair = new RepairOrder();

            using (FibrellaContext context = new FibrellaContext())
            {
                long convertedSmne = Convert.ToInt64(searchString);
                repair = context.RepairOrders.FirstOrDefault(z => z.SMNE == convertedSmne);
            }
            return(repair);
        }
Exemplo n.º 27
0
        public RepairOrder CreateTestRepairOrder()
        {
            var store       = CreateStore();
            var orderStatus = new OrderStatus();

            orderStatus.Title        = "Title";
            orderStatus.StatusKindID = StatusKindSet.Completed.StatusKindID;

            store.SaveOrderStatus(orderStatus);

            var item = new OrderKind();

            item.Title = "Title";
            store.SaveOrderKind(item);

            var branch = CreateTestBranch();
            var user   = CreateTestUser();

            var order = new RepairOrder();

            order.BranchID = branch.BranchID;
            order.CallEventDateDateTime = new DateTime(2015, 06, 01);
            order.ClientAddress         = "ClientAddress33323";
            order.ClientEmail           = "ClientEmail";
            order.ClientFullName        = "ClientFullName";
            order.ClientPhone           = "ClientPhone";
            order.DateOfBeReadyDateTime = new DateTime(2015, 07, 07);
            order.Defect             = "Defect";
            order.DeviceAppearance   = "DeviceAppearance";
            order.DeviceModel        = "DeviceModel";
            order.DeviceSN           = "DeviceSN";
            order.DeviceTitle        = "DeviceTitle";
            order.DeviceTrademark    = "DeviceTrademark";
            order.EngineerID         = user.UserID;
            order.EventDateDateTime  = new DateTime(2014, 02, 05);
            order.GuidePrice         = 44;
            order.IsUrgentBoolean    = true;
            order.IssueDateDateTime  = new DateTime(2013, 05, 04);
            order.IssuerID           = user.UserID;
            order.ManagerID          = user.UserID;
            order.Notes              = "Notes";
            order.Number             = "Number" + Guid.NewGuid();
            order.Options            = "Options";
            order.OrderKindID        = item.OrderKindID;
            order.OrderStatusID      = orderStatus.OrderStatusID;
            order.PrePayment         = 55;
            order.Recommendation     = "Recommendation";
            order.WarrantyToDateTime = new DateTime(2017, 01, 2);
            order.RepairOrderIDGuid  = _repairOrderId;
            store.SaveRepairOrder(order);

            return(order);
        }
Exemplo n.º 28
0
        /// <summary>
        /// Сохраняет в базе модель создания элемента.
        /// </summary>
        /// <param name="token">Токен безопасности.</param>
        /// <param name="model">Модель создания сущности для сохранения.</param>
        /// <param name="result">Результат с ошибками.</param>
        public override void SaveCreateModel(SecurityToken token, RepairOrderCreateModel model, SaveModelResult result)
        {
            var entity = new RepairOrder();

            entity.BranchIDGuid          = model.BranchID;
            entity.CallEventDateDateTime = model.CallEventDate;
            entity.ClientAddress         = model.ClientAddress;
            entity.ClientEmail           = model.ClientEmail;
            entity.ClientFullName        = model.ClientFullName;
            entity.ClientPhone           = model.ClientPhone;
            entity.DateOfBeReadyDateTime = model.DateOfBeReady;
            entity.Defect            = model.Defect;
            entity.DeviceAppearance  = model.DeviceAppearance;
            entity.DeviceModel       = model.DeviceModel;
            entity.DeviceSN          = model.DeviceSN;
            entity.DeviceTitle       = model.DeviceTitle;
            entity.DeviceTrademark   = model.DeviceTrademark;
            entity.EngineerIDGuid    = model.EngineerID;
            entity.EventDateDateTime = DateTime.Now;
            entity.GuidePrice        = (double?)WpfUtils.StringToDecimal(model.GuidePrice);
            entity.IsUrgentBoolean   = model.IsUrgent;
            entity.IssueDate         = null;
            entity.IssuerID          = null;
            entity.ManagerIDGuid     = model.ManagerID;
            entity.Notes             = model.Notes;
            entity.Number            = model.Number;
            entity.Options           = model.Options;
            entity.OrderKindIDGuid   = model.OrderKindID;
            OrderStatus status;

            if (entity.EngineerID == null)
            {
                status =
                    ClientCore.Instance.DataStore.GetOrderStatusByKind(StatusKindSet.New.StatusKindID);
            } //if
            else
            {
                status =
                    ClientCore.Instance.DataStore.GetOrderStatusByKind(StatusKindSet.OnWork.StatusKindID);
            } //else

            entity.OrderStatusID      = status.OrderStatusID;
            entity.PrePayment         = (double?)WpfUtils.StringToDecimal(model.PrePayment);
            entity.Recommendation     = null;
            entity.WarrantyToDateTime = DateTime.Today;

            ClientCore.Instance.DataStore.SaveRepairOrder(entity);

            model.Id = entity.RepairOrderIDGuid;


            ClientCore.Instance.OrderTimelineManager.TrackNewOrder(token, entity);
        }
Exemplo n.º 29
0
        public IHttpActionResult PostRepairOrder(RepairOrder repairOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.RepairOrders.Add(repairOrder);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = repairOrder.ID }, repairOrder));
        }
Exemplo n.º 30
0
        public void Update(RepairOrder repairOrder)
        {
            var existing = Get(repairOrder.Id);

            if (existing != null)
            {
                existing.Name         = repairOrder.Name;
                existing.StatusRepair = repairOrder.StatusRepair;
                existing.BeginDate    = repairOrder.BeginDate;
                existing.EndDate      = repairOrder.EndDate;
            }
        }
Exemplo n.º 31
0
        public IHttpActionResult PostUserAddress(OrderData repairOrder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (getCooikedUser() == null)
            {
                return(Unauthorized());
            }

            RepairOrder order = new RepairOrder();

            order.Create_time   = System.DateTime.Now;
            order.Service_time  = repairOrder.Service_time;
            order.Customer_note = repairOrder.Customer_note;
            order.Staff_note    = repairOrder.Staff_note;
            order.Price         = repairOrder.Price;
            order.State         = repairOrder.State;
            order.Loc_name      = repairOrder.Loc_name;
            order.Loc_detail    = repairOrder.Loc_detail;
            order.Customer_ID   = getCooikedUser().ID;
            order.Engineer_ID   = null;



            var entry = db.RepairOrders.Add(order);

            db.SaveChanges();

            db.Entry(order).GetDatabaseValues();

            Console.WriteLine(order.ID);

            foreach (var choice in repairOrder.Choices)
            {
                var repairOrderRepairChoice =
                    new RepairOrder_RepairChoice
                {
                    Rep_choice_ID = choice,
                    Rep_order_ID  = order.ID
                };

                db.RepairOrder_RepairChoice.Add(repairOrderRepairChoice);
                db.SaveChanges();
            }



            return(CreatedAtRoute("GetUserRepairOrder", new { id = order.ID }, order));
        }
Exemplo n.º 32
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;
 }
Exemplo n.º 33
0
        public RepairOrder UpdateRO(RepairOrder ro, int _logIncidentId = 0, int _logContactId = 0)
        {
            //throw new NotImplementedException();
            RepairOrder retval = new RepairOrder();
            /*
            EBSMockSvcClient _client = new EBSMockSvcClient(binding, addr);

            try
            {
                MockEBSRepairOrder mock_ro = new MockEBSRepairOrder()
                {
                    ApprovalStatus = ro.ApprovalStatus,
                    Quantity = Convert.ToInt64(ro.Quantity),

                    //Sophia: Change later
                    ProblemDescription = ro.ProblemDescription,
                    RepairLineID = Convert.ToInt64(ro.RepairLineID)-2     

                };

                RepairOrderOutputParameters output;
                using (new OperationContextScope(_client.InnerChannel))
                {
                    Credential userInfo = new Credential();
                    userInfo.username = ROServiceUsername;
                    userInfo.password = ROServicePassword;

                    MessageHeader aMessageHeader = MessageHeader.CreateHeader("Credential", "", userInfo);
                    OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);

                    output = _client.UpdateRepairOrder(mock_ro);
                }

                if (!String.IsNullOrWhiteSpace(output.Error_Message))
                {
                    retval.ErrorMessage = output.Error_Message;
                }
                else
                {
                    retval.RepairLineID = (decimal?)Convert.ToDecimal(output.Repair_Line_ID);
                }
            }
            catch (CommunicationException e)
            {
                retval.ErrorMessage = e.ToString();
                _client.Abort();
            }
            catch (TimeoutException e)
            {
                retval.ErrorMessage = e.ToString();
                _client.Abort();
            }
            catch (Exception ex)
            {
                retval.ErrorMessage = String.Format("The following error occurred: {0}", ex);
                _client.Abort();
            }
            */
            retval.RepairLineID = ro.RepairLineID;
            return retval;
        }
Exemplo n.º 34
0
        public RepairOrder CreateRO(RepairOrder ro, int _logIncidentId = 0, int _logContactId = 0)
        {return null;
            /*RepairOrder retval = new RepairOrder();
            EBSMockSvcClient _client = new EBSMockSvcClient(binding, addr);
            
                //IEBSMockSvc _client = factory.CreateChannel();

            try
            {
                MockEBSRepairOrder mock_ro = new MockEBSRepairOrder()
                {
                    ApprovalRequired = ro.ApprovalRequired,
                    ApprovalStatus = ro.ApprovalStatus,
                    Currency = ro.Currency,
                    CustomerProductID = 110001,
                    ServiceRequestID = Convert.ToInt64(ro.ServiceRequestID.Value),
                    InventoryItemID = Convert.ToInt64(ro.InventoryItemID.Value),
                    ProblemDescription = ro.ProblemDescription,
                    Quantity = Convert.ToInt64(ro.Quantity.Value),
                    ResourceID = Convert.ToInt64(ro.ResourceID.Value),
                    UnitOfMeasure = ro.UnitOfMeasure
                };

                RepairOrderOutputParameters output;
                using (new OperationContextScope(_client.InnerChannel))
                {
                    Credential userInfo = new Credential();
                    userInfo.username = ROServiceUsername;
                    userInfo.password = ROServicePassword;

                    MessageHeader aMessageHeader = MessageHeader.CreateHeader("Credential", "", userInfo);
                    OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);

                    output = _client.SaveRepairOrder(mock_ro);
                }


                if (!String.IsNullOrWhiteSpace(output.Error_Message))
                {
                    retval.ErrorMessage = output.Error_Message;
                }
                else
                {
                    retval.RepairLineID = (decimal?)Convert.ToDecimal(output.Repair_Line_ID);
                    retval.RepairNumber = output.Repair_Number;
                }
            }
            catch (CommunicationException e)
            {
                retval.ErrorMessage = e.ToString();
                _client.Abort();
            }
            catch (TimeoutException e)
            {
                retval.ErrorMessage = e.ToString();
                _client.Abort();
            }            
            catch (Exception ex)
            {
                retval.ErrorMessage = String.Format("The following error occurred: {0}", ex); 
                _client.Abort();
            }
           

            return retval;*/
        }
Exemplo n.º 35
0
        public RepairOrder UpdateRO(RepairOrder ro, int _logIncidentId = 0, int _logContactId = 0)
        {
            //throw new NotImplementedException();
            RepairOrder result = ro;
            string request = "";
            string response = "";

            string logMessage, logNote;

            if (String.IsNullOrWhiteSpace(ROUpdateURL) || String.IsNullOrWhiteSpace(ROServiceUsername) || String.IsNullOrWhiteSpace(ROServicePassword))
            {
                throw new Exception("Provider's InitForRO not run.");
            }

            RO.CSD_REPAIRS_PUB_Service client = EBSProxyFactory.GetDepotInstance(ROCreateURL, ROServiceUsername, ROServicePassword, ROServiceTimeout);
            RO.SOAHeader hdr = new RO.SOAHeader();
            hdr.Responsibility = "ORACLE_SUPPORT";
            hdr.RespApplication = "CSS";
            hdr.Org_Id = "204";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";

            client.SOAHeaderValue = hdr;

            if (ro.RepairNumber != null)
            {
                RO.InputParameters1 ip_update_ro_status = new RO.InputParameters1();

                ip_update_ro_status.P_API_VERSION = 1.0M;
                ip_update_ro_status.P_API_VERSIONSpecified = true;
                ip_update_ro_status.P_INIT_MSG_LIST = "F";
                ip_update_ro_status.P_COMMIT = "T";

                RO.APPSCSD_REPAIRS_PUB_RX220752X3X7 repair_status = new RO.APPSCSD_REPAIRS_PUB_RX220752X3X7();

                repair_status.REPAIR_NUMBER = ro.RepairNumber;
                repair_status.REPAIR_STATUS_ID = ro.RepairStatusID;
                repair_status.REPAIR_STATUS_IDSpecified = true;
                repair_status.FROM_STATUS_ID = ro.StoredRepairStatusID;
                repair_status.FROM_STATUS_IDSpecified = true;
                repair_status.OBJECT_VERSION_NUMBER = 0;
                repair_status.OBJECT_VERSION_NUMBERSpecified = true;
                repair_status.REASON_CODE = String.Empty;
                ip_update_ro_status.P_REPAIR_STATUS_REC = repair_status;

                RO.APPSCSD_REPAIRS_PUB_X220752X3X18 other = new RO.APPSCSD_REPAIRS_PUB_X220752X3X18();
                other.CHECK_TASK_WIP = String.Empty;
                ip_update_ro_status.P_STATUS_UPD_CONTROL_REC = other;

                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_update_ro_status);
                    stopwatch.Start();
                    RO.OutputParameters1 op_update_ro_status = client.UPDATE_RO_STATUS(ip_update_ro_status);
                    stopwatch.Stop();
                    response = serializer.Serialize(op_update_ro_status);
                    if (op_update_ro_status.X_RETURN_STATUS == "S")
                    {

                        result.RepairNumber = ro.RepairNumber;


                        logMessage = "Request of updating Repair Order (Success). RO Number = " + result.RepairNumber;
                        logNote = "Request Payload: " + request;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Repair Order  (Success). RO Number = " + result.RepairNumber;
                        logNote = "Response Payload: " + response;

                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);

                    }
                    else if (op_update_ro_status.X_RETURN_STATUS == "U")
                    {
                        result.ErrorMessage = String.Format("Cannot set status from {0} to {1}", ro.StoredRepairStatus, ro.RepairStatus);

                        logMessage = "Request of updating Repair Order(Failure). RO Number = " + result.RepairNumber + " Error: " + result.ErrorMessage;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Repair Order (Failure). RO Number = " + result.RepairNumber + " Error: " + result.ErrorMessage;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        result.RepairNumber = "-1";
                    }
                    else
                    {
                        result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                        logMessage = "Request of updating Repair Order(Failure). RO Number = "  +result.RepairNumber + " Error: " + op_update_ro_status.X_MSG_DATA;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of updating Repair Order (Failure). RO Number = "  +result.RepairNumber + " Error: " + op_update_ro_status.X_MSG_DATA;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                    logMessage = "Request of updating Repair Order(Failure). RO Number = " + result.RepairNumber + " Error: " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of updating Repair Order (Failure). RO Number = " + result.RepairNumber + " Error: " + ex.Message;
                    logNote = "Response Payload: " + response;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    handleEBSException(ex, "Update Repair Order Status");
                }

            }

            return result;
        }
Exemplo n.º 36
0
        /// <summary>
        /// Returns a list of repair orders from EBS
        /// </summary>
        /// <param name="contact_id"></param>
        /// <param name="incident_id"></param>
        /// <param name="incident_number"></param>
        /// <param name="repair_number"></param>
        /// <param name="rntIncidentId"></param>
        /// <param name="rntContactId"></param>
        public RepairOrder[] LookupRepairOrderList(decimal contact_id, decimal incident_id, 
            string incident_number, string repair_number,
            int rntIncidentId = 0, int rntContactId = 0)
        {
            RepairOrder[] retvals = new RepairOrder[0];
            string logMessage, logNote;
                //validate user name and password for EBS web service
            if (String.IsNullOrWhiteSpace(RepairOrderListURL) ||
                String.IsNullOrWhiteSpace(RepairOrderListServiceUsername) ||
                String.IsNullOrWhiteSpace(RepairOrderListServicePassword))
            {
                throw new Exception("Provider's InitForRO not run.");
            }
                //create a soap header
            REPAIR_ORDER.CSD_REPAIR_ORDERS_WEB_Service client = EBSProxyFactory.GetRepairOrderListInstance(RepairOrderListURL, RepairOrderListServiceUsername, RepairOrderListServicePassword, RepairOrderListServiceTimeout);
            REPAIR_ORDER.SOAHeader hdr = new REPAIR_ORDER.SOAHeader();
            hdr.Responsibility = "DEPOT REPAIR";
            hdr.RespApplication = "CSD";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";
            hdr.Org_Id = "204";

            client.SOAHeaderValue = hdr;
                //create request payload
            REPAIR_ORDER.InputParameters ip = new REPAIR_ORDER.InputParameters();
            bool has_incident = false;
            bool has_contact = false;
            if (incident_id > 0)
            {
                ip.P_INCIDENT_ID = Convert.ToString(incident_id);
                ip.P_INCIDENT_IDSpecified = true;
                has_incident = true;
            }
            else
            {
                ip.P_INCIDENT_ID = "";
                ip.P_INCIDENT_IDSpecified = false;
            }
            if (contact_id > 0)
            {
                has_contact = true;
                ip.P_SR_CONTACT_PARTY_ID = Convert.ToString(contact_id);
                ip.P_SR_CONTACT_PARTY_IDSpecified = true;
                ip.P_SR_CONTACT_TYPE = "PARTY_RELATIONSHIP";
            }
            else
            {
                ip.P_SR_CONTACT_PARTY_ID = "";
                ip.P_SR_CONTACT_PARTY_IDSpecified = false;
                ip.P_SR_CONTACT_TYPE = "";
            }
            bool has_repair_number = false;
            if (String.IsNullOrWhiteSpace(repair_number))
            {
                ip.P_REPAIR_NUMBER = "";
            }
            else
            {
                has_repair_number = true;
                ip.P_REPAIR_NUMBER = repair_number;
            }
            bool has_incident_number = false;
            if (String.IsNullOrWhiteSpace(incident_number))
            {
                ip.P_INCIDENT_NUMBER = "";
            }
            else
            {
                has_incident_number = true;
                ip.P_INCIDENT_NUMBER = incident_number;
            }
            string parameters = String.Format("GET_REPAIR_ORDERS_WEBSRVC for contact_id {0}, incident_id {1}, incident_number {2}, repair_number {3}",
                Convert.ToString(contact_id), Convert.ToString(incident_id), Convert.ToString(incident_number), Convert.ToString(repair_number));

            if ( !(has_incident | has_contact | has_repair_number | has_incident_number) )
            {
                logMessage = parameters + ". No valid parameters found. No search performed.";
                logNote = null;
                ConfigurationSetting.logWrap.DebugLog(incidentId: rntIncidentId, contactId: rntContactId, logMessage: logMessage, logNote: logNote);
                return retvals;
            }
            ip.P_RECORD_LIMIT = 100;
            ip.P_RECORD_LIMITSpecified = true;
            ip.P_REPAIR_LINE_ID = "";
            ip.P_REPAIR_LINE_IDSpecified = false;
            ip.P_SR_CUSTOMER_PARTY_ID = "";
            ip.P_SR_CUSTOMER_PARTY_IDSpecified = false;
            ip.P_SR_CUSTOMER_TYPE = "";

            logMessage = parameters + ". Request payload.";
            logNote = serializer.Serialize(ip);
            ConfigurationSetting.logWrap.DebugLog(incidentId: rntIncidentId, contactId: rntContactId, logMessage: logMessage, logNote: logNote);
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
                //invoke ebs
            StringBuilder response = new StringBuilder("[{}");
            try
            {
                REPAIR_ORDER.OutputParameters opList = client.GET_REPAIR_ORDERS_WEBSRVC(ip);
                List<RepairOrder> items = new List<RepairOrder>();

                foreach (REPAIR_ORDER_LIST op in opList.X_REPLN_TBL)
                {
                    RepairOrder ro = new RepairOrder(getPropertyValues(op), contact_id, incident_id);
                    items.Add(ro);
                    response.Append(",").Append(ro.ToJSON());
                }
                retvals = items.ToArray();
            }
            catch (Exception ex)
            {
                handleEBSException(ex, parameters, rntIncidentId, rntContactId);
                throw;
            }
            stopwatch.Stop();
            int timeElapsed = stopwatch.Elapsed.Milliseconds;
            logMessage = new StringBuilder(parameters)
                .Append(" returned ").Append(retvals.Count()).Append(" records in ")
                .Append(timeElapsed).Append("ms")
                .ToString();
            logNote = response.Append(",{\"Count\":").Append("\"")
                .Append(retvals.Count()).Append("\"}]").ToString();
            ConfigurationSetting.logWrap.DebugLog(incidentId: rntIncidentId, contactId: rntContactId, logMessage: logMessage, logNote: logNote, timeElapsed: timeElapsed);
            return retvals;
        }
Exemplo n.º 37
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 bw_LoadROList(object sender, DoWorkEventArgs e)
        {
            string logMessage, logNote;
            var sr_id = "";
            var sr_num = "";
            IList<ICustomAttribute> customAttributes = incident.CustomAttributes;
            string[] incCustomAttrs = { "Accelerator$ebs_sr_id", "Accelerator$ebs_sr_num" };
            Dictionary<String, Object> incCustomAttrsResults = CustomAttrHelper.fetchCustomAttrValue(customAttributes, incCustomAttrs, this._logIncidentId, 0);
            sr_id = incCustomAttrsResults["Accelerator$ebs_sr_id"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_id"].ToString() : "";
            sr_num = incCustomAttrsResults["Accelerator$ebs_sr_num"] != null ? incCustomAttrsResults["Accelerator$ebs_sr_num"].ToString() : "";

            //Check incident whether associated to a service request
            if (!String.IsNullOrWhiteSpace(sr_id))
            {
                //If incident is related to a SR
                //Lookup repair order by service request id
                RepairOrder ro = new RepairOrder();

                RepairOrder[] results = null;
                try
                {
                    results = ro.LookupList(sr_id, sr_num, _logIncidentId, 0);
                    e.Result = results;
                }
                catch (Exception ex)
                {
                    e.Cancel = true;
                    bw_roList.CancelAsync();
                    logMessage = "Error in loading Repair Order List. Error: " + ex.Message;
                    _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage);
                    return;
                }

                if (ro.ErrorMessage != null)
                {
                    e.Cancel = true;
                    logMessage = "Loading Repair Order List is failed. SR ID = " + sr_id;
                    logNote = "Response shows error code when loading repair order list. Response's error message: " + ro.ErrorMessage;
                    _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                    return;
                }
                else
                {
                    logMessage = "Loading Repair Order List Successfully. Current Service Request has " + results.Length + " Repair Order(s)";
                    logNote = "";
                    _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                }
            }
            else
            {
                e.Result = null;
            }
        }
 private void bw_LoadRODetails(object sender, DoWorkEventArgs e)
 {
     string logMessage, logNote;
     string repairNum = (string)e.Argument;
     RepairOrder ro = new RepairOrder();
     try
     {
         ro = ro.Lookup(repairNum, _logIncidentId, 0);
         e.Result = ro;
     }
     catch (Exception ex)
     {
         e.Cancel = true;
         bw_roList.CancelAsync();
         logMessage = "Error in loading Repair Order. Error: " + ex.Message;
         _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage);
         return;
     }
     if (ro.ErrorMessage != null)
     {
         e.Cancel = true;
         logMessage = "Loading Repair Order is failed. RO Num = " + repairNum;
         logNote = "Response shows error code when loading repair order. Response's error message: " + ro.ErrorMessage;
         _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
         return;
     }
 }
Exemplo n.º 40
0
        void SaveRepairOrderToServer(decimal sr_id)
        {
            string logMessage = "Create/Update RO.";
            string logNote = "";
            _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);

            string ro_saved_num;
            RepairOrder ro = null;
            ro = new RepairOrder();

            ro.ServiceRequestID = sr_id;
            if (_repairOrderControl.isAddingRO == true)
            {
                //Create Additional RO
                ro.Quantity = Convert.ToDecimal(_repairOrderControl.InputQuantity);
                ro.UnitOfMeasure = _repairOrderControl.SelectedUnit;
                ro.InventoryItemID = this.currentInventoryItemID;
                ro.SerialNumber = this.current_serial_num;
                ro.ApprovalRequired = _repairOrderControl.SelectedApprovalRequired;
                ro.Currency = "USD";
                ro.ResourceID = _ebsDefaultSrOwnerId;
                ro.ProblemDescription = _repairOrderControl.InputProblem;
            }
            else if (_repairOrderControl.isChangingRO == true)
            {
                //Edit RO
                ro.RepairNumber = _repairOrderControl.changingRONum;
                ro.RepairStatus = selected_status;
                ro.RepairStatusID = selected_status_id;
                ro.StoredRepairStatus = stored_status;
                ro.StoredRepairStatusID = stored_status_id;
            }

            try
            {
                if (_repairOrderControl.isChangingRO == true)
                {
                    logMessage = "Ready to update Repair Order. SR ID = " + sr_id + "; RO Number = " + ro.RepairLineID;
                    logNote = "";
                    _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                    ro_saved_num = ro.Update( _logIncidentId, 0);
                }
                else
                {
                    logMessage = "Ready to update Repair Order. RO Number = " + ro.RepairLineID;
                    logNote = "";
                    _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);

                    ro_saved_num = ro.Create(_logIncidentId, 0);
                }

            }
            catch (Exception ex)
            {
                logMessage = "Error in creating/updating Repair Order.Error Message: " + ex.Message;
                logNote = "";
                _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);

                string message = "There has been an error communicating with EBS. Please check log for detail.";
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (ro_saved_num == "-1")
            {
                //Cannot change status between statuses
                string message = ro.ErrorMessage;
                MessageBox.Show(message, "Notice", MessageBoxButtons.OK, MessageBoxIcon.Information);

                logMessage = "Error in creating/updating RepairOrder. " + message;
                _log.NoticeLog(incidentId: _logIncidentId, logMessage: logMessage);
                return;
            }else if (String.IsNullOrEmpty(ro_saved_num))
            {
                string message = "There has been an error communicating with EBS. Please check log for detail.";
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                logMessage = "Error in creating/updating RepairOrder. Response's error message: " + ro.ErrorMessage;
                logNote = "";
                _log.ErrorLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);
                return;
            }
            else
            {
                // Save successfully
                logMessage = "Creating/updating Repair Order successfully. RO Num = " + ro.RepairLineID;
                logNote = "";
                _log.DebugLog(incidentId: _logIncidentId, logMessage: logMessage, logNote: logNote);

                _repairOrderControl.previousRONum = ro_saved_num;
            }
        }
Exemplo n.º 41
0
        public RepairOrder CreateRO(RepairOrder ro, int _logIncidentId = 0, int _logContactId = 0)
        {
            RepairOrder result = ro;
            string request = "";
            string response = "";
            string logMessage, logNote;

            if (String.IsNullOrWhiteSpace(ROCreateURL) || String.IsNullOrWhiteSpace(ROServiceUsername) || String.IsNullOrWhiteSpace(ROServicePassword))
            {
                throw new Exception("Provider's InitForRO not run.");
            }

            RO.CSD_REPAIRS_PUB_Service client = EBSProxyFactory.GetDepotInstance(ROCreateURL, ROServiceUsername, ROServicePassword, ROServiceTimeout);
            RO.SOAHeader hdr = new RO.SOAHeader();
            hdr.Responsibility = "ORACLE_SUPPORT";
            hdr.RespApplication = "CSS";
            hdr.Org_Id = "204";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";

            client.SOAHeaderValue = hdr;

            if (ro.RepairNumber == null)
            {
                RO.InputParameters ip_create_ro = new RO.InputParameters();
                ip_create_ro.P_API_VERSION_NUMBER = 1.0M;
                ip_create_ro.P_API_VERSION_NUMBERSpecified = true;
                ip_create_ro.P_INIT_MSG_LIST = "T";
                ip_create_ro.P_COMMIT = "F";
                ip_create_ro.P_CREATE_DEFAULT_LOGISTICS = "N";

                RO.APPSCSD_REPAIRS_PUB_RX220752X1X6 ro_info = new RO.APPSCSD_REPAIRS_PUB_RX220752X1X6();
                ro_info.INCIDENT_ID = ro.ServiceRequestID;
                ro_info.INCIDENT_IDSpecified = true;
                ro_info.UNIT_OF_MEASURE = ro.UnitOfMeasure;
                ro_info.REPAIR_TYPE_ID = ro.RepairTypeID;
                ro_info.REPAIR_TYPE_IDSpecified = true;
                ro_info.QUANTITY = ro.Quantity;
                ro_info.QUANTITYSpecified = true;
                ro_info.INVENTORY_ITEM_ID = ro.InventoryItemID;
                ro_info.INVENTORY_ITEM_IDSpecified = true;
                ro_info.APPROVAL_REQUIRED_FLAG = ro.ApprovalRequired;
                ro_info.CURRENCY_CODE = ro.Currency;
                ro_info.PROBLEM_DESCRIPTION = ro.ProblemDescription;
                ro_info.RESOURCE_ID = ro.ResourceID;
                ro_info.RESOURCE_IDSpecified = true;
                ro_info.AUTO_PROCESS_RMA = String.Empty;
                ro_info.SERIAL_NUMBER = ro.SerialNumber;
                if (!string.IsNullOrWhiteSpace(ro.HasValidSerialNumber))
                    ro_info.ATTRIBUTE15 = ro.HasValidSerialNumber;

                ip_create_ro.P_REPLN_REC = ro_info;
                Stopwatch stopwatch = new Stopwatch();
                try
                {
                    request = serializer.Serialize(ip_create_ro);
                    stopwatch.Start();
                    RO.OutputParameters op_create_ro = client.CREATE_REPAIR_ORDER(ip_create_ro);
                    stopwatch.Stop();
                    response = serializer.Serialize(op_create_ro);

                    if (op_create_ro.X_RETURN_STATUS == "S")
                    {
                        result.RepairNumber = op_create_ro.X_REPAIR_NUMBER;
                        result.RepairLineID = Convert.ToDecimal(op_create_ro.X_REPAIR_LINE_ID);

                        logMessage = "Request of creating Repair Order (Success). Created RO Number: " + result.RepairNumber;
                        logNote = "Request Payload: " + request;
                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of creating Repair Order (Success). Created RO Number: " + result.RepairNumber;
                        logNote = "Response Payload: " + response;

                        log.DebugLog(_logIncidentId, _logContactId, logMessage, logNote, (int)stopwatch.ElapsedMilliseconds);
                    }
                    else
                    {
                        result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                        logMessage = "Request of creating Repair Order (Failure). " + op_create_ro.X_MSG_DATA;
                        logNote = "Request Payload: " + request;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                        logMessage = "Response of creating Repair Order (Failure). " + op_create_ro.X_MSG_DATA;
                        logNote = "Response Payload: " + response;
                        log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);
                    }
                }
                catch (Exception ex)
                {
                    result.ErrorMessage = "There has been an error communicating with EBS. Please check log for detail.";

                    logMessage = "Request of creating Repair Order (Failure). " + ex.Message;
                    logNote = "Request Payload: " + request;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    logMessage = "Response of creating Repair Order (Failure). " + ex.Message;
                    logNote = "Response Payload: " + response;
                    log.ErrorLog(_logIncidentId, _logContactId, logMessage, logNote);

                    handleEBSException(ex, "Create Repair Order", _logIncidentId, _logContactId);
                }

            }

            return result;
        }