/// <summary>
 /// 根据端口号获取进程ID
 /// </summary>
 /// <param name="port"></param>
 /// <returns></returns>
 public static int GetPidByPort(int port)
 {
     try
     {
         TcpRow[] list = GetTcps();
         if (Ls.Ok(list))
         {
             foreach (var item in list)
             {
                 if (item.LocalPort == port)
                 {
                     return(item.ProcessId);
                 }
             }
         }
     }
     catch { }
     try
     {
         UdpRow[] list = GetUdps();
         if (Ls.Ok(list))
         {
             foreach (var item in list)
             {
                 if (item.LocalPort == port)
                 {
                     return(item.ProcessId);
                 }
             }
         }
     }
     catch { }
     return(-1);
 }
        public override int GetHashCode()
        {
            int hashCode = -1049898043;

            hashCode = hashCode * -1521134295 + Id.GetHashCode();
            hashCode = hashCode * -1521134295 + LabBookId.GetHashCode();
            hashCode = hashCode * -1521134295 + Lm.GetHashCode();
            hashCode = hashCode * -1521134295 + Am.GetHashCode();
            hashCode = hashCode * -1521134295 + Bm.GetHashCode();
            hashCode = hashCode * -1521134295 + Ls.GetHashCode();
            hashCode = hashCode * -1521134295 + As.GetHashCode();
            hashCode = hashCode * -1521134295 + Bs.GetHashCode();
            hashCode = hashCode * -1521134295 + WIm.GetHashCode();
            hashCode = hashCode * -1521134295 + YIm.GetHashCode();
            hashCode = hashCode * -1521134295 + WIs.GetHashCode();
            hashCode = hashCode * -1521134295 + YIs.GetHashCode();
            hashCode = hashCode * -1521134295 + X.GetHashCode();
            hashCode = hashCode * -1521134295 + Y.GetHashCode();
            hashCode = hashCode * -1521134295 + Z.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Comment);

            hashCode = hashCode * -1521134295 + Created.GetHashCode();
            hashCode = hashCode * -1521134295 + Updated.GetHashCode();
            return(hashCode);
        }
Example #3
0
        /// <summary>
        /// 获取所有目录中的所有文件
        /// </summary>
        /// <param name="path"></param>
        /// <param name="action"></param>
        /// <param name="patterns"></param>
        public static void GetAllFile(string path, Action <List <string> > action, string[] patterns = null)
        {
            List <string> allpath = DirFinder.GetAllPath(path);

            if (allpath == null)
            {
                allpath = new List <string>();
            }
            allpath.Add(path);

            foreach (var p in allpath)
            {
                if (Ls.Ok(patterns))
                {
                    foreach (var pattern in patterns)
                    {
                        List <string> files = GetFile(p, pattern);
                        if (Ls.Ok(files))
                        {
                            action?.Invoke(files);
                        }
                    }
                }
                else
                {
                    List <string> files = GetFile(p);
                    if (Ls.Ok(files))
                    {
                        action?.Invoke(files);
                    }
                }
            }
        }
Example #4
0
    public void Solve()
    {
        int N = ri();

        int[] LArray = ria();
        if (N < 3)
        {
            Console.WriteLine(0);
            Console.ReadLine();
            return;
        }

        Array.Sort(LArray);
        int[][] Lss = Combination.Enumerate(LArray, 3, withRepetition: false).ToArray();

        int ans = 0;

        foreach (int[] Ls in Lss)
        {
            if (Ls.Distinct().Count() != 3)
            {
                continue;
            }

            Array.Sort(Ls);
            if (Ls[2] < Ls[0] + Ls[1])
            {
                ans++;
            }
        }


        Console.WriteLine(ans);
        Console.ReadLine();
    }
