예제 #1
0
        private static void ExportDocument(IList <Form> forms, string name, string fileName, bool portrait, string type, Type sourceObjectType = null, bool recalculateForm = true, PrintSettings printSettings = null, MarginsI margins = null)
        {
            IDocumentExporter exporter;
            string            filename;
            bool?  toFile;
            string email;
            string subject;

            using (ExportDocuments dialog = new ExportDocuments(sourceObjectType ?? forms [0].SourceObject.GetType(), fileName)) {
                if (dialog.Run() != ResponseType.Ok)
                {
                    return;
                }

                exporter = dialog.DocumentExporter;
                filename = dialog.FileName;
                toFile   = dialog.ToFile;
                email    = dialog.Email;
                subject  = dialog.EmailSubject;
            }

            BusinessDomain.FeedbackProvider.TrackEvent("Export document", type);

            try {
                exporter.Export(filename, toFile, email, subject, name, forms, portrait, recalculateForm, printSettings, margins);
            } catch (LicenseLimitationException ex) {
                MessageError.ShowDialog(ex.Message, ErrorSeverity.Warning, ex);
            } catch (IOException ex) {
                MessageError.ShowDialog(string.Format(Translator.GetString("Error occurred while saving export to \"{0}\". Please check if you have write permissions to that location."), filename), ErrorSeverity.Warning, ex);
            } catch (Exception ex) {
                MessageError.ShowDialog(Translator.GetString("Error occurred while performing export."), ErrorSeverity.Warning, ex);
            }
        }
예제 #2
0
        public void HandleObject_Error(Socket socket, MessageError messageError)
        {
            // Outputs the error message to the server ouput
            PrintMessage($"{socket.RemoteEndPoint}'s error: {messageError.Message}");

            // Could confirm error receive || remove the client for safety
        }
예제 #3
0
        private void DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            _serialBuffer.Append(SerialPort.ReadExisting());
            string messageData    = _serialBuffer.ToString();
            int    lastMessageEnd = messageData.LastIndexOf('\n');

            if (lastMessageEnd > -1)
            {
                messageData = messageData.Substring(0, lastMessageEnd);
                _serialBuffer.Remove(0, lastMessageEnd);
                string[] messages = messageData.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string message in messages)
                {
                    string  messageTrimmed = message.Trim(new[] { ' ', '\r', '\n' });
                    Message x10Message;
                    try
                    {
                        x10Message = Message.Parse(messageTrimmed);
                        _log.Debug(x10Message.GetType().Name + " parsed successfully: " + messageTrimmed);
                    }
                    catch (Exception ex)
                    {
                        string errorMessage = ex.GetType().Name + " thrown when parsing message \"" + messageTrimmed + "\". " + ex.Message;
                        _log.Warn(errorMessage);
                        x10Message = new MessageError(MessageSource.Parser, "Parser", errorMessage);
                    }
                    InvokeMessageReceived(x10Message);
                }
            }
        }
예제 #4
0
        public static void ExportData <T> (string defaultFileName, string dataTypeName, DataExchangeSet exportData)
        {
            IDataExporter exporter;
            string        filename;
            bool?         toFile;
            string        email;
            string        subject;

            using (ExportObjects <T> dialog = new ExportObjects <T> (exportData.Contents, defaultFileName)) {
                if (dialog.Run() != ResponseType.Ok)
                {
                    return;
                }

                exporter = dialog.Exporter;
                filename = dialog.FileName;
                toFile   = dialog.ToFile;
                email    = dialog.Email;
                subject  = dialog.EmailSubject;
            }

            BusinessDomain.FeedbackProvider.TrackEvent("Export data", dataTypeName);

            try {
                exporter.Export(filename, toFile, email, subject, exportData);
            } catch (LicenseLimitationException ex) {
                MessageError.ShowDialog(ex.Message, ErrorSeverity.Warning, ex);
            } catch (IOException ex) {
                MessageError.ShowDialog(string.Format(Translator.GetString("Error occurred while saving export to \"{0}\". Please check if you have write permissions to that location."), filename), ErrorSeverity.Warning, ex);
            } catch (Exception ex) {
                MessageError.ShowDialog(Translator.GetString("Error occurred while performing export."), ErrorSeverity.Warning, ex);
            }
        }
