Прикрутили загружку картинок

This commit is contained in:
klavirshik 2024-10-25 19:05:49 +02:00
parent 9a00a0c841
commit 9672e258d0
30 changed files with 175 additions and 56 deletions

Binary file not shown.

View File

@ -63,8 +63,8 @@ namespace Remontor.Connector
View.Dock = DockStyle.Fill; View.Dock = DockStyle.Fill;
panel.Controls.Add(View); panel.Controls.Add(View);
ModeMonitor = new OneMon(); ModeMonitor = new OneMon();
//Proc = Process.Start(@"CmRcViewer.exe", Comp.GetNetNameStr()); Proc = Process.Start(SGlobalSetting.settingApp.pathApp, Comp.GetNetNameStr());
Proc = Process.Start(SGlobalSetting.settingApp.pathApp); //Proc = Process.Start(SGlobalSetting.settingApp.pathApp);
//Thread.Sleep(500); // Allow the process to open it's window //Thread.Sleep(500); // Allow the process to open it's window
Proc.WaitForInputIdle(); Proc.WaitForInputIdle();
SetParent(Proc.MainWindowHandle, View.Handle); SetParent(Proc.MainWindowHandle, View.Handle);
@ -72,7 +72,7 @@ namespace Remontor.Connector
ModeMonitor.Resize(Proc, View); ModeMonitor.Resize(Proc, View);
} }
catch (Exception) { catch (Exception) {
MessageBox.Show("Не верно заданно придложение для подключения."); MessageBox.Show("Не верно заданно приложение для подключения.");
ModeMonitor = new OffMon(); ModeMonitor = new OffMon();
SConnector.Panel.Controls.Remove(View); SConnector.Panel.Controls.Remove(View);
return; return;

View File

@ -100,6 +100,7 @@
this.Controls.Add(this.SeaherPanel); this.Controls.Add(this.SeaherPanel);
this.Controls.Add(this.CompNameLB); this.Controls.Add(this.CompNameLB);
this.Name = "Finder"; this.Name = "Finder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Новое подключение"; this.Text = "Новое подключение";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Finder_FormClosed); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Finder_FormClosed);
this.SeaherPanel.ResumeLayout(false); this.SeaherPanel.ResumeLayout(false);

View File

@ -155,7 +155,7 @@ namespace Remontor.Finder
private void Finder_FormClosed(object sender, FormClosedEventArgs e) private void Finder_FormClosed(object sender, FormClosedEventArgs e)
{ {
PingManager.StopPing();
} }
} }
} }

View File

@ -27,7 +27,7 @@ namespace Remontor.History
string output = string.Format("{0,17: HH:mm:ss dd.MM.yy}", hitem.GetStart()); string output = string.Format("{0,17: HH:mm:ss dd.MM.yy}", hitem.GetStart());
TimeLB.Text = output; TimeLB.Text = output;
PCLB.Text = hitem.NameNode(); PCLB.Text = hitem.NameNode();
FIOLB.Text = hitem.GetComp().GetName(); FIOLB.Text = hitem.GetComp().GetDescription();
BackCustum = this.BackColor; BackCustum = this.BackColor;
} }

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -8,5 +9,46 @@ namespace Remontor.Picter
{ {
internal class PicBase internal class PicBase
{ {
private Image Img;
private string Login;
private bool loaded;
public PicBase(Image img)
{
if(img != null)
{
Img = img;
loaded = true;
}
else
{
loaded = false;
}
}
public PicBase(Image img, string login)
{
Login = login;
if (img != null)
{
Img = img;
loaded = true;
}
else
{
loaded = false;
}
}
public bool Loaded()
{
return loaded;
}
public Image ImageGet
{
get { return Img; }
}
} }
} }

View File