Example #5
0
 internal static void Bind(ref List <USBStorageModel> list)
 {
     if (Ls.Ok(list) && Ls.Ok(__USBIDS))
     {
         foreach (var item in list)
         {
             string vid = item.VID.Substring(4, 4);
             string pid = item.PID.Substring(4, 4);
             //查询厂商信息
             var vendor = __USBIDS.FirstOrDefault(x => x.VendorID == vid);
             if (vendor != null)
             {
                 item.VendorName = vendor.VendorName;//设置厂商信息
                 if (Ls.Ok(vendor.USBProducts))
                 {
                     //查询产品信息
                     var product = vendor.USBProducts.FirstOrDefault(x => x.ProductID.Contains(pid));
                     if (product != null)
                     {
                         item.ProductName = product.ProductName;                 //设置产品信息
                     }
                 }
             }
         }
     }
 }
Example #6
0
        /// <summary>
        /// 清理日志文件
        /// </summary>
        public static void CleanLogFile()
        {
            Task.Factory.StartNew(() =>
            {
                if (IsCleaning == false)
                {
                    IsCleaning = true;

                    List <string> all_log    = GetAllLogFile();
                    List <string> expire_log = GetExpireLogFile(all_log, out long allSize, out long expireSize);

                    if (Ls.Ok(expire_log))
                    {
                        foreach (var file in expire_log)
                        {
                            FileTool.Delete(file);
                        }

                        R.SystemStatus.DriveTotal = DriveTool.GetDriveTotalSize(R.Paths.App);
                        R.SystemStatus.DriveAvail = DriveTool.GetDriveAvailableSize(R.Paths.App);
                        LogCleaner.LogFileAnalyse();
                    }

                    IsCleaning = false;
                }
            });
        }
Example #7
0
        // GET: Report
        public ActionResult Index()
        {
            using (Muse db = new Muse())
            {
                IEnumerable <ReportDataSourceModel> sources = db.GetAll <ReportDataSourceModel>(new string[] { "ReportDataSetModels" }, false);

                if (Ls.Ok(sources))
                {
                    var    source = sources.First();
                    string cs     = source.ConnectionString;
                    string sql    = source.ReportDataSets.First().Sql;

                    MySqlHelper msHelper = new MySqlHelper(cs);
                    DataTable   a        = msHelper.Select(sql, out int recordsAffected);
                    ReportModel ri       = new ReportModel()
                    {
                        DataTable    = a,
                        ReportOption = new ReportOptionModel()
                        {
                            Title      = "标题XXXXXX",
                            Type       = "ECharts.BasicLineChart",
                            Dimensions = "continent,cts,rgs",
                            SeriesType = "bar,bar",
                            Height     = 400,
                        }
                    };
                    ViewBag.Report = ri;
                }
            }
            return(View());
        }
Example #8
0
 public static List <NetworkInterface> GetNetworkInterfaces()
 {
     try
     {
         NetworkInterface[] adapters = NetworkInterface.GetAllNetworkInterfaces();
         if (Ls.Ok(adapters))
         {
             foreach (var item in adapters)
             {
                 try
                 {
                     if (NetworkInterfaces.Any(x => x.Id == item.Id))
                     {
                     }
                     else
                     {
                         NetworkInterfaces.Add(item);
                     }
                 }
                 catch { }
             }
         }
     }
     catch { }
     return(NetworkInterfaces);
 }
Example #9
0
        private void Do()
        {
            Task.Factory.StartNew(() =>
            {
                List <int> ports = CMDNetstatTool.GetAvailablePorts(10, 52810);
                if (Ls.Ok(ports))
                {
                    foreach (var p in ports)
                    {
                        try
                        {
                            R.Tx.TcppPort   = p;
                            R.Tx.TcppServer = new TcppServer(R.Tx.TcppPort, TcppEvent.ReceiveMessage,
                                                             TcppEvent.OnConnect, TcppEvent.OnDisconnect);
                            R.Tx.TcppServer.Start();//启动 Socket Tcp 通信机制
                            IniTool.Set(R.Files.Settings, "Tx", "TcppPort", R.Tx.TcppPort);
                            IniTool.Set(R.Files.Settings, "Tx", "StartTime", DateTime.Now.ToString());
                            break;
                        }
                        catch { }
                    }
                }

                R.USBListener.Start();        // 启动USB监控
                R.USBStorageListener.Start(); // 启动U盘监控
            });
        }