예제 #5
0
        private void SearchDataWeatherCitys(object sender, RoutedEventArgs e)
        {
            if (IsConnected)
            {
                switch (TextBoxLocation.Text == "")
                {
                case true:
                    MessageError MessageErrorObject = new MessageError("Fill in the field");
                    MessageErrorObject.Show();
                    //LabelDirections.Content = "Fill in the field";
                    break;

                case false:
                    LabelDirections.Content = "Wait please";
                    JsonWeatherApi.CreateJsonRequest(TextBoxLocation.Text);
                    DispatcherTimer DispatherTimerObject = new DispatcherTimer()
                    {
                        Interval = TimeSpan.FromMilliseconds(1000)
                    };
                    DispatherTimerObject.Start();

                    DispatherTimerObject.Tick += new EventHandler((object e, EventArgs a) =>
                    {
                        LabelDirections.Content = "Choose your position";
                        DispatherTimerObject.Stop();
                    });
                    break;
                }
            }
        }
예제 #6
0
 private void Messenger_MessageReceived(object sender, WebsocketReceiveEventArgs e)
 {
     try
     {
         // TODO: type is response, not command
         var response = Responseo.Parse(e.Message);
         if (response.Sequence == 0)
         {
             // TODO: message type
             Broadcast?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             if (commandCompletionSources.TryRemove(response.Sequence, out var tcs))
             {
                 // TODO: outcome
                 tcs.TrySetResult(response);
             }
             else
             {
                 // TODO: desync? throw?
             }
         }
     }
     catch (FormatException)
     {
         MessageError?.Invoke(this, EventArgs.Empty);
     }
 }
예제 #7
0
        public void HandleObject_Error(MessageError messageError)
        {
            // Displays error message to the user via a pop-up
            MessageBox.Show(messageError.Message, "Error encountered");

            // Close LoginViewModel and open ShellViewModel
        }
예제 #8
0
        public virtual void StartWork(MainConfig config, Message msg)
        {
            string  error       = "账号不存在";
            UIUser  realUser    = this.FindUser(config, msg.UserID);
            Message respondsMsg = null;

            if (null != realUser)
            {
                respondsMsg = this.GetRespondsMsg(config, realUser, msg);
            }
            else
            {
                respondsMsg = new MessageError()
                {
                    User   = msg.User,
                    CallID = msg.CallID,
                    UserID = msg.UserID,
                    Error  = error,
                }
            };
            if (respondsMsg != null)
            {
                config._serverProtocol.SendMsg(respondsMsg);
            }
        }
예제 #9
0
        //message back function that dosent care what operations are happening because it has an asynchronus operation
        private void MessageBack(IAsyncResult Result)
        {
            try
            {
                //End receive from other person
                int recieve = sock.EndReceiveFrom(Result, ref Foreign);
                //parsing data given
                if (recieve > 0)
                {
                    //breaking it into byte streams max
                    byte[] RecievedData = new byte[1464];
                    RecievedData = (byte[])Result.AsyncState;

                    //encoding to ascii for message send and recieve
                    ASCIIEncoding Encoding        = new ASCIIEncoding();
                    string        MessageRecieved = Encoding.GetString(RecievedData);

                    //Insert into view box
                    Viewbox.Dispatcher.Invoke(() => Viewbox.Items.Add("Friend: " + MessageRecieved));
                }

                byte[] buffer = new byte[1500];

                //Begin recieve with properties allocated below
                sock.BeginReceiveFrom(buffer, 0, buffer.Length, SocketFlags.None, ref Foreign, new AsyncCallback(MessageBack), buffer);
            }
            catch (Exception MessageError)
            {
                //show excpetion in message window
                System.Windows.MessageBox.Show(MessageError.ToString());
            }
        }
