///<summary>Converts parameters into sheetfield objects, and then saves those objects in the database. The parameters will never again enjoy full parameter status, but will just be read-only fields from here on out. It ignores PatNum parameters, since those are already part of the sheet itself.</summary> public static void SaveParameters(Sheet sheet) { //No need to check RemotingRole; no call to db SheetField field; for (int i = 0; i < sheet.Parameters.Count; i++) { if (sheet.Parameters[i].ParamName == "PatNum") { continue; } field = new SheetField(); field.IsNew = true; field.SheetNum = sheet.SheetNum; field.FieldType = SheetFieldType.Parameter; field.FieldName = sheet.Parameters[i].ParamName; field.FieldValue = sheet.Parameters[i].ParamValue.ToString(); //the object will be an int. Stored as a string. field.FontSize = 0; field.FontName = ""; field.FontIsBold = false; field.XPos = 0; field.YPos = 0; field.Width = 0; field.Height = 0; field.GrowthBehavior = GrowthBehaviorEnum.None; field.RadioButtonValue = ""; SheetFields.Insert(field); } }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Signature ///fields are inserted as they are, so they must be keyed to the field values already. Saves the sheet and sheetfields exactly as they are. Used by ///webforms, for example, when a sheet is retrieved from the web server and the sheet signatures have already been keyed to the field values and ///need to be inserted as-is into the user's db.</Summary> public static void SaveNewSheet(Sheet sheet) { //This remoting role check is technically unnecessary but it significantly speeds up the retrieval process for Middle Tier users due to looping. if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheet); return; } if (!sheet.IsNew) { throw new ApplicationException("Only new sheets allowed"); } Insert(sheet); //insert 'blank' sheetfields to get sheetfieldnums assigned, then use ordered sheetfieldnums with actual field data to update 'blank' db fields List <long> listSheetFieldNums = sheet.SheetFields.Select(x => SheetFields.Insert(new SheetField() { SheetNum = sheet.SheetNum })) .OrderBy(x => x)//PKs of all sheet fields that were just inserted. Signatures require sheet fields be ordered by PK. .ToList(); if (listSheetFieldNums.Count != sheet.SheetFields.Count) //shouldn't be possible, just in case { Delete(sheet.SheetNum); //any blank inserted sheetfields will be linked to the sheet marked deleted throw new ApplicationException("Incorrect sheetfield count."); } //now that we have an ordered list of sheetfieldnums, update db blank fields with all field data from field in memory for (int i = 0; i < sheet.SheetFields.Count; i++) { SheetField fld = sheet.SheetFields[i]; fld.SheetFieldNum = listSheetFieldNums[i]; fld.SheetNum = sheet.SheetNum; SheetFields.Update(fld); } }
///<summary>Converts parameters into sheetfield objects, and then saves those objects in the database. The parameters will never again enjoy full parameter status, but will just be read-only fields from here on out. It ignores PatNum parameters, since those are already part of the sheet itself.</summary> public static void SaveParameters(Sheet sheet) { //No need to check RemotingRole; no call to db List <SheetField> listFields = new List <SheetField>(); for (int i = 0; i < sheet.Parameters.Count; i++) { if (sheet.Parameters[i].ParamName.In("PatNum", //These types are not primitives so they cannot be saved to the database. "CompletedProcs", "toothChartImg")) { continue; } SheetField field = new SheetField(); field.IsNew = true; field.SheetNum = sheet.SheetNum; field.FieldType = SheetFieldType.Parameter; field.FieldName = sheet.Parameters[i].ParamName; field.FieldValue = sheet.Parameters[i].ParamValue.ToString(); //the object will be an int. Stored as a string. field.FontSize = 0; field.FontName = ""; field.FontIsBold = false; field.XPos = 0; field.YPos = 0; field.Width = 0; field.Height = 0; field.GrowthBehavior = GrowthBehaviorEnum.None; field.RadioButtonValue = ""; listFields.Add(field); } SheetFields.InsertMany(listFields); }
///<summary>Gets a single sheet from the database. Then, gets all the fields and parameters for it. So it returns a fully functional sheet.</summary> public static Sheet GetSheet(long sheetNum) { //No need to check RemotingRole; no call to db. Sheet sheet = CreateObject(sheetNum); SheetFields.GetFieldsAndParameters(sheet); return(sheet); }
public Sheet Copy() { Sheet retVal = (Sheet)this.MemberwiseClone(); retVal.Parameters = Parameters.Select(x => x.Copy()).ToList(); retVal.SheetFields = SheetFields.Select(x => x.Copy()).ToList(); return(retVal); }
///<summary>Sorts fields in the order that they shoudl be drawn on top of eachother. First Images, then Drawings, Lines, Rectangles, Text, Check Boxes, and SigBoxes. In that order.</summary> public static int SortDrawingOrderLayers(SheetFieldDef f1, SheetFieldDef f2) { if (f1.FieldType != f2.FieldType) { return(SheetFields.FieldTypeSortOrder(f1.FieldType).CompareTo(SheetFields.FieldTypeSortOrder(f2.FieldType))); } return(f1.YPos.CompareTo(f2.YPos)); //return f1.SheetFieldNum.CompareTo(f2.SheetFieldNum); }
///<summary>Gets a single sheet from the database. Then, gets all the fields and parameters for it. So it returns a fully functional sheet. ///Returns null if the sheet isn't found in the database.</summary> public static Sheet GetSheet(long sheetNum) { //No need to check RemotingRole; no call to db. Sheet sheet = GetOne(sheetNum); if (sheet == null) { return(null); //Sheet was deleted. } SheetFields.GetFieldsAndParameters(sheet); return(sheet); }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Does not save any drawings. Does not save signatures. Does not save any parameters (PatNum parameters never get saved anyway).</Summary> public static void SaveNewSheet(Sheet sheet) { //No need to check RemotingRole; no call to db. if (!sheet.IsNew) { throw new Exception("Only new sheets allowed"); } Insert(sheet); foreach (SheetField fld in sheet.SheetFields) { fld.SheetNum = sheet.SheetNum; SheetFields.Insert(fld); } }
///<Summary>This is normally done in FormSheetFillEdit, but if we bypass that window for some reason, we can also save a new sheet here. Does not save any drawings. Does not save signatures. Does not save any parameters (PatNum parameters never get saved anyway).</Summary> public static void SaveNewSheet(Sheet sheet) { //This remoting role check is technically unnecessary but it significantly speeds up the retrieval process for Middle Tier users due to looping. if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), sheet); return; } if (!sheet.IsNew) { throw new Exception("Only new sheets allowed"); } Insert(sheet); foreach (SheetField fld in sheet.SheetFields) { fld.SheetNum = sheet.SheetNum; SheetFields.Insert(fld); } }
///<summary>Gets sheets with PatNum=0 and IsDeleted=0. Sheets with no PatNums were most likely transferred from CEMT tool. ///Also sets the sheet's SheetFields.</summary> public static List <Sheet> GetTransferSheets() { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetObject <List <Sheet> >(MethodBase.GetCurrentMethod())); } //Sheets with patnum=0 and the sheet has a sheetfield. string command = "SELECT * FROM sheet " + "INNER JOIN sheetfield ON sheetfield.SheetNum=sheet.SheetNum " + "WHERE PatNum=0 AND IsDeleted=0 " + "AND sheetfield.FieldName='isTransfer' " + $"AND SheetType={POut.Int((int)SheetTypeEnum.PatientForm)}"; List <Sheet> retVal = Crud.SheetCrud.SelectMany(command); //Get the Sheetfields and parameters for each of the CEMT sheets foreach (Sheet sheet in retVal) { SheetFields.GetFieldsAndParameters(sheet); } return(retVal); }
///<summary>SigBoxes must be synced after all other fields have been synced for the keyData to be in the right order. ///So sync must be called first without SigBoxes, then the keyData for the signature(s) can be retrieved, then the SigBoxes can be synced. ///This function uses a DB comparison rather than a stale list because we are not worried about concurrency of a single sheet and enhancing the ///functions that call this would take a lot of restructuring.</summary> public static void Sync(List <SheetField> listSheetFieldsNew, long sheetNum, bool isSigBoxOnly) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), listSheetFieldsNew, sheetNum, isSigBoxOnly); return; } List <SheetField> listSheetFieldsDB = SheetFields.GetListForSheet(sheetNum); if (!isSigBoxOnly) { List <SheetField> listNoSigNew = listSheetFieldsNew.FindAll(x => x.FieldType != SheetFieldType.Parameter && x.FieldType != SheetFieldType.SigBox); List <SheetField> listNoSigDB = listSheetFieldsDB.FindAll(x => x.FieldType != SheetFieldType.Parameter && x.FieldType != SheetFieldType.SigBox); Crud.SheetFieldCrud.Sync(listNoSigNew, listNoSigDB); } else { //SigBoxes must come after ALL other types in order for the keyData to be in the right order. List <SheetField> listSigOnlyNew = listSheetFieldsNew.FindAll(x => x.FieldType == SheetFieldType.SigBox); List <SheetField> listSigOnlyDB = listSheetFieldsDB.FindAll(x => x.FieldType == SheetFieldType.SigBox); Crud.SheetFieldCrud.Sync(listSigOnlyNew, listSigOnlyDB); } }