Example #10
0
        public static void Bind(ref List <USBDeviceModel> list)
        {
            var ids = GetStorageID();

            if (Ls.Ok(ids) && Ls.Ok(list))
            {
                foreach (var l in list)
                {
                    foreach (var i in ids)
                    {
                        if (l.VID.Contains(i.VID) && l.PID.Contains(i.PID))
                        {
                            l.IsStorage = true;
                        }
                    }
                }
            }

            var vols = GetAll();

            if (Ls.Ok(vols) && Ls.Ok(list))
            {
                foreach (var l in list)
                {
                    foreach (var v in vols)
                    {
                        if (l.VID.Contains(v.VID) && l.PID.Contains(v.PID))
                        {
                            l.Volume += v.Symbol + ",";
                        }
                    }
                }
            }
        }
Example #11
0
        public static List <USBStorageModel> GetAll()
        {
            List <USBStorageModel> result = new List <USBStorageModel>();

            try
            {
                var idList = GetStorageID();
                if (Ls.Ok(idList))
                {
                    foreach (var id in idList)
                    {
                        var volumeList = GetVolumeID(id);
                        if (Ls.Ok(volumeList))
                        {
                            foreach (var volume in volumeList)
                            {
                                var storageList = GetStorage(id, volume);
                                if (Ls.Ok(storageList))
                                {
                                    result.AddRange(storageList);
                                }
                            }
                        }
                    }
                }
            }
            catch { }
            return(result);
        }
Example #12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetLast10Days();

            List <string> file_list = new List <string>();
            var           md        = Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetToday();
            var           md2       = Azylee.YeahWeb.ExtWebAPI.BingWebAPI.WallpaperUtils.WallpaperTool.GetYesterday();

            if (md != null && Ls.Ok(md.images))
            {
                foreach (var item in md.images)
                {
                    string image_url   = item.GetImageUrl();
                    string file_path   = DirTool.Combine(@"F:\imgs", item.hsh + ".jpg");
                    bool   down_result = HttpTool.Download(image_url, file_path);
                    if (down_result)
                    {
                        file_list.Add(file_path);
                    }
                }
            }
            //string a = WallpaperTool.Get();

            //bool b = WallpaperTool.Set(@"C:\Users\yuzhengyang\Pictures\\cc.jpg");

            //Bitmap b1 = new Bitmap(@"F:\图片压缩测试\未标题-1.jpg");
            //byte[] b1_byte = IMG.Compression(b1, 30);
            //File.WriteAllBytes(@"F:\图片压缩测试\未标题-1(Compression).jpg", b1_byte);
        }
Example #13
0
        public static List <USBStorageIDModel> GetStorageID()
        {
            List <USBStorageIDModel> result = null;

            try
            {
                RegistryKey usbsKey = Registry.LocalMachine.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR\Enum", false);
                if (usbsKey != null)
                {
                    string[] usbs = usbsKey.GetValueNames();
                    if (Ls.Ok(usbs))
                    {
                        result = new List <USBStorageIDModel>();
                        foreach (var usb in usbs)
                        {
                            object valueObj = usbsKey.GetValue(usb);
                            string value    = valueObj.ToString();
                            if (int.TryParse(usb, out int index) && value.Contains("USB"))
                            {
                                result.Add(USBStorageIDModel.String2Model(value));
                            }
                        }
                    }
                }
            }
            catch { }
            return(result);
        }
        private void Descendre_List <T>(object sender, RoutedEventArgs e)
            where T : ObjetGestion
        {
            ListBox V; ListeObservable <T> Liste; List <T> Ls; T L;

            if (Info(sender as MenuItem, out V, out Liste, out Ls, out L))
            {
                // On test si une ligne n'est pas à la dernière position pour eviter les erreurs
                foreach (T iL in Ls)
                {
                    if (Liste.IndexOf(iL) == (Liste.Count - 1))
                    {
                        return;
                    }
                }

                // Si c'est bon, on les déplace toutes
                Ls.Reverse();
                foreach (T iL in Ls)
                {
                    int De = Liste.IndexOf(iL);

                    Liste.Move(De, De + 1);
                }

                Liste.Numeroter();
            }
        }
