Beispiel #1
0
        private string serialText; //aid serial text

        #endregion Fields

        #region Constructors

        /// <summary>
        /// constructor
        /// </summary>
        public Aid()
        {
            this.serialText = "";
            this.modelText = "";
            this.model = null;
            this.ear = AidEar.Unknown;
        }
Beispiel #2
0
 /// <summary>
 /// Process input which should be a model
 /// </summary>
 /// <param name="input">input text</param>
 /// <param name="model">model matching input text</param>
 /// <returns></returns>
 private ProcessResult ProcessModel(string input, Model model)
 {
     if (!this.IsTailAidComplete())
     {
         //tail aid not complete
         Aid aid = this.GetIncompleteAid(true);
         if (! aid.HasModel())
         {
             //check existing serial if valid for model
             if (aid.HasSerial() == false || Models.Instance.ValidateSerial(model, aid.SerialText))
             {
                 //add model to aid
                 this.AddModelToAid(aid, input, model);
                 this.AidsQueueModified();
                 if (aid.IsComplete() == true)
                     this.CompleteAidAdded();
             }
             else
             {
                 //existing serial invalid
                 return ProcessResult.InvalidModelForSerial;
             }
         }
         else
         {
             //aid already has model
             return ProcessResult.AidHasModel;
         }
     }
     else
     {
         //tail aid complete
         this.AddModelToAid(this.GetIncompleteAid(true), input, model);
     }
     return ProcessResult.OK;
 }
Beispiel #3
0
 /// <summary>
 /// Load models from xml file
 /// </summary>
 /// <param name="file">xml file to load</param>
 public void LoadModels(string file)
 {
     XmlTextReader reader = null;
     Model model;
     string name = "";
     string modelFormat = null;
     string serialFormat = null;
     string tag = "";
     try
     {
         reader = new XmlTextReader(file);
         while (reader.Read())
         {
             switch (reader.NodeType)
             {
                 case XmlNodeType.Element:
                     tag = reader.Name;
                     break;
                 case XmlNodeType.Text:
                     if (tag == "name")
                         name = reader.Value;
                     else if (tag == "modeltext")
                         modelFormat = reader.Value;
                     else if (tag == "serial")
                         serialFormat = reader.Value;
                     break;
                 case XmlNodeType.EndElement:
                     if (reader.Name == "model")
                     {
                         model = new Model(name, modelFormat, serialFormat);
                         this.modelList.Add(model);
                         LaserMarker.Instance.LoadFile(name);
                         modelFormat = null;
                         serialFormat = null;
                     }
                     break;
             }
         }
     }
     finally
     {
         if (reader != null)
             reader.Close();
     }
 }
Beispiel #4
0
 /// <summary>
 /// Adds a model to an aid
 /// </summary>
 /// <param name="aid">aid to add model to</param>
 /// <param name="modelText">model text</param>
 /// <param name="model">model to add to aid</param>
 private void AddModelToAid(Aid aid, string modelText, Model model)
 {
     aid.Model = model;
     aid.ModelText = modelText;
     //also add models with no serial format
     if (model.SerialFormat == null)
     {
         aid.SerialText = modelText;
     }
     this.AidsQueueModified();
 }
Beispiel #5
0
        /// <summary>
        /// Checks if a serial number is valid.
        /// If model is null serial number is checked against all models
        /// </summary>
        /// <param name="model">model to check against or null</param>
        /// <param name="serialText">serial text to check</param>
        /// <returns></returns>
        public bool ValidateSerial(Model model, string serialText)
        {
            if (model == null)
            {
                //check all models
                if (this.modelList.Count == 0)
                    return false;

                foreach (Model modelEach in this.modelList)
                {
                    if (modelEach.TestSerial(serialText))
                    {
                        return true;
                    }
                }
            }
            else
            {
                //check just model
                return model.TestSerial(serialText);
            }
            return false;
        }