Прикрепили длл к ехе
This commit is contained in:
parent
ca3345dce7
commit
7fcb14155b
|
|
@ -9,6 +9,7 @@ using System.Data;
|
|||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
|
|
@ -36,7 +37,7 @@ namespace Reseter2
|
|||
public Form1()
|
||||
{
|
||||
|
||||
|
||||
|
||||
SGlobalSetting.LoadSetting();
|
||||
|
||||
WordsList.MainCategory = SGlobalSetting.LoadWords();
|
||||
|
|
@ -50,6 +51,7 @@ namespace Reseter2
|
|||
//ListComp.SetSelected(1,true);
|
||||
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
InitializeComponent();
|
||||
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
||||
this.Save += settingWordsControl1.Save;
|
||||
this.Save += settingSCCMControl1.Save;
|
||||
this.Save += settingRebootControl1.Save;
|
||||
|
|
@ -64,6 +66,7 @@ namespace Reseter2
|
|||
ListComp.Location = new Point(tb_comp.Location.X, tb_comp.Location.Y + tb_comp.Height);
|
||||
ListComp.Width = tb_comp.Width;
|
||||
ListComp.Visible = false;
|
||||
ListComp.ItemHeight = 14;
|
||||
ListComp.Height = ListComp.ItemHeight * 2;
|
||||
ListComp.Items.Add("Введите запрос");
|
||||
ListComp.SelectedIndexChanged += ListComp_ChangeIndex;
|
||||
|
|
@ -88,7 +91,14 @@ namespace Reseter2
|
|||
tabControl1.SelectedIndex = 1;
|
||||
}
|
||||
|
||||
|
||||
Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||
{
|
||||
if (args.Name.Contains("MySql.Data"))
|
||||
{
|
||||
return Assembly.Load(Reseter2.Properties.Resources.MySql_Data);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void UpdateTree()
|
||||
{
|
||||
|
|
@ -101,22 +111,30 @@ namespace Reseter2
|
|||
{
|
||||
if (CompSelected == null)
|
||||
{
|
||||
DialogResult result = MessageBox.Show("Перезагрузить ПК: " + tb_comp.Text.Trim(), "Создание новой задачи", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result == DialogResult.Yes)
|
||||
if (tb_comp.Text.Length > 0)
|
||||
{
|
||||
Reseter.AddTask(tb_comp.Text.Trim());
|
||||
tabControl1.SelectedIndex = 0;
|
||||
ListComp.SelectedIndex = -1;
|
||||
StopRefreshSeacher = true;
|
||||
tb_comp.Text = "";
|
||||
ListComp.Items.Clear();
|
||||
ListComp.Items.Add("Введите запрос");
|
||||
ListComp.Height = ListComp.ItemHeight * 2;
|
||||
StopRefreshSeacher = false;
|
||||
ListComp.Visible = false;
|
||||
tabControl1.SelectedIndex = 0;
|
||||
DialogResult result = MessageBox.Show("Перезагрузить ПК: " + tb_comp.Text.Trim(), "Создание новой задачи", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
Reseter.AddTask(tb_comp.Text.Trim());
|
||||
tabControl1.SelectedIndex = 0;
|
||||
ListComp.SelectedIndex = -1;
|
||||
StopRefreshSeacher = true;
|
||||
tb_comp.Text = "";
|
||||
ListComp.Items.Clear();
|
||||
ListComp.Items.Add("Введите запрос");
|
||||
ListComp.Enabled = false;
|
||||
ListComp.ItemHeight = 14;
|
||||
ListComp.Height = ListComp.ItemHeight * 2;
|
||||
StopRefreshSeacher = false;
|
||||
ListComp.Visible = false;
|
||||
tabControl1.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Введите имя ПК","Ошибка перезагрузки",MessageBoxButtons.OK,MessageBoxIcon.Warning);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -130,6 +148,8 @@ namespace Reseter2
|
|||
tb_comp.Text = "";
|
||||
ListComp.Items.Clear();
|
||||
ListComp.Items.Add("Введите запрос");
|
||||
ListComp.ItemHeight = 14;
|
||||
ListComp.Enabled = false;
|
||||
ListComp.Height = ListComp.ItemHeight * 2;
|
||||
StopRefreshSeacher = false;
|
||||
ListComp.Visible = false;
|
||||
|
|
@ -554,10 +574,11 @@ namespace Reseter2
|
|||
}
|
||||
|
||||
}
|
||||
public void cb_comp_ResultUpdate(List<string> Items, bool enable)
|
||||
public void cb_comp_ResultUpdate(List<string> Items, bool enable, int itemHeight)
|
||||
{
|
||||
PreSelected = -1;
|
||||
if (ListComp.Items.Count != Items.Count) ListComp.Height = ListComp.ItemHeight * (Items.Count+1) ;
|
||||
ListComp.ItemHeight = itemHeight;
|
||||
ListComp.Height = ListComp.ItemHeight * (Items.Count+1) ;
|
||||
ListComp.Items.Clear();
|
||||
ListComp.Items.AddRange(Items.ToArray());
|
||||
ListComp.Enabled = enable;
|
||||
|
|
@ -590,7 +611,7 @@ namespace Reseter2
|
|||
PreSelected = ListComp.SelectedIndex;
|
||||
// Console.WriteLine(ListComp.SelectedItem.ToString());
|
||||
StopRefreshSeacher = true;
|
||||
tb_comp.Text = ListComp.SelectedItem.ToString();
|
||||
tb_comp.Text = SSeaher.seaherMetod.ResultString(ListComp.SelectedIndex);
|
||||
StopRefreshSeacher = false;
|
||||
ListComp.Refresh();
|
||||
}
|
||||
|
|
@ -603,7 +624,8 @@ namespace Reseter2
|
|||
{
|
||||
|
||||
if (e.Index != -1) {
|
||||
if(e.Index == PreSelected)
|
||||
Point BoundNew = new(e.Bounds.Location.X, e.Bounds.Y + 1);
|
||||
if (e.Index == PreSelected)
|
||||
{
|
||||
e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds);
|
||||
}
|
||||
|
|
@ -616,11 +638,11 @@ namespace Reseter2
|
|||
if(e.Index == ListComp.SelectedIndex)
|
||||
{
|
||||
e.Graphics.FillRectangle(Brushes.DodgerBlue, e.Bounds);
|
||||
e.Graphics.DrawString(ListComp.Items[e.Index].ToString(), e.Font, Brushes.White, e.Bounds.Location);
|
||||
e.Graphics.DrawString(ListComp.Items[e.Index].ToString(), e.Font, Brushes.White, BoundNew);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.DrawString(ListComp.Items[e.Index].ToString(), e.Font, Brushes.Black, e.Bounds.Location);
|
||||
e.Graphics.DrawString(ListComp.Items[e.Index].ToString(), e.Font, Brushes.Black, BoundNew);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,71 +1,73 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программным средством.
|
||||
// Версия среды выполнения: 4.0.30319.42000
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильному поведению и будут утрачены, если
|
||||
// код создан повторно.
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Reseter2.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace Reseter2.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурсов со строгим типом для поиска локализованных строк и пр.
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс был автоматически создан при помощи StronglyTypedResourceBuilder
|
||||
// класс с помощью таких средств, как ResGen или Visual Studio.
|
||||
// Для добавления или удаления члена измените файл .ResX, а затем перезапустите ResGen
|
||||
// с параметром /str или заново постройте свой VS-проект.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Возврат кэшированного экземпляра ResourceManager, используемого этим классом.
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Reseter2.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Переопределяет свойство CurrentUICulture текущего потока для всех
|
||||
/// подстановки ресурсов с помощью этого класса ресурсов со строгим типом.
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Byte[].
|
||||
/// </summary>
|
||||
internal static byte[] MySql_Data {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("MySql_Data", resourceCulture);
|
||||
return ((byte[])(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
|
|
@ -60,6 +60,7 @@
|
|||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
|
|
@ -68,9 +69,10 @@
|
|||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
|
|
@ -85,9 +87,10 @@
|
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
|
|
@ -109,9 +112,13 @@
|
|||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="MySql_Data" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>MySql.Data.dll;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
</root>
|
||||
|
|
@ -56,7 +56,7 @@
|
|||
<ItemGroup>
|
||||
<Reference Include="MySql.Data, Version=9.0.0.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>.\MySql.Data.dll</HintPath>
|
||||
<HintPath>Properties\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
@ -100,7 +100,6 @@
|
|||
<Compile Include="SCCMsearch\AuthLogin.cs" />
|
||||
<Compile Include="SCCMsearch\AuthWin.cs" />
|
||||
<Compile Include="SCCMsearch\IAuthType.cs" />
|
||||
<Compile Include="SCCMsearch\SQLconnector.cs" />
|
||||
<Compile Include="Seacher\ISeaherMetod.cs" />
|
||||
<Compile Include="Seacher\SeachSCCM.cs" />
|
||||
<Compile Include="Seacher\SeahcLocal.cs" />
|
||||
|
|
@ -195,6 +194,7 @@
|
|||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Setting\SettingRebootControl.resx">
|
||||
<DependentUpon>SettingRebootControl.cs</DependentUpon>
|
||||
|
|
@ -237,6 +237,8 @@
|
|||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="bin\Debug\MySql.Data.dll" />
|
||||
<None Include="Properties\MySql.Data.dll" />
|
||||
<Content Include="reseter.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -4,19 +4,29 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Reseter2.SCCMsearch
|
||||
{
|
||||
internal class AuthLogin : IAuthType
|
||||
{
|
||||
private string User = null;
|
||||
private string Pass = null;
|
||||
public AuthLogin()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public AuthLogin(string user, string pass)
|
||||
{
|
||||
User = user;
|
||||
Pass = pass;
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if(User != null) return User;
|
||||
return SGlobalSetting.settingSCCM.username;
|
||||
}
|
||||
}
|
||||
|
|
@ -24,6 +34,7 @@ namespace Reseter2.SCCMsearch
|
|||
{
|
||||
get
|
||||
{
|
||||
if(Pass != null) return Pass;
|
||||
return SGlobalSetting.settingSCCM.password;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
using Reseter2.Setting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MySql.Data;
|
||||
|
||||
namespace Reseter2.SCCMsearch
|
||||
{
|
||||
internal class SQLconnector
|
||||
{
|
||||
private MySql.Data.MySqlClient.MySqlConnection Connection;
|
||||
private IAuthType AuthType;
|
||||
public SQLconnector()
|
||||
{
|
||||
if (SGlobalSetting.settingSCCM.windowsAuth)
|
||||
{
|
||||
AuthType = new AuthWin();
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthType = new AuthLogin();
|
||||
}
|
||||
string stringConnect = "server=" + SGlobalSetting.settingSCCM.server + ";database=" + SGlobalSetting.settingSCCM.dataBase + ";" + AuthType.AuthString();
|
||||
try
|
||||
{
|
||||
Connection = new MySql.Data.MySqlClient.MySqlConnection(stringConnect);
|
||||
Connection.Open();
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Повторное бы подключение");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ namespace Reseter2.Seacher
|
|||
{
|
||||
public void Change(ResultUpdate sender, string seach);
|
||||
public IComp Result(int index);
|
||||
public string ResultString(int index);
|
||||
public void Activate();
|
||||
public void Deactivate();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using MySql.Data.MySqlClient;
|
||||
using MySqlX.XDevAPI.Common;
|
||||
using MySqlX.XDevAPI.Relational;
|
||||
using Reseter2.SCCMsearch;
|
||||
using Reseter2.Setting;
|
||||
|
|
@ -11,7 +12,9 @@ using System.Text;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using static Reseter2.Seacher.SeahcLocal;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
|
||||
|
||||
namespace Reseter2.Seacher
|
||||
{
|
||||
|
|
@ -23,6 +26,14 @@ namespace Reseter2.Seacher
|
|||
private ResultUpdate Update;
|
||||
private bool enable;
|
||||
private string error;
|
||||
private Mode mode;
|
||||
|
||||
private enum Mode{
|
||||
PCname,
|
||||
Login,
|
||||
Username
|
||||
}
|
||||
|
||||
public SeachSCCM()
|
||||
{
|
||||
if (SGlobalSetting.settingSCCM.windowsAuth)
|
||||
|
|
@ -34,6 +45,19 @@ namespace Reseter2.Seacher
|
|||
AuthType = new AuthLogin();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public SeachSCCM(bool AuthMetod, string User = "", string Pass = "")
|
||||
{
|
||||
if (AuthMetod)
|
||||
{
|
||||
AuthType = new AuthWin();
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthType = new AuthLogin(User, Pass);
|
||||
}
|
||||
|
||||
}
|
||||
public void Change(ResultUpdate sender, string seach)
|
||||
{
|
||||
|
|
@ -41,46 +65,55 @@ namespace Reseter2.Seacher
|
|||
Update = sender;
|
||||
if (Connection.State == ConnectionState.Open)
|
||||
{
|
||||
|
||||
List<string> result;
|
||||
if (seach.Length > 2)
|
||||
{
|
||||
|
||||
Update(ResultSeach(seach), enable);
|
||||
result = ResultSeach(seach);
|
||||
int itemHeight = 14;
|
||||
if(enable) itemHeight = 40;
|
||||
Update(result, enable, itemHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
result = new List<string>();
|
||||
result.Add("Введите запрос, к бд подключенно");
|
||||
Update(result, false);
|
||||
Update(result, false, 14);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
result.Add(error);
|
||||
Update(result, false);
|
||||
Update(result, false,14);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private string QueryBilder(string query)
|
||||
{
|
||||
string result = "";
|
||||
Regex regexCyrillic = new(@"\p{IsCyrillic}*", RegexOptions.IgnoreCase);
|
||||
Regex regexNumrable = new(@"\d*", RegexOptions.IgnoreCase);
|
||||
string result;
|
||||
Regex regexCyrillic = new(@"\p{IsCyrillic}+", RegexOptions.IgnoreCase);
|
||||
Regex regexNumrable = new(@"\d+", RegexOptions.IgnoreCase);
|
||||
MatchCollection jjj = regexNumrable.Matches(query);
|
||||
if (regexCyrillic.Matches(query).Count > 0)
|
||||
{
|
||||
result = "SELECT * FROM " + SGlobalSetting.settingSCCM.dataBase + " WHERE pcname LIKE '%" + query + "%'";
|
||||
result = "SELECT test.pcname, test.login, username_tb.username, test.action FROM username_tb JOIN test ON username_tb.login=test.login WHERE LOWER(username_tb.username) LIKE LOWER('%" + query + "%') LIMIT 15";
|
||||
mode = Mode.Username;
|
||||
}
|
||||
else if(regexNumrable.Matches(query).Count > 0)
|
||||
{
|
||||
result = "SELECT * FROM " + SGlobalSetting.settingSCCM.dataBase + " WHERE pcname LIKE '%" + query + "%'";
|
||||
|
||||
|
||||
result = "SELECT test.pcname, test.login, username_tb.username, test.action FROM test LEFT JOIN username_tb ON test.login = username_tb.login WHERE LOWER(test.pcname) LIKE LOWER('%" + query + "%') LIMIT 15";
|
||||
mode = Mode.PCname;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "SELECT * FROM " + SGlobalSetting.settingSCCM.dataBase + " WHERE login LIKE '%" + query + "%'";
|
||||
result = "SELECT test.pcname, test.login, username_tb.username, test.action FROM test LEFT JOIN username_tb ON test.login = username_tb.login WHERE LOWER(test.pcname) LIKE LOWER('%" + query + "%') OR LOWER(test.login) LIKE LOWER('%" + query + "%') LIMIT 15" +
|
||||
""; ;
|
||||
mode = Mode.Login;
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
public List<string> ResultSeach(string seach)
|
||||
{
|
||||
|
|
@ -102,10 +135,11 @@ namespace Reseter2.Seacher
|
|||
DataRow[] myData = dt.Select();
|
||||
for (int i = 0; i < myData.Length; i++)
|
||||
{
|
||||
IComp comp = new CompId(myData[i].ItemArray[1].ToString());
|
||||
comp.SetName(myData[i].ItemArray[2].ToString());
|
||||
IComp comp = new CompId(myData[i].ItemArray[0].ToString());
|
||||
comp.SetName(myData[i].ItemArray[1].ToString());
|
||||
comp.SetDescription(myData[i].ItemArray[2].ToString());
|
||||
comps.Add(comp);
|
||||
result.Add(comp.GetName() + "(" + comp.GetNetNameStr() + ")");
|
||||
result.Add("ПК:"+ comp.GetNetNameStr() + " Логин:" + comp.GetName() + "\r\n" + comp.GetDescription() + "\r\nLastLogin:" + myData[i].ItemArray[3].ToString());
|
||||
++y;
|
||||
}
|
||||
enable = true;
|
||||
|
|
@ -131,7 +165,7 @@ namespace Reseter2.Seacher
|
|||
{
|
||||
if (Connection == null)
|
||||
{
|
||||
string stringConnect = "server=" + SGlobalSetting.settingSCCM.server + ";database=" + SGlobalSetting.settingSCCM.dataBase + ";" + AuthType.AuthString();
|
||||
string stringConnect = "server=" + SGlobalSetting.settingSCCM.server + ";database=" + SGlobalSetting.settingSCCM.dataBase + ";" + AuthType.AuthString() + ";charset=utf8";
|
||||
try
|
||||
{
|
||||
Connection = new MySql.Data.MySqlClient.MySqlConnection(stringConnect);
|
||||
|
|
@ -158,5 +192,61 @@ namespace Reseter2.Seacher
|
|||
{
|
||||
return comps[index];
|
||||
}
|
||||
public string ResultString(int index)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case Mode.Login:
|
||||
return comps[index].GetName();
|
||||
case Mode.Username:
|
||||
return comps[index].GetDescription();
|
||||
case Mode.PCname:
|
||||
return comps[index].GetNetNameStr();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
public string CheckConnect(string server, string basa)
|
||||
{
|
||||
if (Connection == null)
|
||||
{
|
||||
string stringConnect = "server=" + server + ";database=" + basa + ";" + AuthType.AuthString() + ";charset=utf8";
|
||||
try
|
||||
{
|
||||
Connection = new MySql.Data.MySqlClient.MySqlConnection(stringConnect);
|
||||
Connection.Open();
|
||||
error = "Подключенно";
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "Не удалось подключиться к серверу";
|
||||
}
|
||||
}
|
||||
if (Connection.State == ConnectionState.Open)
|
||||
{
|
||||
try
|
||||
{
|
||||
string sql = "SELECT * FROM test LIMIT 1";
|
||||
MySqlCommand sqlCom = new MySqlCommand(sql, Connection);
|
||||
sqlCom.ExecuteNonQuery();
|
||||
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sqlCom);
|
||||
DataTable dt = new DataTable();
|
||||
dataAdapter.Fill(dt);
|
||||
|
||||
DataRow[] myData = dt.Select();
|
||||
if(myData.Length > 0)
|
||||
{
|
||||
error = "Соединие успешно установленно";
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
error = "Ошибка выполнения запроса \nКакая то не правильная база";
|
||||
}
|
||||
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace Reseter2.Seacher
|
|||
{
|
||||
internal class SeahcLocal : ISeaherMetod
|
||||
{
|
||||
internal delegate void ResultUpdate(List<string> Item, bool eneble);
|
||||
internal delegate void ResultUpdate(List<string> Item, bool eneble, int itemHeight);
|
||||
private ResultUpdate Update;
|
||||
private List<IComp> comps = new List<IComp>();
|
||||
private bool enable;
|
||||
|
|
@ -19,13 +19,13 @@ namespace Reseter2.Seacher
|
|||
if (seach.Length > 2)
|
||||
{
|
||||
|
||||
Update(ResultSeach(seach), enable);
|
||||
Update(ResultSeach(seach), enable,14);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
result.Add("Введите запрос");
|
||||
Update(result,false);
|
||||
Update(result,false, 14);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -66,6 +66,22 @@ namespace Reseter2.Seacher
|
|||
{
|
||||
return comps[index];
|
||||
}
|
||||
|
||||
public string ResultString(int index)
|
||||
{
|
||||
string buf;
|
||||
if (comps[index].GetName() == null)
|
||||
{
|
||||
buf = comps[index].GetNetNameStr();
|
||||
}
|
||||
else
|
||||
{
|
||||
buf = comps[index].GetName();
|
||||
if (comps[index].GetNetNameStr() != null) buf += "(" + comps[index].GetNetNameStr() + ")";
|
||||
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
public void Activate() { }
|
||||
public void Deactivate() { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@
|
|||
this.bt_checkConnect.TabIndex = 11;
|
||||
this.bt_checkConnect.Text = "Проверить связь";
|
||||
this.bt_checkConnect.UseVisualStyleBackColor = true;
|
||||
this.bt_checkConnect.Click += new System.EventHandler(this.bt_checkConnect_Click);
|
||||
//
|
||||
// label10
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Reseter2.Seacher;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
|
|
@ -78,5 +79,11 @@ namespace Reseter2.Setting
|
|||
SGlobalSetting.settingSCCM.windowsAuth = cb_windowsAuth.Checked;
|
||||
|
||||
}
|
||||
|
||||
private void bt_checkConnect_Click(object sender, EventArgs e)
|
||||
{
|
||||
SeachSCCM SeacherCheck = new(cb_windowsAuth.Checked, ib_username.Text, ib_password.Text);
|
||||
MessageBox.Show(SeacherCheck.CheckConnect(ib_server.Text,ib_dataBase.Text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,16 +33,12 @@ namespace Reseter2
|
|||
CompId compid = new CompId(ip);
|
||||
AddTask(compid);
|
||||
}
|
||||
catch (FormatException e)
|
||||
catch
|
||||
{
|
||||
CompId compid = new CompId(name);
|
||||
AddTask(compid);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void AddTask(List<IComp> comps)
|
||||
|
|
|
|||
Loading…
Reference in New Issue