예제 #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="mensaje"></param>
 private void RaiseMessageError(Exception x,
                                [System.Runtime.CompilerServices.CallerMemberName] string memberName    = "",
                                [System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath  = "",
                                [System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
 {
     MessageError?.Invoke(String.Format("[{0},{1},{2}]: {3}",
                                        System.IO.Path.GetFileName(sourceFilePath), sourceLineNumber, x.Message, memberName), x);
 }
예제 #11
0
 /// <summary>
 ///		Añade un elemento de error
 /// </summary>
 internal void AddError(MessageError error)
 {
     // Añade el elemento al error
     ErrorItems.Add(error);
     // Si tiene demasiados elementos de log quita el primero
     if (ErrorItems.Count > 1000)
     {
         ErrorItems.RemoveAt(0);
     }
 }
예제 #12
0
        private void btnRemove_Clicked(object sender, EventArgs e)
        {
            Button btn  = (Button)sender;
            User   user = (User)btn.Data ["User"];

            switch (User.RequestDelete(user.Id))
            {
            case DeletePermission.InUse:
                MessageError.ShowDialog(
                    Translator.GetString("This user cannot be deleted, because it is used in operations. Please, delete the corresponding operations in order to delete this user!"),
                    "Icons.User16.png");
                return;

            case DeletePermission.Reserved:
            case DeletePermission.No:
                MessageError.ShowDialog(string.Format(Translator.GetString("Cannot delete user \"{0}\"!"), user.Name),
                                        "Icons.User16.png");
                return;

            default:
                if (user.UserLevel == UserAccessLevel.Owner)
                {
                    bool foundOwner = false;
                    bool foundUser  = false;
                    foreach (User u in User.GetAll())
                    {
                        if (u.Id == User.DefaultId || u.Id == user.Id)
                        {
                            continue;
                        }

                        if (u.UserLevel == UserAccessLevel.Owner)
                        {
                            foundOwner = true;
                        }
                        else
                        {
                            foundUser = true;
                        }
                    }

                    if (!foundOwner && foundUser)
                    {
                        MessageError.ShowDialog(Translator.GetString("The last owner cannot be deleted before the rest of the users!"),
                                                "Icons.User16.png");
                        return;
                    }
                }
                break;
            }

            User.Delete(user.Id);
            RefreshUsersTable();
        }
예제 #13
0
 private void ShowCreateATest()
 {
     if (CurrentUser.Instance.Role == Roles.Master)
     {
         RedirectDecorator.ToViewModel(typeof(CreateTestViewModel));
     }
     else
     {
         MessageError.Show(ErrorResources.OnlyMasterCanCreateTests);
     }
 }
예제 #14
0
        public override bool Validate()
        {
            foreach (Location location in locations)
            {
                location.Name = entries [location].Text;
            }

            for (int i = 0; i < locations.Count - 2; i++)
            {
                for (int j = i + 1; j < locations.Count - 1; j++)
                {
                    if (locations [i].Name != locations [j].Name)
                    {
                        continue;
                    }

                    if (MessageError.ShowDialog(string.Format(Translator.GetString("Location with the name \"{0}\" is used more than once! Are you sure you want to continue?"), locations [i].Name),
                                                buttons: MessageButtons.YesNo) != ResponseType.Yes)
                    {
                        return(false);
                    }
                }
            }

            foreach (Location location in locations)
            {
                if (!location.Validate((message, severity, code, state) =>
                {
                    using (MessageError dlgError = new MessageError(message, severity))
                        if (severity == ErrorSeverity.Warning)
                        {
                            dlgError.Buttons = MessageButtons.YesNo;
                            if (dlgError.Run() != ResponseType.Yes)
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            dlgError.Run();
                            return(false);
                        }

                    return(true);
                }, null))
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #15
0
        private void btn_Clicked(object sender, EventArgs e)
        {
            EventHandler <EntitySuggestedEventArgs> handler = EntitySuggested;

            if (handler == null)
            {
                return;
            }

            MessageError.ShowDialog(string.Format(Translator.GetString("You can enable the suggestions from {0}->{1}"), Translator.GetString("Settings"), Translator.GetString("Special")), ErrorSeverity.Information);
            BusinessDomain.AppConfiguration.ShowItemSuggestionsWhenNotFound = false;
            handler(this, new EntitySuggestedEventArgs(null));
        }
예제 #16
0
        private static byte[] SerializeError(GameMessage message)
        {
            MessageError msg = (MessageError)message;

            ProtoMessageError proto = new ProtoMessageError();

            proto.ErrorCode = (ProtoQuestEngineError)msg.ErrorCode;
            proto.Message   = msg.Message;

            var data = proto.ToByteArray();

            return(data);
        }
예제 #17
0
        public async Task <MessageResult> ProcessMessage(MessageViewModel model, string ipAddress)
        {
            var message = ContactFormMessage.FromViewModel(model, ipAddress);

            if (string.IsNullOrEmpty(message.Subject))
            {
                var form = await GetFormSettings().ConfigureAwait(false);

                message.Subject = form.NotificationSubject;
            }

            int successCount = 0;
            int failureCount = 0;
            var errorList    = new List <MessageError>();

            foreach (var processor in _messageProcessors)
            {
                try
                {
                    var tempResult = await processor.Process(message).ConfigureAwait(false);

                    if (tempResult.Succeeded)
                    {
                        successCount += 1;
                    }
                    else
                    {
                        failureCount += 1;
                        errorList.AddRange(tempResult.Errors);
                    }
                }
                catch (Exception ex)
                {
                    failureCount += 1;
                    _log.LogError("error processing contact form message", ex);
                    var me = new MessageError
                    {
                        Code        = "processfailure",
                        Description = ex.Message
                    };
                    errorList.Add(me);
                }
            }

            if (successCount > 0)
            {
                return(MessageResult.Success);
            }

            return(MessageResult.Failed(errorList.ToArray()));
        }
예제 #18
0
        public static bool InteractiveValidationCallback(string message, ErrorSeverity severity, int code, StateHolder state)
        {
            Dictionary <int, bool> responses       = (Dictionary <int, bool>)state ["responses"];
            MessageProgress        messageProgress = null;

            if (state.ContainsKey("messageProgress"))
            {
                messageProgress = (MessageProgress)state ["messageProgress"];
            }

            if (responses.ContainsKey(code))
            {
                return(severity == ErrorSeverity.Warning && responses [code]);
            }

            try {
                if (messageProgress != null)
                {
                    messageProgress.Hide();
                }
                using (MessageError dlgError = new MessageError(message, severity)) {
                    if (severity == ErrorSeverity.Warning)
                    {
                        dlgError.Buttons = MessageButtons.YesNo | MessageButtons.Remember;
                        ResponseType resp = dlgError.Run();
                        if (dlgError.RememberChoice)
                        {
                            responses [code] = resp == ResponseType.Yes;
                        }

                        return(resp == ResponseType.Yes);
                    }
                    else
                    {
                        dlgError.Buttons = MessageButtons.OK | MessageButtons.Remember;
                        dlgError.Run();
                        if (dlgError.RememberChoice)
                        {
                            responses [code] = true;
                        }
                        return(false);
                    }
                }
            } finally {
                if (messageProgress != null)
                {
                    messageProgress.Show();
                }
            }
        }
예제 #19
0
 public Form LoadForm(IDocument document)
 {
     try {
         return(document.LoadForm());
     } catch (Exception exception) {
         if (exception is XmlException)
         {
             MessageError.ShowDialog(string.Format(Translator.GetString("The file \"{0}\" has an incorrect structure (invalid XML)."),
                                                   Path.Combine(BusinessDomain.AppConfiguration.DocumentTemplatesFolder, Path.ChangeExtension(document.FormName, "xml"))), ErrorSeverity.Error);
         }
         ErrorHandling.LogException(exception);
         return(document.LoadForm(string.Empty));
     }
 }
예제 #20
0
        public void VerifyThatMessageTypesAndCodesMapToErrorMessage()
        {
            MessageError  unknownMessageError = new MessageError(MessageSource.Unknown, null);
            List <string> errorCodes          = new List <string>(new[] { "Buffer", "Syntax", "TimOut", "NoAuth", "Method" });

            foreach (MessageSource source in Enum.GetNames(typeof(MessageSource)).Select(name => (MessageSource)Enum.Parse(typeof(MessageSource), name)))
            {
                foreach (MessageError error in errorCodes.Select(code => new MessageError(source, code)))
                {
                    Assert.IsNotNullOrEmpty(error.Message);
                    Assert.AreNotEqual(unknownMessageError.Message, error.Message);
                }
            }
        }
예제 #21
0
        public static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            HangmanView    hangman        = new HangmanView();
            ManagerFile    managerFile    = new ManagerFile();
            ManagerPicture managerPicture = new ManagerPicture();
            MessageError   messageError   = new MessageError();
            ManagerString  managerString  = new ManagerString();

            Presenter presenter = new Presenter(hangman, managerFile, managerPicture, messageError, managerString);

            Application.Run(hangman);
        }
예제 #22
0
        protected virtual void btnPrint_Clicked(object sender, EventArgs e)
        {
            try {
                if (PrintDocument.PrintSettings != null)
                {
                    PrintDocument.PrintSettings.Orientation = currentPreview.Portrait ? PageOrientation.Portrait : PageOrientation.Landscape;
                }

                FormHelper.PrintObject(document, PrintDocument.PrintSettings);
            } catch (Exception ex) {
                MessageError.ShowDialog(
                    Translator.GetString("An error occurred while printing document!"),
                    ErrorSeverity.Error, ex);
            }
        }
예제 #23
0
        private static bool IsConnectionFailure(Message m)
        {
            MessageError et = m.Error;
            // If it's a connect exception,
            string exType = et.ErrorType;

            if (exType.Equals("System.Net.Sockets.SocketException"))
            {
                return(true);
            }
            if (exType.Equals("Deveel.Data.Net.ServiceNotConnectedException"))
            {
                return(true);
            }
            return(false);
        }
        public bool Validate <T>(T value)
        {
            bool sucess = true;

            ValidationTask?.ForEach(item =>
            {
                if (!item.Validate(value))
                {
                    sucess = false;

                    MessageError.Add(item.GetErrorMessage());
                }
            });

            return(sucess);
        }
예제 #25
0
        private static void ImportData <T> (ImporterCallback <T> callback, bool usesLocation)
        {
            IDataImporter importer;
            string        filename;
            long?         locationId;

            BusinessDomain.FeedbackProvider.TrackEvent("Import data", typeof(T).Name.CamelSpace());

            using (ImportObjects <T> dialog = new ImportObjects <T> (usesLocation)) {
                if (dialog.Run() != ResponseType.Ok)
                {
                    return;
                }

                importer   = dialog.Importer;
                filename   = dialog.FileName;
                locationId = dialog.Location != null ? dialog.Location.Id : (long?)null;
            }

            if (importer.UsesFile && !File.Exists(filename))
            {
                MessageError.ShowDialog(Translator.GetString("Please select a valid source file to import!"));
                return;
            }

            try {
                PropertyMap propertyMap;
                using (ImportObjectsMapping <T> dialog = new ImportObjectsMapping <T> (importer, filename)) {
                    if (dialog.Run() != ResponseType.Ok)
                    {
                        return;
                    }

                    propertyMap = dialog.PropertyMap;
                }

                ExchangeHelper.ImportObjects(importer, filename, propertyMap, locationId, callback);
                MessageError.ShowDialog(Translator.GetString("Import completed successfully."), ErrorSeverity.Information);
            } catch (LicenseLimitationException ex) {
                MessageError.ShowDialog(ex.Message, ErrorSeverity.Warning, ex);
            } catch (IOException ex) {
                MessageError.ShowDialog(Translator.GetString("The selected source file is in use by another application! Please close all other applications and try again."), ErrorSeverity.Warning, ex);
            } catch (Exception ex) {
                MessageError.ShowDialog(Translator.GetString("Error occurred while performing import."), ErrorSeverity.Warning, ex);
            }
        }
예제 #26
0
        public void btnDelete_Clicked(object sender, EventArgs e)
        {
            T group = gPanel.GetSelectedGroup();
            DeletePermission permission = GetDeletePermission(group);

            switch (permission)
            {
            case DeletePermission.InUse:
                MessageError.ShowDialog(
                    Translator.GetString("This group cannot be deleted, because it is not empty. Please, delete or move to another group the containing items in order to delete this group!"),
                    "Icons.Group16.png");
                return;

            case DeletePermission.Reserved:
            case DeletePermission.No:
                MessageError.ShowDialog(
                    string.Format(Translator.GetString("Cannot delete group \"{0}\"!"), group.Name),
                    "Icons.Group16.png");
                return;
            }

            using (MessageOkCancel dialog = new MessageOkCancel(
                       Translator.GetString("Delete group"), "Icons.Group16.png",
                       string.Format(Translator.GetString("Do you want to delete group with name \"{0}\"?"), group.Name),
                       "Icons.Delete32.png")) {
                if (dialog.Run() != ResponseType.Ok)
                {
                    return;
                }
            }

            DeleteGroup(group);
            ReloadGroups();
            if (group.Parent != null)
            {
                gPanel.SelectGroupId(group.Parent.Id);
            }
            else
            {
                gPanel.SelectGroupId(-1);
            }
            OnGroupDeleted();
        }
예제 #27
0
        protected override void SetDate(DateTime d)
        {
            useCalculatedAvailability = false;
            if (date != DateTime.MinValue && d < BusinessDomain.Today)
            {
                if (BusinessDomain.AppConfiguration.AllowNegativeAvailability)
                {
                    useCalculatedAvailability = Message.ShowDialog(Translator.GetString("Stock-taking in the Past"), string.Empty,
                                                                   Translator.GetString("You are setting a date in the past. Do you want to use calculated availability for the selected date?"), "Icons.Question32.png",
                                                                   MessageButtons.YesNo) == ResponseType.Yes;
                }
                else
                {
                    MessageError.ShowDialog(Translator.GetString("You are setting a date in the past. Using calculated items availability " +
                                                                 "is only available when working with negative availability is allowed. The items availability in this moment will be used."));
                }
            }

            base.SetDate(d);
        }
예제 #28
0
        public override bool Validate()
        {
            IList <CustomerWrapper> allCustomers = GetAllCustomers();

            for (int i = 0; i < allCustomers.Count - 2; i++)
            {
                for (int j = i + 1; j < allCustomers.Count - 1; j++)
                {
                    if (allCustomers [i].Customer.Name != allCustomers [j].Customer.Name)
                    {
                        continue;
                    }

                    if (MessageError.ShowDialog(string.Format(Translator.GetString("Customer with the name \"{0}\" is used more than once! Are you sure you want to continue?"), allCustomers [i].Customer.Name),
                                                buttons: MessageButtons.YesNo) != ResponseType.Yes)
                    {
                        return(false);
                    }
                }
            }

            return(allCustomers.All(customer => customer.Validate((message, severity, code, state) =>
            {
                using (MessageError dlgError = new MessageError(message, severity))
                    if (severity == ErrorSeverity.Warning)
                    {
                        dlgError.Buttons = MessageButtons.YesNo;
                        if (dlgError.Run() != ResponseType.Yes)
                        {
                            return false;
                        }
                    }
                    else
                    {
                        dlgError.Run();
                        return false;
                    }

                return true;
            }, null)));
        }
        public bool Validate()
        {
            string name = txtName.Text.Trim();

            if (name.Length == 0)
            {
                MessageError.ShowDialog(Translator.GetString("Company name cannot be empty!"));
                return(false);
            }

            CompanyRecord c = CompanyRecord.GetByName(name);

            if (c != null && c.Id != companyRecord.Id)
            {
                if (Message.ShowDialog(Translator.GetString("Warning!"), string.Empty,
                                       Translator.GetString("Company with this name already exists! Do you want to continue?"), "Icons.Warning32.png",
                                       MessageButtons.YesNo) != ResponseType.Yes)
                {
                    return(false);
                }
            }

            string code = txtCode.Text.Trim();

            c = CompanyRecord.GetByCode(name);

            if (!string.IsNullOrEmpty(code) && c != null && c.Id != companyRecord.Id)
            {
                if (Message.ShowDialog(Translator.GetString("Warning!"), string.Empty,
                                       Translator.GetString("Company with this code already exists! Do you want to continue?"), "Icons.Warning32.png",
                                       MessageButtons.YesNo) != ResponseType.Yes)
                {
                    return(false);
                }
            }

            return(true);
        }
예제 #30
0
        //Get Cities
        public static void CreateJsonRequest(string city)
        {
            DispatcherTimer DispatherTimerObject = new DispatcherTimer()
            {
                Interval = TimeSpan.FromMilliseconds(1000)
            };

            DispatherTimerObject.Start();

            DispatherTimerObject.Tick += new EventHandler((object e, EventArgs a) =>
            {
                try
                {
                    string Url = $"http://api.openweathermap.org/data/2.5/weather?q={city}&units=metric&appid=82630901bb3f9ed64d98d0a72e3ad275";
                    HttpWebRequest httpWebRequest   = (HttpWebRequest)WebRequest.Create(Url);
                    HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    string Response;
                    using (StreamReader SR = new StreamReader(httpWebResponse.GetResponseStream()))
                    {
                        Response = SR.ReadToEnd();
                    }
                    JsonWeatherApi.Wr = JsonConvert.DeserializeObject <WeatherResponse>(Response);
                    DataAboutWeather DataAboutWeatherObject = new DataAboutWeather();
                    Application.Current.Windows[0].Close();
                    DataAboutWeatherObject.Show();
                }
                catch (WebException ex)
                {
                    HttpWebResponse ErrorRespose = ex.Response as HttpWebResponse;
                    if (ErrorRespose.StatusCode == HttpStatusCode.NotFound)
                    {
                        MessageError MessageErrorObject = new MessageError("Not found");
                        MessageErrorObject.Show();
                    }
                }
                DispatherTimerObject.Stop();
            });
        }