예제 #1
0
 public static IApplicationBuilder RegisterAsService(this IApplicationBuilder app,
                                                     ServiceTypes serviceType,
                                                     string IPResolverHost,
                                                     ILogger logger)
 {
     try
     {
         using (var client = new HttpClient())
         {
             var jsonString = JsonConvert.SerializeObject(new
             {
                 token       = GlobalTokens.RegisterServiseToken,
                 serviceType = serviceType.ToString()
             });
             logger.LogDebug($"Registration string is {jsonString}");
             StringContent content = new StringContent(jsonString, Encoding.UTF8, "application/json");
             var           result  = client.PostAsync($"http://{IPResolverHost}/ip/register", content).Result;
             logger.LogInformation($"result from registration {(int)result.StatusCode} {result.StatusCode}");
             if (result.StatusCode != System.Net.HttpStatusCode.OK)
             {
                 throw new Exception("Can't register service!!!");
             }
         }
     }
     catch
     {
         Console.WriteLine("ERROR BLYAT");
     }
     return(app);
 }
예제 #2
0
        public string ToString()
        {
            StringBuilder builder = new StringBuilder();

            if (myServiceID != null)
            {
                builder.Append("Service ID: " + myServiceID + "\n");
            }
            builder.Append("This Service is to " + myServiceType.ToString() + " " + myDonationRequest.ToString() + "\n");
            if (myServiceDescription != null)
            {
                builder.Append("User Submitted Description: " + myServiceDescription + "\n");
            }
            builder.Append("Service is Selected: " + isTrue(mySelected) + "\n");
            builder.Append("Service is Completed: " + isTrue(myCompleted) + "\n");
            if (myTimeStart != null)
            {
                builder.Append(myTimeStart + " to " + myTimeStop + "\n");
            }
            if (myReview != null)
            {
                builder.Append("Review of Service:\n" + myReview.ToString() + "\n");
            }
            builder.Append("______________________________________________________\n");

            return(builder.ToString());
        }
예제 #3
0
 private void XFSDevice_OpenComplete(ServiceTypes serviceType)
 {
     L4Logger.Info("OpenComplete => " + serviceType.ToString());
     lock (syncObject)
     {
         XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.IsExecuteSuccessfully = true;
         XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand.Detail = "XFSDevice_OpenComplete";
         SendResponse(XFS_DevicesCollection.Instance.GetValue(serviceType).CurrentCommand);
     }
 }
예제 #4
0
        public IService GetService(ServiceTypes type)
        {
            IService service;

            if (services.TryGetValue(type, out service))
            {
                return(service);
            }

            throw new ServiceNotFoundException("No such service: " + type.ToString());
        }
        public IActionResult Create(Int32?ID, ServiceTypes serviceType, string chosenDateTime)
        {
            if (ID == null)
            {
                return(NotFound());
            }

            try
            {
                CultureInfo provider   = CultureInfo.InvariantCulture;
                var         chosenDate = DateTime.ParseExact(chosenDateTime, "yyyyMMddHHmmss", provider);

                _inProgressReservation = new Reservation();
                _inProgressReservation.ProvidedService = new CarServices();
                _inProgressReservation.UserID          = Int32.Parse(_userManager.GetUserId(User));
                _inProgressReservation.ReservationTime = chosenDate;
                _inProgressReservation.Workshop        = _service.GetWorkShopByID((int)ID);
                switch (serviceType)
                {
                case ServiceTypes.TireReplacement:
                    _inProgressReservation.ProvidedService.TireReplacement = true;
                    break;

                case ServiceTypes.AirConCharging:
                    _inProgressReservation.ProvidedService.AirConCharging = true;
                    break;

                case ServiceTypes.PunctureRepair:
                    _inProgressReservation.ProvidedService.PunctureRepair = true;
                    break;

                case ServiceTypes.SuspensionAdjustment:
                    _inProgressReservation.ProvidedService.SuspensionAdjustment = true;
                    break;

                default:
                    break;
                }

                ViewBag.ChosenShop  = _inProgressReservation.Workshop.Name;
                ViewBag.ServiceType = serviceType;
                ViewBag.ChosenDate  = _inProgressReservation.ReservationTime;

                HttpContext.Session.SetString(_service.SShopID, ID.ToString());
                HttpContext.Session.SetString(_service.SServiceType, serviceType.ToString());
                HttpContext.Session.SetString(_service.STime, chosenDate.ToString("yyyMMddHHmmss"));

                return(View(_inProgressReservation));
            }
            catch (InvalidOperationException)
            {
                return(NotFound());
            }
        }
