// констркутор
        public DatabaseRequestViewModel(RequestWindow window, DatabaseContext context, IOpenDialogWindow openDialogWindow)
        {
            _window           = window;
            _context          = context;
            _openDialogWindow = openDialogWindow;

            SetValues();
        } // DatabaseRequestViewModel
Ejemplo n.º 2
0
 public void Register(HttpRequest request)
 {
     if (RequestQueue.Contains(request) || RequestWindow.Contains(request))
     {
         throw new InvalidOperationException("HTTP 请求已经在处理中,或正在队列中。");
     }
     request._queueWaitHandle.Reset();
     Task.Run(() => { AddRequestToQueue(request); });
 }
Ejemplo n.º 3
0
        // Редактируем недокомплекты
        void EditRequest(ProjectPropertyType type, OMTSRequestType rType, Project project)
        {
            var win = new RequestWindow(rType, project)
            {
                Owner = Window.GetWindow(this)
            };

            if (win.ShowDialog() != true)
            {
                return;
            }
        }
Ejemplo n.º 4
0
        // Редактируем недокомплекты
        void EditRequest(ProjectPropertyType type, OMTSRequestType rType, Project project)
        {
            var win = new RequestWindow(rType, project)
            {
                Owner = Window.GetWindow(this)
            };

            if (win.ShowDialog() != true)
            {
                return;
            }

            ProjectManager.ChangeProjectPropety(project.ProjectID, type, win.Requests);
        }
Ejemplo n.º 5
0
        private void HandleRequest(HttpRequest request)
        {
            lock (_lockWindowObject)
            {
                RequestWindow.Add(request);
            }
            request._queueWaitHandle.Set();

            Task.Run(() =>
            {
                request._progressWaitHandle.WaitOne();
                lock (_lockWindowObject)
                {
                    RequestWindow.Remove(request);
                }
                UpdateState();
            });
        }