@ -1,12 +1,38 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq; using System.Linq;
using System.Net;
using System.Security.Policy;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms;
namespace Remontor.Picter namespace Remontor.Picter
{ {
internal class PicLoaderTask internal class PicLoaderTask
{ {
private string Name;
private WebClient Client;
private Image Img;
private PictureBox ImagePanel;
public PicLoaderTask(string name, PictureBox imagePanel)
{
ImagePanel = imagePanel;
this.Name = name;
Client = new WebClient();
Client.DownloadDataCompleted += Client_DownloadDataCompleted;
Uri url = new Uri("http://localhost/Photo/titov.png");
Client.DownloadDataAsync(url);
}
private void Client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
{
Img = new Bitmap(new MemoryStream(e.Result));
ImagePanel.Image = Img;
// throw new NotImplementedException();
}
} }
} }

View File

@ -1,4 +1,5 @@
using System; using Remontor.Words;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -7,12 +8,34 @@ using System.Windows.Forms;
namespace Remontor.Picter namespace Remontor.Picter
{ {
internal class SPicManager internal static class SPicManager
{ {
Dictionary<string, PicBase> PicList = new Dictionary<string, PicBase>(); private static Dictionary<string, PicBase> PicList = new Dictionary<string, PicBase>();
public void PictureSet(PictureBox image, IComp comp) public static void PictureSet(PictureBox image, IComp comp)
{ {
IComp Comp = WordsList.FindCompName(comp.GetNetName());
if(Comp != null)
{
// image = comp.GetImage();
return;
}
else
{
comp.SetName("titov");
if (comp.GetName() != null)
{
if (PicList.ContainsKey(comp.GetName()))
{
image.Image = PicList[comp.GetName()].ImageGet;
}
else
{
new PicLoaderTask(comp.GetName(), image);
}
}
}
} }
} }
} }

View File

