// GET: Service/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServiceEntity serviceEntity = db.Services.Find(id); if (serviceEntity == null) { return(HttpNotFound()); } ViewBag.CityID = new SelectList(db.Citys, "ID", "Name", serviceEntity.CityID); ViewBag.CountryID = new SelectList(db.Countrys, "ID", "Code", serviceEntity.CountryID); ViewBag.CustomerID = new SelectList(db.Customers, "ID", "Code", serviceEntity.CustomerID); ViewBag.FlightRouteID = new SelectList(db.FlightRoutes, "ID", "Origin", serviceEntity.FlightRouteID); ViewBag.PriorityID = new SelectList(db.Prioritys, "ID", "Name", serviceEntity.PriorityID); ViewBag.ServiceAdditionalDetailID = new SelectList(db.ServiceAdditionalDetails, "ID", "Name", serviceEntity.ServiceAdditionalDetailID); ViewBag.ServiceCenterID = new SelectList(db.ServiceCenters, "ID", "Name", serviceEntity.ServiceCenterID); ViewBag.ServiceStatusID = new SelectList(db.ServiceStatuses, "ID", "Name", serviceEntity.ServiceStatusID); ViewBag.ServiceSupplementalDetailID = new SelectList(db.ServiceSupplementalDetails, "ID", "Name", serviceEntity.ServiceSupplementalDetailID); ViewBag.ServiceTypeID = new SelectList(db.ServiceTypes, "ID", "Name", serviceEntity.ServiceTypeID); ViewBag.ServiceTypeDetailID = new SelectList(db.ServiceTypeDetails, "ID", "Name", serviceEntity.ServiceTypeDetailID); ViewBag.StationID = new SelectList(db.Stations, "ID", "Name", serviceEntity.StationID); return(View(serviceEntity)); }
internal EditConditionForm(IServiceUI parentEditor, ServiceEntity serviceHandler) { InitializeComponent(); _editor = parentEditor; this._editor.EditVarForm.Completed += new EventHandler(EditVarForm_Completed); this._service = serviceHandler; }
public ServiceEntity Save(ServiceEntity serviceEntity, string session) { try { ServiceEntity result; // if we are connected if (Connection.IsConnected) { CheckIsSynchronized(); result = Remote.Save(serviceEntity, session); } else { result = Local.Save(serviceEntity); } return(result); } catch (UtnEmallDataAccessException dataAccessError) { throw new UtnEmallSmartLayerException(dataAccessError.Message, dataAccessError); } catch (UtnEmallBusinessLogicException businessLogicError) { throw new UtnEmallSmartLayerException(businessLogicError.Message, businessLogicError); } catch (CommunicationException communicationError) { throw new UtnEmallSmartLayerException(communicationError.Message, communicationError); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime lifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); var serviceEntity = new ServiceEntity { IP = "localhost", Port = Convert.ToInt32(Configuration["Service:Port"]), ServiceName = Configuration["Service:Name"], ConsulIP = Configuration["Consul:IP"], ConsulPort = Convert.ToInt32(Configuration["Consul:Port"]) }; app.RegisterConsul(lifetime, serviceEntity); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } //注册Consul服务 var serviceEntity = new ServiceEntity { IP = "127.0.0.1", Port = Convert.ToInt32(Configuration["Service:Port"]), ServiceName = Configuration["Service:Name"], ConsulIP = Configuration["Consul:IP"], ConsulPort = Convert.ToInt32(Configuration["Consul:Port"]) }; app.RegisterConsul(lifetime, serviceEntity); app.UseHttpsRedirection(); app.UseMvc(); }
public void ServiceEntitiesHaveAnOrganizationId() { var entity = new ServiceEntity(); entity.OrganizationId = 1; entity.OrganizationId.Should().Be(1); }
private void RefreshServiceHistoryLogFiles(ServiceEntity service) { BarListItem bliLogs = MenuItemHelper.Instance.Buttons[MenuItem.ViewHistoryLog] as BarListItem; bliLogs.Strings.Clear(); if (service != null) { string logPath = Path.Combine( Path.GetDirectoryName(service.ServiceHomePath), "Logs"); string currengLogPath = Path.Combine( logPath, $"IRAPS7GatewayConsole-{DateTime.Now.ToString("yyyy-MM-dd")}.log"); if (Directory.Exists(logPath)) { string[] files = Directory.GetFiles(logPath); for (int i = 0; i < files.Length; i++) { if (files[i].ToUpper() == currengLogPath.ToUpper()) { continue; } bliLogs.Strings.Add(Path.GetFileName(files[i])); } } } bliLogs.Enabled = bliLogs.Strings.Count > 0; }
private void ServiceLogLoadFromFile(ServiceEntity service) { RefreshServiceHistoryLogFiles(service); if (service == null) { MenuItemHelper.Instance.Buttons[MenuItem.ServiceLogReload].Enabled = false; MenuItemHelper.Instance.Buttons[MenuItem.ViewHistoryLog].Enabled = false; edtLog.Text = ""; tpLog.Text = ""; return; } MenuItemHelper.Instance.Buttons[MenuItem.ServiceLogReload].Enabled = true; string servDirectory = Path.Combine( Path.GetDirectoryName(service.ServiceHomePath), "Logs"); string servLogPath = Path.Combine( servDirectory, $"IRAPS7GatewayConsole-{DateTime.Now.ToString("yyyy-MM-dd")}.log"); ViewLogFile(servLogPath); }
private async Task <bool> SetUpMonRNorSvcFreq(ServiceEntity item, ServiceInput input, string mode) { int svcFreq = 0; int svcGroup = await GetSvcGroup(item.Button); CultureInfo myCI = new CultureInfo("en-US"); CalendarWeekRule myCWR = myCI.DateTimeFormat.CalendarWeekRule; Calendar myCal = myCI.Calendar; switch (mode) { case ServiceFrequency.EveryOtherDay: svcFreq = input.Today.DayOfYear % 2; break; case ServiceFrequency.BiWeekly: svcFreq = myCal.GetWeekOfYear(DateTime.Now, myCWR, input.Today.DayOfWeek) % 2; break; case ServiceFrequency.Monthly: svcFreq = myCal.GetWeekOfYear(DateTime.Now, myCWR, input.Today.DayOfWeek) % 4; break; default: break; } if (svcGroup != svcFreq) { item.MonRN = 1000; return(true); //breaks one iteration (in the loop) } item.SvcFreq += $"-{svcFreq}"; return(false); }
private async Task LocalExecuteAsync(ServiceEntity entry, RemoteInvokeMessage remoteInvokeMessage, RemoteInvokeResultMessage resultMessage) { try { var result = await entry.Func(remoteInvokeMessage.Parameters); var task = result as Task; if (task == null) { resultMessage.Result = result; } else { task.Wait(); var taskType = task.GetType().GetTypeInfo(); if (taskType.IsGenericType) { resultMessage.Result = taskType.GetProperty("Result")?.GetValue(task); } } } catch (Exception exception) { if (_logger.IsEnabled(LogLevel.Error)) { _logger.LogError("执行本地逻辑时候发生了错误", exception); } resultMessage.ExceptionMessage = GetExceptionMessage(exception); } }
public static Response.Service ToResponseService(this ServiceEntity serviceDomain) { return(new Response.Service { Id = serviceDomain.Id, Name = serviceDomain.Name, Categories = serviceDomain.ServiceTaxonomies.ToResponseCategoryList(), Contact = serviceDomain.ToResponseContact(), Demographic = serviceDomain.ServiceTaxonomies.ToResponseDemographicList(), Description = serviceDomain.Description, Images = serviceDomain.ToResponseImage(), Locations = serviceDomain.ServiceLocations.ToResponseServiceLocationList(), Organization = serviceDomain.Organization.ToResponseOrganization(), Referral = serviceDomain.ToResponseReferral(), Social = serviceDomain.ToResponseSocial(), Status = serviceDomain.Status }); }
public void Initialize(string serviceFullName, XmlElement source) { this.Service = ServiceEntity.Parse(source); this.txtServiceName.Text = serviceFullName; this.txtSQLTemplate.Text = Service.SQLTemplate.Trim(); this.LoadVariables(); this.EditVarForm = new EditVariableForm(this.Service); this.EditVarForm.Completed += delegate(object s, EventArgs arg) { LoadVariables(); }; txtRequestElement.Text = Service.ResponseRecordElement; LoadFields(); LoadConditions(); LoadOrders(); LoadPreprocesses(); LoadConverters(); this.txtSQLTemplate.Document.LoadLanguageFromXml(Assembly.GetExecutingAssembly().GetManifestResourceStream("ProjectManager.ActiproSoftware.SQL.xml"), 0); MakeSuggest(); _original = this.GetResult().OuterXml; _init = true; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApiVersionDescriptionProvider provider, IApplicationLifetime lifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //swagger app.UseUserSwaggerWithVersion(provider); //授权 app.UseAuthentication(); //配置Consul ServiceEntity serviceEntity = new ServiceEntity { IP = "localhost", Port = Convert.ToInt32(Configuration["Service:Port"]), ServiceName = Configuration["Service:Name"], ConsulIP = Configuration["Consul:IP"], ConsulPort = Convert.ToInt32(Configuration["Consul:Port"]) }; app.RegisterConsul(lifetime, serviceEntity); app.UseMvc(); }
public static IApplicationBuilder RegisterConsul(this IApplicationBuilder app, IApplicationLifetime lifetime, ServiceEntity serviceEntity) { var consulClient = new ConsulClient(x => x.Address = new Uri($"http://{serviceEntity.ConsulIP}:{serviceEntity.ConsulPort}")); //请求注册的 Consul 地址 var httpCheck = new AgentServiceCheck() { DeregisterCriticalServiceAfter = TimeSpan.FromSeconds(5), // 服务启动多久后注册 Interval = TimeSpan.FromSeconds(10), // 健康检查时间间隔,或者称为心跳间隔 HTTP = $"http://{serviceEntity.IP}:{serviceEntity.Port}/api/health", // 健康检查地址 Timeout = TimeSpan.FromSeconds(5) // 超时时间 }; // Register service with consul var registration = new AgentServiceRegistration() { Checks = new[] { httpCheck }, ID = Guid.NewGuid().ToString(), Name = serviceEntity.ServiceName, Address = serviceEntity.IP, Port = serviceEntity.Port, Tags = new[] { $"urlprefix-/{serviceEntity.ServiceName}" } // 添加 urlprefix-/servicename 格式的 tag 标签,以便 Fabio 识别 }; consulClient.Agent.ServiceRegister(registration).Wait(); // 服务启动时注册,内部实现其实就是使用 Consul API 进行注册(HttpClient发起) lifetime.ApplicationStopping.Register(() => { consulClient.Agent.ServiceDeregister(registration.ID).Wait(); // 服务停止时取消注册 }); return(app); }
public void CreateAppointment(CustomerEntity customer, List <Resource> resources, List <TimeDuration> durations, ServiceEntity service, List <Pet> pets) { // Check whether all the calendars of the resources don't have an appointment (Would be replaced by a call to the // Availability Micro service foreach (var resource in resources) { foreach (var duration in durations) { var schedule = resource.Calendar.Schedules.FirstOrDefault(s => s.Date == duration.StartDateTime); if (schedule == null) { throw new Exception("This schedule doesn't exist!"); } // Approximate the DateTime to Hour var totalDurationHours = duration.Duration.TotalHours + duration.StartDateTime.Hour; // Check that none of the time slots in the schedule have an assigned appointment if (!schedule.TimeSlots.Where(ts => ts.StartTime.Hour > duration.StartDateTime.Hour && ts.StartTime.Hour < totalDurationHours) .All(t => t.Appointment == null)) { throw new Exception("Some time slots have been taken!"); } } } var appointment = new AppointmentEntity(durations, customer, pets).AddResources(resources).AddService(service); Database.Appointments.Add(appointment); Database.SaveChanges(); }