예제 #6
0
        public async Task <string> GenerateNonSequentialReferenceCode(ServiceTypes serviceType, string destinationCode)
        {
            var itineraryNumber = await GenerateItn();

            var values = new List <string>
            {
                _tagProcessingOptions.ReferenceCodePrefix,
                serviceType.ToString(),
                destinationCode,
                itineraryNumber
            };

            return(string.Join(ReferenceCodeItemsSeparator, values.Where(v => !string.IsNullOrEmpty(v))));
        }
예제 #7
0
        public async Task <string> GenerateReferenceCode(ServiceTypes serviceType, string destinationCode, string itineraryNumber)
        {
            var currentNumber = await _context.GenerateNextItnMember(itineraryNumber);

            var values = new List <string>
            {
                _tagProcessingOptions.ReferenceCodePrefix,
                serviceType.ToString(),
                destinationCode,
                itineraryNumber,
                currentNumber.ToString("D2")
            };

            return(string.Join(ReferenceCodeItemsSeparator, values.Where(v => !string.IsNullOrEmpty(v))));
        }
예제 #8
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg >= XFSDefinition.WFS_OPEN_COMPLETE &&
                m.Msg <= XFSDefinition.WFS_SYSTEM_EVENT)
            {
                var msg = m.Msg;
                Task.Run(() => { L4Logger.Info(string.Format("Xfs WndProc ServiceName {0} msg {1} ", ServiceName, msg)); });
                WFSRESULT result = new WFSRESULT();
                if (m.LParam != IntPtr.Zero)
                {
                    XFSUtil.PtrToStructure(m.LParam, ref result);
                }
                switch (m.Msg)
                {
                case XFSDefinition.WFS_OPEN_COMPLETE:
                {
                    Task.Run(() => { L4Logger.Info("OpenCompleted =>  " + serviceType.ToString()); });
                    OnOpenComplete();
                }
                break;

                case XFSDefinition.WFS_CLOSE_COMPLETE:
                    OnCloseComplete();
                    break;

                case XFSDefinition.WFS_REGISTER_COMPLETE:
                {
                    Task.Run(() => { L4Logger.Info("RegisterCompleted =>  " + serviceType.ToString()); });
                    OnRegisterComplete();
                }
                break;

                case XFSDefinition.WFS_EXECUTE_COMPLETE:
                    Task.Run(() => { L4Logger.Info(string.Format("ExecuteCompleted  Service => {0} CommandCode => {1} ",
                                                                 serviceType.ToString(), result.dwCommandCodeOrEventID)); });

                    if (commandHandlers.Contains(result.dwCommandCodeOrEventID))
                    {
                        OnExecuteComplete(ref result, result.dwCommandCodeOrEventID);
                    }
                    break;

                case XFSDefinition.WFS_EXECUTE_EVENT:
                case XFSDefinition.WFS_SERVICE_EVENT:
                case XFSDefinition.WFS_USER_EVENT:
                case XFSDefinition.WFS_SYSTEM_EVENT:
                    Task.Run(() => { L4Logger.Info(string.Format("WFS_SYSTEM_EVENT servicename {0}  lpBuffer {1} EventId => ",
                                                                 serviceName, result.lpBuffer, result.dwCommandCodeOrEventID)); });
                    if (eventHandlers.Contains(result.dwCommandCodeOrEventID))
                    {
                        OnExecuteEvent(ref result);
                    }
                    else
                    {
                        Task.Run(() =>
                        {
                            L4Logger.Info(string.Format("EventId = {0} AcceptsEvents = {1}",
                                                        result.dwCommandCodeOrEventID,
                                                        string.Join(",", eventHandlers.ToArray())));
                        });
                    }
                    break;
                }
                XfsApi.WFSFreeResult(ref result);
            }
            else
            {
                base.WndProc(ref m);
            }
        }