private void GenerateSchedule(string scheduleText) { string[] items = scheduleText.Split("~".ToCharArray()); if (items == null || items.Length < 4) { Debug.Log("Failed to generate schedule."); return; } int periodIndex = GetPeriod(items[0]); string grade = items[1]; string section = items[2]; string entry = items[3]; Schedule schedule = GetSchedule(section, grade); ScheduleObject target = GetTarget(section, typeof(StudentClass).ToString()); if (schedule == null) { Debug.Log("Failed to create schedule."); return; } SetSchedule(new SerializedObject(schedule), target, periodIndex, entry); }
private void GetEntries(string entryText, out Room room, out ScheduleObject title, out string subtitle) { string[] items = entryText.Split("/".ToCharArray()); subtitle = items[0].Replace("@empty", ""); room = GetRoom(items[1]); title = GetTarget(FilterOutMiddleInitial(items[2]), typeof(Teacher).ToString()); }
private void SetSchedule(SerializedObject schedule, ScheduleObject target, int index, string entryText) { SerializedProperty targetProperty = schedule.FindProperty("target"); SerializedProperty periodsProperty = schedule.FindProperty("m_periods"); targetProperty.objectReferenceValue = target; schedule.ApplyModifiedPropertiesWithoutUndo(); if (index < 0 || index >= periodsProperty.arraySize) { return; } SerializedProperty prop = periodsProperty.GetArrayElementAtIndex(index); SerializedProperty entriesProperty = prop.FindPropertyRelative("m_entries"); if (entriesProperty == null) { return; } string[] entryPerDay = entryText.Split("|".ToCharArray()); for (int i = 0; i < entriesProperty.arraySize; i++) { SerializedProperty entry = entriesProperty.GetArrayElementAtIndex(i); Room room; ScheduleObject title; string subtitle; GetEntries(entryPerDay[i], out room, out title, out subtitle); SetEntry(entry, room, title, subtitle); } }
public void Remove(ScheduleObject schedule) { try { CheckTransaction(); new ScheduleDataService(Transaction).Remove(schedule); if (IsOwner) { Transaction.Commit(); } } catch (Exception exception1) { if (IsOwner) { Transaction.Rollback(); } Exception innerException = exception1; throw new Exception(MethodBase.GetCurrentMethod().Name, innerException); } finally { if (IsOwner) { Connection.Close(); } } }
public bool Remove(ScheduleObject schedule) { SqlCommand cmd = null; try { ExecuteNonQuery(out cmd, false, "Schedule_DELETE", CreateParameter("@schedID", SqlDbType.UniqueIdentifier, schedule.SchedID, ParameterDirection.Input) ); return(true); } catch (Exception exception1) { Exception innerException = exception1; throw new Exception(MethodBase.GetCurrentMethod().Name, innerException); } finally { if (cmd != null) { cmd.Dispose(); } cmd = null; } }
private SubjectPosition ConstructSubject(Dictionary <string, object> KeyValueData) { object CausesOfLossObject; HashSet <SymbolicValue> CausesOfLoss = new HashSet <SymbolicValue>(); if (KeyValueData.TryGetValue("CausesOfLoss", out CausesOfLossObject)) { CausesOfLoss.UnionWith(ToHashSet(CausesOfLossObject.ToString())); } object ScheduleObject; HashSet <SymbolicValue> ScheduleSymbols = new HashSet <SymbolicValue>(); if (KeyValueData.TryGetValue("Schedule", out ScheduleObject)) { ScheduleSymbols.UnionWith(ToHashSet(ScheduleObject.ToString())); } Schedule _Schedule = new Schedule(ScheduleSymbols); object ExposureTypesObject; HashSet <SymbolicValue> ExposureTypes = new HashSet <SymbolicValue>(); if (KeyValueData.TryGetValue("ExposureTypes", out ExposureTypesObject)) { ExposureTypes.UnionWith(ToHashSet(ExposureTypesObject.ToString())); } bool Resolution = false; if (KeyValueData.ContainsKey("PerRisk")) { Resolution = bool.Parse((string)KeyValueData["PerRisk"]); } if ((CausesOfLoss.Count == 0) && (ScheduleSymbols.Count == 0) && (ExposureTypes.Count == 0)) { SubjectPosition CoverSubjectPosition = new SubjectPosition(); if (this.ContractSubject is Subject) { CoverSubjectPosition = new Subject(this.ContractSubject as Subject); ((Subject)CoverSubjectPosition).PerRisk = Resolution; } else if (this.ContractSubject is NetPosition) { CoverSubjectPosition = new NetPosition(this.ContractSubject as NetPosition); } else if (this.ContractSubject is SubjectPosition) { CoverSubjectPosition = new SubjectPosition(this.ContractSubject as SubjectPosition); } return(CoverSubjectPosition); } return(new Subject(UniversalSubject, _Schedule, CausesOfLoss, ExposureTypes, ResolvedSchedule, CoverageIdAttrMap, Resolution)); }
private void SetEntry(SerializedProperty entryProperty, Room room, ScheduleObject title, string subtitle) { SerializedProperty roomProperty = entryProperty.FindPropertyRelative("m_room"); SerializedProperty titleProperty = entryProperty.FindPropertyRelative("m_title"); SerializedProperty subtitleProperty = entryProperty.FindPropertyRelative("m_subtitle"); roomProperty.objectReferenceValue = room as Object; titleProperty.objectReferenceValue = title as Object; subtitleProperty.stringValue = subtitle; entryProperty.serializedObject.ApplyModifiedPropertiesWithoutUndo(); entryProperty.serializedObject.Update(); }
/// <summary> /// Get the available schedules from the Get().Schedules() command and return the schedules as a JSON object /// </summary> /// /// <param name="Settings"> /// A settings object passed on from the SchedulesReader /// </param> /// /// <returns> /// JSON schedules list /// </returns> public JObject ScheduleWriter(IConfiguration Settings) { // We will use Get to call Get.Schedules() Get = new Get(Settings); ScheduleString = Get.Schedules(); // Parse SchedulesString into a Json object SchedulesJson = JObject.Parse(ScheduleString); // Get a token of the Services property of the SchedulesJson SchedulesToken = SchedulesJson["Services"]; // Create the objects to format the JSON to be written RootObject = new JObject(); SchedulesObject = new JObject(); LastUpdatedObject = new JObject(); // There can be multiple lists of services, though there is usually only one foreach (var ServicesListToken in SchedulesToken) { // Get the list of schedules within a given service foreach (var ScheduleObject in ServicesListToken["Schedules"]) { // Build a schedule object Models.Schedules.ScheduleName = ScheduleObject["Name"].ToString(); if (ScheduleObject.ToString().Contains("AD-HOC Payments")) { Models.Schedules.ScheduleAdHoc = true; } else { Models.Schedules.ScheduleAdHoc = false; } Models.Schedules.ScheduleFrequency = ScheduleObject["Frequency"].ToString(); // We use a temp object to prepare the JObject. We could just add three entries to the Schedule object, but this ensures correct formatting JObject _TempObject = new JObject(); _TempObject.Add(nameof(Models.Schedules.ScheduleAdHoc), Models.Schedules.ScheduleAdHoc); _TempObject.Add(nameof(Models.Schedules.ScheduleFrequency), Models.Schedules.ScheduleFrequency); SchedulesObject.Add(Models.Schedules.ScheduleName, _TempObject); } } RootObject.Add("Schedules", SchedulesObject); RootObject.Add("LastUpdated", DateTime.Today.Date.ToString("yyyy-MM-dd")); Environment = Settings.GetSection("currentEnvironment")["Environment"].ToLower(); if (!Directory.Exists(Directory.GetCurrentDirectory() + @"\Includes")) { Directory.CreateDirectory(Directory.GetCurrentDirectory() + @"\Includes"); } File.WriteAllText(Directory.GetCurrentDirectory() + @"\Includes\" + Environment + "scheduleslist.json", RootObject.ToString()); return(RootObject); }
private void btnCancel_Click(object sender, EventArgs e) { try { ScheduleMember = _scheduleOriginal; this.Close(); } catch (System.Exception exception1) { System.Exception thisException = exception1; Management.ShowException(thisException); } }
void IEditableObject.EndEdit() { try { if (inTxn) { _loadedTask = this.Task; _loadedSchedule = this.Schedule; inTxn = false; } } catch (Exception exception1) { Exception innerException = exception1; throw new Exception(MethodBase.GetCurrentMethod().Name, innerException); } }
private Schedule GetSchedule(string section, string grade) { string[] result = AssetDatabase.FindAssets("\"" + section + " \"" + " t:" + typeof(Schedule).ToString()); if (result == null || result.Length == 0) { ScheduleObject studentClass = GetTarget(section, typeof(StudentClass).ToString()); if (studentClass == null) { Debug.Log("Failed to get " + section); return(null); } return(CreateNewSchedule(studentClass, grade)); } string assetPath = AssetDatabase.GUIDToAssetPath(result[0]); Schedule schedule = AssetDatabase.LoadAssetAtPath <Schedule>(assetPath); return(schedule); }
private ScheduleObject GetTarget(string target, string type) { // target = target.TrimEnd().TrimStart(); if (string.IsNullOrEmpty(target.TrimEnd().TrimStart())) { return(null); } string[] result = FindAssets(target, type); if (result == null || result.Length == 0) { target = target.TrimEnd().TrimStart(); result = FindAssets(target, type); Debug.Log("Attempting to search again."); } if (result == null || result.Length == 0) { Debug.Log("Cannot get schedule object for : " + target + " end of line."); return(null); } string assetPath = AssetDatabase.GUIDToAssetPath(result[0]); ScheduleObject scheduleObject = AssetDatabase.LoadAssetAtPath <ScheduleObject>(assetPath); if (scheduleObject == null) { // Debug.Log("Failed to get " + target + " with result of " + result.Length); Debug.Log("asset path ? " + assetPath); // scheduleObject = AssetDatabase.LoadAssetAtPath<ScheduleObject>(result[0]); // if(scheduleObject == null) // Debug.Log("Really failed hard."); } return(scheduleObject); }
private Schedule CreateNewSchedule(ScheduleObject target, string grade) { if (target == null) { Debug.Log("Failed to create new schedule because target is empty."); return(null); } string path = "Assets/Scriptable Objects/Schedules/" + grade + '/'; string name = target.name + " Schedule"; Schedule schedule = (scheduleTemplate != null ? ScriptableObject.Instantiate <Schedule>(scheduleTemplate) : ScriptableObject.CreateInstance <Schedule>()); if (!AssetDatabase.IsValidFolder(path)) { Directory.CreateDirectory(path); } AssetDatabase.CreateAsset(schedule, path + name + ".asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); return(schedule); }
public void Save(ScheduleObject schedule) { SqlCommand cmd = null; try { ExecuteNonQuery(out cmd, false, "Schedule_SAVE", CreateParameter("@schedID", SqlDbType.UniqueIdentifier, schedule.SchedID, ParameterDirection.InputOutput), CreateParameter("@Frequency", SqlDbType.Int, (int)schedule.Frequency), CreateParameter("@Monday", SqlDbType.Bit, schedule.Monday), CreateParameter("@Tuesday", SqlDbType.Bit, schedule.Tuesday), CreateParameter("@Wednesday", SqlDbType.Bit, schedule.Wednesday), CreateParameter("@Thursday", SqlDbType.Bit, schedule.Thursday), CreateParameter("@Friday", SqlDbType.Bit, schedule.Friday), CreateParameter("@Saterday", SqlDbType.Bit, schedule.Saterday), CreateParameter("@Sunday", SqlDbType.Bit, schedule.Sunday), CreateParameter("@Startdate", SqlDbType.VarChar, schedule.StartDate), CreateParameter("@Time", SqlDbType.VarChar, schedule.Time), CreateParameter("@LastSend", SqlDbType.VarChar, schedule.LastSend) ); schedule.SchedID = (Guid)cmd.Parameters["@schedID"].Value; } catch (Exception exception1) { Exception innerException = exception1; throw new Exception(MethodBase.GetCurrentMethod().Name, innerException); } finally { if (cmd != null) { cmd.Dispose(); } cmd = null; } }
private async void GetTransport() { DateTime TimeBus2, TimeBus7; DateTime TimeNow; TimeSpan TimeDif; ScheduleObject BusSchedule = new ScheduleObject(); Byte k, l, m, i; ColorRed.Color = Color.FromArgb(255, 255, 0, 0); ColorBlack.Color = Color.FromArgb(255, 255, 255, 255); ColorYellow.Color = Color.FromArgb(255, 200, 200, 0); ColorLilac.Color = Color.FromArgb(255, 0, 120, 137); // Fill a string with API Transport Data Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - Request Transport(2) Data..."); WebRequest T_wrGETURL = WebRequest.Create("https://timetable.search.ch/api/route.json?from=8573675&to=8506899&num=5&via=8573674"); WebResponse T_response = await T_wrGETURL.GetResponseAsync(); Stream T_dataStream = T_response.GetResponseStream(); StreamReader T_reader = new StreamReader(T_dataStream); string T_sResponse2 = T_reader.ReadToEnd(); Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - ...Data received"); Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - Request Transport(7) Data..."); // Fill a string with API Transport Data T_wrGETURL = WebRequest.Create("https://timetable.search.ch/api/route.json?from=8590942&to=8506899&num=5&via=8590969"); T_response = await T_wrGETURL.GetResponseAsync(); T_dataStream = T_response.GetResponseStream(); T_reader = new StreamReader(T_dataStream); string T_sResponse7 = T_reader.ReadToEnd(); Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - ...Data received"); // Parse JSON Data Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - Load Transport(2) Data Stream..."); TransportRootObject TransportObj2 = JsonConvert.DeserializeObject <TransportRootObject>(T_sResponse2); Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - ...OK"); Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - Load Transport(7) Data Stream..."); TransportRootObject TransportObj7 = JsonConvert.DeserializeObject <TransportRootObject>(T_sResponse7); Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - ...OK"); List <ScheduleObject> ScheduleBus = new List <ScheduleObject>(); k = 0; m = 0; for (l = 0; l <= 4; l++) { DateTime.TryParse(TransportObj2.connections[k].departure, out TimeBus2); DateTime.TryParse(TransportObj7.connections[m].departure, out TimeBus7); if (TimeBus2 <= TimeBus7) { ScheduleBus.Add(new ScheduleObject() { Number = TransportObj2.connections[k].legs[0].line, Time = TimeBus2 }); k++; } else { ScheduleBus.Add(new ScheduleObject() { Number = TransportObj7.connections[k].legs[0].line, Time = TimeBus7 }); m++; } Debug.WriteLine("Bus" + ScheduleBus[l].Number + " at " + ScheduleBus[l].Time); } TimeNow = DateTime.Now; TimeDif = ScheduleBus[0].Time - TimeNow; if (TimeDif.Minutes < 7) { TimeDif = ScheduleBus[0].Time - TimeNow; if (ScheduleBus[0].Number == "2") { Bus1_rect.Fill = ColorRed; } else if (ScheduleBus[0].Number == "7") { Bus1_rect.Fill = ColorLilac; } else { Bus1_rect.Fill = ColorYellow; } Bus1_num.Text = ScheduleBus[0].Number; Bus1_time.Text = ScheduleBus[0].Time.ToString("HH:mm"); Bus1_due.Text = "in " + TimeDif.Minutes.ToString() + "min"; i = 0; } else { Bus1_rect.Fill = ColorBlack; Bus1_num.Text = ""; Bus1_time.Text = ""; Bus1_due.Text = ""; i = 1; } TimeDif = ScheduleBus[1 - i].Time - TimeNow; if (ScheduleBus[1 - i].Number == "2") { Bus2_rect.Fill = ColorRed; } else if (ScheduleBus[1 - i].Number == "7") { Bus2_rect.Fill = ColorLilac; } else { Bus2_rect.Fill = ColorYellow; } Bus2_num.Text = ScheduleBus[1 - i].Number; Bus2_time.Text = ScheduleBus[1 - i].Time.ToString("HH:mm"); Bus2_due.Text = "in " + TimeDif.Minutes.ToString() + "min"; TimeDif = ScheduleBus[2 - i].Time - TimeNow; if (ScheduleBus[2 - i].Number == "2") { Bus3_rect.Fill = ColorRed; } else if (ScheduleBus[2 - i].Number == "7") { Bus3_rect.Fill = ColorLilac; } else { Bus3_rect.Fill = ColorYellow; } Bus3_num.Text = ScheduleBus[2 - i].Number; Bus3_time.Text = ScheduleBus[2 - i].Time.ToString("HH:mm"); Bus3_due.Text = "in " + TimeDif.Minutes.ToString() + "min"; TimeDif = ScheduleBus[3 - i].Time - TimeNow; if (ScheduleBus[3 - i].Number == "2") { Bus4_rect.Fill = ColorRed; } else if (ScheduleBus[3 - i].Number == "7") { Bus4_rect.Fill = ColorLilac; } else { Bus4_rect.Fill = ColorYellow; } Bus4_num.Text = ScheduleBus[3 - i].Number; Bus4_time.Text = ScheduleBus[3 - i].Time.ToString("HH:mm"); Bus4_due.Text = "in " + TimeDif.Minutes.ToString() + "min"; TimeDif = ScheduleBus[4 - i].Time - TimeNow; if (ScheduleBus[4 - i].Number == "2") { Bus5_rect.Fill = ColorRed; } else if (ScheduleBus[4 - i].Number == "7") { Bus5_rect.Fill = ColorLilac; } else { Bus5_rect.Fill = ColorYellow; } Bus5_num.Text = ScheduleBus[4 - i].Number; Bus5_time.Text = ScheduleBus[4 - i].Time.ToString("HH:mm"); Bus5_due.Text = "in " + TimeDif.Minutes.ToString() + "min"; Debug.WriteLine(DateTime.Now.ToString("HH:mm:ss.f") + " - Finished GetTransport()"); }
public Contract(Dictionary <string, object> IR, Dictionary <string, HashSet <long> > resolvedSchedule, Dictionary <long, RiskItemCharacteristicIDAttributes> CoverageIdAttrMap) { this.ResolvedSchedule = resolvedSchedule; this.CoverageIdAttrMap = CoverageIdAttrMap; // Construct universal subject position HashSet <long> AllRITEIds = new HashSet <long>(); if (resolvedSchedule != null) { AllRITEIds = resolvedSchedule.Aggregate(new HashSet <long>(), (a, b) => { a.UnionWith(b.Value); return(a); }); } HashSet <long> AllRiskItemIds = new HashSet <long>(); if (CoverageIdAttrMap != null) { AllRiskItemIds = new HashSet <long>(AllRITEIds.Where(x => CoverageIdAttrMap.ContainsKey(x)).Select(x => CoverageIdAttrMap[x].RITExposureId).Distinct()); } UniversalSubject = new UniversalSubjectPosition(AllRITEIds, AllRiskItemIds); // Declarations Declarations = (Dictionary <string, object>)IR["Declarations"]; // Claims Adjustment Settings if (!Declarations.ContainsKey("Claims Adjustment Options") || Declarations["Claims Adjustment Options"] == null) { _AreSublimitsNetOfDeductible = false; _AreDeductiblesAbsorbable = false; } else { if (!((Declarations["Claims Adjustment Options"] as Dictionary <string, object>).ContainsKey("Claims Adjustment Sublimits")) || (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Sublimits"] == null) { _AreSublimitsNetOfDeductible = false; } else { _AreSublimitsNetOfDeductible = (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Sublimits"].ToString().Equals("Net Of Deductible"); } if (!((Declarations["Claims Adjustment Options"] as Dictionary <string, object>).ContainsKey("Claims Adjustment Deductibles")) || (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Deductibles"] == null) { _AreDeductiblesAbsorbable = false; } else { _AreDeductiblesAbsorbable = (Declarations["Claims Adjustment Options"] as Dictionary <string, object>)["Claims Adjustment Deductibles"].ToString().Equals("Absorbable"); } } object NameObject; if (Declarations.TryGetValue("Name", out NameObject)) { this.Name = NameObject.ToString(); } object CausesOfLossObject; Declarations.TryGetValue("CausesOfLoss", out CausesOfLossObject); object ScheduleObject; Declarations.TryGetValue("Schedule", out ScheduleObject); object ExposureTypesObject; Declarations.TryGetValue("ExposureTypes", out ExposureTypesObject); object GrossPositionObject; Declarations.TryGetValue("GrossPosition", out GrossPositionObject); object CededPositionObject; Declarations.TryGetValue("CededPosition", out CededPositionObject); if (GrossPositionObject != null) { if (CededPositionObject != null) { this.ContractSubject = new NetPosition(ToHashSet(GrossPositionObject.ToString()), ToHashSet(CededPositionObject.ToString())); } else if (CausesOfLossObject != null) { this.ContractSubject = new SubjectPosition(ToHashSet(GrossPositionObject.ToString()), ToHashSet(CausesOfLossObject.ToString())); } else { this.ContractSubject = new SubjectPosition(ToHashSet(GrossPositionObject.ToString())); } } else if (CausesOfLossObject != null && ScheduleObject != null && ExposureTypesObject != null) { this.ContractSubject = new Subject( UniversalSubject, new Schedule(ToHashSet(ScheduleObject.ToString())), ToHashSet(CausesOfLossObject.ToString()), ToHashSet(ExposureTypesObject.ToString()), ResolvedSchedule, CoverageIdAttrMap); } // Covers object[] covers = (object[])IR["Covers"]; Covers = new List <ICover <Value, Value, Value> >(covers.Length); foreach (object cover in covers) { Dictionary <string, object> coverData = (Dictionary <string, object>)cover; Covers.Add(ConstructCover(coverData)); } // Sublimits object[] sublimits = (object[])IR["Sublimits"]; Sublimits = new List <ITerm <Value> >(sublimits.Length); foreach (object sublimit in sublimits) { Sublimits.Add(ConstructSublimit((Dictionary <string, object>)sublimit, AreSublimitsNetOfDeductible())); } // Deductibles object[] deductibles = (object[])IR["Deductibles"]; Deductibles = new List <ITerm <Value> >(deductibles.Length); foreach (object deductible in deductibles) { Deductibles.Add(ConstructDeductible((Dictionary <string, object>)deductible, AreDeductiblesAbsorbable())); } }