Exemple #1
0
 public void Fix()
 {
   if (_well.CanFixErrors())
   {
     WasFixed = true;
     statusString = statusString + _well.FixErrors();
     RaisePropertyChanged("WasFixed");
     RaisePropertyChanged("HasFixableErrors");
     RaisePropertyChanged("MissingData");
     RaisePropertyChanged("StatusString");
     screens = null;
     RaisePropertyChanged("Screens");
   }
 }
Exemple #2
0
        public static string FixErrors(this IWell well)
        {
            StringBuilder Returnstring = new StringBuilder();

            if (well.CanFixErrors())
            {
                foreach (IIntake I in well.Intakes)
                {
                    //No screen but we have well or intake depth
                    if (I.Screens.Count == 0)
                    {
                        if (I.Depth.HasValue || well.Depth.HasValue)
                        {
                            Screen sc = new Screen(I);
                            Returnstring.AppendLine("Added screen in Intake number " + I.IDNumber + ".");
                        }
                    }

                    //Make sure it does not enter if no screen was added above
                    if (I.Screens.Count > 0)
                    {
                        foreach (Screen sc in I.Screens)
                        {
                            if (!sc.DepthToTop.HasValue)
                            {
                                if (sc.DepthToBottom.HasValue)
                                {
                                    sc.DepthToTop = Math.Max(0, sc.DepthToBottom.Value - DefaultScreenLength);
                                    Returnstring.AppendLine(String.Format("Top of screen number {0} in Intake number {1} was set from bottom of screen.", sc.Number, I.IDNumber));
                                }
                                else if (I.Depth.HasValue)
                                {
                                    sc.DepthToTop = I.Depth;
                                    Returnstring.AppendLine(String.Format("Top of screen number {0} in Intake number {1} was set to bottom of intake.", sc.Number, I.IDNumber));
                                }
                                else if (well.Depth.HasValue)
                                {
                                    sc.DepthToTop = Math.Max(0, well.Depth.Value - DefaultScreenLength);
                                    Returnstring.AppendLine(String.Format("Top of screen number {0} in Intake number {1} was set to {2} m above well bottom.", sc.Number, I.IDNumber, DefaultScreenLength));
                                }
                                else
                                {
                                    Returnstring.AppendLine("Could not autocorrect depth to screen top");
                                }
                            }
                            if (!sc.DepthToBottom.HasValue)
                            {
                                if (sc.DepthToTop.HasValue)
                                {
                                    sc.DepthToBottom = sc.DepthToTop + DefaultScreenLength;
                                    Returnstring.AppendLine(String.Format("Bottom of screen number {0} in Intake number {1} was set from top of screen.", sc.Number, I.IDNumber));
                                }
                                else if (well.Depth.HasValue)
                                {
                                    sc.DepthToBottom = well.Depth;
                                    Returnstring.AppendLine(String.Format("Bottom of screen number {0} in Intake number {1} was set to well depth", sc.Number, I.IDNumber));
                                }
                                else if (I.Depth.HasValue)
                                {
                                    sc.DepthToBottom = I.Depth.Value + DefaultScreenLength;
                                    Returnstring.AppendLine(String.Format("Bottom of screen number {0} in Intake number {1} was set to {2} m below intake depth.", sc.Number, I.IDNumber, DefaultScreenLength));
                                }
                                else
                                {
                                    Returnstring.AppendLine("Could not autocorrect depth to screen bottom");
                                }
                            }
                        }
                    }
                }
                return(Returnstring.ToString());
            }
            return("Could not fix error");
        }