当前位置: 首页 > news >正文

.NET WebService \ WCF \ WebAPI 部署总结 以及 window 服务 调试

一、webservice 部署只能部署IIS上,
比较简单,就不做说明了

二、 WCF 部署 1
部署到IIS 跟部署 webservice 部署方法一样的
wcf 部署2
部署到控制台 要以管理员运行vs,或者 管理员运行 控制台的exe
在控制器项目中
创建IUserInfoService 接口

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApp1
{[ServiceContract]public interface  IUserInfoService{[OperationContract]int Add(int a, int b);}
}

在这里插入图片描述
实现接口
在这里插入图片描述
在app.config中增加
在这里插入图片描述

 <system.serviceModel><services><service name="ConsoleApp1.UserInfoService" behaviorConfiguration="behaviorConfiguration"><!--服务的对象--><host><baseAddresses><add baseAddress="http://localhost:8000/"/><!--服务的IP和端口号--></baseAddresses></host><endpoint address="" binding="basicHttpBinding" contract="ConsoleApp1.IUserInfoService"></endpoint><!--contract:服务契约--></service></services><behaviors><serviceBehaviors><behavior name="behaviorConfiguration"><serviceMetadata httpGetEnabled="true"/></behavior></serviceBehaviors></behaviors></system.serviceModel>

《《《启动服务
在这里插入图片描述
在这里插入图片描述

》》》验证是否有效
在这里插入图片描述
》》》如果不放在配置文件中
在这里插入图片描述
》》》

 using (ServiceHost host = new ServiceHost(typeof(UserInfoService))){host.AddServiceEndpoint(typeof(IUserInfoService), new WSHttpBinding(), "http://localhost:8686/userinfoservice");ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();behavior.HttpGetEnabled = true;behavior.HttpGetUrl = new Uri("http://localhost:8686/userinfoservice/metadata");host.Description.Behaviors.Add(behavior);host.Opened +=delegate{ Console.WriteLine("服务已启动");};host.Open();             Console.ReadKey();host.Close();}

》》》 校验是否成功

在这里插入图片描述
在这里插入图片描述

部署到winform

