static void Main(string[] args)
        {
            Process process = new Process();

            CreatePerson createPerson = new CreatePerson();

            List <Person> createdPersons = createPerson.List(500);


            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine();
            }

            Console.WriteLine("Persons Started SQL Server Database Saving!");
            DateTime startTime = DateTime.Now;

            foreach (Person item in createdPersons)
            {
                process.Add(new SqlServer(), item);
            }
            DateTime endTime = DateTime.Now;

            Console.WriteLine("Persons SQL Server Database Saving Finished!");
            TimeSpan differenceTime = endTime - startTime;

            Console.WriteLine($"{ differenceTime.TotalSeconds } Seconds");

            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine();
            }

            Console.WriteLine($"Persons Started MySQL Database Saving! { startTime }");
            startTime = DateTime.Now;
            foreach (Person item in createdPersons)
            {
                process.Add(new MySQL(), item);
            }
            endTime = DateTime.Now;
            Console.WriteLine($"Persons MySQL Database Saving Finished! { DateTime.Now }");
            differenceTime = endTime - startTime;
            Console.WriteLine($"{ differenceTime.TotalSeconds } Seconds");

            Console.ReadKey();
        }
Exemple #2
0
        /// <summary>
        /// 把装订工艺插入到工艺序列,并插入配页工艺
        /// </summary>
        /// <param name="bindtype"></param>
        public void InserBind(int bindtype)
        {
            BindType = bindtype;
            List <Model.recttange> plist = new List <Model.recttange>();

            Model.P_ProcessList w1 = new Model.P_ProcessList();

            Model.Process p = DAL.Process.GetModel(bindtype);
            if (p != null)
            {
                w1.ProcessId   = p.ProcessId;
                w1.ProcessName = p.ProcessName;
                w1.Num         = ProductNum;
                w1.PType       = 2;
                w1.GroupId     = 0;
                int extend = p.MinExtendPaper;
                w1.Price         = DAL.C_ProcessPrice.GetPrice(w1.ProcessId, w1.Num);
                Cover.ExtendNum += extend;
                w1.ListCode      = Cover.UnitName;
                Process.Add(w1);
                int id = p.MustNext;
                if (id > 0)
                {
                    Model.Process       p2 = DAL.Process.GetModel(id);
                    Model.P_ProcessList w2 = new Model.P_ProcessList();
                    int alltie             = 0;

                    if (Inner != null)
                    {
                        foreach (ProductUnit p1 in Inner)
                        {
                            alltie        += p1.PrintPs.HalfPsNum + p1.PrintPs.AllPsNum + p1.PrintPs.QuarPsNum;
                            p1.ExtendNum  += p2.MinExtendPaper;
                            p1.ExtendRatio = ConstantValue.Process.ExtendRatio;
                        }
                    }
                    alltie        += Cover.PrintPs.HalfPsNum + Cover.PrintPs.AllPsNum + Cover.PrintPs.QuarPsNum;
                    w2.ProcessId   = id;
                    w2.GroupId     = 1;
                    w2.ProcessName = p2.ProcessName;
                    w2.Num         = alltie * ProductNum;
                    w2.PType       = 2;
                    w2.Price       = DAL.C_ProcessPrice.GetPrice(w2.ProcessId, w2.Num);
                    w2.ListCode    = "内页总贴";
                    Process.Add(w2);
                }
            }
        }
        public void SetValues(Type typeContent, IEnumerable values)
        {
            this.State = TypeControl.Create;
            using (DBContext context = new DBContext(false))
            {
                foreach (var item in values)
                {
                    CurrentStartProcess           = StartProcess.New();
                    CurrentStartProcess.IdUser    = App.CurrentUser.ID;
                    CurrentStartProcess.PathToApp = item.ToString();
                    CurrentStartProcess.Caption   = Path.GetFileNameWithoutExtension(item.ToString());
                    context.StartProcesses.AddObject(CurrentStartProcess);
                    context.SaveChanges();

                    Process.Add(CurrentStartProcess);
                    CurrentStartProcess = null;
                }
            }
            this.State = TypeControl.Normal;
        }
        private async Task <string> Save()
        {
            ForceRefresh           = true;
            _this.Output           = txtOutput.Text;
            _this.InitialDiagnosis = txtInitialDiagnosis.Text;
            _this.RepairActions    = txtRepairActions.Text;
            _this.Comment          = txtComment.Text;
            string _Result = "OK";

            if (IsMesSyncSelected())
            {
                _this.MesId  = txtMesId.Text;
                _this.Reason = txtDescription.Text;
            }
            else
            {
                _this.Description = txtDescription.Text;
            }

            if (txtStartedOn.Text == " ")
            {
                _this.StartedOn = null;
            }
            else
            {
                _this.StartedOn = txtStartedOn.Value;
            }
            if (txtFinishedOn.Text == " ")
            {
                _this.FinishedOn = null;
            }
            else
            {
                _this.FinishedOn = txtFinishedOn.Value;
            }
            if (txtPlannedStart.Text == " ")
            {
                _this.PlannedStart = null;
            }
            else
            {
                _this.PlannedStart = txtPlannedStart.Value;
            }
            if (txtPlannedFinish.Text == " ")
            {
                _this.PlannedFinish = null;
            }
            else
            {
                _this.PlannedFinish = txtPlannedFinish.Value;
            }
            if (cmbPlace.SelectedItem != null)
            {
                _this.PlaceId = (int)cmbPlace.GetSelectedValue <Place>();
            }
            if (cmbActionType.SelectedItem != null)
            {
                _this.ActionTypeId = Convert.ToInt32(cmbActionType.SelectedValue.ToString());
            }
            if (cmbStatus.SelectedItem != null)
            {
                _this.Status = cmbStatus.SelectedItem.ToString();
            }
            if (cmbStartedBy.SelectedItem != null)
            {
                _this.StartedBy = Convert.ToInt32(cmbStartedBy.SelectedValue.ToString());
            }
            if (cmbFinishedBy.SelectedItem != null)
            {
                _this.FinishedBy = Convert.ToInt32(cmbFinishedBy.SelectedValue.ToString());
            }

            try
            {
                Looper.Show(this);
                if (mode == 1)
                {
                    _this.CreatedBy = RuntimeSettings.UserId;
                    _this.CreatedOn = DateTime.Now;
                    if (await _this.Add())
                    {
                        if (assignedUsersHandler.AssignedUsers.Any())
                        {
                            _Result = await _this.AssignUsers(assignedUsersHandler.AssignedUsers);
                        }

                        mode      = 2;
                        this.Text = "Szczegóły zgłoszenia";
                    }
                    else
                    {
                        _Result = "Błąd podczas tworzenia nowego zgłoszenia..";
                    }
                }
                else if (mode == 2)
                {
                    if (await _this.Edit())
                    {
                        if (assignedUsersHandler.AssignedUsers.Any())
                        {
                            _Result = await _this.AssignUsers(assignedUsersHandler.AssignedUsers);
                        }
                    }
                    else
                    {
                        _Result = "Błąd podczas edycji zgłoszenia..";
                    }
                }
                if (_Result == "OK")
                {
                    _Result = await files.Save($"ProcessId={_this.ProcessId}");
                }

                if (_Result != "OK")
                {
                    _Result = $"Wystąpiły problemy podczas zapisywania plików. Szczegóły: {_Result}";
                }
            }
            catch (Exception ex)
            {
                _Result = ex.ToString();
            }
            finally
            {
                Looper.Hide();
            }
            ChangeLook();

            return(_Result);
        }
Exemple #5
0
 /// <summary>
 ///   Adds preprocessing middleware.
 /// </summary>
 /// <param name="middleware"> The middleware to add. </param>
 /// <param name="processor"> </param>
 /// <returns> The server instance. </returns>
 public ServerBase Use(Action <IContext, Action> processor)
 {
     Process.Add(processor);
     return(this);
 }