protected DateTime GetLastDateBatchSendTreatmentNotesAllReferrers() { SystemVariables systemVariables = SystemVariableDB.GetAll(); string strLastDate = systemVariables["LastDateBatchSendTreatmentNotesAllReferrers"].Value; if (strLastDate.Length == 0) { return(DateTime.MinValue); } // "12:46:48 05-12-2012" string[] parts = strLastDate.Split(' '); string[] timeParts = parts[0].Split(':'); string[] dateParts = parts[1].Split('-'); DateTime dateTime = new DateTime( Convert.ToInt32(dateParts[2]), Convert.ToInt32(dateParts[1]), Convert.ToInt32(dateParts[0]), Convert.ToInt32(timeParts[0]), Convert.ToInt32(timeParts[1]), Convert.ToInt32(timeParts[2]) ); return(dateTime); }
public static void UnsubscribeAll(int patientID, string DB) { SystemVariables sysVariables = SystemVariableDB.GetAll(DB); if (sysVariables["AddressType"].Value == "Contact") { Contact[] emails = ContactDB.GetByEntityID(-1, patientID, 27, false, DB); foreach (Contact email in emails) { ContactDB.UpdateIsBillingIsNonbilling(email.ContactID, email.IsBilling, false, DB); } } else if (sysVariables["AddressType"].Value == "ContactAus") { ContactAus[] emails = ContactAusDB.GetByEntityID(-1, patientID, 27, false, DB); foreach (ContactAus email in emails) { ContactAusDB.UpdateIsBillingIsNonbilling(email.ContactID, email.IsBilling, false, DB); } } else { throw new Exception("Unknown AddressType in config: " + sysVariables["AddressType"].Value); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (this.LoginUser != null) { int adminid = this.LoginUser.Admin_ID; TBLL.AdminBLL adminbll = new TBLL.AdminBLL(); TModel.TAdmin tadmin = new TModel.TAdmin(); tadmin = adminbll.GetAdmin(adminid); lit_Count.Text = tadmin.Admin_LogTimes.ToString(); lit_TrueName.Text = this.LoginUser.Admin_RealName; lit_User.Text = LoginUser.Admin_UID; lit_ClientIP.Text = SystemVariables.GetClientIP(); lit_ServerIP.Text = SystemVariables.GetServerIP(); lit_Directory.Text = Server.MapPath("/"); lit_ServerName.Text = SystemVariables.GetServerName(); lit_ServerOs.Text = SystemVariables.GetServerOs(); lit_ScriptEngin.Text = SystemVariables.GetSoftWare(); lit_CPU.Text = SystemVariables.GetNumberOfCPU(); lit_ClientOS.Text = SystemVariables.GetClientOS(); L_browser.Text = SystemVariables.GetClientBrowser(); } } }
public void ExecuteDNA(Bot bot) { BoolStack.Clear(); IntStack.Clear(); currentFlowState = FlowState.Clear; foreach (var basePair in bot.DNA) { switch (basePair.Type) { case BasePairType.Number: if (currentFlowState != FlowState.Clear) { IntStack.Push(basePair.Command); } break; case BasePairType.StarNumber: if (currentFlowState != FlowState.Clear) { IntStack.Push(bot.Memory[SystemVariables.NormaliseAddress(basePair.Command)]); } break; case BasePairType.Basic: if (currentFlowState != FlowState.Clear) { ExecuteBasicCommand(basePair.GetBasicCommand()); } break; case BasePairType.Store: if (currentFlowState == FlowState.Body) { ExecuteStoreCommand(bot, basePair.GetStoreCommand()); } break; case BasePairType.Flow: ExecuteFlowCommand(basePair.GetFlowCommand()); break; case BasePairType.Boolean: if (currentFlowState != FlowState.Clear) { ExecuteBooleanCommand(basePair.GetBooleanCommand()); } break; case BasePairType.Condition: if (currentFlowState != FlowState.Clear) { ExecuteConditionCommand(basePair.GetConditionCommand()); } break; } } }
public static SystemVariables GetActualSystemVariables() { SystemVariables variables = new SystemVariables(); variables.CLayer = (string)CADProxy.GetSystemVariable("CLayer"); return(variables); }
public void NormaliseAddressHandlesZero() { var testAddress = 0; var actualAddress = SystemVariables.NormaliseAddress(testAddress); Assert.Equal(testAddress, actualAddress); }
public void NormaliseAddressHandlesSecondLargestValue() { var testAddress = SystemVariables.MemoryLength - 1; var actualAddress = SystemVariables.NormaliseAddress(testAddress); Assert.Equal(testAddress, actualAddress); }
public void NormaliseAddressHandlesLargeAddress() { var testAddress = 1; var actualAddress = SystemVariables.NormaliseAddress(testAddress + SystemVariables.MemoryLength * 20); Assert.Equal(testAddress, actualAddress); }
public CpuUsageGremlin() { System = new SystemVariables { CoreCount = GetCpuCount(), CpuCount = GetCpuCount(), LogicalProcessorCount = GetTotalLogicalProcessorCount() }; }
/// <summary> /// Create a JSON file if it does not exist already. I have opted to use a JSON file instead /// of a DB because there isn't much data to store so I thought it would be more efficient to /// use a JSON file. /// </summary> /// <param name="args"></param> static void Main(string[] args) { Console.WriteLine("Starting setup..."); //If debug store a file in a seperate location, else store in another #if DEBUG string expectedFilePath = $"{Environment.CurrentDirectory.Split(new string[] { "InitialSetup" }, StringSplitOptions.None)[0]}SetupFiles\\PrintingApp.txt"; #else string expectedFilePath = $"{Environment.CurrentDirectory}\\SetupFiles\\PrintingApp.txt"; #endif //If file doesnt exist, create the file if (!File.Exists(expectedFilePath)) { Console.WriteLine("Setup file does not exist.."); SystemVariables systemVariables = new SystemVariables(); ComboBoxItem[] ink = new ComboBoxItem[] { new ComboBoxItem("1", 1), new ComboBoxItem("2", 2), new ComboBoxItem("3", 3), new ComboBoxItem("4", 4), new ComboBoxItem("5", 5), new ComboBoxItem("6", 6), new ComboBoxItem("7", 7), new ComboBoxItem("8", 8), new ComboBoxItem("None", 0) }; ComboBoxItem[] coating = new ComboBoxItem[] { new ComboBoxItem("None", 0), new ComboBoxItem("Gloss varnish", 1), new ComboBoxItem("Dull varnish", 1), new ComboBoxItem("Satin varnish", 1), new ComboBoxItem("Gloss AQ", 0), new ComboBoxItem("Satin AQ", 0), }; SideOptions sideOptions = new SideOptions(ink, coating); //Serialise object var json = JsonConvert.SerializeObject(new RootJsonObject(sideOptions, systemVariables)); //Create file and write data to file FileInfo file = new FileInfo(expectedFilePath); file.Directory.Create(); File.WriteAllText(file.FullName, json); Console.WriteLine("Setup file created..."); } Console.WriteLine("Finished setup..."); Console.WriteLine("Press any key to close..."); Console.ReadKey(); }
//NUD - Numeric Up Down (WinForms control) private void DisplayNudSystemVariables(object sender, EventArgs e) { try { SystemVariables variables = _systemVariablesManager.ReturnNudVariables(); _view.BindingLip = variables.BindingLip; _view.HeadTrim = variables.HeadTrim; _view.FootTrim = variables.FootTrim; } catch (Exception ex) { LogErrorToView(this, new ErrorEventArgs(ex.Message)); } }
public static SystemVariables GetAll(string DB = null) { string sql = "SELECT descr,value,editable_in_gui,viewable_in_gui FROM SystemVariable"; DataTable tbl = DBBase.ExecuteQuery(sql, DB).Tables[0]; SystemVariables systemVariables = new SystemVariables(); for (int i = 0; i < tbl.Rows.Count; i++) { SystemVariable var = Load(tbl.Rows[i]); systemVariables[var.Descr] = var; } return systemVariables; }
public override void Awake() { base.Awake(); Terminal = GetComponentInChildren <Terminal>(true); DataHolder = GetComponentInChildren <DataHolder>(true); CampaignManager = new CampaignManager(); DeviceCollection = new DeviceCollection(); ProgramCollection = new ProgramCollection(); SystemVariables = new SystemVariables(); Firewalls = new Dictionary <FirewallType, IFirewall>(); }
public static SystemVariables GetAll(string DB = null) { string sql = "SELECT descr,value,editable_in_gui,viewable_in_gui FROM SystemVariable"; DataTable tbl = DBBase.ExecuteQuery(sql, DB).Tables[0]; SystemVariables systemVariables = new SystemVariables(); for (int i = 0; i < tbl.Rows.Count; i++) { SystemVariable var = Load(tbl.Rows[i]); systemVariables[var.Descr] = var; } return(systemVariables); }
/// <summary> /// Open a config window to modify the system variables. /// </summary> public static void ConfigSystemVariables() { var configWindow = new ParameterizedConfigWindow("System Variables", SystemVariables.ParameterDefinitions, SystemVariables.Context) { Width = 800 }; if (!configWindow.ShowDialog(out var @params)) { return; } SystemVariables.Apply(@params); SaveSystemVariables(); }
public void SetVariable() { if (SystemVariables.IsIntVariableExisted(想要改的變數名字)) { var oriValue = SystemVariables.otherVariables_int[想要改的變數名字]; SystemVariables.AddIntVariable(想要改的變數名字, 想要改的值); Debug.Log(想要改的變數名字 + "已從" + oriValue + "改為" + 想要改的值); SystemVariables.AddIntVariable(想要改的變數名字, 想要改的值); } else { SystemVariables.AddIntVariable(想要改的變數名字, 想要改的值); Debug.Log(想要改的變數名字 + "已改為" + 想要改的值); } }
public string InitialMapName = "MapDemo";//初期にロードするマップ名 void Awake() { string DirectoryPath = SystemVariables.RootPath + "/Data"; //JsonIO.JsonImport<SystemScript>(DirectoryPath, "System.json"); 現在読み込むべきシステム変数がないためコメントアウト SystemVariables.CopiedFrom(this); JsonIO.TiledJsonConvert(); ///sprite読み込み/// string jsonPath = SystemVariables.RootPath + "/TiledData"; string jsonName = "MapDemo_Default"; string tsxPath = SystemVariables.RootPath + "/TiledData/tsx"; LoadSpriteList(jsonPath, jsonName, tsxPath); }//Awake時にシステム関係(アイテム情報やマップチップ情報など)をロードして,SystemVariable.Initialize(this)で適用する.
public string GetValue(params string[] args) { if (args.Length != 1) { return(SystemVariables.GetValue(Default)); } string dateTimeString = "yyyyMMddHHmmss"; for (int i = 0; i < Convert.ToInt32(args[0]); i++) { dateTimeString += "f"; } return(DateTime.Now.ToString(dateTimeString)); }
private void ExecuteStoreCommand(Bot bot, StoreCommand storeCommand) { int a, b; switch (storeCommand) { case StoreCommand.Store: b = SystemVariables.NormaliseAddress(IntStack.Pop()); a = IntStack.Pop(); if (SystemVariables.IsAddressWritable(b)) { bot.Memory[b] = a; } break; } }
private static IVariable GetSystemVariable(string variableName) { IVariable target = null; if (Enum.IsDefined(typeof(SystemVariables), variableName)) { SystemVariables targetType = (SystemVariables)Enum.Parse(typeof(SystemVariables), variableName); Type type = typeof(MemoryRegion).GetNestedType(variableName, System.Reflection.BindingFlags.NonPublic); target = (IVariable)Activator.CreateInstance(type); } else { // look up from plugin =) } return(target); }
/// <summary> /// Gets the value of the MODE system variable /// </summary> /// <param name="modeValue">Value of the system variable</param> /// <returns>True, if value obtained; otherwise, false</returns> private bool GetModeValue(out ushort?modeValue) { modeValue = null; if (SpectNetPackage.Default.MachineViewModel.VmState != VmState.Running) { return(false); } var memory = SpectrumVm.MemoryDevice.CloneMemory(); var mode = SystemVariables.Get("MODE")?.Address; if (mode == null) { return(false); } modeValue = memory[(ushort)mode]; return(true); }
void Awake() { current = this; }
/// <summary> /// Load system variables from file. /// </summary> public static void LoadSystemVariables() => SystemVariables.Deserialize(SystemVariableFilePath);
public static string Run(bool incDisplay, bool incSending, DateTime date) { date = date.Date; bool EnableDailyBookingReminderSMS = Convert.ToInt32(SystemVariableDB.GetByDescr("EnableDailyBookingReminderSMS").Value) == 1; bool EnableDailyBookingReminderEmails = Convert.ToInt32(SystemVariableDB.GetByDescr("EnableDailyBookingReminderEmails").Value) == 1; int NbrDaysAheadToSendDailyBookingReminderSMS = Convert.ToInt32(SystemVariableDB.GetByDescr("NbrDaysAheadToSendDailyBookingReminderSMS").Value); string SendDailyBookingReminderText_SMS = SystemVariableDB.GetByDescr("SendDailyBookingReminderText_SMS").Value; string SendDailyBookingReminderText_Email = SystemVariableDB.GetByDescr("SendDailyBookingReminderText_Email").Value; string SendDailyBookingReminderText_EmailSubject = SystemVariableDB.GetByDescr("SendDailyBookingReminderText_EmailSubject").Value; string PT_Reminders_HasBothSMSandEmail = SystemVariableDB.GetByDescr("PT_Reminders_HasBothSMSandEmail").Value; date = date.AddDays(NbrDaysAheadToSendDailyBookingReminderSMS - 1); Booking[] bookings = BookingDB.GetBetween(date, date.AddDays(1).AddMinutes(-1), null, null, null, null, false, "0", false, null); Hashtable patientContactPhoneNbrHash = GetPatientPhoneNbrCache(bookings); Hashtable patientContactEmailHash = GetPatientEmailCache(bookings); Hashtable orgContactHash = GetOrgPhoneNbrCache(bookings); Hashtable orgAddrContactHash = GetOrgAddrCache(bookings); decimal balance = SMSCreditDataDB.GetTotal() - SMSHistoryDataDB.GetTotal(); decimal cost = Convert.ToDecimal(SystemVariableDB.GetByDescr("SMSPrice").Value); string callerId = System.Configuration.ConfigurationManager.AppSettings["SMSTech_callerId"]; // not used here as the callerId will be the org name string countryCode = System.Configuration.ConfigurationManager.AppSettings["SMSTech_CountryCode"]; ArrayList messagesToSMS = new ArrayList(); ArrayList messagesToEmail = new ArrayList(); ArrayList bookingIDsConfirmedSMS = new ArrayList(); ArrayList bookingIDsConfirmedEmail = new ArrayList(); string output = "<table class=\"table table-bordered table-striped table-grid table-grid-top-bottum-padding-thick auto_width block_center\" border=\"1\" style=\"border-collapse:collapse;\">"; int countWithPatient = 0; foreach (Booking booking in bookings) { if (booking.BookingTypeID != 34) // only bookings, not days marked off { continue; } if (booking.Patient == null || booking.Offering == null) // prob aged care booking { continue; } // Marcus: send sms even if booking is confirmed //if (booking.ConfirmedBy != null) // don't send reminders to those already confirmed // continue; // get all info to send via sms or email string phoneNumPatient = GetPhoneNbr(patientContactPhoneNbrHash, booking.Patient.Person.EntityID, true); if (phoneNumPatient != null) { phoneNumPatient = phoneNumPatient.StartsWith("0") ? countryCode + phoneNumPatient.Substring(1) : phoneNumPatient; } string emailPatient = GetEmail(patientContactEmailHash, booking.Patient.Person.EntityID); string phoneNumOrg = GetPhoneNbrs(orgContactHash, booking.Organisation.EntityID); string addrOrg = GetAddr(orgAddrContactHash, booking.Organisation.EntityID); string smsText = GetSMSText(booking, phoneNumOrg, addrOrg, SendDailyBookingReminderText_SMS); string emailText = GetEmailText(booking, phoneNumOrg, addrOrg, SendDailyBookingReminderText_Email); string emailSubjectText = GetEmailSubjectText(booking, phoneNumOrg, addrOrg, SendDailyBookingReminderText_EmailSubject); // kept just to show their email/phone number exists even though we may not be sending to there due to settings or low balance. string phoneNumPatient_Original = phoneNumPatient; string emailPatient_Original = emailPatient; // ignore if setting is to not sending sms's or emails if (phoneNumPatient != null && !EnableDailyBookingReminderSMS) { phoneNumPatient = null; } if (emailPatient != null && !EnableDailyBookingReminderEmails) { emailPatient = null; } // if balance too low, can not send by SMS if (phoneNumPatient != null && balance < cost) { phoneNumPatient = null; } // if has both, then send based on setting if (phoneNumPatient != null && emailPatient != null) { if (PT_Reminders_HasBothSMSandEmail == "Email") // setting is - when both, send only via email { phoneNumPatient = null; } if (PT_Reminders_HasBothSMSandEmail == "SMS") // setting is - when both, send only via sms { emailPatient = null; } } string textToDisplay = string.Empty; if (phoneNumPatient != null) { textToDisplay += "<b>" + smsText.Replace(Environment.NewLine, "<br />") + "</b>"; } if (emailPatient != null) { textToDisplay += (textToDisplay.Length == 0 ? "" : "<br><hr>") + "<u>" + emailSubjectText + "</u><br /><br />" + emailText; } // display the info string tdTagStart = phoneNumPatient == null && emailPatient == null ? "<td class=\"nowrap\" style=\"color:grey;\">" : (phoneNumPatient == null ? "<td>" : "<td>"); string tdTagStartLeftAlign = phoneNumPatient == null && emailPatient == null ? "<td class=\"nowrap text_left\" style=\"color:grey;\">" : (phoneNumPatient == null ? "<td class=\"text_left\">" : "<td class=\"text_left\">"); string tdTagEnd = phoneNumPatient == null && emailPatient == null ? "</td>" : (phoneNumPatient == null ? "</td>" : "</td>"); output += "<tr>"; output += tdTagStart + booking.BookingID + tdTagEnd; output += tdTagStart + booking.DateStart.ToString("dd-MM-yy") + "<br />" + booking.DateStart.ToString("HH:mm") + " - " + booking.DateEnd.ToString("HH:mm") + tdTagEnd; output += tdTagStart + booking.Organisation.Name + "<br />" + (phoneNumOrg == null ? "-- No Phone --" : phoneNumOrg.Replace(",", "<br />").Replace("or", "<br />")) + tdTagEnd; output += tdTagStart + booking.Patient.Person.FullnameWithoutMiddlename + "<br />" + (phoneNumPatient_Original == null ? "-- No Mobile --" : "<u>" + phoneNumPatient_Original + "</u>") + "<br />" + (emailPatient_Original == null ? "-- No Email --" : "<u>" + emailPatient_Original + "</u>") + tdTagEnd; output += tdTagStartLeftAlign + textToDisplay + tdTagEnd; output += "</tr>"; countWithPatient++; /* * add to lists to sms or email (or both) */ if (phoneNumPatient != null) { messagesToSMS.Add(new Tuple <int, decimal, string, string, string>(booking.BookingID, cost, phoneNumPatient, smsText, booking.Organisation.Name)); bookingIDsConfirmedSMS.Add(booking.BookingID); if (incSending) { balance -= cost; } } if (emailPatient != null) { messagesToEmail.Add(new Tuple <int, string, string, string, string>(booking.BookingID, booking.Organisation.Name, emailPatient, emailText, emailSubjectText)); bookingIDsConfirmedEmail.Add(booking.BookingID); } /* * bool sendingAlready = false; * if (EnableDailyBookingReminderSMS && phoneNumPatient != null && balance >= cost) * { * messagesToSMS.Add(new Tuple<int, decimal, string, string, string>(booking.BookingID, cost, phoneNumPatient, smsText, booking.Organisation.Name)); * bookingIDsConfirmedSMS.Add(booking.BookingID); * sendingAlready = true; * if (incSending) * balance -= cost; * } * if (EnableDailyBookingReminderEmails && emailPatient != null) * { * messagesToEmail.Add(new Tuple<int, string, string, string, string>(booking.BookingID, booking.Organisation.Name, emailPatient, emailText, emailSubjectText)); * if (!sendingAlready) // if not already added for sms sending * bookingIDsConfirmedEmail.Add(booking.BookingID); * } */ } output += "</table>"; // run the sending and send off reminders -- but only if there was any bookings if (incSending && bookings.Length > 0) { /* * run the sendings */ SendSMSes((Tuple <int, decimal, string, string, string>[])messagesToSMS.ToArray(typeof(Tuple <int, decimal, string, string, string>))); SendEmails((Tuple <int, string, string, string, string>[])messagesToEmail.ToArray(typeof(Tuple <int, string, string, string, string>))); /* * if sms or email sent, set booking as confirmed */ BookingDB.UpdateSetConfirmed((int[])bookingIDsConfirmedSMS.ToArray(typeof(int)), 2, -1); BookingDB.UpdateSetConfirmed((int[])bookingIDsConfirmedEmail.ToArray(typeof(int)), 3, -1); /* * send balance warning */ SystemVariables systemVariables = SystemVariableDB.GetAll(); string warningEmail = systemVariables["SMSCreditNotificationEmailAddress"].Value; decimal warningThreshold = Convert.ToDecimal(systemVariables["SMSCreditLowBalance_Threshold"].Value); bool checkSMSCreditOutOfBalance = Convert.ToInt32(systemVariables["SMSCreditOutOfBalance_SendEmail"].Value) == 1; bool checkMSCreditLowBalance = Convert.ToInt32(systemVariables["SMSCreditLowBalance_SendEmail"].Value) == 1; if (warningEmail.Length > 0 && checkSMSCreditOutOfBalance && balance < cost) { SendEmail( warningEmail, "SMS Credit Used Up", "Please note that your SMS credit at mediclinic has been used up. To continue sending, please top up.<br /><br />Best regards,<br />Mediclinic"); } else if (warningEmail.Length > 0 && checkMSCreditLowBalance && balance <= warningThreshold) // dont send warning low balance if already sending out of credit email { SendEmail( warningEmail, "SMS Credit Warning - Don't Forget To Top-Up Before It Runs Out", "Hi! Just a friendly reminder that the SMS reminder threshold you set has been reached.<br /> To avoid missing SMS'es being sent, don't forget to top-up before the remainder runs out!<br /><br />Best regards,<br />Mediclinic"); } } if (incDisplay) { return("Count: <b>" + countWithPatient + "</b> [Sending Via SMS: <b>" + messagesToSMS.Count + "</b>] [Sending Via Email: <b>" + messagesToEmail.Count + "</b>] " + "<br /><br />" + output); } else { return(string.Empty); } }
/// <summary> /// Save system variables to file. /// </summary> public static void SaveSystemVariables() => SystemVariables.Serialize(SystemVariableFilePath);
public static void RestoreSystemVariables(SystemVariables variables) { CADProxy.SetSystemVariable("CLayer", variables.CLayer); }
public override IEnumerable <MemberResult> GetDefinedMembers(int index, AstMemberType memberType, bool isMemberAccess = false) { HashSet <MemberResult> members = new HashSet <MemberResult>(); HashSet <GeneroPackage> includedPackages = new HashSet <GeneroPackage>(); if (memberType.HasFlag(AstMemberType.SystemTypes) && !isMemberAccess) { // Built-in types members.AddRange(BuiltinTypes.Select(x => new MemberResult(Tokens.TokenKinds[x], GeneroMemberType.Keyword, this))); foreach (var package in Packages.Values.Where(x => _importedPackages[x.Name] && x.ContainsInstanceMembers && (this.LanguageVersion >= x.MinimumLanguageVersion && this.LanguageVersion <= x.MaximumLanguageVersion))) { members.Add(new MemberResult(package.Name, GeneroMemberType.Module, this)); includedPackages.Add(package); } } if (memberType.HasFlag(AstMemberType.Constants) && !isMemberAccess) { members.AddRange(SystemConstants.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Keyword, this))); members.AddRange(SystemMacros.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this))); } if (memberType.HasFlag(AstMemberType.Variables) && !isMemberAccess) { members.AddRange(SystemVariables.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Keyword, this))); } if (memberType.HasFlag(AstMemberType.Functions) && !isMemberAccess) { members.AddRange(SystemFunctions.Where(x => this.LanguageVersion >= x.Value.MinimumLanguageVersion && this.LanguageVersion <= x.Value.MaximumLanguageVersion) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Function, this))); foreach (var package in Packages.Values.Where(x => _importedPackages[x.Name] && x.ContainsStaticClasses && (this.LanguageVersion >= x.MinimumLanguageVersion && this.LanguageVersion <= x.MaximumLanguageVersion))) { if (!includedPackages.Contains(package)) { members.Add(new MemberResult(package.Name, GeneroMemberType.Module, this)); } } } // TODO: need to handle multiple results of the same name AstNode containingNode = GetContainingNode(_body, index); if (containingNode != null) { if (containingNode is IFunctionResult) { if (memberType.HasFlag(AstMemberType.Variables)) { members.AddRange((containingNode as IFunctionResult).Variables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))); foreach (var varList in (containingNode as IFunctionResult).LimitedScopeVariables) { foreach (var item in varList.Value) { if (item.Item2.IsInSpan(index)) { members.Add(new MemberResult(item.Item1.Name, item.Item1, GeneroMemberType.Instance, this)); break; } } } } if (memberType.HasFlag(AstMemberType.SystemTypes)) { members.AddRange((containingNode as IFunctionResult).Types.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this))); } if (memberType.HasFlag(AstMemberType.Constants)) { members.AddRange((containingNode as IFunctionResult).Constants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this))); } if (memberType.HasFlag(AstMemberType.Functions)) { foreach (var res in (containingNode as IFunctionResult).Variables /*.Where(x => x.Value.HasChildFunctions(this)) */.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))) { if (!members.Contains(res)) { members.Add(res); } } foreach (var varList in (containingNode as IFunctionResult).LimitedScopeVariables) { foreach (var item in varList.Value) { if (item.Item2.IsInSpan(index)) { members.Add(new MemberResult(item.Item1.Name, item.Item1, GeneroMemberType.Instance, this)); break; } } } } } if (_body is IModuleResult) { // check for module vars, types, and constants (and globals defined in this module) if (memberType.HasFlag(AstMemberType.Variables)) { members.AddRange((_body as IModuleResult).Variables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))); members.AddRange((_body as IModuleResult).GlobalVariables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))); } if (memberType.HasFlag(AstMemberType.UserDefinedTypes)) { members.AddRange((_body as IModuleResult).Types.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this))); members.AddRange((_body as IModuleResult).GlobalTypes.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this))); } if (memberType.HasFlag(AstMemberType.Constants)) { members.AddRange((_body as IModuleResult).Constants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this))); members.AddRange((_body as IModuleResult).GlobalConstants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this))); } if (memberType.HasFlag(AstMemberType.Dialogs)) { members.AddRange((_body as IModuleResult).Functions.Where(x => x.Value is DeclarativeDialogBlock) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Dialog, this))); members.AddRange((_body as IModuleResult).FglImports.Select(x => new MemberResult(x, GeneroMemberType.Module, this))); } if (memberType.HasFlag(AstMemberType.Reports)) { members.AddRange((_body as IModuleResult).Functions.Where(x => x.Value is ReportBlockNode) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Report, this))); } if (memberType.HasFlag(AstMemberType.Functions)) { members.AddRange((_body as IModuleResult).Functions .Where(x => !(x.Value is ReportBlockNode) && !(x.Value is DeclarativeDialogBlock)) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Method, this))); foreach (var res in (_body as IModuleResult).Variables /*.Where(x => x.Value.HasChildFunctions(this)) */.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))) { if (!members.Contains(res)) { members.Add(res); } } foreach (var res in (_body as IModuleResult).GlobalVariables /*.Where(x => x.Value.HasChildFunctions(this)) */.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))) { if (!members.Contains(res)) { members.Add(res); } } } // Tables and cursors are module specific, and cannot be accessed via fgl import if (memberType.HasFlag(AstMemberType.DeclaredCursors) || memberType.HasFlag(AstMemberType.PreparedCursors) || memberType.HasFlag(AstMemberType.Tables)) { if (memberType.HasFlag(AstMemberType.DeclaredCursors)) { members.AddRange((_body as IModuleResult).Cursors.Where(x => x.Value is DeclareStatement).Select(x => new MemberResult(x.Value.Name, x.Value, GeneroMemberType.Cursor, this))); } if (memberType.HasFlag(AstMemberType.PreparedCursors)) { members.AddRange((_body as IModuleResult).Cursors.Where(x => x.Value is PrepareStatement).Select(x => new MemberResult(x.Value.Name, x.Value, GeneroMemberType.Cursor, this))); } if (memberType.HasFlag(AstMemberType.Tables)) { members.AddRange((_body as IModuleResult).Tables.Select(x => new MemberResult(x.Value.Name, x.Value, GeneroMemberType.DbTable, this))); } } else { members.AddRange((_body as IModuleResult).FglImports.Select(x => new MemberResult(x, GeneroMemberType.Module, this))); } } } // TODO: this could probably be done more efficiently by having each GeneroAst load globals and functions into // dictionaries stored on the IGeneroProject, instead of in each project entry. // However, this does required more upkeep when changes occur. Will look into it... if (_projEntry != null && _projEntry is IGeneroProjectEntry) { IGeneroProjectEntry genProj = _projEntry as IGeneroProjectEntry; if (genProj.ParentProject != null && !genProj.FilePath.ToLower().EndsWith(".inc")) { foreach (var projEntry in genProj.ParentProject.ProjectEntries.Where(x => x.Value != genProj)) { if (projEntry.Value.Analysis != null && projEntry.Value.Analysis.Body != null) { projEntry.Value.Analysis.Body.SetNamespace(null); IModuleResult modRes = projEntry.Value.Analysis.Body as IModuleResult; if (modRes != null) { // check global types // TODO: need to add an option to enable/disable legacy linking (to not reference other modules' non-public members if (memberType.HasFlag(AstMemberType.Variables)) { members.AddRange(modRes.GlobalVariables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))); members.AddRange(modRes.Variables.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))); } if (memberType.HasFlag(AstMemberType.UserDefinedTypes)) { members.AddRange(modRes.GlobalTypes.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this))); members.AddRange(modRes.Types.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Class, this))); } if (memberType.HasFlag(AstMemberType.Constants)) { members.AddRange(modRes.GlobalConstants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this))); members.AddRange(modRes.Constants.Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Constant, this))); } if (memberType.HasFlag(AstMemberType.Dialogs)) { members.AddRange(modRes.Functions.Where(x => x.Value is DeclarativeDialogBlock) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Dialog, this))); } if (memberType.HasFlag(AstMemberType.Reports)) { members.AddRange(modRes.Functions.Where(x => x.Value is ReportBlockNode) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Report, this))); } if (memberType.HasFlag(AstMemberType.Functions)) { members.AddRange(modRes.Functions.Where(x => !(x.Value is ReportBlockNode) && !(x.Value is DeclarativeDialogBlock)) .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Method, this))); foreach (var res in modRes.GlobalVariables/*.Where(x => * { * return x.Value.HasChildFunctions(this); * })*/ .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))) { if (!members.Contains(res)) { members.Add(res); } } foreach (var res in modRes.Variables/*.Where(x => * { * return x.Value.HasChildFunctions(this); * })*/ .Select(x => new MemberResult(x.Key, x.Value, GeneroMemberType.Variable, this))) { if (!members.Contains(res)) { members.Add(res); } } } } } } } } if (memberType.HasFlag(AstMemberType.Functions)) { _includePublicFunctions = true; // allow for deferred adding of public functions } if (memberType.HasFlag(AstMemberType.Tables)) { _includeDatabaseTables = true; // allow for deferred adding of external database tables } members.AddRange(this.ProjectEntry.GetIncludedFiles().Where(x => x.Analysis != null).SelectMany(x => x.Analysis.GetDefinedMembers(1, memberType))); return(members); }
public static IAnalysisResult GetValueByIndex(string exprText, int index, Genero4glAst ast, out IGeneroProject definingProject, out IProjectEntry projectEntry, out bool isDeferredFunction, FunctionProviderSearchMode searchInFunctionProvider = FunctionProviderSearchMode.NoSearch, bool isFunctionCallOrDefinition = false, bool getTypes = true, bool getVariables = true, bool getConstants = true) { isDeferredFunction = false; definingProject = null; projectEntry = null; //_functionProvider = functionProvider; //_databaseProvider = databaseProvider; //_programFileProvider = programFileProvider; AstNode containingNode = null; if (ast != null) { containingNode = GetContainingNode(ast.Body, index); ast.Body.SetNamespace(null); } IAnalysisResult res = null; int tmpIndex = 0; int bracketDepth = 0; bool doSearch = false; bool resetStartIndex = false; int startIndex = 0, endIndex = 0; bool noEndIndexSet = false; if (exprText == null) { return(null); } while (tmpIndex < exprText.Length) { if (resetStartIndex) { startIndex = tmpIndex; resetStartIndex = false; if (startIndex + 1 > exprText.Length) { break; } } doSearch = false; switch (exprText[tmpIndex]) { case '.': { if (bracketDepth == 0) { endIndex = tmpIndex - 1; if (endIndex >= startIndex) { // we have our 'piece' doSearch = true; } if (exprText[startIndex] == '.') { startIndex++; } } tmpIndex++; } break; case '[': if (noEndIndexSet) { noEndIndexSet = false; } else { if (bracketDepth == 0) { endIndex = tmpIndex - 1; } } bracketDepth++; tmpIndex++; break; case ']': { bracketDepth--; if (bracketDepth == 0) { if (exprText.Length <= tmpIndex + 1 || exprText[tmpIndex + 1] != '[') { // we have our first 'piece' doSearch = true; } else { noEndIndexSet = true; } } tmpIndex++; } break; default: { if (bracketDepth == 0 && (tmpIndex + 1 == exprText.Length)) { endIndex = tmpIndex; doSearch = true; } tmpIndex++; } break; } if (!doSearch) { continue; } // we can do our search var dotPiece = exprText.Substring(startIndex, (endIndex - startIndex) + 1); if (dotPiece.Contains('(')) { // remove the params piece int remIndex = dotPiece.IndexOf('('); dotPiece = dotPiece.Substring(0, remIndex); } bool lookForFunctions = isFunctionCallOrDefinition && (endIndex + 1 == exprText.Length); resetStartIndex = true; if (res != null) { if (ast != null) { var gmi = new GetMemberInput { Name = dotPiece, AST = ast, IsFunction = lookForFunctions }; IAnalysisResult tempRes = res.GetMember(gmi); if (gmi.DefiningProject != null && definingProject != gmi.DefiningProject) { definingProject = gmi.DefiningProject; } if (gmi.ProjectEntry != null && projectEntry != gmi.ProjectEntry) { projectEntry = gmi.ProjectEntry; } res = tempRes; if (tempRes == null) { res = null; break; } } else { res = null; break; } } else { IFunctionResult funcRes; if (!lookForFunctions) { if (SystemVariables.TryGetValue(dotPiece, out res) || SystemConstants.TryGetValue(dotPiece, out res) || SystemMacros.TryGetValue(dotPiece, out res)) { continue; } } else { if (SystemFunctions.TryGetValue(dotPiece, out funcRes)) { res = funcRes; continue; } if (ast != null && ast._functionProvider != null && ast._functionProvider.Name.Equals(dotPiece, StringComparison.OrdinalIgnoreCase)) { res = ast._functionProvider; continue; } } if (containingNode != null && containingNode is IFunctionResult) { IFunctionResult func = containingNode as IFunctionResult; if ((getVariables && func.Variables.TryGetValue(dotPiece, out res))) { continue; } if (!lookForFunctions) { // Check for local vars, types, and constants if ((getTypes && func.Types.TryGetValue(dotPiece, out res)) || (getConstants && func.Constants.TryGetValue(dotPiece, out res))) { continue; } List <Tuple <IAnalysisResult, IndexSpan> > limitedScopeVars; if ((getVariables && func.LimitedScopeVariables.TryGetValue(dotPiece, out limitedScopeVars))) { foreach (var item in limitedScopeVars) { if (item.Item2.IsInSpan(index)) { res = item.Item1; break; } } if (res != null) { continue; } } } } if (ast != null && ast.Body is IModuleResult) { IModuleResult mod = ast.Body as IModuleResult; if (!lookForFunctions) { // check for module vars, types, and constants (and globals defined in this module) if ((getVariables && (mod.Variables.TryGetValue(dotPiece, out res) || mod.GlobalVariables.TryGetValue(dotPiece, out res))) || (getTypes && (mod.Types.TryGetValue(dotPiece, out res) || mod.GlobalTypes.TryGetValue(dotPiece, out res))) || (getConstants && (mod.Constants.TryGetValue(dotPiece, out res) || mod.GlobalConstants.TryGetValue(dotPiece, out res)))) { continue; } // check for cursors in this module if (mod.Cursors.TryGetValue(dotPiece, out res)) { continue; } } else { // check for module functions if (mod.Functions.TryGetValue(dotPiece, out funcRes)) { // check for any function info collected at the project entry level, and update the function's documentation with that. if (ast._projEntry != null && ast._projEntry is IGeneroProjectEntry) { var commentInfo = (ast._projEntry as IGeneroProjectEntry).GetFunctionInfo(funcRes.Name); if (commentInfo != null) { funcRes.SetCommentDocumentation(commentInfo); } } res = funcRes; continue; } } } // TODO: this could probably be done more efficiently by having each GeneroAst load globals and functions into // dictionaries stored on the IGeneroProject, instead of in each project entry. // However, this does required more upkeep when changes occur. Will look into it... if (ast != null && ast.ProjectEntry != null && ast.ProjectEntry is IGeneroProjectEntry) { IGeneroProjectEntry genProj = ast.ProjectEntry as IGeneroProjectEntry; if (genProj.ParentProject != null && !genProj.FilePath.ToLower().EndsWith(".inc")) { bool found = false; foreach (var projEntry in genProj.ParentProject.ProjectEntries.Where(x => x.Value != genProj)) { if (projEntry.Value.Analysis != null && projEntry.Value.Analysis.Body != null) { projEntry.Value.Analysis.Body.SetNamespace(null); IModuleResult modRes = projEntry.Value.Analysis.Body as IModuleResult; if (modRes != null) { if (!lookForFunctions) { // check global vars, types, and constants // TODO: need option to enable/disable legacy linking if ((getVariables && (modRes.Variables.TryGetValue(dotPiece, out res) || modRes.GlobalVariables.TryGetValue(dotPiece, out res))) || (getTypes && (modRes.Types.TryGetValue(dotPiece, out res) || modRes.GlobalTypes.TryGetValue(dotPiece, out res))) || (getConstants && (modRes.Constants.TryGetValue(dotPiece, out res) || modRes.GlobalConstants.TryGetValue(dotPiece, out res)))) { found = true; break; } // check for cursors in this module if (modRes.Cursors.TryGetValue(dotPiece, out res)) { found = true; break; } } else { // check project functions if (modRes.Functions.TryGetValue(dotPiece, out funcRes)) { if (funcRes.AccessModifier == AccessModifier.Public) { res = funcRes; found = true; break; } } } } } } if (found) { continue; } } } // check for classes GeneroPackage package; if (Packages.TryGetValue(dotPiece, out package)) { res = package; continue; } /* TODO: * Need to check for: * 1) Temp tables */ // Nothing found yet... // If our containing node is at the function or globals level, we need to go deeper if (containingNode != null && (containingNode is GlobalsNode || containingNode is FunctionBlockNode || containingNode is ReportBlockNode)) { containingNode = GetContainingNode(containingNode, index); } // check for record field if (containingNode != null && (containingNode is DefineNode || containingNode is TypeDefNode)) { containingNode = GetContainingNode(containingNode, index); if (containingNode != null && (containingNode is VariableDefinitionNode || containingNode is TypeDefinitionNode) && containingNode.Children.Count == 1 && containingNode.Children[containingNode.Children.Keys[0]] is TypeReference) { var typeRef = containingNode.Children[containingNode.Children.Keys[0]] as TypeReference; while (typeRef != null && typeRef.Children.Count == 1) { if (typeRef.Children[typeRef.Children.Keys[0]] is RecordDefinitionNode) { var recNode = typeRef.Children[typeRef.Children.Keys[0]] as RecordDefinitionNode; VariableDef recField; if (recNode.MemberDictionary.TryGetValue(exprText, out recField)) { res = recField; break; } else { recField = recNode.MemberDictionary.Where(x => x.Value.LocationIndex < index) .OrderByDescending(x => x.Value.LocationIndex) .Select(x => x.Value) .FirstOrDefault(); if (recField != null) { typeRef = recField.Type; } else { break; } } } else if (typeRef.Children[typeRef.Children.Keys[0]] is TypeReference) { typeRef = typeRef.Children[typeRef.Children.Keys[0]] as TypeReference; } else { break; } } } } // try an imported module if (ast != null && ast.Body is IModuleResult && ast.ProjectEntry != null && ast.ProjectEntry != null) { if ((ast.Body as IModuleResult).FglImports.Contains(dotPiece)) { // need to get the ast for the other project entry var refProjKVP = (ast.ProjectEntry as IGeneroProjectEntry).ParentProject.ReferencedProjects.Values.FirstOrDefault( x => { var fn = Path.GetFileNameWithoutExtension(x.Directory); return(fn?.Equals(dotPiece, StringComparison.OrdinalIgnoreCase) ?? false); }); if (refProjKVP is IAnalysisResult) { definingProject = refProjKVP; res = refProjKVP as IAnalysisResult; continue; } IAnalysisResult sysImportMod; // check the system imports if (SystemImportModules.TryGetValue(dotPiece, out sysImportMod)) { res = sysImportMod; continue; } } } if (!lookForFunctions) { // try include files var foundInclude = false; if (ast?.ProjectEntry != null) { foreach (var includeFile in ast.ProjectEntry.GetIncludedFiles()) { if (includeFile.Analysis?.Body is IModuleResult) { var mod = includeFile.Analysis.Body as IModuleResult; if ((getTypes && (mod.Types.TryGetValue(dotPiece, out res) || mod.GlobalTypes.TryGetValue(dotPiece, out res))) || (getConstants && (mod.Constants.TryGetValue(dotPiece, out res) || mod.GlobalConstants.TryGetValue(dotPiece, out res)))) { foundInclude = true; break; } } } } if (foundInclude) { continue; } if (ast?._databaseProvider != null) { res = ast._databaseProvider.GetTable(dotPiece); if (res != null) { continue; } } } // Only do a public function search if the dotPiece is the whole text we're searching for // I.e. no namespaces if (lookForFunctions && dotPiece == exprText) { if (searchInFunctionProvider == FunctionProviderSearchMode.Search) { if (res == null && ast?._functionProvider != null) { // check for the function name in the function provider var funcs = ast._functionProvider.GetFunction(dotPiece); if (funcs != null) { res = funcs.FirstOrDefault(); if (res != null) { continue; } } } } else if (searchInFunctionProvider == FunctionProviderSearchMode.Deferred) { isDeferredFunction = true; } } if (res == null) { break; } } } return(res); }
public RootJsonObject(SideOptions sideOptions, SystemVariables systemVariables) { SideOptions = sideOptions; SystemVariables = systemVariables; PageParameters = null; }
protected void DisplayInfo() { string curDbName = Session["DB"].ToString(); ddlDBs.Items.Clear(); ddlDBs.Items.Add(new ListItem("All Clients", "0")); ddlDBs2.Items.Clear(); ddlDBs2.Items.Add(new ListItem("All Clients", "0")); ArrayList dbNames = new ArrayList(); Hashtable dbHash = new Hashtable(); try { bool isSupportStaff3 = Session != null && Session["StaffID"] != null && Convert.ToInt32(Session["StaffID"]) == -4; List <Tuple <string, string> > list = new List <Tuple <string, string> >(); System.Data.DataTable tbl = DBBase.ExecuteQuery("EXEC sp_databases;", "master").Tables[0]; for (int i = 0; i < tbl.Rows.Count; i++) { string databaseName = tbl.Rows[i][0].ToString(); if (!Regex.IsMatch(databaseName, @"Mediclinic_\d{4}")) { continue; } //if (databaseName == "Mediclinic_0001") // continue; SystemVariables sysVariables = SystemVariableDB.GetAll(databaseName); dbNames.Add(sysVariables["Site"].Value); dbHash[sysVariables["Site"].Value] = databaseName; System.Text.StringBuilder output = new System.Text.StringBuilder(); Session["DB"] = databaseName; Session["SystemVariables"] = SystemVariableDB.GetAll(); string callCenterPrefix = ((SystemVariables)Session["SystemVariables"])["CallCenterPrefix"].Value; int loginsPastWeek_Total = UserLoginDB.GetCount(7); int loginsPastWeek_Staff = UserLoginDB.GetStaffCount(7); if (((SystemVariables)Session["SystemVariables"])["UseMediclinicCallCenter"].Value == "1") { Organisation[] orgs = OrganisationDB.GetAll(false, true, false, false, true, true); Site[] sites = SiteDB.GetAll(); int clinicSiteID = -1; int agedCareSiteID = -1; for (int j = 0; j < sites.Length; j++) { if (sites[j].SiteType.ID == 1) { clinicSiteID = sites[j].SiteID; } if (sites[j].SiteType.ID == 2) { agedCareSiteID = sites[j].SiteID; } } string showHideID1 = "heading_" + databaseName; string showHideLink1 = @"<a href=""javascript:void(0)"" onclick=""hide_show_all('" + showHideID1 + @"');return false;"">Show/Hide Clinics/Facs</a>"; string siteTitleLink = @"<span style=""display:inline-block;vertical-align:middle;max-width:300px;min-width:300px;overflow:hidden;text-overflow:ellipsis;""><a style=""white-space:nowrap;"" class=""call_centre_header"" title=""" + ((SystemVariables)Session["SystemVariables"])["Site"].Value + @""" href=""" + HttpContext.Current.Request.Url.AbsolutePath + "?db=" + databaseName + @""" onclick=""http_post('" + databaseName + @"','0','0',-1);return false;"">" + ((SystemVariables)Session["SystemVariables"])["Site"].Value + @"</a></span>"; //string siteTitleLink = @"<span style=""display:inline-block;min-width:250px;""><a class=""call_centre_header"" title=""" + ((SystemVariables)Session["SystemVariables"])["Site"].Value + @""" href=""" + HttpContext.Current.Request.Url.AbsolutePath + "?db=" + databaseName + @""" onclick=""http_post('" + databaseName + @"','0','0',-1);return false;"">" + ((SystemVariables)Session["SystemVariables"])["Site"].Value + @"</a></span>"; string callCentrePrefixText = @"<span style=""display:inline-block;min-width:160px;"">[Call Center Prefix: " + callCenterPrefix + "]</span>"; output.AppendLine("<tr>"); //output.AppendLine(" <td><u>" + ((SystemVariables)Session["SystemVariables"])["Site"].Value + "</u> [Call Center Prefix: " + callCenterPrefix + "] [" + Session["DB"] + "]</td>"); output.AppendLine(" <td>" + showHideLink1 + " " + (isSupportStaff3 ? @"<span style=""display:inline-block;min-width:55px;"">" + (loginsPastWeek_Staff == 0 && loginsPastWeek_Total == 0 ? "" : "[" + loginsPastWeek_Staff + "," + loginsPastWeek_Total + "]") + "</span>" + " " : "") + siteTitleLink + " " + callCentrePrefixText + " [" + Session["DB"] + "]</td>"); output.AppendLine("</tr>"); if (orgs.Length > 0) { for (int j = 0; j < orgs.Length; j++) { string showHideID = databaseName + "_" + orgs[j].OrganisationID; string contactInfo = GetContactInfo(orgs[j].EntityID, 60, showHideID); string titleLink = @"<a href=""" + HttpContext.Current.Request.Url.AbsolutePath + "?db=" + databaseName + @"&org=" + orgs[j].OrganisationID + @""" onclick=""http_post('" + databaseName + "','" + orgs[j].OrganisationID + @"','" + (orgs[j].IsClinic ? clinicSiteID : agedCareSiteID) + @"',-1);return false;"">" + orgs[j].Name + " " + (orgs[j].IsClinic ? @"(Clinic)" : "(Aged Care)") + @"</a>"; string showHideLink = @"<a href=""javascript:void(0)"" onclick=""hide_show('" + showHideID + @"');return false;"">Show/Hide Details</a>"; output.AppendLine(@"<tr id=""" + showHideID1 + j.ToString() + @""" style=""margin:0 0;display:none;"">"); output.AppendLine(@" <td style=""margin:0 0;"">"); output.AppendLine(@" <table><tr style=""vertical-align:top;""><td style=""width:500px;""><ul style=""margin:0 0;""><li>" + titleLink + @"</li></ul></td><td style=""min-width:10px;""></td><td>" + (contactInfo.Length > 0 ? showHideLink : "") + "</td></tr></table>"); if (contactInfo.Length > 0) { output.AppendLine(contactInfo); } output.AppendLine(@" </td>"); output.AppendLine(@"</tr>"); } } } list.Add(new Tuple <string, string>(((SystemVariables)Session["SystemVariables"])["Site"].Value, output.ToString())); Session.Remove("DB"); Session.Remove("SystemVariables"); } dbNames.Sort(); foreach (string siteName in dbNames) { ddlDBs.Items.Add(new ListItem("[" + dbHash[siteName] + "] " + siteName, dbHash[siteName].ToString())); ddlDBs2.Items.Add(new ListItem("[" + dbHash[siteName] + "] " + siteName, dbHash[siteName].ToString())); } list.Sort((a, b) => a.Item1.CompareTo(b.Item1)); System.Text.StringBuilder finalOutput = new System.Text.StringBuilder(); foreach (Tuple <string, string> item in list) { finalOutput.Append(item.Item2); } lblInfo1.Text = "<table>" + finalOutput.ToString() + "</table>"; } finally { Session["DB"] = curDbName; Session["SystemVariables"] = SystemVariableDB.GetAll(); } }
protected void Search(string phoneNumberIn = null, string surnameIn = null, string dob_day = null, string dob_month = null, string dob_year = null) { string phoneNumberSearch = phoneNumberIn == null ? "" : Regex.Replace(phoneNumberIn, "[^0-9]", ""); string surnameSearch = surnameIn == null ? "" : surnameIn.Trim(); if (phoneNumberSearch == "" && surnameSearch == "" && dob_day == "-1" && dob_month == "-1" && dob_year == "-1") { lblSearchResults.Text = "<font color=\"red\"><br />Please enter a phone number or surname or DOB to search</font>"; return; } string curDbName = Session["DB"].ToString(); ArrayList dbNames = new ArrayList(); Hashtable dbHash = new Hashtable(); string searchResults = string.Empty; try { List <Tuple <string, string> > list = new List <Tuple <string, string> >(); System.Data.DataTable tbl = DBBase.ExecuteQuery("EXEC sp_databases;", "master").Tables[0]; for (int i = 0; i < tbl.Rows.Count; i++) { string databaseName = tbl.Rows[i][0].ToString(); if (!Regex.IsMatch(databaseName, @"Mediclinic_\d{4}")) { continue; } SystemVariables sysVariables = SystemVariableDB.GetAll(databaseName); dbNames.Add(sysVariables["Site"].Value); dbHash[sysVariables["Site"].Value] = databaseName; StringBuilder output = new StringBuilder(); Session["DB"] = databaseName; Session["SystemVariables"] = SystemVariableDB.GetAll(); string callCenterPrefix = ((SystemVariables)Session["SystemVariables"])["CallCenterPrefix"].Value; string siteName = ((SystemVariables)Session["SystemVariables"])["Site"].Value; list.Add(new Tuple <string, string>(((SystemVariables)Session["SystemVariables"])["Site"].Value, output.ToString())); Site[] sites = SiteDB.GetAll(); int clinicSiteID = -1; int agedCareSiteID = -1; for (int j = 0; j < sites.Length; j++) { if (sites[j].SiteType.ID == 1) { clinicSiteID = sites[j].SiteID; } if (sites[j].SiteType.ID == 2) { agedCareSiteID = sites[j].SiteID; } } DataTable dt = PatientDB.GetDataTable(false, false, false, false, surnameSearch, true, "", false, "", "", phoneNumberSearch, "", "", false, Convert.ToInt32(dob_day), Convert.ToInt32(dob_month), Convert.ToInt32(dob_year)); if (dt.Rows.Count > 0) { int[] entityIDs = new int[dt.Rows.Count]; int[] patientIDs = new int[dt.Rows.Count]; for (int p = 0; p < dt.Rows.Count; p++) { entityIDs[p] = Convert.ToInt32(dt.Rows[p]["entity_id"]); patientIDs[p] = Convert.ToInt32(dt.Rows[p]["patient_id"]); } Hashtable bullkPhoneNumbers = PatientsContactCacheDB.GetBullkPhoneNumbers(entityIDs, -1); Hashtable ptOrgsHash = RegisterPatientDB.GetMostRecentOrganisationOf(patientIDs); for (int p = 0; p < dt.Rows.Count; p++) { string ptName = dt.Rows[p]["firstname"].ToString() + " " + dt.Rows[p]["surname"].ToString(); DateTime dob = dt.Rows[p]["dob"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(dt.Rows[p]["dob"]); int ptID = Convert.ToInt32(dt.Rows[p]["patient_id"]); int entityID = Convert.ToInt32(dt.Rows[p]["entity_id"]); Organisation org = ptOrgsHash[ptID] as Organisation; string phoneNbrs = string.Empty; if (bullkPhoneNumbers[entityID] != null) { if (Utilities.GetAddressType().ToString() == "Contact") { foreach (Contact c in ((Contact[])bullkPhoneNumbers[entityID])) { string phoneNumber = Regex.Replace(c.AddrLine1, "[^0-9]", ""); phoneNbrs += (phoneNbrs.Length == 0 ? string.Empty : "<br />") + Utilities.FormatPhoneNumber(phoneNumber).Replace(" ", "-"); } } else if (Utilities.GetAddressType().ToString() == "ContactAus") { foreach (ContactAus c in ((ContactAus[])bullkPhoneNumbers[entityID])) { string phoneNumber = Regex.Replace(c.AddrLine1, "[^0-9]", ""); if (phoneNumber.StartsWith(phoneNumberSearch)) { phoneNbrs += (phoneNbrs.Length == 0 ? string.Empty : "<br />") + Utilities.FormatPhoneNumber(phoneNumber).Replace(" ", "-"); } } } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } } string orgLink = org == null ? "" : @"<a href=""" + HttpContext.Current.Request.Url.AbsolutePath + "?db=" + databaseName + @"&org=" + org.OrganisationID + @"&patient=" + ptID + @""" onclick=""http_post('" + databaseName + "','" + org.OrganisationID + @"','" + (org.IsClinic ? clinicSiteID : agedCareSiteID) + @"'," + ptID + @");return false;"">" + org.Name + @"</a>"; string ptLink = @"<a href=""" + HttpContext.Current.Request.Url.AbsolutePath + "?db=" + databaseName + @"&org=0" + @"&patient=" + ptID + @""" onclick=""http_post('" + databaseName + "','" + "0" + @"','" + clinicSiteID + @"'," + ptID + @");return false;"">" + ptName + @"</a>"; output.AppendLine("<tr><td>" + siteName + "</td><td>" + ptLink + "</td><td>" + orgLink + "</td><td style=\"white-space:nowrap\">" + (dob == DateTime.MinValue ? "" : dob.ToString("d MMM, yyyy")) + "</td>" + (phoneNumberSearch == null ? "" : "<td>" + phoneNbrs + "</td>") + "</tr>"); } } list.Add(new Tuple <string, string>(((SystemVariables)Session["SystemVariables"])["Site"].Value, output.ToString())); Session.Remove("DB"); Session.Remove("SystemVariables"); } list.Sort((a, b) => a.Item1.CompareTo(b.Item1)); System.Text.StringBuilder finalOutput = new System.Text.StringBuilder(); foreach (Tuple <string, string> item in list) { finalOutput.Append(item.Item2); } if (finalOutput.Length == 0) { lblSearchResults.Text = "<font color=\"red\"><br />No patient found with the search parameters entered</font>"; } else { lblSearchResults.Text = @"<br /> <table class=""table table-bordered table-striped table-grid table-grid-top-bottum-padding-normal auto_width block_center""> <tr> <th>Site</th> <th>Patient</th> <th>Book</th> <th>D.O.B</th> " + (phoneNumberSearch == null ? "" : "<th>Phone Nbr</th>") + @" </tr> " + finalOutput.ToString() + "</table>"; } } finally { Session["DB"] = curDbName; Session["SystemVariables"] = SystemVariableDB.GetAll(); } }
private void FillEmptyAddForm() { Tuple <string, int> formParams = GetFormParams(false); Invoice invoice = InvoiceDB.GetByID(formParams.Item2, formParams.Item1); if (invoice == null) { HideTableAndSetErrorMessage("Invalid invoice ID"); return; } lblInvoiceNbr.Text = invoice.InvoiceID.ToString(); lblAmountOwing.Text = "$" + invoice.TotalDue.ToString(); DataTable dt = DBBase.GetGenericDataTable(formParams.Item1, "ReceiptPaymentType", "receipt_payment_type_id", "descr"); for (int i = dt.Rows.Count - 1; i >= 0; i--) { if (Convert.ToInt32(dt.Rows[i]["receipt_payment_type_id"]) != 133) { dt.Rows.RemoveAt(i); } } // add column for displaying data in first few rows with invoice id and invoice amount owing dt.Columns.Add("text"); dt.Columns.Add("tab_index"); for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["text"] = ""; } lstPayments.DataSource = dt; lstPayments.DataBind(); for (int i = lstPayments.Items.Count - 1; i >= 0; i--) { Label lblReceiptPaymentTypeID = (Label)lstPayments.Items[i].FindControl("lblTypeID"); TextBox txtReceiptPaymentTypeAmount = (TextBox)lstPayments.Items[i].FindControl("txtAmount"); Button btnWebPay = (Button)lstPayments.Items[i].FindControl("btnWebPay"); if (lblReceiptPaymentTypeID.Text != "133" && lblReceiptPaymentTypeID.Text != "362") { btnWebPay.Visible = false; } txtReceiptPaymentTypeAmount.Text = invoice.TotalDue.ToString(); SystemVariables sysVariables = SystemVariableDB.GetAll(formParams.Item1); if (sysVariables["EziDebit_Enabled"].Value != "1") { btnWebPay.Visible = false; } Utilities.SetEditControlBackColour(txtReceiptPaymentTypeAmount, true, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); } if (invoice.IsPaID) { maintable.Visible = false; SetErrorMessage("Invoice already paid"); } }