在这里插入图片描述

 private void button1_Click(object sender, EventArgs e){ServiceHost Host = new ServiceHost(typeof(WCF.Student));//绑定System.ServiceModel.Channels.Binding httpBinding = new BasicHttpBinding();//终结点Host.AddServiceEndpoint(typeof(IWCF.IStudent), httpBinding, "http://localhost:8002/");if (Host.Description.Behaviors.Find<ServiceMetadataBehavior>() == null){//行为ServiceMetadataBehavior behavior = new ServiceMetadataBehavior();behavior.HttpGetEnabled = true;//元数据地址behavior.HttpGetUrl = new Uri("http://localhost:8002");Host.Description.Behaviors.Add(behavior);//启动Host.Open();}}

》》》验证
在这里插入图片描述
app.config 配置

<service name="WCF.Student" behaviorConfiguration="behaviorConfiguration"><!--//服务的对象--><host><baseAddresses><add baseAddress="http://localhost:5678"/><!--// 服务的IP和端口号--></baseAddresses></host><endpoint address="" binding="wsHttpBinding" contract="IWCF.IStudent"></endpoint><!--//contract:服务契约--></service></services><behaviors><serviceBehaviors><behavior name="behaviorConfiguration"><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="False"/></behavior></serviceBehaviors></behaviors></system.serviceModel>

在这里插入图片描述

》》》》验证
在这里插入图片描述

WCF 宿主 服务中

在这里插入图片描述
在这里插入图片描述
》》》 app.config 或者写作code 都行
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
LocalService:充当本地计算机上非特权用户的帐户,该帐户将匿名凭据提供给所有远程服务器。

NetworkService:提供广泛的本地特权的帐户,该帐户将计算机的凭据提供给所有远程服务器。

LocalSystem:服务控制管理员使用的帐户,它具有本地计算机上的许多权限并作为网络上的计算机。

User:由网络上特定的用户定义的帐户。如果为 ServiceProcessInstaller.Account 成员指定 User,则会使系统在安装服务时提示输入有效的用户名和密码,除非您为 ServiceProcessInstaller 实例的 Username 和 Password 这两个属性设置值。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

删除服务

sc delete 服务名称
在这里插入图片描述
在这里插入图片描述

window 服务调试
正常是无法调试的,可以在window服务中做调整
如下

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

window 服务 卸载

》》》1 在cmd中 录入 sc delete 服务名称 注意注意 是服务名称 不是显示名称

这种方法 不需要 停车服务,可以直接干掉

》》》2、 代码实现
卸载前,一定要停止掉Windows服务,否则需要重启或注销电脑。代码无法停止服务时,使用services.msc来停止。
获取系统所有window 服务
ServiceController[] services = ServiceController.GetServices();

》》》》“Service1.cs”的代码,增加服务启动日志和停止日志。

using CommonUtils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;namespace ADemoWinSvc
{public partial class Service1 : ServiceBase{public Service1(){InitializeComponent();}protected override void OnStart(string[] args){GLog.WLog("服务已启动");}protected override void OnStop(){GLog.WLog("服务已停止");}}
}

》》》》 工具类

using System;
using System.IO;namespace CommonUtils
{public static class GLog{static object _lockObj = new object();public static void WLog(string content){lock (_lockObj){string curPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);string logDir = "Logs";string logDirFullName = Path.Combine(curPath, logDir);try{if (!Directory.Exists(logDirFullName))Directory.CreateDirectory(logDirFullName);}catch { return; }string fileName = "Logs" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";string logFullName = Path.Combine(logDirFullName, fileName);try{using (FileStream fs = new FileStream(logFullName, FileMode.Append, FileAccess.Write))using (StreamWriter sw = new StreamWriter(fs))sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + " " + content);}catch { return; }}}}
}

========= 上面代码都是 服务中的

下面代码 是winForm程序中的==
在这里插入图片描述

using CommonUtils;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace Windows服务操作
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){}/// <summary>/// windows服务名/// </summary>static string _winSvcName = "ADemoWinSvc";/// <summary>/// windows服务对应的exe 名/// </summary>static string _winSvcExeName = "ADemoWinSvc.exe";private void btnSetup_Click(object sender, EventArgs e){try{//是否存在服务if (ServiceUtil.ServiceIsExisted(_winSvcName)){//已存在,检查是否启动if (ServiceUtil.IsRun(_winSvcName)){//服务是已启动状态lblMsg.Text = "[001]服务是已启动状态";}else{//未启动,则启动ServiceUtil.StarService(_winSvcName);lblMsg.Text = "[002]服务是已启动状态";}}else{//不存在,则安装IDictionary mySavedState = new Hashtable();string curPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName);string apppath = Path.Combine(curPath, _winSvcExeName);ServiceUtil.InstallService(mySavedState, apppath);lblMsg.Text = "[003]服务是已启动状态";//安装后并不会自动启动。需要启动这个服务ServiceUtil.StarService(_winSvcName);lblMsg.Text = "[004]服务是已启动状态";}}catch (Exception ex){MessageBox.Show(ex.Message);}}private void btnUninstall_Click(object sender, EventArgs e){//** 卸载服务最重要的是先停止,否则电脑需要重启或注销 **try{//是否存在服务if (!ServiceUtil.ServiceIsExisted(_winSvcName)){MessageBox.Show("服务不存在,不需要卸载");return;}//如果服务正在运行,停止它if (ServiceUtil.IsRun(_winSvcName)){ServiceUtil.StopService(_winSvcName);}//再检查一次是否在运行if (ServiceUtil.IsRun(_winSvcName)){MessageBox.Show("服务无法停止,请手动停止这个服务");return;}//卸载ServiceUtil.UnInstallServiceByName(_winSvcName);lblMsg.Text = "[005]服务已卸载";}catch (Exception ex){MessageBox.Show(ex.Message);}}}
}

》》》》》
AssemblyInstaller 帮助文件
https://learn.microsoft.com/zh-cn/dotnet/api/system.configuration.install.assemblyinstaller?view=netframework-4.8.1

》》》》 工具类

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration.Install;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;namespace CommonUtils
{/// <summary>/// windows服务操作工具类/// </summary>public static class ServiceUtil{/// <summary>/// 服务是否正在运行/// </summary>/// <param name="name"></param>/// <returns></returns>public static bool IsRun(string name){bool IsRun = false;try{if (!ServiceIsExisted(name)) return false;var sc = new ServiceController(name);if (sc.Status == ServiceControllerStatus.StartPending || sc.Status == ServiceControllerStatus.Running){IsRun = true;}sc.Close();}catch{IsRun = false;}return IsRun;}/// <summary>/// 启动服务/// </summary>/// <param name="name"></param>/// <returns></returns>public static bool StarService(string name){try{var sc = new ServiceController(name);if (sc.Status == ServiceControllerStatus.Stopped || sc.Status == ServiceControllerStatus.StopPending){sc.Start();sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 10));}else{}sc.Close();return true;}catch (Exception ex){throw ex;}}/// <summary>/// 停止服务(有可能超时)/// </summary>/// <param name="name"></param>/// <returns></returns>public static bool StopService(string name){try{var sc = new ServiceController(name);if (sc.Status == ServiceControllerStatus.Running || sc.Status == ServiceControllerStatus.StartPending){sc.Stop();//停止服务超时时间:56秒。sc.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 56));}else{}sc.Close();return true;}catch (Exception ex){throw ex;}}/// <summary>/// 是否存在/// </summary>/// <param name="serviceName"></param>/// <returns></returns>public static bool ServiceIsExisted(string serviceName){ServiceController[] services = ServiceController.GetServices();foreach (ServiceController s in services)if (s.ServiceName.ToLower() == serviceName.ToLower())return true;return false;}/// <summary>/// 安装/// </summary>/// <param name="stateSaver"></param>/// <param name="filepath"></param>public static void InstallService(IDictionary stateSaver, string filepath){try{AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();myAssemblyInstaller.UseNewContext = true;myAssemblyInstaller.Path = filepath;myAssemblyInstaller.Install(stateSaver);myAssemblyInstaller.Commit(stateSaver);myAssemblyInstaller.Dispose();}catch (Exception ex){throw ex;}}/// <summary>/// 使用路径卸载(有时候不便于用路径来卸载,则使用SC DELETE 名称来卸载)/// </summary>/// <param name="filepath"></param>public static void UnInstallService(string filepath){try{AssemblyInstaller myAssemblyInstaller = new AssemblyInstaller();myAssemblyInstaller.UseNewContext = true;myAssemblyInstaller.Path = filepath;myAssemblyInstaller.Uninstall(null);myAssemblyInstaller.Dispose();}catch (Exception ex){throw ex;}}/// <summary>/// 使用windows服务名卸载/// </summary>/// <param name="WinServiceName"></param>public static void UnInstallServiceByName(string WinServiceName){ProcessStartInfo pStart = new ProcessStartInfo("sc.exe");Process pRoc = new Process();pStart.Arguments = " delete " + WinServiceName;pStart.UseShellExecute = false;pStart.CreateNoWindow = false;pRoc.StartInfo = pStart;pRoc.Start();pRoc.WaitForExit();}}
}

WebAPI 部署

部署 IIS

跟wcf 、webservice 一样。

部署 控制台

相关文章:

.NET WebService \ WCF \ WebAPI 部署总结 以及 window 服务 调试

一、webservice 部署只能部署IIS上&#xff0c; 比较简单&#xff0c;就不做说明了 二、 WCF 部署 1 部署到IIS 跟部署 webservice 部署方法一样的 wcf 部署2 部署到控制台 要以管理员运行vs&#xff0c;或者 管理员运行 控制台的exe 在控制器项目中 创建IUserInfoService 接口…...

Centos系统实用运维命令记录(持续更新)

本文记录Centos服务器常用的运维命令&#xff0c;备忘 查询当前内存占用最高(前10)的进程列表和占用比例&#xff0c;进程ID ps -eo pid,comm,%mem,cmd --sort-%mem | head -n 11注: 内存警报时定位问题时非常有用 查询占用某个端口号的进程id lsof -i :9000注: 后面的9000…...

大势模方在修模过程中,如何导入su单体模型?

答&#xff1a;在单体化界面右键即可显示导入入口&#xff0c;若仍不可行&#xff0c;需要换最新版dv 模方是一款针对实景三维模型的冗余碎片、水面残缺、道路不平、标牌破损、纹理拉伸模糊等共性问题研发的实景三维模型修复编辑软件。模方4.1新增自动单体化建模功能&#xff…...

uniapp百度地图聚合

// loadBMap.js ak 百度key export default function loadBMap(ak) {return new Promise((resolve, reject) > {//聚合API依赖基础库,因此先加载基础库再加载聚合APIasyncLoadBaiduJs(ak).then(() > {// 调用加载第三方组件js公共方法加载其他资源库// 加载聚合API// Ma…...

nginx的应用部署nginx

这里写目录标题 nginxnginx的优点什么是集群常见的集群什么是正向代理、反向代理、透明代理常见的代理技术正向代理反向代理透明代理 nginx部署 nginx nginx&#xff08;发音同enginex&#xff09;是一款轻量级的Web服务器/反向代理服务器及电子邮件&#xff08;IMAP/POP3&…...

Centos固定静态ip地址

这里我用的是Vmware虚拟机搭建的三台机器 进入 cd /etc/sysconfig/network-scripts然后使用 ip addr命令&#xff0c;查看自己虚拟机的以太网地址。 我这里是ens33 上面的第一个选项是本地环回地址&#xff0c;不用管它 然后查看刚刚进入的network-scripts目录下的文件 找到…...

豆芽机置入语音芯片WTN6040-8S:开启智能生活新篇章,让豆芽制作更便捷有趣

豆芽机的开发背景&#xff1a; 豆芽作为一种营养丰富、味道鲜美的食品&#xff0c;深受广大消费者的喜爱。然而&#xff0c;传统的豆芽生产过程繁琐&#xff0c;需要耗费大量的时间和人力&#xff0c;且存在生产效率低、质量不稳定等问题。随着人们生活节奏的加快和对健康饮食的…...

BLIP2预研笔记

0. 前言 文章是公司内部分享学习写的预研报告&#xff0c;里面有小部分文段是直接从网上借鉴的&#xff0c;侵删 1. 任务和方法历史进化&#xff1a; 在大模型等类似的预训练模型的方式&#xff08;以包含“预训练阶段”等n阶段训练方式为特色&#xff09;为主流之前&#xf…...

安卓开发问题:安卓Ble出现动态鉴权失败以及扫描设备一直进入不了的问题

问题1描述 1、安卓12需要动态鉴权 // 鉴权函数 requestPermissions(permissionsList.toArray(strings), MyConstants.REQUEST_CODE_PERMISSIONS);但是在鉴权回调函数中如Manifest.permission.BLUETOOTH_SCAN、Manifest.permission.BLUETOOTH_CONNECT一直显示失败&…...

DSP ARM FPGA 实验箱_音频处理_滤波操作教程:3-9 音频信号的滤波实验

一、实验目的 掌握Matlab辅助设计滤波器系数的方法&#xff0c;并实现音频混噪及IIR滤波器滤除&#xff0c;并在LCD上显示音频信号的FFT计算结果。 二、实验原理 音频接口采用的是24.576MHz&#xff08;读兆赫兹&#xff09;晶振&#xff0c;实验板上共有3个音频端口&#x…...

Rust多线程交叉打印+Send Sync特征讲解

导航 Rust多线程交叉打印Send Sync特征讲解 一、Rust多线程交叉打印二、Send Sync 特征讲解 Rust多线程交叉打印Send Sync特征讲解 一、Rust多线程交叉打印 先说背景有两个线程&#xff0c;分别为0号线程和1号线线程两个线程交叉打印共享值&#xff0c;并将共享值1当标志为fa…...

C#爬虫爬取某东商品信息

&#x1f3c6;作者&#xff1a;科技、互联网行业优质创作者 &#x1f3c6;专注领域&#xff1a;.Net技术、软件架构、人工智能、数字化转型、DeveloperSharp、微服务、工业互联网、智能制造 &#x1f3c6;欢迎关注我&#xff08;Net数字智慧化基地&#xff09;&#xff0c;里面…...

【Stylus详解与引入】

文章目录 Stylus详解与引入一、Stylus简介二、Stylus的特性1. 变量2. 嵌套规则3. 混合&#xff08;Mixins&#xff09;4. 函数5. 条件语句和循环 三、Stylus的引入与配置1. 安装Stylus和stylus-loader2. 配置Webpack3. 在Vue项目中使用Stylus4. 编译Stylus代码四、Stylus的性能…...

001 登录(md5加密)

文章目录 pom.xmlLoginController.javaUserMapper.javaUser.javaUserServiceImpl.javaUserService.javaMD5Util.javaMD5UtilTest.javaValidatorUtil.javaLoginVo.javaRespBean.javaRespBeanEnum.javaSeckillApplication.javaUserMapper.xmllogin.htmlapplication.yamlsql 传统方…...

Linux学习笔记5---WSL2编译裸机程序并烧录至SD卡

在用WLS进行开发的时候发现在mnt/底下竟然识别不了U盘&#xff01;&#xff01;也识别不了SD卡&#xff01;&#xff01;那程序不就不能烧录到SD卡上了&#xff1f;&#xff1f;&#xff1f;那还开发个锤子。 在网上查找了一些相关资料&#xff0c;发现可以通过Win32DiskImager…...

React 第二十九章 React 和 Vue 描述页面的区别

面试题&#xff1a;React 和 Vue 是如何描述 UI 界面的&#xff1f;有一些什么样的区别&#xff1f; 标准且浅显的回答&#xff1a; React 中使用的是 JSX&#xff0c;Vue 中使用的是模板来描述界面 前端领域经过长期的发展&#xff0c;目前有两种主流的描述 UI 的方案&#xf…...

Dnspy附加进程调试---代码被优化及无法获取局部变量

代码被优化或者无法获取局部变量的效果图如下&#xff1a; 当你在调试的时候&#xff0c;看到这种情况还是挺恼火的&#xff0c;经过查阅资料后&#xff0c;发现可以这种解决&#xff1a; 参考链接&#xff1a;Making an Image Easier to Debug dnSpy/dnSpy Wiki GitHub 假设…...

Redis---------实现更改数据业务,包括缓存更新,缓存穿透雪崩击穿的处理

三种更新策略 内存淘汰是Redis内存的自动操作&#xff0c;当内存快满了就会触发内存淘汰。超时剔除则是在存储Redis时加上其有限期(expire)&#xff0c;有限期一过就会自动删除掉。而主动更新则是自己编写代码去保持更新&#xff0c;所以接下来研究主动更新策略。 主动更新策略…...

蓝牙小车的具体实现

title: 蓝牙小车开发时的一些细节 cover: >- https://tse1-mm.cn.bing.net/th/id/OIP-C.BrSgB91U1MPHGyaaZEqcbwHaEo?w273&h180&c7&r0&o5&dpr1.3&pid1.7 abbrlink: 842d5faf date: tags: #小车基本运动之最重要的—PWM ##1.PWM&#xff08;Pulse …...

污染修复乙级设计资质中关于设计成果保护的规定

关于污染修复乙级设计资质中设计成果的保护&#xff0c;虽然直接针对该资质的设计成果保护规定可能未在公开资料中有详细阐述&#xff0c;但根据中国知识产权法律体系和行业惯例&#xff0c;设计成果作为智力成果的一部分&#xff0c;主要受以下几个方面的法律保护&#xff1a;…...

376. Wiggle Subsequence

376. Wiggle Subsequence 代码 class Solution { public:int wiggleMaxLength(vector<int>& nums) {int n nums.size();int res 1;int prediff 0;int curdiff 0;for(int i 0;i < n-1;i){curdiff nums[i1] - nums[i];if( (prediff > 0 && curdif…...

Cinnamon修改面板小工具图标

Cinnamon开始菜单-CSDN博客 设置模块都是做好的&#xff0c;比GNOME简单得多&#xff01; 在 applet.js 里增加 const Settings imports.ui.settings;this.settings new Settings.AppletSettings(this, HTYMenusonichy, instance_id); this.settings.bind(menu-icon, menu…...

三体问题详解

从物理学角度&#xff0c;三体问题之所以不稳定&#xff0c;是因为三个天体在万有引力作用下相互作用&#xff0c;形成一个非线性耦合系统。我们可以从牛顿经典力学出发&#xff0c;列出具体的运动方程&#xff0c;并说明为何这个系统本质上是混沌的&#xff0c;无法得到一般解…...

Linux 内存管理实战精讲:核心原理与面试常考点全解析

Linux 内存管理实战精讲&#xff1a;核心原理与面试常考点全解析 Linux 内核内存管理是系统设计中最复杂但也最核心的模块之一。它不仅支撑着虚拟内存机制、物理内存分配、进程隔离与资源复用&#xff0c;还直接决定系统运行的性能与稳定性。无论你是嵌入式开发者、内核调试工…...

mac 安装homebrew (nvm 及git)

mac 安装nvm 及git 万恶之源 mac 安装这些东西离不开Xcode。及homebrew 一、先说安装git步骤 通用&#xff1a; 方法一&#xff1a;使用 Homebrew 安装 Git&#xff08;推荐&#xff09; 步骤如下&#xff1a;打开终端&#xff08;Terminal.app&#xff09; 1.安装 Homebrew…...

从面试角度回答Android中ContentProvider启动原理

Android中ContentProvider原理的面试角度解析&#xff0c;分为​​已启动​​和​​未启动​​两种场景&#xff1a; 一、ContentProvider已启动的情况 1. ​​核心流程​​ ​​触发条件​​&#xff1a;当其他组件&#xff08;如Activity、Service&#xff09;通过ContentR…...

嵌入式常见 CPU 架构

架构类型架构厂商芯片厂商典型芯片特点与应用场景PICRISC (8/16 位)MicrochipMicrochipPIC16F877A、PIC18F4550简化指令集&#xff0c;单周期执行&#xff1b;低功耗、CIP 独立外设&#xff1b;用于家电、小电机控制、安防面板等嵌入式场景8051CISC (8 位)Intel&#xff08;原始…...

用鸿蒙HarmonyOS5实现中国象棋小游戏的过程

下面是一个基于鸿蒙OS (HarmonyOS) 的中国象棋小游戏的实现代码。这个实现使用Java语言和鸿蒙的Ability框架。 1. 项目结构 /src/main/java/com/example/chinesechess/├── MainAbilitySlice.java // 主界面逻辑├── ChessView.java // 游戏视图和逻辑├──…...

【Kafka】Kafka从入门到实战:构建高吞吐量分布式消息系统

Kafka从入门到实战:构建高吞吐量分布式消息系统 一、Kafka概述 Apache Kafka是一个分布式流处理平台,最初由LinkedIn开发,后成为Apache顶级项目。它被设计用于高吞吐量、低延迟的消息处理,能够处理来自多个生产者的海量数据,并将这些数据实时传递给消费者。 Kafka核心特…...

字符串哈希+KMP

P10468 兔子与兔子 #include<bits/stdc.h> using namespace std; typedef unsigned long long ull; const int N 1000010; ull a[N], pw[N]; int n; ull gethash(int l, int r){return a[r] - a[l - 1] * pw[r - l 1]; } signed main(){ios::sync_with_stdio(false), …...