Example #15
0
        /// <summary>
        /// 查询过期的日志文件(15天前)
        /// </summary>
        /// <returns></returns>
        private static List <string> GetExpireLogFile(List <string> list, out long allSize, out long expireSize)
        {
            List <string> result = new List <string>();

            allSize    = 0;
            expireSize = 0;
            if (Ls.Ok(list))
            {
                foreach (var file in list)
                {
                    try
                    {
                        FileInfo file_info = new FileInfo(file);
                        if (file_info.LastWriteTime.AddDays(15) < DateTime.Now)
                        {
                            result.Add(file);
                            expireSize += file_info.Length;
                        }
                        allSize += file_info.Length;
                    }
                    catch { }
                }
            }
            return(result);
        }
        public object Any(Ls request)
        {
            var result = DfsUtils.listFiles();

            return(new LsResponse {
                Result = new List <FileHeader>(result.Item1.Values.ToArray()), inactiveWorkers = result.Item2
            });
        }
Example #17
0
 public bool IsExistByNumber(int number)
 {
     if (Ls.Ok(TcpClientList))
     {
         return(TcpClientList.Any(x => x.Number == number));
     }
     return(false);
 }
Example #18
0
 public bool IsExistByHost(string host)
 {
     if (Ls.Ok(TcpClientList))
     {
         return(TcpClientList.Any(x => x.Host == host));
     }
     return(false);
 }
Example #19
0
 public void Setup()
 {
     cliente      = new Client();
     commandHelp  = new Help();
     commantTouch = new Touch();
     commandLs    = new Ls();
     commandMove  = new Mv();
     commandCd    = new Cd();
 }
Example #20
0
        private bool CheckCurrentAuth(HttpContextBase httpContext, List <AuthorizeModel> list, string controller, string action)
        {
            bool result = false;

            if (Ls.Ok(list))
            {
                var userManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                var currentUser = userManager.FindById(httpContext.User.Identity.GetUserId());

                foreach (var item in list)
                {
                    //通配符验证方式
                    if (item.Controller == controller && item.Action == "*")
                    {
                        if (item.IsEnable)
                        {
                            if (item.AllowAnonymous)
                            {
                                result = true;
                            }
                            else
                            {
                                if (currentUser != null && userManager.IsInRole(currentUser.Id, item.Role))
                                {
                                    result = true;
                                }
                            }
                        }
                    }

                    //标准验证方式
                    if (item.Controller == controller && item.Action == action)
                    {
                        if (item.IsEnable)
                        {
                            if (item.AllowAnonymous)
                            {
                                result = true;
                            }
                            else
                            {
                                if (currentUser != null && userManager.IsInRole(currentUser.Id, item.Role))
                                {
                                    result = true;
                                }
                            }
                        }
                    }
                    if (result)
                    {
                        break;        //如果已验证通过,直接跳过其他验证
                    }
                }
            }
            return(result);
        }
Example #21
0
        /// <summary>
        /// 禁用设备列表
        /// </summary>
        /// <param name="host"></param>
        /// <param name="model"></param>
        public static void Disable(TcpDataModel model)
        {
            List <USBDeviceModel> list = Json.Byte2Object <List <USBDeviceModel> >(model.Data);

            if (Ls.Ok(list))
            {
                int count = list.Count(x => x.Running == false);
                R.Toast.Show("启用设备", $"已禁用{count}个设备");
            }
        }
