예제 #1
0
        public void LoadMultipleTable(MultiTableLoadData data)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            serializer.MaxJsonLength = int.MaxValue;

            Socket socket = buildSocket(SocketResourcePath + "/multiple_load/");

            socket.OnMessage += (sender, e) =>
            {
                SaveInfo info = deserializeSaveInfo(e.Data);
                if (info != null)
                {
                    if (LoadMultipleTableHandler != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() => LoadMultipleTableHandler(info, null));
                    }
                    if (info.isEnd)
                    {
                        socket.Close(CloseStatusCode.Normal);
                    }
                    return;
                }

                TableSaveIssue issue = deserializeIssue(e.Data);
                if (issue != null)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        ModelModificationDialog dialog = new ModelModificationDialog();
                        dialog.Display(this, issue);
                        dialog.ShowDialog();
                        issue       = dialog.tableSaveIssue;
                        string json = serializer.Serialize(issue);
                        socket.Send(json);
                    });
                    return;
                }
                logger.Debug("Recieve unreconized message : " + e.Data);
            };

            socket.OnOpen  += (sender, e) => { logger.Debug("Socket opened!"); };
            socket.OnError += (sender, e) => {
                logger.Debug("Socket error : " + e.Message);
            };
            socket.OnClose += (sender, e) => { logger.Debug("Socket closed : " + e.Reason); };

            socket.Connect();
            string text = serializer.Serialize(data);

            socket.Send(text);
        }
예제 #2
0
        public override Misp.Kernel.Domain.InputTable Save(Misp.Kernel.Domain.InputTable item)
        {
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            serializer.MaxJsonLength = int.MaxValue;

            Socket socket = buildSocket(SocketResourcePath + "/Save/");

            socket.OnMessage += (sender, e) =>
            {
                SaveInfo info = deserializeSaveInfo(e.Data);
                if (info != null)
                {
                    if (SaveTableHandler != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (SaveTableHandler != null)
                            {
                                SaveTableHandler(info, null);
                            }
                        }
                                                                             );
                    }
                    if (info.isEnd)
                    {
                        socket.Close(CloseStatusCode.Normal);
                    }
                    return;
                }

                TableSaveIssue issue = deserializeIssue(e.Data);
                if (issue != null)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(() =>
                    {
                        ModelModificationDialog dialog = new ModelModificationDialog();
                        dialog.Display(this, issue);
                        dialog.ShowDialog();
                        issue = dialog.tableSaveIssue;
                        if (issue != null && issue.targetItem != null)
                        {
                            issue.targetItem.attribute = null;
                        }
                        string json = serializer.Serialize(issue);
                        socket.Send(json);
                    });
                    return;
                }

                InputTable table = deserializeInputTable(e.Data);
                if (table != null)
                {
                    if (SaveTableHandler != null)
                    {
                        System.Windows.Application.Current.Dispatcher.Invoke(() =>
                        {
                            if (SaveTableHandler != null)
                            {
                                SaveTableHandler(null, table);
                            }
                        }
                                                                             );
                    }
                    return;
                }

                logger.Debug("Recieve text : " + e.Data);
            };

            socket.OnOpen  += (sender, e) => { logger.Debug("Socket opened!"); };
            socket.OnError += (sender, e) => {
                logger.Debug("Socket error : " + e.Message);
            };
            socket.OnClose += (sender, e) => {
                logger.Debug("Socket closed : " + e.Reason);
            };

            socket.Connect();
            socket.Send(item.name);

            //item = base.Save(item);
            return(item);
        }