///<summary>(Only used during AutoNote import process) Takes in a List of SerializableAutoNoteControl and SerializableAutoNotes and trims
        ///the Control list down to only the unique items. This appends numbers to names if names are duplicated but prompt text is new and, in
        ///that case, changes the prompt name in the associated AutoNote.MainText. This operates on the objects passed in so there is no return
        ///value.</summary>
        public static void RemoveDuplicatesFromList(List <SerializableAutoNoteControl> listSerializableAutoNoteControls, List <SerializableAutoNote> listSerializableAutoNotes)
        {
            List <string> listTrueDuplicates = new List <string>();

            foreach (SerializableAutoNoteControl curControl in listSerializableAutoNoteControls)
            {
                bool            wasNameChanged = false;
                AutoNoteControl dbControl      = GetByDescript(curControl.Descript);
                int             dupNum         = 0;
                string          name           = curControl.Descript; //Used to hold the current name so we can safely change the name while we check for duplicates
                while (dbControl != null)                             //While the control name is not unique
                {
                    if (dbControl.ControlOptions == curControl.ControlOptions &&
                        dbControl.ControlType == curControl.ControlType)                     //ControlLabel is omitted because it serves no functional purpose in a duplication check
                    {
                        listTrueDuplicates.Add(curControl.Descript);                         //Add this to a list of true duplicates so it doesn't get reimported
                        break;
                    }
                    dupNum++;
                    curControl.Descript = string.Join("_", name, dupNum.ToString());
                    wasNameChanged      = true;
                    dbControl           = GetByDescript(curControl.Descript);
                }
                if (wasNameChanged)                  //If the name changed, replace all instances of it across the new AutoNotes
                {
                    foreach (SerializableAutoNote note in listSerializableAutoNotes)
                    {
                        note.MainText = note.MainText.Replace("[Prompt:\"" + name + "\"]", "[Prompt:\"" + curControl.Descript + "\"]");
                    }
                }
            }
            listSerializableAutoNoteControls.RemoveAll(x => x.Descript.In(listTrueDuplicates));
        }
 public SerializableAutoNoteControl(AutoNoteControl control)
 {
     ControlLabel   = control.ControlLabel;
     ControlOptions = control.ControlOptions;
     ControlType    = control.ControlType;
     Descript       = control.Descript;
 }
        ///<summary>Returns a list of unique AutoNoteControls based on parsing a list of AutoNotes' MainText (used for exporting AutoNoteControls).</summary>
        public static List <AutoNoteControl> GetListByParsingAutoNoteText(List <SerializableAutoNote> listSerializableAutoNotes)
        {
            //No need to check RemotingRole; no call to db.
            List <AutoNoteControl> listAutoNoteControls = new List <AutoNoteControl>();
            List <Match>           listPrompts          = new List <Match>();

            //Find all prompts in all the provided AutoNotes
            foreach (SerializableAutoNote autoNote in listSerializableAutoNotes)
            {
                listPrompts.AddRange(GetPrompts(autoNote.MainText));
            }
            //Clean up the text for every discovered prompt to retrieve the appropriate AutoNoteControl if it exists
            foreach (Match control in listPrompts)
            {
                string descript = control.ToString();
                //Trimming down the match to just the Descript of the prompt text
                descript = descript.Replace("[Prompt:\"", "");
                descript = descript.Replace("\"]", "");
                AutoNoteControl newControl = GetByDescript(descript);
                if (newControl != null)
                {
                    listAutoNoteControls.Add(newControl);
                }
            }
            return(listAutoNoteControls.DistinctBy(x => x.Descript).ToList());
        }
		public static void Update(AutoNoteControl autoNoteControl) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				Meth.GetVoid(MethodBase.GetCurrentMethod(),autoNoteControl);
				return;
			}
			Crud.AutoNoteControlCrud.Update(autoNoteControl);
		}
		public static long Insert(AutoNoteControl autoNoteControl) {
			if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) {
				autoNoteControl.AutoNoteControlNum=Meth.GetLong(MethodBase.GetCurrentMethod(),autoNoteControl);
				return autoNoteControl.AutoNoteControlNum;
			}
			return Crud.AutoNoteControlCrud.Insert(autoNoteControl);
		}
示例#6
0
 public static void Update(AutoNoteControl autoNoteControl)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), autoNoteControl);
         return;
     }
     Crud.AutoNoteControlCrud.Update(autoNoteControl);
 }
示例#7
0
 public static long Insert(AutoNoteControl autoNoteControl)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         autoNoteControl.AutoNoteControlNum = Meth.GetLong(MethodBase.GetCurrentMethod(), autoNoteControl);
         return(autoNoteControl.AutoNoteControlNum);
     }
     return(Crud.AutoNoteControlCrud.Insert(autoNoteControl));
 }
		private void butAdd_Click(object sender,EventArgs e) {
			FormAutoNoteControlEdit FormA=new FormAutoNoteControlEdit();
			AutoNoteControl control=new AutoNoteControl();
			control.ControlType="Text";
			FormA.ControlCur=control;
			FormA.IsNew=true;
			FormA.ShowDialog();
			if(FormA.DialogResult!=DialogResult.OK) {
				return;
			}
			FillGrid();
		}
        public static void InsertBatch(List <SerializableAutoNoteControl> listSerializableAutoNoteControls)
        {
            if (listSerializableAutoNoteControls == null || listSerializableAutoNoteControls.Count == 0)
            {
                return;
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                Meth.GetVoid(MethodBase.GetCurrentMethod(), listSerializableAutoNoteControls);
                return;
            }
            List <AutoNoteControl> listAutoNoteControls = new List <AutoNoteControl>();

            foreach (SerializableAutoNoteControl control in listSerializableAutoNoteControls)
            {
                AutoNoteControl newControl = new AutoNoteControl();
                newControl.ControlLabel   = control.ControlLabel;
                newControl.ControlOptions = control.ControlOptions;
                newControl.ControlType    = control.ControlType;
                newControl.Descript       = control.Descript;
                listAutoNoteControls.Add(newControl);
            }
            Crud.AutoNoteControlCrud.InsertMany(listAutoNoteControls);
        }