Example #22
0
        internal static List <USBVendorModel> GetByFile()
        {
            string s = TxtTool.Read(R.Files.USBIds);
            List <USBVendorModel> list = Json.String2Object <List <USBVendorModel> >(s);

            if (Ls.Ok(list))
            {
                return(list);
            }
            return(null);
        }
Example #23
0
 public virtual void CopyFrom(Rect other)
 {
     Min.CopyFrom(other.Min);
     Max.CopyFrom(other.Max);
     Ps.Clear();
     Ps.AddRange(other.Ps);
     Ls.Clear();
     Ls.AddRange(other.Ls);
     LLs.Clear();
     LLs.AddRange(other.LLs);
 }
Example #24
0
 private static bool SelectOne(Dictionary <string, List <string> > info, string x)
 {
     foreach (var Ls in info.Values)
     {
         if (Ls.Contains(x))
         {
             return(false);
         }
     }
     return(true);
 }
Example #25
0
 public void NIMainText()
 {
     if (Ls.Ok(R.Hosts))
     {
         NIMain.Text = R.AppNameCHShort + $" [{R.Hosts.Count()}C]";
     }
     else
     {
         NIMain.Text = R.AppNameCHShort;
     }
 }
Example #26
0
        /// <summary>
        /// Makes each level set load the appropriate <paramref name="data"/>
        /// for the given <paramref name="tsi"/>.
        /// </summary>
        /// <param name="tsi">
        /// Information about the time-step
        /// </param>
        /// <param name="data">
        /// Data to be loaded
        /// </param>
        /// <param name="loadedObjects">
        /// Cache for already loaded objects
        /// </param>
        /// <remarks>
        /// Causes an update of the level set tracker!
        /// </remarks>
        public void LoadData(ITimestepInfo tsi, IList <CellFieldDataSet> data, HashSet <object> loadedObjects)
        {
            if (loadedObjects.Contains(this))
            {
                return;
            }

            foreach (var Ls in this.LevelSets)
            {
                Ls.As <LevelSet>().LoadData(tsi, data, loadedObjects);
            }
            this.UpdateTracker(0.0);
            loadedObjects.Add(this);
        }
Example #27
0
 /// <summary>
 /// 检查 Administrator 密码是否正确
 /// </summary>
 /// <param name="pwds"></param>
 /// <returns></returns>
 public static string CheckPasswords(List <string> pwds)
 {
     if (Ls.Ok(pwds))
     {
         foreach (var item in pwds)
         {
             if (CheckPassword(item))
             {
                 return(item);
             }
         }
     }
     return(null);
 }
Example #28
0
        /// <summary>
        /// 禁用设备列表
        /// </summary>
        /// <param name="host"></param>
        /// <param name="model"></param>
        public static void Disable(string host, TcpDataModel model)
        {
            List <USBStorageModel> list = Json.Byte2Object <List <USBStorageModel> >(model.Data);

            if (Ls.Ok(list))
            {
                foreach (var item in list)
                {
                    //if (DevconUSBTool.Disable(item.ID))
                    //    item.Running = false;
                }
            }
            R.Tx.TcppServer.Write(host, 30003001, Json.Object2Byte(list));
        }
 public static void Start()
 {
     Task.Factory.StartNew(() =>
     {
         while (!R.MainUI.IsDisposed)
         {
             if (Ls.Ok(R.Tx.Hosts))
             {
                 R.Store.Persistence();
             }
             Sleep.S(10);
         }
     });
 }
Example #30
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            R.AppointFile = textBox1.Text;
            string filename = Path.GetFileName(R.AppointFile);
            string filemd5  = FileTool.GetMD5(R.AppointFile);

            if (Ls.Ok(R.Tx.Hosts))
            {
                foreach (var item in R.Tx.Hosts)
                {
                    R.Tx.TcppServer.Write(item, 90001000, Json.Object2Byte(new Tuple <string, string>(filename, filemd5)));
                }
            }
        }