Ejemplo n.º 1
0
        private void WebRequestDirHistoryEdit(MResponse ClientResponse, MNetworkClient NetworkClient)
        {
            var RequestHistory = Package.Unpacking <WebRequestHistory>(ClientResponse.DataBytes);

            using (var db = new DatabaseContext())
            {
                ModelRequestDirectory RequestDir = new ModelRequestDirectory();
                RequestDir.RequestMethod = RequestHistory.Method;
                RequestDir.RequestTitle  = RequestHistory.Title;
                RequestDir.WebRequestId  = RequestHistory.WebRequestItemId;

                WebRequestDir WebDir = db.WebRequestDirs.FirstOrDefault(x => x.WebRequestItemId == RequestHistory.WebRequestItemId);
                RequestDir.Id    = WebDir.Id;
                RequestDir.Title = WebDir.Title;

                Debug.Log($"\r\nId - {RequestDir.Id}\n" +
                          $"RequestMethod - {RequestDir.RequestMethod}\n" +
                          $"RequestTitle - {RequestDir.RequestTitle}\n" +
                          $"Title - {RequestDir.Title}\n" +
                          $"WebRequestId - {RequestDir.WebRequestId}\r\n");

                Sender.Broadcast("WebRequestDir.History.Edit.Confirm",
                                 RequestDir, ClientResponse.WindowUid);
            }
        }