@ -14,7 +14,7 @@ namespace Remontor.Pinger
static Dictionary<string, PingResult> ResultPing = new Dictionary<string, PingResult>(); static Dictionary<string, PingResult> ResultPing = new Dictionary<string, PingResult>();
static List<PingTask> TaskList = new List<PingTask>(); static List<PingTask> TaskList = new List<PingTask>();
static int LifeTimePing = 20; static int LifeTimePing = 20;
static Thread PingerHost = new Thread(PingHost);
static public void NewTaskPing(Panel panel, IComp comp) static public void NewTaskPing(Panel panel, IComp comp)
{ {
@ -48,7 +48,7 @@ namespace Remontor.Pinger
//panel.Visible = true; //panel.Visible = true;
// panel.BackColor = Color.Gold; // panel.BackColor = Color.Gold;
PingTask pingTask = new PingTask(panel, comp); PingTask pingTask = new PingTask(panel, comp);
TaskList.Add(pingTask);
//if(PingerHost.ThreadState == ThreadState.Unstarted) //if(PingerHost.ThreadState == ThreadState.Unstarted)
//{ //{
// PingerHost.Start(); // PingerHost.Start();
@ -63,33 +63,8 @@ namespace Remontor.Pinger
} }
static public void PingHost()
{
// while ()
// {
Thread.Sleep(300);
PingTask[] TaskListBuff = new PingTask[TaskList.Count];
TaskList.CopyTo(TaskListBuff);
TaskList.Clear();
System.Console.WriteLine(TaskListBuff.Length.ToString());
foreach (PingTask Task in TaskListBuff)
{
// Task.PingHost();
}
if (TaskList.Count > 0) PingHost();
else
{
}
// }
}
static public void StopPing()
{
// PingerHost.Join();
}
static public void WriteResult(PingResult pingResult) static public void WriteResult(PingResult pingResult)
{ {

View File

@ -19,6 +19,24 @@ namespace Remontor.Pinger
private Panel panel; private Panel panel;
private Ping pinger; private Ping pinger;
public PingTask( IComp comp)
{
this.Comp = comp;
this.NameOrAddress = comp.GetNetName();
pinger = new Ping();
pinger.PingCompleted += Pinger_PingCompleted;
try
{
pinger.SendPingAsync(NameOrAddress, 3);
}
catch
{
pinger.SendAsyncCancel();
if (panel != null) panel.BackColor = Color.OrangeRed;
}
}
public PingTask(Panel panel, IComp comp) public PingTask(Panel panel, IComp comp)
{ {
this.panel = panel; this.panel = panel;

View File

@ -9,13 +9,13 @@ namespace Remontor.Seacher
internal class SCCMResult : ISeacherResult internal class SCCMResult : ISeacherResult
{ {
private IComp Comp; private IComp Comp;
private DateTime LastConnect; private string LastConnect;
private string StrQuestion; private string StrQuestion;
public SCCMResult() public SCCMResult()
{ {
} }
public SCCMResult(IComp comp, DateTime lastConnect) public SCCMResult(IComp comp, string lastConnect)
{ {
Comp = comp; Comp = comp;
LastConnect = lastConnect; LastConnect = lastConnect;
@ -24,7 +24,7 @@ namespace Remontor.Seacher
public SCCMResult(IComp comp, string lastConnect, string strQuestion) public SCCMResult(IComp comp, string lastConnect, string strQuestion)
{ {
Comp = comp; Comp = comp;
LastConnect = DateTime.Parse(lastConnect); LastConnect = lastConnect;
StrQuestion = strQuestion; StrQuestion = strQuestion;
} }
@ -33,7 +33,7 @@ namespace Remontor.Seacher
return Comp; return Comp;
} }
public DateTime GetLastConnect() public string GetLastConnect()
{ {
return LastConnect; return LastConnect;
} }

View File

@ -13,6 +13,7 @@ using System.Xml.Linq;
using static Remontor.Seacher.SeahcLocal; using static Remontor.Seacher.SeahcLocal;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel; using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
using System.Threading; using System.Threading;
using System.Windows.Forms;
namespace Remontor.Seacher namespace Remontor.Seacher
{ {
@ -25,7 +26,7 @@ namespace Remontor.Seacher
private bool enable; private bool enable;
private string error; private string error;
private Mode mode; private Mode mode;
private Timer TimerDisconnect; private System.Threading.Timer TimerDisconnect;
private enum Mode{ private enum Mode{
PCname, PCname,
@ -137,10 +138,10 @@ namespace Remontor.Seacher
} }
else else
{ {
result = "SELECT TOP (15) dbo._RES_COLL_SMS00001.Name, dbo._RES_COLL_SMS00001.UserName, dbo.v_R_User.Full_User_Name0, dbo._RES_COLL_SMS00001.LastActiveTime FROM dbo._RES_COLL_SMS00001 LEFT JOIN dbo.v_R_User ON dbo._RES_COLL_SMS00001.UserName = dbo.v_R_User.User_Name0 WHERE LOWER(dbo._RES_COLL_SMS00001.Name) LIKE LOWER(N'%" + query + "%') OR LOWER(dbo._RES_COLL_SMS00001.UserName) LIKE LOWER(N'%" + query + "%')" + result = "SELECT TOP (15) dbo._RES_COLL_SMS00001.Name, dbo._RES_COLL_SMS00001.UserName, dbo.v_R_User.Full_User_Name0, dbo._RES_COLL_SMS00001.LastActiveTime FROM dbo._RES_COLL_SMS00001 LEFT JOIN dbo.v_R_User ON dbo._RES_COLL_SMS00001.UserName = dbo.v_R_User.User_Name0 WHERE LOWER(dbo._RES_COLL_SMS00001.Name) LIKE LOWER(N'%" + query + "%') OR LOWER(dbo._RES_COLL_SMS00001.UserName) LIKE LOWER(N'%" + query + "%')";
""; ;
mode = Mode.Login; mode = Mode.Login;
} }
//MessageBox.Show(mode.ToString());
return result; return result;
} }
//public List<string> ResultSeach(string seach) //public List<string> ResultSeach(string seach)
@ -231,18 +232,26 @@ namespace Remontor.Seacher
quest = comp.GetNetNameStr(); quest = comp.GetNetNameStr();
break; break;
} }
SCCMResult itemResult = new SCCMResult(comp, myData[i].ItemArray[3].ToString(), quest); string buffStr ="NOT";
if (myData[i].ItemArray[3] is DateTime)
{
buffStr = myData[i].ItemArray[3].ToString();
}
else
{
buffStr = "Нет данных";
}
SCCMResult itemResult = new SCCMResult(comp, buffStr, quest);
result.Add(itemResult); result.Add(itemResult);
++y; ++y;
} }
enable = true;
} }
catch catch
{ {
y = 1; y = 1;
enable = false; //result.Clear();
result.Clear(); result.Add(new NoResult("Ошибка обработки"));
result.Add(new NoResult("Ничего не найдено"));
} }
} }
@ -267,7 +276,7 @@ namespace Remontor.Seacher
Console.WriteLine("Подключились"); Console.WriteLine("Подключились");
error = "Подключенно"; error = "Подключенно";
TimerCallback TimerDelegate = new TimerCallback(Deactivate); TimerCallback TimerDelegate = new TimerCallback(Deactivate);
TimerDisconnect = new Timer(TimerDelegate, null, 90000,90000); TimerDisconnect = new System.Threading.Timer(TimerDelegate, null, 90000,90000);
} }
catch catch
{ {
@ -283,9 +292,9 @@ namespace Remontor.Seacher
Connection.Close(); Connection.Close();
Connection = null; Connection = null;
TimerDisconnect.Dispose(); TimerDisconnect.Dispose();
List<ISeacherResult> result = new List<ISeacherResult>(); // List<ISeacherResult> result = new List<ISeacherResult>();
result.Add(new NoResult("Введите запрос")); // result.Add(new NoResult("Введите запрос"));
Update(result); // Update(result);
} }
//public IComp Result(int index) //public IComp Result(int index)

