private void syncSoftwaresToolStripMenuItem_Click(object sender, EventArgs e) { var assetId = Properties.Settings.Default.AssetId; var token = Properties.Settings.Default.Token; if (!string.IsNullOrEmpty(assetId) && !string.IsNullOrEmpty(token)) { var systemData = new SystemInfo { AssetId = assetId, Softwares = SoftwareInfo.GetInstalledApps(), Hardware = HardwareInfo.GetSystemDetails(), RanOn = DateTime.Now }; var snapShot = JsonConvert.SerializeObject(systemData); var response = DataManager.SendData(snapShot); MessageBox.Show(response ? "Sync Complete" : "Sync Failed"); } else { var settingsDialog = new Settings(); settingsDialog.ShowDialog(); } }
/// <summary> /// From: https://stackoverflow.com/a/59804150/89256 /// </summary> /// <param name="registryKey"></param> /// <returns></returns> private void ReadRegistry( RegistryKey registryRoot, ref List <SoftwareInfo> installedprograms, string registryKey) { using (RegistryKey key = registryRoot.OpenSubKey(registryKey)) { if (key != null) { foreach (string subkey_name in key.GetSubKeyNames()) { using (RegistryKey subkey = key.OpenSubKey(subkey_name)) { if (subkey.GetValue("DisplayName") != null) { var softwareInfo = new SoftwareInfo { Name = GetValue(subkey.GetValue("DisplayName")), Version = GetValue(subkey.GetValue("DisplayVersion")), Installed = GetDate(subkey.GetValue("InstallDate")), Publisher = GetValue(subkey.GetValue("Publisher")), Size = GetSize(subkey.GetValue("EstimatedSize")) }; installedprograms.Add(softwareInfo); } } } } } }
CameraModels IProductCameraModelDetector.GetCameraModels(SoftwareInfo softwareInfo, IProgress <double> progress, CancellationToken token) { if (!new[] { "SDM" }.Contains(softwareInfo?.Product?.Name, StringComparer.InvariantCulture)) { return(null); } if (softwareInfo?.Camera == null) { return(null); } //TODO foreach (var kvp in Cameras) { //TODO foreach (var model in kvp.Value.Models) { //TODO if (model.Prefix.StartsWith(softwareInfo.Camera.Platform)) { return(GetCameraModels(model, kvp.Key, kvp.Value, softwareInfo.Camera)); } } } return(null); }
public LightControlConfig() { lightControlList = new List <LightControl>(); string lightcontrolpath = SoftwareInfo.getInstance().IsUserCamParaTips; System.Xml.Linq.XElement root = null; try { root = System.Xml.Linq.XDocument.Load(lightcontrolpath).Root; } catch (Exception e) { Console.WriteLine(e.Message); return; } System.Xml.Linq.XElement controls = root.Element("LightControls"); foreach (var item in controls.Elements()) { LightControl lc = new LightControl() { lightContolParas = XmlSerializer.Deserialize(item, typeof(LightContolParas)) as LightContolParas }; if (!lightControlList.Contains(lc)) { lightControlList.Add(lc); } } }
//HalconDotNet.HWindowControl hWindControl4 = null; #endregion public void showHoImage(HObject hoImage) { try { if (hoImage != null && hoImage.IsInitialized()) { HOperatorSet.DispObj(hoImage, hWindControl1.HalconWindow); } } catch (Exception e) { MessageBox.Show(Application.Current.Resources.MergedDictionaries.First()["Error displaying real-time images"].ToString() + e.Message); //if (SoftwareInfo.getInstance().Language == "English") //{ // MessageBox.Show("Error displaying real-time images" + e.Message); //} //else //{ // //MessageBox.Show("显示实时图像出错" + e.Message); // Console.WriteLine("显示实时图像出错" + e.Message); //} SoftwareInfo.getInstance().WriteLog("showHoImage:显示实时图像出错\n" + e.ToString()); } }
//双击datagrid的事件 private void RunningInfoGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (RunningInfoGrid.SelectedItem == null || RunningInfoGrid.SelectedItem.GetType() != typeof(RunningStatusInfo)) { return; } //显示图片 try { RunningStatusInfo item = RunningInfoGrid.SelectedItem as RunningStatusInfo; RunningStatusInfo itemTemp = new RunningStatusInfo(); if (!string.IsNullOrEmpty(item.ImagePath)) { Tools.ShowImage_shimgvw(item.ImagePath); } } catch (System.Exception ex) { MessageBox.Show(Application.Current.Resources.MergedDictionaries.First()["Error opening picture"].ToString() + ex.Message); //if (SoftwareInfo.getInstance().Language == "English") //{ // MessageBox.Show("Error opening picture " + ex.Message); //} //else //{ // MessageBox.Show("打开图片出错" + ex.Message); //} SoftwareInfo.getInstance().WriteLog("RunningInfoGrid_MouseDoubleClick:打开图片出错\n" + ex.ToString()); } }
public ModuleInfo GetModule(SoftwareInfo software, byte[] buffer, string hashName) { var tuples = Detectors .Select(d => GetBytes(d, software, hashName)) .ToArray(); return(GetValue(buffer, tuples)); }
public void A() { SoftwareInfo.TryParse("Adobe Photoshop CS3 Windows", out SoftwareInfo software); Assert.Equal("Adobe Photoshop", software.Name); Assert.Equal("CS3", software.Version); Assert.Equal("Windows", software.Platform); }
public void B() { SoftwareInfo.TryParse("Adobe Photoshop CS7", out SoftwareInfo software); Assert.Equal("Adobe Photoshop", software.Name); Assert.Equal("CS7", software.Version); Assert.Null(software.Platform); }
public void C() { SoftwareInfo.TryParse("Adobe Illustrator", out SoftwareInfo software); Assert.Equal("Adobe Illustrator", software.Name); Assert.Null(software.Version); Assert.Null(software.Platform); }
public ModuleInfo GetModule(SoftwareInfo software, byte[] buffer, string hashName) { return(new ModuleInfo { Created = software.Product.Created, Changeset = software.Build?.Changeset, Hash = GetHash(hashName), }); }
private SoftwareItemViewModel CreateItemViewModel(SoftwareInfo software, ModulesInfo modules) { return(new SoftwareItemViewModel { DisplayName = GetDisplayName(software), Info = software, Modules = CreateModulesViewModel(software, modules), }); }
public bool UpdateSoftware(SoftwareInfo software, byte[] buffer) { var productName = software.Product.Name; Logger.LogTrace("Updating {0}", productName); return(SoftwareDetectors .Any(d => d.UpdateSoftware(software, buffer))); }
private DownloadData GetCommonDownload(Match commonMatch, SoftwareInfo info) { var version = info.Product.Version; var download = GetDownload(commonMatch); download.TargetPath = $"{ProductName}-{version}-{download.Path}"; download.RootDir = CommonRoot; return(download); }
public UpdateFunction() { log = new LogRecorder(); log.RecordLog(new StackTrace(true).GetFrame(0).GetFileLineNumber().ToString(), "UpdateFunction.cs", "Initial Start"); CloudSoftwareTotal = new List <SoftwareInfo>(); readyInstallSoftwareInfo = new SoftwareInfo(); readyUninstallSoftwareInfo = new SoftwareInfo(); downloadfilepath = ""; }
/// <summary> /// 检测菜鸟打印组件是否安装到客户机 /// </summary> /// <param name="modelInfo"></param> /// <returns></returns> public static bool IsCaiNiaoPrintInstalled(out SoftwareInfo modelInfo) { bool result = false; modelInfo = null; RegistryKey[] keys = new RegistryKey[] { // search in: CurrentUser Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"), // search in: LocalMachine_32 Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"), // search in: LocalMachine_64 Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall") }; bool isCanStop = false; foreach (var keyItem in keys) { if (isCanStop == true) { break; } var key = keyItem; if (null != key) { foreach (String keyName in key.GetSubKeyNames()) { RegistryKey subkey = key.OpenSubKey(keyName); string displayName = subkey.GetValue("DisplayName") as string; if (!string.IsNullOrEmpty(displayName) && displayName.Contains(CaiNiaoPrintName)) { modelInfo = SystemAppExtension.InitSoftInfoModelFromRegistryKey(ref key, keyName); //获取安装路径 if (string.IsNullOrEmpty(modelInfo.InstallLocation)) { if (!string.IsNullOrEmpty(modelInfo.UninstallString)) { string installDir = Path.GetDirectoryName(modelInfo.UninstallString); modelInfo.InstallLocation = Path.Combine(installDir, CaiNiaoExcutePath); } } result = true; isCanStop = true; break; } } } } return(result); }
private string GetModuleTitle(SoftwareInfo software, string name) { return(null //?? GetModuleTitle(software, name) ?? TryGetModuleTitle(software, name) //?? EnglishGetModuleTitle(software, name) ?? DoGetModuleTitle(software, name) ?? GetDefaultModuleTitle(software, name)); }
public SoftwareInfo GetSoftwareInfo() { var softwareInfo = new SoftwareInfo { OS = GetOsInfo(), Processes = GetProcesses().ToList() }; return(softwareInfo); }
public ModulesInfo GetModules(CardInfo card, CardInfo card2, SoftwareInfo software, IProgress <double> progress, CancellationToken token) { if (card2 == null) { return(null); } var rootPath = card2.GetRootPath(); return(GetModules(software, rootPath, progress, token)); }
public SoftwareCompilerInfo GetCompiler(SoftwareInfo software) { if (software.Camera != null) { return(Data[0]); } else { return(Data[1]); } }
/// <summary> /// 顺德报警记录 /// </summary> //public static string AlarmImagePath = "" ; //public static string AlarmImageType = "" ; /// <summary> /// 设置通道编码器值 /// </summary> /// <param name="ChannelNo"></param> /// <param name="CodeNum"></param> public static void SetChannelCode(int ChannelNo, double CodeNum) { if (ChannelNo == 0) { Channel1Code = Convert.ToDouble(CodeNum / SoftwareInfo.getInstance().DistanceToAlarmCode *SoftwareInfo.getInstance().UniteLenth); } else if (ChannelNo == 1) { Channel2Code = Convert.ToDouble(CodeNum / SoftwareInfo.getInstance().DistanceToAlarmCode *SoftwareInfo.getInstance().UniteLenth2); } }
public SoftwareBuildInfo GetBuild(SoftwareInfo software) { if (software.Camera != null) { return(Data[0][software.Product.Version]); } else { return(Data[1][software.Product.Version]); } }
//private string GetModuleTitle(SoftwareInfo software, string name) //{ // var productName = software.Product.Name; // if (!productName.Equals("CHDK")) // return null; // name = name.Replace('.', '_'); // return CHDK.ResourceManager.GetString($"Module_{name}"); //} private string TryGetModuleTitle(SoftwareInfo software, string name) { var productName = software.Product.Name; var id = ModuleProvider.GetModuleId(productName, name); if (id == null) { return(null); } return(ResourceProvider.GetString(id)); }
private void ProproForm_Load(object sender, EventArgs e) { this.Text = SoftwareInfo.getVersion(); this.cbMzPrecision.SelectedIndex = 1; //默认选择精确到小数点后4位的精度 this.cbAlgorithm.SelectedIndex = 0; //默认选择Aird第一代压缩算法ZDPD this.cbStackLayers.SelectedIndex = 3; //默认堆叠256层 this.tbFolderPath.Text = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); this.tbOperator.Text = Environment.UserName; RedisClient.getInstance(); ConvertTaskManager.getInstance().run(); }
private static string GetDisplayName(SoftwareInfo software) { var productName = software.Product?.Name; if (productName == null) { return(Resources.Software_Product_Unknown_Text); } return(Resources.ResourceManager.GetString($"Product_{productName}") ?? productName); }
private static void DisplayInstalledApps(RegistryKey key, List <SoftwareInfo> softwareInfos) { string displayName; if (key != null) { foreach (String keyName in key.GetSubKeyNames()) { RegistryKey subkey = key.OpenSubKey(keyName); displayName = subkey.GetValue("DisplayName") as string; if (displayName == null) { continue; } if (softwareInfos.Any(q => q.Name == displayName)) { continue; } SoftwareInfo info = new SoftwareInfo(); info.Name = displayName; info.Icon = subkey.GetValue("DisplayIcon") as string; info.Version = subkey.GetValue("DisplayVersion") as string; info.Publisher = subkey.GetValue("Publisher") as string; info.InstallDate = subkey.GetValue("InstallDate") as string; info.InstallLocation = subkey.GetValue("InstallLocation") as string ?? subkey.GetValue("InstallDir") as string; if (info.Icon != null && info.Icon.StartsWith("\"")) { info.Icon = info.Icon.Trim('"'); } if (string.IsNullOrWhiteSpace(info.InstallLocation)) { continue; } if (string.IsNullOrWhiteSpace(info.Icon) && softwareInfos.Any(q => info.InstallLocation == q.InstallLocation && info.Publisher == q.Publisher)) { continue; } //if (string.IsNullOrWhiteSpace(info.Icon) && softwareInfos.Any(q => info.InstallLocation.StartsWith(q.InstallLocation) && info.Publisher == q.Publisher)) //{ // continue; //} //if (string.IsNullOrWhiteSpace(info.Icon) == false) //{ // softwareInfos.RemoveAll(q => q.InstallLocation == info.InstallLocation // && info.Publisher == q.Publisher // && string.IsNullOrWhiteSpace(q.Icon)); //} softwareInfos.Add(info); } } }
/// <summary> /// 写文件,异常写入 /// </summary> /// <param name="str"></param> public static void WriteLog(string str) { try { List <string> ListErrLogFileName = new List <string>() { }; List <string> timeList = new List <string>() { }; string[] strArray = new string[] { }; ListErrLogFileName = Directory.GetFiles(SoftwareInfo.getInstance().ErrorLogPath).ToList(); int count = 0; foreach (string ErrLogFileName in ListErrLogFileName) { strArray = ErrLogFileName.Split(' '); timeList.Add(strArray[strArray.Length - 1].Split('.')[0]); } foreach (string time in timeList) { //相等:0 小于today:1 大于today:-1 DateTime fileTime = Convert.ToDateTime(time); DateTime fileTimeNew = fileTime.AddDays(SoftwareInfo.getInstance().SaveErrorLogTime); if (DateTime.Today.CompareTo(fileTimeNew) == 1) { File.Delete(ListErrLogFileName[count]); } //dates t = DateTime.Today-fileTime; count++; } string path = SoftwareInfo.getInstance().ErrorLogPath; string pathtxt = path + "\\ErrLog " + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } using (StreamWriter sw = new StreamWriter(pathtxt, true)) { sw.WriteLine(DateTime.Now.ToString()); sw.WriteLine(str); sw.WriteLine("---------------------------------------------------------"); sw.Close(); } } catch (Exception ex) { WriteLog(ex.Message); } }
public override string GetBuildName(SoftwareInfo software) { var product = software?.Product; var source = software?.Source; if (product == null || source == null) { return("full"); } return(product.Version?.MinorRevision >= 0 && source.Name.Equals(Source.Name, StringComparison.InvariantCulture) ? string.Empty : "full"); }
private bool UpdateModules(SoftwareInfo software, out ModulesInfo modules, string destPath, IProgress <double> progress, CancellationToken token) { modules = MetadaModulesDetector.GetModules(destPath, destPath, software, progress, token); if (modules != null) { return(false); } modules = FileSystemModulesDetector.GetModules(software, destPath, progress, token); Logger.LogObject(LogLevel.Information, "Detected {0}", modules); return(true); }
public ModulesInfo GetModules(CardInfo card, CardInfo card2, SoftwareInfo software, IProgress <double> progress, CancellationToken token) { var productName = software.Product?.Name; if (productName == null) { return(null); } Logger.LogTrace("Detecting {0} modules from {1}", productName, card.DriveLetter); return(ModulesDetectors .Select(d => d.GetModules(card, card2, software, progress, token)) .FirstOrDefault(m => m != null)); }
public SoftwareInfo GetSoftwareInfo() { var softwareInfo = new SoftwareInfo { OS = GetOsInfo(), Processes = GetProcesses().ToList() }; return softwareInfo; }