Ejemplo n.º 6
0
        void oldEntity_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            var cs = sender as ChartScriptEntity;

            if (RequestWindow != null && e.PropertyName == "Script")
            {
                RequestWindow.Dispatcher.Invoke(() =>
                {
                    if (!RequestWindow.IsLoaded)
                    {
                        RequestWindow = null;
                    }
                    else
                    {
                        RequestWindow.SetResults(cs.Script); //If saved, different clone
                    }
                });
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 打开需求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsmiRequest_Click(object sender, EventArgs e)
        {
            if (null == requestWindow || requestWindow.IsDisposed)
            {
                requestWindow            = new RequestWindow();
                requestWindow.MdiParent  = this;
                requestWindow.StartLoad += (obj, ev) =>
                {
                    StartLoad(obj);
                };
                requestWindow.StopLoad += (obj, ev) =>
                {
                    StopLoad(obj);
                };

                requestWindow.Show();
            }

            SetSelect(null, tsmiRequest);
            requestWindow.Activate();
        }
Ejemplo n.º 8
0
        void btnOMTS_E_Complete_Click(object sender, RoutedEventArgs e)
        {
            var btn = sender as Button;

            if (btn == null || !(btn.Tag is Project))
            {
                return;
            }

            var win = new RequestWindow(OMTSRequestType.Electrician, (Project)btn.Tag, true)
            {
                Owner = Window.GetWindow(this)
            };

            if (win.ShowDialog() != true)
            {
                return;
            }

            ProjectManager.ChangeProjectPropety(((Project)btn.Tag).ProjectID, ProjectPropertyType.Requests_E, win.Requests);
        }
Ejemplo n.º 9
0
        private void Connection_AcceptMessage(MessageClass message)
        {
            #region StandartCommands
            if (message.Command == Commands.Disconnect)
            {
                Task.Run(LostConnection);
                Dispatcher.Invoke(() =>
                {
                    int count = Users.Count;
                    for (int i = 0; i < count; i++)
                    {
                        FullTable.Items.Remove(Users[0]);
                        Users.Remove(Users[0]);
                    }

                    DisconnectLabel.Opacity = 1;
                });
            }

            if (message.Command == Commands.AcceptLogin)
            {
                Task.Run(FindConnection);
                Dispatcher.Invoke(() => DisconnectLabel.Opacity = 0);
                Connection.ID = message.Getter;
                Connection.SendMessage(new MessageClass(Connection.ID, -1, Commands.RsaKey, 0, Connection.Secure.GetPublicKey()));
            }

            if (message.Command == Commands.AesKey)
            {
                Connection.Secure.SetAesKey(Connection.Secure.RsaDecrypt(message.Package));
                Connection.Secured = true;
                Connection.SendMessage(new MessageClass(Connection.ID, -1, Commands.GetList, 0));
                Connection.SendMessage(new MessageClass(Connection.ID, -1, Commands.KeyPass, 0, Settings.KeyWord));
            }

            if (message.Command == Commands.List)
            {
                try
                {
                    string[] com = message.GetStringPackage().Split(';');
                    AddUser(com);
                    Dispatcher.Invoke(() =>
                    {
                        try
                        {
                            /*
                             * int count = Users.Count;
                             * for (int i = 0; i < count; i++)
                             * {
                             *  FullTable.Items.Remove(Users[0]);
                             *  Users.Remove(Users[0]);
                             * }
                             *
                             * for (int i = 0; i < com.Length; i += 3)
                             * {
                             *  var user = new UserControll(Convert.ToInt32(com[i]), com[i + 1], com[i + 2]);
                             *  user.ActiveEvent += User_ActiveEvent;
                             *  Users.Add(user);
                             *  FullTable.Items.Add(user);
                             *  if (Status != "Simple")
                             *      user.SetEnabled(1, true);
                             * }
                             */
                        }
                        catch { }
                    });
                }
                catch { }
            }

            if (message.Command == Commands.ChangeStatus)
            {
                Status = message.GetStringPackage();
                if (Status != "Simple")
                {
                    Dispatcher.Invoke(() =>
                    {
                        for (int i = 0; i < VideoClasses.Count; i++)
                        {
                            VideoClasses[i].Close();
                        }
                        var window   = new StatusWindow(Version, Status);
                        window.Owner = this;
                        window.Show();
                    });
                    for (int i = 0; i < Users.Count; i++)
                    {
                        Dispatcher.Invoke(() => Users[i].SetEnabled(1, true));
                    }
                }
                else
                {
                    for (int i = 0; i < Users.Count; i++)
                    {
                        Dispatcher.Invoke(() => Users[i].SetEnabled(0, false));
                    }
                }
            }

            if (message.Command == Commands.ChangeName)
            {
                Dispatcher.Invoke(() =>
                {
                    for (int i = 0; i < Users.Count; i++)
                    {
                        if (message.Getter == Users[i].ID)
                        {
                            Users[i].NameLabel.Content = message.GetStringPackage();
                        }
                    }
                });
            }

            if (message.Command == Commands.GetInfo)
            {
                string result = Version + "\n";
                if (Status != "Simple")
                {
                    result += "[Secret]\n";
                }
                else
                {
                    result += "Simple\n";
                }

                result += Directory.GetCurrentDirectory() + "\n";

                result += TurnOnTime.ToString();

                Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.Info, 0, result));
            }

            if (message.Command == Commands.Info)
            {
                Dispatcher.Invoke(() => System.Windows.MessageBox.Show(message.GetStringPackage()));
            }
            #endregion

            #region FileCommands
            if (message.Command == Commands.RFileSend)
            {
                Task.Run(() =>
                {
                    Dispatcher.Invoke(() =>
                    {
                        string name = "[Secret]";
                        for (int i = 0; i < Users.Count; i++)
                        {
                            if (message.Sender == Users[i].ID)
                            {
                                name = Users[i].NameLabel.Content as string;
                            }
                        }
                        var window   = new RequestWindow(name, message.GetStringPackage());
                        window.Owner = this;
                        if (!SilenceControll.Mode)
                        {
                            window.Topmost = false;
                            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                            if (!IsActive)
                            {
                                this.Show();
                                if (Icons != null)
                                {
                                    Icons.Visible = false;
                                }
                                this.WindowState = WindowState.Minimized;
                            }
                        }
                        Helper.FlashApplicationWindow();
                        window.ShowDialog();
                        if (window.Result)
                        {
                            Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.AcceptFile, message.ElementID));
                        }
                        else
                        {
                            Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.CancelFile, message.ElementID));
                        }
                    });
                });
            }

            if (message.Command == Commands.AcceptFile)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        var setuper = FindSetuper(message.ElementID);
                        setuper.Accept();
                    }
                    catch { }
                });
            }

            if (message.Command == Commands.CancelFile)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        var setuper = FindSetuper(message.ElementID);
                        setuper.Cancel();
                    }
                    catch { }
                });
            }

            if (message.Command == Commands.FileOK)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        var setuper = FindSetuper(message.ElementID);
                        setuper.OK();
                    }
                    catch { }
                });
            }

            if (message.Command == Commands.FileInfo)
            {
                Dispatcher.Invoke(() =>
                {
                    var getter         = new GettingWindow(Connection, Settings);
                    getter.ID          = message.ElementID;
                    getter.UserID      = message.Sender;
                    string[] com       = message.GetStringPackage().Split(';');
                    getter.FileName    = com[0];
                    getter.FileSize    = Convert.ToInt64(com[1]);
                    getter.CloseEvent += (GettingWindow window) =>
                    {
                        Getters.Remove(window);
                        GC.Collect();
                    };
                    getter.Owner = this;
                    getter.Show();
                    Getters.Add(getter);
                });
            }

            if (message.Command == Commands.FileData)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        var getter = FindGetter(message.ElementID, message.Sender);
                        getter.SetData(message.Package);
                    }
                    catch { }
                });
            }

            if (message.Command == Commands.FileDone)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        var getter = FindGetter(message.ElementID, message.Sender);
                        getter.Done();
                    }
                    catch { }
                });
            }

            #endregion

            #region VideoMCommands
            if (message.Command == Commands.RVideoModule)
            {
                Task.Run(() =>
                {
                    Dispatcher.Invoke(() =>
                    {
                        string name = "[Secret]";
                        for (int i = 0; i < Users.Count; i++)
                        {
                            if (message.Sender == Users[i].ID)
                            {
                                name = Users[i].NameLabel.Content as string;
                            }
                        }
                        var window   = new RequestWindow(name, "<Video.mp4>");
                        window.Owner = this;
                        if (!SilenceControll.Mode)
                        {
                            window.Topmost = false;
                            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                            if (!IsActive)
                            {
                                this.Show();
                                if (Icons != null)
                                {
                                    Icons.Visible = false;
                                }
                                this.WindowState = WindowState.Minimized;
                            }
                        }
                        Helper.FlashApplicationWindow();
                        window.ShowDialog();
                        if (window.Result)
                        {
                            var video         = new VideoClass(message.ElementID, message.Sender, Connection);
                            video.CloseEvent += (VideoClass obj) =>
                            {
                                VideoClasses.Remove(obj);
                                GC.Collect();
                            };
                            video.Start();
                            VideoClasses.Add(video);
                        }
                        else
                        {
                            Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.VideoDenied, message.ElementID));
                        }
                    });
                });
            }

            if (message.Command == Commands.HVideoModule)
            {
                var video = new VideoClass(message.ElementID, message.Sender, Connection);
                video.CloseEvent += (VideoClass obj) =>
                {
                    VideoClasses.Remove(obj);
                    GC.Collect();
                };
                video.Start();
                VideoClasses.Add(video);
            }

            if (message.Command == Commands.VideoDenied)
            {
                try
                {
                    Dispatcher.Invoke(FindVideoWindow(message.ElementID).Denied);
                }
                catch { }
            }

            if (message.Command == Commands.VideoPulsar)
            {
                try
                {
                    Dispatcher.Invoke(FindVideoClasses(message.ElementID, message.Sender).Pulsar);
                }
                catch { }
            }

            if (message.Command == Commands.VideoClose)
            {
                try
                {
                    Dispatcher.Invoke(FindVideoClasses(message.ElementID, message.Sender).Close);
                }
                catch { }
            }

            if (message.Command == Commands.VideoData)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        FindVideoWindow(message.ElementID).SetVideoData(message.Package);
                    }
                    catch
                    {
                        Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.VideoClose, message.ElementID));
                    }
                });
            }

            if (message.Command == Commands.SetVideo)
            {
                try
                {
                    if (message.GetStringPackage() == "True")
                    {
                        Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).VideoStream = true);
                    }
                    else
                    {
                        Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).VideoStream = false);
                    }
                }
                catch { }
            }

            if (message.Command == Commands.SetMaxFps)
            {
                try
                {
                    Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).MaxFps = Convert.ToInt32(message.GetStringPackage()));
                }
                catch { }
            }

            if (message.Command == Commands.SetSize)
            {
                try
                {
                    Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).Size = Convert.ToInt32(message.GetStringPackage()));
                }
                catch { }
            }

            if (message.Command == Commands.SetQuality)
            {
                try
                {
                    Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).Quality = Convert.ToInt32(message.GetStringPackage()));
                }
                catch { }
            }

            if (message.Command == Commands.SetMicro)
            {
                try
                {
                    if (message.GetStringPackage() == "True")
                    {
                        Dispatcher.Invoke(FindVideoClasses(message.ElementID, message.Sender).MicroInput.StartRecording);
                    }
                    else
                    {
                        Dispatcher.Invoke(FindVideoClasses(message.ElementID, message.Sender).MicroInput.StopRecording);
                    }
                }
                catch { }
            }

            if (message.Command == Commands.MicroData)
            {
                try
                {
                    if (message.Package != null)
                    {
                        Dispatcher.Invoke(() => FindVideoWindow(message.ElementID).MicroBuffer.AddSamples(message.Package, 0, message.Package.Length));
                    }
                }
                catch { }
            }

            if (message.Command == Commands.SetCursor)
            {
                try
                {
                    if (message.GetStringPackage() == "True")
                    {
                        Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).Cursor = true);
                    }
                    else
                    {
                        Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).Cursor = false);
                    }
                }
                catch { }
            }

            if (message.Command == Commands.SetLoop)
            {
                try
                {
                    if (message.GetStringPackage() == "True")
                    {
                        Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).LoopInput.StartRecording());
                    }
                    else
                    {
                        Dispatcher.Invoke(() => FindVideoClasses(message.ElementID, message.Sender).LoopInput.StopRecording());
                    }
                }
                catch { }
            }

            if (message.Command == Commands.LoopInfo)
            {
                try
                {
                    Dispatcher.Invoke(() => FindVideoWindow(message.ElementID).SetupLoop(message.Package));
                }
                catch { }
            }


            if (message.Command == Commands.LoopData)
            {
                try
                {
                    Dispatcher.Invoke(() => FindVideoWindow(message.ElementID).LoopBuffer.AddSamples(message.Package, 0, message.Package.Length));
                }
                catch { }
            }
            #endregion

            #region FileMCommands
            if (message.Command == Commands.RFileModule)
            {
                Task.Run(() =>
                {
                    Dispatcher.Invoke(() =>
                    {
                        string name = "[Secret]";
                        for (int i = 0; i < Users.Count; i++)
                        {
                            if (message.Sender == Users[i].ID)
                            {
                                name = Users[i].NameLabel.Content as string;
                            }
                        }
                        var window   = new RequestWindow(name, "<TextFile>");
                        window.Owner = this;
                        if (!SilenceControll.Mode)
                        {
                            window.Topmost = false;
                            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                            if (!IsActive)
                            {
                                this.Show();
                                if (Icons != null)
                                {
                                    Icons.Visible = false;
                                }
                                this.WindowState = WindowState.Minimized;
                            }
                        }
                        Helper.FlashApplicationWindow();
                        window.ShowDialog();
                        if (window.Result)
                        {
                            var fileClass         = new FileClass(message.ElementID, message.Sender, Connection);
                            fileClass.CloseEvent += (FileClass obj) =>
                            {
                                FileClasses.Remove(obj);
                                GC.Collect();
                            };
                            fileClass.Start();
                            FileClasses.Add(fileClass);
                        }
                        else
                        {
                            Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.FileMDenied, message.ElementID));
                        }
                    });
                });
            }

            if (message.Command == Commands.HFileModule)
            {
                var fileClass = new FileClass(message.ElementID, message.Sender, Connection);
                fileClass.CloseEvent += (FileClass obj) =>
                {
                    FileClasses.Remove(obj);
                    GC.Collect();
                };
                fileClass.Start();
                FileClasses.Add(fileClass);
            }

            if (message.Command == Commands.FileMAccepted)
            {
                try
                {
                    FindFileWindow(message.ElementID).Accept();
                }
                catch { }
            }

            if (message.Command == Commands.FileMDenied)
            {
            }

            if (message.Command == Commands.FilePulsar)
            {
                try
                {
                    FindFileClass(message.ElementID, message.Sender).Pulsar();
                }
                catch { }
            }

            if (message.Command == Commands.CD)
            {
                try
                {
                    byte[] data = FindFileClass(message.ElementID, message.Sender).CD(message.GetStringPackage());
                    Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.Dirs, message.ElementID, data));
                }
                catch { }
            }

            if (message.Command == Commands.Dirs)
            {
                Dispatcher.Invoke(() =>
                {
                    try
                    {
                        FindFileWindow(message.ElementID).SetDirs(message.Package);
                    }
                    catch { }
                });
            }

            if (message.Command == Commands.Run)
            {
                try
                {
                    if (FindFileClass(message.ElementID, message.Sender) == null)
                    {
                        return;
                    }
                    ProcessStartInfo startInfo = new ProcessStartInfo(message.GetStringPackage());
                    startInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(message.GetStringPackage());
                    Process.Start(startInfo);
                }
                catch { }
            }

            if (message.Command == Commands.RunWith)
            {
                try
                {
                    if (FindFileClass(message.ElementID, message.Sender) == null)
                    {
                        return;
                    }
                    string[]         com       = message.GetStringPackage().Split(';');
                    ProcessStartInfo startInfo = new ProcessStartInfo(com[0], com[1]);
                    startInfo.WorkingDirectory = System.IO.Path.GetDirectoryName(com[0]);
                    Process.Start(startInfo);
                }
                catch { }
            }

            if (message.Command == Commands.Delete)
            {
                try
                {
                    FileClass fileClass = FindFileClass(message.ElementID, message.Sender);
                    if (fileClass == null)
                    {
                        return;
                    }

                    string path = message.GetStringPackage();
                    if (Directory.Exists(path))
                    {
                        Directory.Delete(path);
                    }
                    else if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    byte[] data = fileClass.CD(Path.GetDirectoryName(message.GetStringPackage()));
                    Connection.SendMessage(new MessageClass(Connection.ID, message.Sender, Commands.Dirs, message.ElementID, data));
                }
                catch { }
            }

            if (message.Command == Commands.StartDownload)
            {
                try
                {
                    Task.Run(() => FindFileClass(message.ElementID, message.Sender).StartDownload(message.GetStringPackage()));
                }
                catch { }
            }

            if (message.Command == Commands.StopDownload)
            {
                try
                {
                    FindFileClass(message.ElementID, message.Sender).StopDownload();
                }
                catch { }
            }

            if (message.Command == Commands.FileUData)
            {
                try
                {
                    FindFileClass(message.ElementID, message.Sender).SetData(message.Package);
                }
                catch { }
            }

            if (message.Command == Commands.FileUError)
            {
                try
                {
                    FindFileWindow(message.ElementID).SetUError(message.GetStringPackage());
                }
                catch { }
            }

            if (message.Command == Commands.FileDData)
            {
                try
                {
                    FindFileWindow(message.ElementID).SetData(message.Package);
                }
                catch { }
            }

            if (message.Command == Commands.GetDirInfo)
            {
                try
                {
                    Task.Run(() => FindFileClass(message.ElementID, message.Sender).GetDirInfo(message.GetStringPackage()));
                }
                catch { }
            }

            if (message.Command == Commands.DirInfo)
            {
                try
                {
                    FindFileWindow(message.ElementID).SetProp(message.Package);
                }
                catch { }
            }
            #endregion
        }
        } // OpenAppendWorkerWindow

        // открытие окна запросов к базе данных
        public void OpenRequestWindow(DatabaseContext context)
        {
            RequestWindow window = new RequestWindow(context);

            window.ShowDialog();
        } // OpenRequestWindow