///<summary>If ClientWeb, then this method is instead run on the server, and the result passed back to the client. And since it's ClientWeb, FillCache will be run on the client.</summary> public static DataSet GetCacheDs(string itypesStr) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetDS(MethodBase.GetCurrentMethod(), itypesStr)); } //so this part below only happens if direct or server------------------------------------------------ List <int> itypes = new List <int>(); string[] strArray = itypesStr.Split(','); for (int i = 0; i < strArray.Length; i++) { itypes.Add(PIn.Int(strArray[i])); } bool isAll = false; if (itypes.Contains((int)InvalidType.AllLocal)) { isAll = true; } DataSet ds = new DataSet(); if (itypes.Contains((int)InvalidType.AccountingAutoPays) || isAll) { ds.Tables.Add(AccountingAutoPays.RefreshCache()); } if (itypes.Contains((int)InvalidType.AutoCodes) || isAll) { ds.Tables.Add(AutoCodes.RefreshCache()); ds.Tables.Add(AutoCodeItems.RefreshCache()); ds.Tables.Add(AutoCodeConds.RefreshCache()); } if (itypes.Contains((int)InvalidType.Automation) || isAll) { ds.Tables.Add(Automations.RefreshCache()); } if (itypes.Contains((int)InvalidType.AutoNotes) || isAll) { ds.Tables.Add(AutoNotes.RefreshCache()); ds.Tables.Add(AutoNoteControls.RefreshCache()); } if (itypes.Contains((int)InvalidType.Carriers) || isAll) { ds.Tables.Add(Carriers.RefreshCache()); //run on startup, after telephone reformat, after list edit. } if (itypes.Contains((int)InvalidType.ClaimForms) || isAll) { ds.Tables.Add(ClaimFormItems.RefreshCache()); ds.Tables.Add(ClaimForms.RefreshCache()); } if (itypes.Contains((int)InvalidType.ClearHouses) || isAll) { ds.Tables.Add(Clearinghouses.RefreshCache()); //kh wants to add an EasyHideClearHouses to disable this } if (itypes.Contains((int)InvalidType.Computers) || isAll) { ds.Tables.Add(Computers.RefreshCache()); ds.Tables.Add(Printers.RefreshCache()); } if (itypes.Contains((int)InvalidType.Defs) || isAll) { ds.Tables.Add(Defs.RefreshCache()); } if (itypes.Contains((int)InvalidType.DentalSchools) || isAll) { ds.Tables.Add(SchoolClasses.RefreshCache()); ds.Tables.Add(SchoolCourses.RefreshCache()); } if (itypes.Contains((int)InvalidType.DictCustoms) || isAll) { ds.Tables.Add(DictCustoms.RefreshCache()); } if (itypes.Contains((int)InvalidType.Diseases) || isAll) { ds.Tables.Add(DiseaseDefs.RefreshCache()); ds.Tables.Add(ICD9s.RefreshCache()); } if (itypes.Contains((int)InvalidType.DisplayFields) || isAll) { ds.Tables.Add(DisplayFields.RefreshCache()); } if (itypes.Contains((int)InvalidType.ElectIDs) || isAll) { ds.Tables.Add(ElectIDs.RefreshCache()); } if (itypes.Contains((int)InvalidType.Email) || isAll) { ds.Tables.Add(EmailAddresses.RefreshCache()); ds.Tables.Add(EmailTemplates.RefreshCache()); } if (itypes.Contains((int)InvalidType.Employees) || isAll) { ds.Tables.Add(Employees.RefreshCache()); ds.Tables.Add(PayPeriods.RefreshCache()); } if (itypes.Contains((int)InvalidType.Employers) || isAll) { ds.Tables.Add(Employers.RefreshCache()); } if (itypes.Contains((int)InvalidType.Fees) || isAll) { ds.Tables.Add(Fees.RefreshCache()); } if (itypes.Contains((int)InvalidType.FeeScheds) || isAll) { ds.Tables.Add(FeeScheds.RefreshCache()); } if (itypes.Contains((int)InvalidType.HL7Defs) || isAll) { ds.Tables.Add(HL7Defs.RefreshCache()); ds.Tables.Add(HL7DefMessages.RefreshCache()); ds.Tables.Add(HL7DefSegments.RefreshCache()); ds.Tables.Add(HL7DefFields.RefreshCache()); } if (itypes.Contains((int)InvalidType.InsCats) || isAll) { ds.Tables.Add(CovCats.RefreshCache()); ds.Tables.Add(CovSpans.RefreshCache()); } if (itypes.Contains((int)InvalidType.InsFilingCodes) || isAll) { ds.Tables.Add(InsFilingCodes.RefreshCache()); ds.Tables.Add(InsFilingCodeSubtypes.RefreshCache()); } if (itypes.Contains((int)InvalidType.Languages) || isAll) { if (CultureInfo.CurrentCulture.Name != "en-US") { ds.Tables.Add(Lans.RefreshCache()); } } if (itypes.Contains((int)InvalidType.Letters) || isAll) { ds.Tables.Add(Letters.RefreshCache()); } if (itypes.Contains((int)InvalidType.LetterMerge) || isAll) { ds.Tables.Add(LetterMergeFields.RefreshCache()); ds.Tables.Add(LetterMerges.RefreshCache()); } if (itypes.Contains((int)InvalidType.Operatories) || isAll) { ds.Tables.Add(Operatories.RefreshCache()); } if (itypes.Contains((int)InvalidType.PatFields) || isAll) { ds.Tables.Add(PatFieldDefs.RefreshCache()); ds.Tables.Add(ApptFieldDefs.RefreshCache()); } if (itypes.Contains((int)InvalidType.Pharmacies) || isAll) { ds.Tables.Add(Pharmacies.RefreshCache()); } if (itypes.Contains((int)InvalidType.Prefs) || isAll) { ds.Tables.Add(Prefs.RefreshCache()); } if (itypes.Contains((int)InvalidType.ProcButtons) || isAll) { ds.Tables.Add(ProcButtons.RefreshCache()); ds.Tables.Add(ProcButtonItems.RefreshCache()); } if (itypes.Contains((int)InvalidType.ProcCodes) || isAll) { ds.Tables.Add(ProcedureCodes.RefreshCache()); ds.Tables.Add(ProcCodeNotes.RefreshCache()); } if (itypes.Contains((int)InvalidType.Programs) || isAll) { ds.Tables.Add(Programs.RefreshCache()); ds.Tables.Add(ProgramProperties.RefreshCache()); } if (itypes.Contains((int)InvalidType.ProviderIdents) || isAll) { ds.Tables.Add(ProviderIdents.RefreshCache()); } if (itypes.Contains((int)InvalidType.Providers) || isAll) { ds.Tables.Add(Providers.RefreshCache()); } if (itypes.Contains((int)InvalidType.QuickPaste) || isAll) { ds.Tables.Add(QuickPasteNotes.RefreshCache()); ds.Tables.Add(QuickPasteCats.RefreshCache()); } if (itypes.Contains((int)InvalidType.RecallTypes) || isAll) { ds.Tables.Add(RecallTypes.RefreshCache()); ds.Tables.Add(RecallTriggers.RefreshCache()); } if (itypes.Contains((int)InvalidType.ReplicationServers) || isAll) { ds.Tables.Add(ReplicationServers.RefreshCache()); } if (itypes.Contains((int)InvalidType.Security) || isAll) { ds.Tables.Add(Userods.RefreshCache()); ds.Tables.Add(UserGroups.RefreshCache()); } if (itypes.Contains((int)InvalidType.Sheets) || isAll) { ds.Tables.Add(SheetDefs.RefreshCache()); ds.Tables.Add(SheetFieldDefs.RefreshCache()); } if (itypes.Contains((int)InvalidType.Signals) || isAll) { ds.Tables.Add(SigElementDefs.RefreshCache()); ds.Tables.Add(SigButDefs.RefreshCache()); //includes SigButDefElements.Refresh() } if (itypes.Contains((int)InvalidType.Sites) || isAll) { ds.Tables.Add(Sites.RefreshCache()); } if (itypes.Contains((int)InvalidType.Sops) || isAll) { ds.Tables.Add(Sops.RefreshCache()); } //InvalidTypes.Tasks not handled here. if (itypes.Contains((int)InvalidType.TimeCardRules) || isAll) { ds.Tables.Add(TimeCardRules.RefreshCache()); } if (itypes.Contains((int)InvalidType.ToolBut) || isAll) { ds.Tables.Add(ToolButItems.RefreshCache()); } if (itypes.Contains((int)InvalidType.Vaccines) || isAll) { ds.Tables.Add(VaccineDefs.RefreshCache()); ds.Tables.Add(DrugManufacturers.RefreshCache()); ds.Tables.Add(DrugUnits.RefreshCache()); } if (itypes.Contains((int)InvalidType.Views) || isAll) { ds.Tables.Add(ApptViews.RefreshCache()); ds.Tables.Add(ApptViewItems.RefreshCache()); ds.Tables.Add(AppointmentRules.RefreshCache()); ds.Tables.Add(ProcApptColors.RefreshCache()); } if (itypes.Contains((int)InvalidType.Wiki) || isAll) { ds.Tables.Add(WikiListHeaderWidths.RefreshCache()); ds.Tables.Add(WikiPages.RefreshCache()); } if (itypes.Contains((int)InvalidType.ZipCodes) || isAll) { ds.Tables.Add(ZipCodes.RefreshCache()); } return(ds); }
///<summary><para>Surround with try catch. Safely renames list by creating new list, selecting existing list into new list, then deleting existing list.</para> ///<para>This code could be used to either copy or backup lists in the future. (With minor modifications).</para></summary> public static void Rename(string nameOriginal, string nameNew) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), nameOriginal, nameNew); return; } //Name should already have been validated and available. string command = "CREATE TABLE wikilist_" + POut.String(nameNew) + " AS SELECT * FROM wikilist_" + POut.String(nameOriginal); Db.NonQ(command); //Validate content before altering and deleting things DataTable tableNew = GetByName(nameNew); DataTable tableOld = GetByName(nameOriginal); if (tableNew.Rows.Count != tableOld.Rows.Count) { command = "DROP TABLE wikilist_" + POut.String(nameNew); Db.NonQ(command); throw new Exception("Error occurred renaming list. Mismatch found in row count. No changes made."); } if (tableNew.Columns.Count != tableOld.Columns.Count) { command = "DROP TABLE wikilist_" + POut.String(nameNew); Db.NonQ(command); throw new Exception("Error occurred renaming list. Mismatch found in column count. No changes made."); } for (int r1 = 0; r1 < tableNew.Rows.Count; r1++) { for (int r2 = 0; r2 < tableOld.Rows.Count; r2++) { if (tableNew.Rows[r1][0] != tableOld.Rows[r2][0]) { continue; //pk does not match } for (int c = 0; c < tableNew.Columns.Count; c++) //both lists have same number of columns { if (tableNew.Rows[r1][c] == tableOld.Rows[r2][c]) { continue; //contents match } throw new Exception("Error occurred renaming list. Mismatch Error found in row data. No changes made."); } //end columns } //end tableOld } //end tableNew //Alter table names---------------------------------------------------------------------------- string priKeyColNameOrig = POut.String(nameOriginal) + "Num"; if (!tableNew.Columns.Contains(priKeyColNameOrig)) //if new table doesn't contain a PK based on the old table name, make the first column the nameNew+"Num" PK column { priKeyColNameOrig = POut.String(tableNew.Columns[0].ColumnName); } if (DataConnection.DBtype == DatabaseType.MySql) { command = "ALTER TABLE wikilist_" + POut.String(nameNew) + " CHANGE " + priKeyColNameOrig + " " + POut.String(nameNew) + "Num bigint NOT NULL auto_increment PRIMARY KEY"; } else { command = "RENAME COLUMN wikilist_" + POut.String(nameNew) + "." + priKeyColNameOrig + " TO " + POut.String(nameNew) + "Num"; } Db.NonQ(command); command = "UPDATE wikilistheaderwidth SET ListName='" + POut.String(nameNew) + "' WHERE ListName='" + POut.String(nameOriginal) + "'"; Db.NonQ(command); command = $@"UPDATE wikilistheaderwidth SET ColName='{POut.String(nameNew)}Num' WHERE ListName='{POut.String(nameNew)}' AND ColName='{priKeyColNameOrig}'" ; Db.NonQ(command); //drop old table--------------------- command = "DROP TABLE wikilist_" + POut.String(nameOriginal); Db.NonQ(command); WikiListHeaderWidths.RefreshCache(); }