Ejemplo n.º 2
0
        public static void ReanmeRequest(string RequestLink, string RequestMethod, ModelRequestDirectory RequestDirectory,
                                         EventEditorRequestRename SaveConfirm = null, EventEditorRequestRename CancelEvent = null)
        {
            var EditorRequestSaver = new EditorRequestRenameWindow(RequestLink, RequestMethod, RequestDirectory, SaveConfirm, CancelEvent);

            EditorRequestSaver.Show();
        }
        /// <summary>
        /// Устанавливает новый метод в списке методов запроса
        /// </summary>
        /// <param name="UC">EditorWebRequestControl</param>
        public static void MethodUpdate_Confirm(EditorWebRequestControl UC)
        {
            NetworkDelegates.Add(delegate(MResponse ServerResponse)
            {
                if (UC.RequestDirectory == null)
                {
                    return;
                }

                var RequestItem = Package.Unpacking <WebRequestItem>(ServerResponse.DataBytes);

                if (RequestItem.Id != UC.RequestDirectory.WebRequestId)
                {
                    return;
                }

                if (RequestItem.Method != UC.GeneralLogic.RequestMethod)
                {
                    TimerLocker_MethodUpdate?.Stop();

                    UC.TextBox_RequestLink.IsReadOnly  = true;
                    UC.ComboBox_RequestType.IsReadOnly = true;
                    UC.ComboBox_RequestType.IsEnabled  = false;

                    TimerLocker_MethodUpdate = CustomTimer.Create(delegate(object sender, EventArgs e)
                    {
                        UC.Dispatcher.Invoke(() =>
                        {
                            UC.ComboBox_RequestType.IsEnabled = true;
                            UC.TextBox_RequestLink.IsReadOnly = false;
                            UC.TextBox_RequestLink.IsReadOnly = false;
                        });
                    }, new TimeSpan(0, 0, 1));

                    int Index = UC.ComboBox_RequestType.Items.IndexOf(RequestItem.Method);
                    if (Index != -1 && UC.ComboBox_RequestType.SelectedIndex != Index)
                    {
                        UC.ComboBox_RequestType.SelectedIndex = Index;
                        UC.GeneralLogic.RequestMethod_SetComboBoxItem(UC.ComboBox_RequestType);

                        for (int i = 0; i < UC.VirtualRequestDirs.Count; i++)
                        {
                            ModelRequestDirectory RequestDirItem = UC.VirtualRequestDirs[i];
                            if (RequestDirItem.WebRequestId == RequestItem.Id)
                            {
                                RequestDirItem.RequestMethod = RequestItem.Method;
                                UC.VirtualRequestDirs[i]     = RequestDirItem;
                                break;
                            }
                        }

                        UC.ListView_WebRequests.Items.Refresh();
                    }
                }
            }, UC.Dispatcher, -1, "WebRequestItem.Update.Method.Confirm", UC.GeneralLogic.UserControl_Uid, true);
        }
        public EditorWebRequestControl(ModelRequestDirectory RequestDirectory = null)
        {
            InitializeComponent();

            this.RequestDirectory = RequestDirectory;

            WebRequestItems    = new ObservableCollection <WebRequestParamsItem>();
            VirtualRequestDirs = new ObservableCollection <ModelRequestDirectory>();

            GeneralLogic = new LEditorGeneral(this);
        }
        /// <summary>
        /// Обновляет строку с ссылкой
        /// </summary>
        /// <param name="UC">EditorWebRequestControl</param>
        public static void LinkUpdate_Confirm(EditorWebRequestControl UC)
        {
            NetworkDelegates.Add(delegate(MResponse ServerResponse)
            {
                if (UC.RequestDirectory == null)
                {
                    return;
                }

                var RequestItem = Package.Unpacking <WebRequestItem>(ServerResponse.DataBytes);

                if (RequestItem.Id != UC.RequestDirectory.WebRequestId)
                {
                    return;
                }

                TimerLocker_LinkUpdate?.Stop();

                UC.TextBox_RequestLink.IsReadOnly = true;
                UC.TextBox_RequestLink.IsEnabled  = false;

                TimerLocker_LinkUpdate = CustomTimer.Create(delegate(object sender, EventArgs e)
                {
                    UC.Dispatcher.Invoke(() =>
                    {
                        UC.TextBox_RequestLink.IsEnabled  = true;
                        UC.TextBox_RequestLink.IsReadOnly = false;
                    });
                }, new TimeSpan(0, 0, 1));

                UC.EditorRequestData.RequestLink = RequestItem.Link;

                for (int i = 0; i < UC.VirtualRequestDirs.Count; i++)
                {
                    ModelRequestDirectory RequestDirItem = UC.VirtualRequestDirs[i];
                    if (RequestDirItem.WebRequestId == RequestItem.Id)
                    {
                        RequestDirItem.WebRequest = RequestItem.Link;
                        //RequestDirItem.RequestMethod = RequestItem.Method;

                        UC.VirtualRequestDirs[i] = RequestDirItem;
                        break;
                    }
                }

                //UC.UpdateDataGrid_OnTextBox();
            }, UC.Dispatcher, -1, "WebRequestItem.Update.Link.Confirm", UC.GeneralLogic.UserControl_Uid, true);
        }
        public EditorRequestRenameWindow(string RequestLink, string RequestMethod, ModelRequestDirectory RequestDirectory,
                                         EventEditorRequestRename SaveConfirm = null, EventEditorRequestRename CancelEvent = null)
        {
            InitializeComponent();
            WindowActions();
            NetworkActions();

            DC_EditorRequestSaver = new DynamicEditorRequestSaver(RequestDirectory.RequestTitle, RequestDirectory.Title);
            this.DataContext      = DC_EditorRequestSaver;

            this.RequestDirectory = RequestDirectory;
            this.RequestLink      = RequestLink;
            this.RequestMethod    = RequestMethod;

            this.SaveConfirm = SaveConfirm;
            this.CancelEvent = CancelEvent;
        }
Ejemplo n.º 7
0
        public static HeaderedItemViewModel AddTab(string Header = "Новый запрос", ModelRequestDirectory RequestDirectory = null)
        {
            var Content = new EditorWebRequestControl(RequestDirectory);

            var TabItemView = new HeaderedItemViewModel()
            {
                Header  = Header,
                Content = Content
            };

            //Content.Construct(TabItemView, RequestDirectory);

            ((EditorWebRequestControl)TabItemView.Content)
            .Construct(TabItemView);

            return(TabItemView);
        }
        private void ButtonClick_OpenWebRequest(object sender, RoutedEventArgs e)
        {
            var RowRequestDirectory = (sender as Button).DataContext as ModelRequestDirectory;

            if (ProjectData.TabCollecton != null)
            {
                ModelRequestDirectory RequestDirectoryItem = Array.Find(VirtualRequestDirs.ToArray(),
                                                                        x => x.Id == RowRequestDirectory.Id);

                ProjectData.TabCollecton.Items.Add(
                    BoundNewItem.AddTab(
                        RequestDirectoryItem.RequestTitle,
                        RequestDirectoryItem
                        )
                    );
            }
        }