Ejemplo n.º 1
0
        public static bool Process(out StructureValueForClient StructureValueForClient, out TimeSpan TimeOnLoad, out ConnectionBackInformation ConnectionBackInformationLoad) // Process
        {
            StructureValueForClient = null;
            TimeOnLoad = default;
            ConnectionBackInformationLoad = null;

            if (ListNameOfValue is null ? false : ListNameOfValue.Count > 0)
            {
                TimeSpan StartLoad = DateTime.Now.TimeOfDay;
                Tuple <StructureValueForClient, string, string> tuple = MethodsCall.GetParamatersForClientReady(ListNameOfValue, out ConnectionBackInformationLoad);
                TimeOnLoad = DateTime.Now.TimeOfDay - StartLoad;
                Console.WriteLine("GetParamatersForClientReady, time on it: " + TimeOnLoad);

                if (ConnectionBackInformationLoad.Recieve_GetResponse)
                {
                    var Time = TimeOnLoad - ConnectionBackInformationLoad.Recieve_TimeSpend - ConnectionBackInformationLoad.Send_TimeSpend;

                    if (TimeOnLoad > TimeSpan.FromSeconds(20))
                    {
                    }

                    if (Time > TimeSpan.FromSeconds(2))
                    {
                    }
                }
                else
                {
                }

                if (!(tuple.Item1 is null))
                {
                    TimeSpan TimeServerWhenGetProperties = DateTime.Now.TimeOfDay - tuple.Item1.TimeServerWhenGetProperties;
                    TimeSpan TimeOnSentFromServer        = TimeOnLoad - TimeServerWhenGetProperties;
                }

                if (tuple.Item3 == "<Not connected>")
                {
                    Console.WriteLine("Result: <Not connected>");
                }
                else if (!(tuple.Item1 is null))
                {
                    StructureValueForClient = tuple.Item1;

                    if (!(StructureValueForClient is null))
                    {
                        return(true);
                    }
Ejemplo n.º 2
0
        private void buttonAuthorization_Click(object sender, EventArgs e)
        {
            string Login    = textBoxLogin.Text;
            string Password = textBoxPassword.Text;
            Tuple <string, string, string> tuple = MethodsCall.GetUser <string>(Login, Password, out ConnectionBackInformation ConnectionBackInformatio);

            if (tuple is null ? false : !string.IsNullOrEmpty(tuple.Item1))
            {
                if (bool.TryParse(tuple.Item1, out bool Parsed))
                {
                    if (!Parsed)
                    {
                        return;
                    }
                }
                else
                {
                    TaskManagerForm.NameUser = tuple.Item1;
                }

                Thread Thread = new Thread(() =>
                {
                    Application.Run(new TaskManagerForm());
                });
                Thread.Priority = ThreadPriority.Highest;
                Thread.SetApartmentState(ApartmentState.STA);
                Thread.IsBackground = false;

                try
                {
                    Thread.Start();
                    this.Close();
                }
                catch (ThreadStateException ex)
                {
                }
                catch (ThreadAbortException ex)
                {
                }
                catch (NullReferenceException ex)
                {
                }
            }
        }
        public bool SetToServer(object sender, EventArgs e, StructureValueForClient StructureValueForClient, out string Exception) // Event
        {
            DateTime Start           = DateTime.Now;
            bool     Done            = false;
            string   Exception_Local = null;

            Thread Thread = new Thread(() =>
            {
                try
                {
                    if (sender is null)
                    {
                        sender = new object();
                    }

                    lock (sender)
                    {
                        if (Thread.CurrentThread.Name is null)
                        {
                            Thread.CurrentThread.Name = nameof(SetToServer);
                        }

                        if (StructureValueForClient != null)
                        {
                            if (TaskManagerForm.StatusStrip.InvokeRequired)
                            {
                                TaskManagerForm.StatusStrip.Invoke(new Action(() =>
                                {
                                    TaskManagerForm.toolStripStatusLabelExport.BackColor = Color.Yellow;
                                    TaskManagerForm.toolStripStatusLabelExport.Text      = string.Format("Export: {0}", "Started");
                                }));
                            }
                            else
                            {
                                TaskManagerForm.toolStripStatusLabelExport.BackColor = Color.Yellow;
                                TaskManagerForm.toolStripStatusLabelExport.Text      = string.Format("Export: {0}", "Started");
                            }

                            DateTime Started = DateTime.Now;
                            Tuple <string, string, string> tuple1 = MethodsCall.SetToServer <string>(StructureValueForClient, out ConnectionBackInformation ConnectionBackInformation);
                            TimeSpan Time = DateTime.Now - Started;

                            if (tuple1 is null ? true : (!string.IsNullOrEmpty(tuple1.Item1) || !string.IsNullOrEmpty(tuple1.Item2) || !string.IsNullOrEmpty(tuple1.Item3)))
                            {
                                Started = DateTime.Now;
                                tuple1  = MethodsCall.SetToServer <string>(StructureValueForClient, out ConnectionBackInformation);
                                Time    = DateTime.Now - Started;
                            }

                            if (tuple1 is null ? false : !string.IsNullOrEmpty(tuple1.Item1))
                            {
                                Done            = false;
                                Exception_Local = tuple1.Item1;
                            }
                            else if (tuple1 is null ? false : !string.IsNullOrEmpty(tuple1.Item2))
                            {
                                Done            = false;
                                Exception_Local = tuple1.Item2;
                            }
                            else if (tuple1 is null ? false : !string.IsNullOrEmpty(tuple1.Item3))
                            {
                                Done            = false;
                                Exception_Local = tuple1.Item3;
                            }