View File

@ -1,4 +1,5 @@
using Remontor.Pinger; using Remontor.Picter;
using Remontor.Pinger;
using Remontor.Seacher; using Remontor.Seacher;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -56,6 +57,8 @@ namespace Remontor
LbData.Text = "last connect:" + result.GetLastConnect(); LbData.Text = "last connect:" + result.GetLastConnect();
Select += UpdateAct; Select += UpdateAct;
Index = index; Index = index;
SPicManager.PictureSet(PbPerson, result.GetComp());
} }

View File

@ -14,6 +14,7 @@ namespace Remontor.Words
public abstract List<WordsCategory> CategoryList(); public abstract List<WordsCategory> CategoryList();
public abstract IComp FindCompName(string compName);
public abstract void Delete(); public abstract void Delete();
public abstract TreeNode NodeList(); public abstract TreeNode NodeList();
public abstract bool ChekMove(IWordsItem wordsItem); public abstract bool ChekMove(IWordsItem wordsItem);

View File

@ -104,6 +104,16 @@ namespace Remontor.Words
} }
public override IComp FindCompName(string compName)
{
foreach (var item in items)
{
IComp comp = item.FindCompName(compName);
if (comp != null) return comp;
}
return null;
}
public override TreeNode NodeList() public override TreeNode NodeList()
{ {
TreeNode treeNode = new TreeNode(GetName()); TreeNode treeNode = new TreeNode(GetName());

View File

@ -92,6 +92,14 @@ namespace Remontor.Words
{ {
return new List<WordsCategory>(); return new List<WordsCategory>();
} }
public override IComp FindCompName(string compName)
{
if(compName.ToUpper() == Comp.GetNetName().ToUpper())
{
return Comp;
}
return null;
}
public string NameNode() public string NameNode()
{ {

View File

@ -25,7 +25,10 @@ namespace Remontor.Words
{ {
SrcCategory.Move(index, item, DstCategory); SrcCategory.Move(index, item, DstCategory);
} }
public static IComp FindCompName(string compName)
{
return MainCategory.FindCompName(compName);
}
public static TreeNode[] ListNodes() public static TreeNode[] ListNodes()
{ {
TreeNode[] treeNodes = new TreeNode[MainCategory.Count()]; TreeNode[] treeNodes = new TreeNode[MainCategory.Count()];

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
09d76672eda20daf058c432a32f616590893aaa4 9a443a3f00d6902d59ef00044ff4ad2031b21723

Binary file not shown.

Binary file not shown.