public void Add(RootModel model) { model.Flag = Constants.DbConstants.Add; DatabaseOperation(model); }
public TrayIcon(RootModel model) { this.model = model; model.PropertyChanged += UpdateTray; ContextMenuStrip trayMenu = new ContextMenuStrip(); ToolStripMenuItem vcItem = new ToolStripMenuItem("Définir le volume", null, delegate { OnVolumeControlClicked(EventArgs.Empty); }); vcItem.Font = new Font(vcItem.Font, vcItem.Font.Style | FontStyle.Bold); trayMenu.Items.Add(vcItem); muteItem = new ToolStripMenuItem("Tout mettre en sourdine", null, delegate { model.Muted = !model.Muted; }); UpdateMuteItemChecked(); trayMenu.Items.Add(muteItem); trayMenu.Items.Add(new ToolStripMenuItem("Basculer depuis/vers son local", null, delegate { foreach (SessionModel session in model.Sessions) { if (session.Valid && session.ShowInMixer && session.CanSwap) { session.Muted = !session.Muted; } } LocalSound.ToggleMute(); })); trayMenu.Items.Add(new ToolStripMenuItem("Réinitialiser", null, delegate { OnResetClicked(EventArgs.Empty); })); trayMenu.Items.Add(new ToolStripMenuItem("Paramètres", null, delegate { OnSettingsClicked(EventArgs.Empty); })); trayMenu.Items.Add(new ToolStripSeparator()); trayMenu.Items.Add(new ToolStripMenuItem("Arrêter EtherSound", null, delegate { if (MessageBox.Show("Voulez-vous vraiment arrêter EtherSound ?", "EtherSound", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { Application.ExitThread(); } })); SystemEvents.UserPreferenceChanged += delegate { UpdateTrayIconIcon(); model.UpdateIcon(); }; trayIcon = new NotifyIcon(); trayIcon.MouseClick += (sender, e) => { switch (e.Button) { case MouseButtons.Left: OnVolumeControlClicked(EventArgs.Empty); break; case MouseButtons.Middle: model.Muted = !model.Muted; break; } }; trayIcon.ContextMenuStrip = trayMenu; UpdateTrayIconIcon(); UpdateTrayIconText(); trayIcon.Visible = true; }
public void ProcessJSONFiles(string sDirt, string dDirt) { try { string[] files = Directory.GetFiles(sDirt); ProcessData processdata = new ProcessData(); foreach (string file in files) { Console.WriteLine("Processing " + Path.GetFileName(file)); string json = File.ReadAllText(file); RootModel jsondata = JsonConvert.DeserializeObject <RootModel>(json); int recordcount = jsondata.products.Count; int qtysum = 0; bool isValidRecordCount = true; bool isValidQuantityCount = true; bool isFileAlreadyProcess = false; List <ProductData> productdatas = new List <ProductData>(); TransmissionsummaryData transmissionsummaryData = new TransmissionsummaryData(); foreach (Product p in jsondata.products) { qtysum += p.qty; ProductData pd = new ProductData(); pd.sku = p.sku; pd.category = p.category; pd.description = p.description; pd.location = p.location; pd.price = p.price; pd.qty = p.qty; string[] s = p.category.Split(">"); pd.l3 = s[2]; productdatas.Add(pd); } transmissionsummaryData.id = jsondata.transmissionsummary.id; transmissionsummaryData.recordcount = jsondata.transmissionsummary.recordcount; transmissionsummaryData.qtysum = jsondata.transmissionsummary.qtysum; if (recordcount != jsondata.transmissionsummary.recordcount) { isValidRecordCount = false; } if (qtysum != jsondata.transmissionsummary.qtysum) { isValidQuantityCount = false; } //Validate recordcount and qtysum against transmissionsummary if ((isValidRecordCount) && (isValidQuantityCount)) { //Check if the file has been processed before //Check if the TransmissionSummaryID Already exit in the database isFileAlreadyProcess = processdata.CheckTransmissionsummaryDataExist(jsondata.transmissionsummary.id); if (!isFileAlreadyProcess) { //Update Database with the data processdata.InsertData(productdatas, transmissionsummaryData); Console.WriteLine("Completed " + Path.GetFileName(file)); } else { Console.WriteLine("Skipped " + Path.GetFileName(file)); } } else { if (!isValidQuantityCount) { Console.WriteLine("Discarding " + Path.GetFileName(file) + ", incorrect qtysum"); } if (!isValidRecordCount) { Console.WriteLine("Discarding " + Path.GetFileName(file) + ", incorrect recordcount"); } } //Read & Print Product Details from the database //Print out aggregate of L3 categories and total qty stock per store if (!isFileAlreadyProcess) { List <StatisticData> statisticDatas = new List <StatisticData>(); statisticDatas = processdata.DisplayStatistics(); var result = statisticDatas.GroupBy(x => new { x.location, x.l3 }) .Select(x => new { l3 = x.Key.l3, location = x.Key.location, total = x.Sum(y => y.total) }); List <StatisticData> s2 = new List <StatisticData>(); foreach (var r in result) { s2.Add(new StatisticData { l3 = r.l3, location = r.location, total = r.total }); } foreach (StatisticData sd1 in statisticDatas) { foreach (StatisticData r in s2) { if (r.location == sd1.location && r.l3 == sd1.l3) { sd1.total = r.total; } } Console.WriteLine(sd1.l3 + " - " + sd1.location + " - " + sd1.total); } } //Move the File to different folder string destFile = System.IO.Path.Combine(dDirt, Path.GetFileName(file)); System.IO.File.Move(file, destFile, true); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public async Task <ActionResult> Index() { RootModel rootModel = new RootModel("tickets"); return(await Task.Run(() => View(rootModel))); }
public void Test_Reading_AdjacentListsWithCrossJoin() { RootModel model = new RootModel() { ComplexList = new List <RootModel.SubModel>() { new RootModel.SubModel() { Value = 1 }, new RootModel.SubModel() { Value = 2 }, new RootModel.SubModel() { Value = 3 }, }, ComplexList2 = new List <RootModel.SubModel>() { new RootModel.SubModel() { Value = 4 }, new RootModel.SubModel() { Value = 5 }, new RootModel.SubModel() { Value = 6 }, new RootModel.SubModel() { Value = 7 }, } }; Relation rel1 = DatabaseHelper.Default.Relation(model, "ComplexList.Item.Value", "ComplexList2.Item.Value"); Relation rel2 = DatabaseHelper.Default.Relation(model, "ComplexList2.Item.Value", "ComplexList.Item.Value"); IList <(int, int)> pairs1 = rel1.Select(t => ((int)t[0].Value, (int)t[1].Value)).ToList(); IList <(int, int)> pairs2 = rel2.Select(t => ((int)t[0].Value, (int)t[1].Value)).ToList(); pairs1.Count.ShouldBe(3 * 4); pairs2.Count.ShouldBe(4 * 3); pairs1[0].ShouldBe((1, 4)); pairs1[1].ShouldBe((1, 5)); pairs1[2].ShouldBe((1, 6)); pairs1[3].ShouldBe((1, 7)); pairs1[4].ShouldBe((2, 4)); pairs1[5].ShouldBe((2, 5)); pairs1[6].ShouldBe((2, 6)); pairs1[7].ShouldBe((2, 7)); pairs1[8].ShouldBe((3, 4)); pairs1[9].ShouldBe((3, 5)); pairs1[10].ShouldBe((3, 6)); pairs1[11].ShouldBe((3, 7)); pairs2[0].ShouldBe((4, 1)); pairs2[1].ShouldBe((4, 2)); pairs2[2].ShouldBe((4, 3)); pairs2[3].ShouldBe((5, 1)); pairs2[4].ShouldBe((5, 2)); pairs2[5].ShouldBe((5, 3)); pairs2[6].ShouldBe((6, 1)); pairs2[7].ShouldBe((6, 2)); pairs2[8].ShouldBe((6, 3)); pairs2[9].ShouldBe((7, 1)); pairs2[10].ShouldBe((7, 2)); pairs2[11].ShouldBe((7, 3)); }
public ActionResult Index(string Did = null, string Eid = null) { ViewBag.Edit = new bool(); var Employees = new RootModel(); var jsonFile = new StreamReader(Server.MapPath("~/Models/DataBase.json")); //SAVE DataBase.json in ISS var jsonString = jsonFile.ReadToEnd(); Employees = JsonConvert.DeserializeObject <RootModel>(jsonString); jsonFile.Close(); //EMPLOYEE VIEWMODEL var curEmp = new Employee(); if (Did != null || Eid != null) { foreach (var department in Employees.Database.Departments) { // if (department.Employees == null) // { // continue; // } if (department.Did == Did) { foreach (var employee in department.Employees) { if (employee.Eid == Eid) { curEmp = employee; curEmp.Did = Did; } } } } } else { curEmp = null; } var viewModel = new EmployeeViewModel { Employee = curEmp }; if (curEmp == null) { viewModel.IsEdit = false; } else { viewModel.IsEdit = true; } //DEPARTMENT LIST VIEWBAG var departmentList = new Dictionary <string, string>(); foreach (var department in Employees.Database.Departments) { departmentList.Add(department.Did, department.Name); } ViewBag.DepartmentList = departmentList; return(View(viewModel)); }
public TaxonomyChange(Taxonomy taxonomy, RootModel model) { this.Taxonomy = taxonomy; this.Model = model; }
private async Task Create() { model = await new RootModelFactoryTest().ConstructedModel(); sut = new RootViewModel(model); }
/// <summary> /// Получить модели, соответствующие заданному обработчику. /// </summary> /// <param name = "rootModel" > Модель.</param> /// <returns>Модели записей.</returns> protected override List <RecordRefModel> GetComponentModelList(RootModel rootModel) { return(rootModel.Records.FindAll(x => !x.ReferenceName.Equals(WizardsGroupReferenceName))); }
public string WriteGraph(RootModel model, string file = null) { var regionNodes = new Node("record", "filled", "yellow"); var envNodes = new Node("doublecircle", "filled", "lightblue"); var zoneNodes = new Node("doublecircle", "filled", "lightgreen"); var edgesTo = new Edge("bold", null, null); //var edgesFrom = new Edge("bold", null, null); var edgesBoth = new Edge("bold", null, "both"); foreach (var region in model.Regions) { regionNodes.Elements.Add(region.Id); foreach (var env in region.Environments) { envNodes.Elements.Add(env.Id); edgesTo.Connections.Add(new Connection(region.Id, env.Id, "")); foreach (var zone in env.Zones) { edgesTo.Connections.Add(new Connection(env.Id, zone.Id, "")); zoneNodes.Elements.Add(zone.Id); } foreach (var rule in env.Rules) { if (rule.IsBidirectional) { edgesBoth.Connections.Add(new Connection(rule.From, rule.To, rule.Description)); //need a bidirectional edge } else { edgesTo.Connections.Add(new Connection(rule.From, rule.To, rule.Description)); } } } } var graphBuilder = new GraphBuilder(); var nodes = new List <Node> { regionNodes, envNodes, zoneNodes }; var edges = new List <Edge> { edgesTo, edgesBoth }; var dotGraph = graphBuilder.Build(nodes, edges, model.ZoneGroup); if (!string.IsNullOrWhiteSpace(file)) { File.WriteAllText(file, dotGraph); } return(dotGraph); }
/// <summary> /// Executes this action. /// </summary> /// <param name="model">The model.</param> /// <param name="context">The context.</param> public override void Execute(RootModel model, ActionExecutionContext context) { Assert.ArgumentNotNull(model, "model"); Assert.ArgumentNotNull(context, "context"); var firstVal = LeftConditionParameter.GetParameterValue(model, context); var secondVal = RightConditionParameter.GetParameterValue(model, context); double firstValDouble; double secondValDouble; bool isFirstValDouble = double.TryParse(firstVal, NumberStyles.Any, CultureInfo.InvariantCulture, out firstValDouble); bool isSecondValDouble = double.TryParse(secondVal, NumberStyles.Any, CultureInfo.InvariantCulture, out secondValDouble); bool isSuccess = false; if (isFirstValDouble && isSecondValDouble) { switch (Condition) { case ActionCondition.Equals: isSuccess = firstValDouble == secondValDouble; break; case ActionCondition.Greater: isSuccess = firstValDouble > secondValDouble; break; case ActionCondition.GreaterOrEquals: isSuccess = firstValDouble >= secondValDouble; break; case ActionCondition.Less: isSuccess = firstValDouble < secondValDouble; break; case ActionCondition.LessOrEquals: isSuccess = firstValDouble <= secondValDouble; break; case ActionCondition.NotEquals: isSuccess = firstValDouble != secondValDouble; break; } } else { switch (Condition) { case ActionCondition.Equals: isSuccess = firstVal == secondVal; break; case ActionCondition.NotEquals: isSuccess = firstVal != secondVal; break; case ActionCondition.IsEmpty: isSuccess = string.IsNullOrEmpty(firstVal); break; case ActionCondition.IsNotEmpty: isSuccess = !string.IsNullOrEmpty(firstVal); break; } } if (isSuccess) { foreach (var action in ActionsToExecute) { action.Execute(model, context); } } }
public void AddNode(RootModel parent, ChartModel child) { child.ContextMenuStrip = chartNodeMenu; parent.Nodes.Add(child); }
/// <summary> /// /// </summary> /// <param name="rootModel"></param> public void OutputWindowCreated([NotNull] RootModel rootModel) { Assert.ArgumentNotNull(rootModel, "rootModel"); _monsterHolders.Add(rootModel.Uid, new MonsterHolder(this, rootModel)); }
public void Delete(RootModel model) { model.Flag = Constants.DbConstants.Delete; DatabaseOperation(model); }
public ActionResult UseApplicationPermissions(RootModel rootModel) { HomeController.useAppPermissions = true; rootModel.UseAppPermissions = true; return(DefaultView(rootModel)); }
/// <summary> /// /// </summary> /// <param name="rootModel"></param> public virtual void OnClosedOutputWindow(RootModel rootModel) { }
private void ImportProfile(object obj) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.DefaultExt = ".set"; fileDialog.Filter = "Config|*.set|All Files|*.*"; fileDialog.Multiselect = false; var result = fileDialog.ShowDialog(); if (result.HasValue && result.Value) { if (!File.Exists(fileDialog.FileName)) { return; } RootModel rootModel = new RootModel(Profile); var conveyor = ConveyorFactory.CreateNew(rootModel); try { using (var stream = new StreamReader(fileDialog.FileName, Encoding.Default, false, 1024)) { string line; while ((line = stream.ReadLine()) != null) { //XML не читает символ \x01B //TODO: Need FIX IT if (!line.Contains("\x001B")) { //rootModel.PushCommandToConveyor(new TextCommand(line)).ImportJMC(line, rootModel); conveyor.ImportJMC(line, rootModel); } } } } catch { } _groupsViewModel = new GroupsViewModel(Profile.Groups, Profile.Name, RootModel.AllActionDescriptions); var profile = SettingsHolder.Instance.GetProfile(Profile.Name); foreach (var newVar in Profile.Variables) { var v = profile.Variables.FirstOrDefault(var => var.Name == newVar.Name); if (v != null) { v.Value = newVar.Value; } else { profile.Variables.Add(new Variable() { Name = newVar.Name, Value = newVar.Value }); } } OnPropertyChanged("AliasesCount"); OnPropertyChanged("GroupsCount"); OnPropertyChanged("HighlightsCount"); OnPropertyChanged("HotkeysCount"); OnPropertyChanged("SubstitutionsCount"); OnPropertyChanged("TriggersCount"); } }
/// <summary> /// Executes this action. /// </summary> /// <param name="model">The model.</param> /// <param name="context">The context.</param> public override void Execute(RootModel model, ActionExecutionContext context) { model.PushCommandToConveyor(new SendToWindowCommand(OutputWindowName, ActionsToExecute, SendToAllWindows, context)); }
public ActionResult Create(EmployeeViewModel viewModel) { var Employees = new RootModel(); var jsonFile = new StreamReader(Server.MapPath("~/Models/DataBase.json")); //SAVE DataBase.json in ISS var jsonString = jsonFile.ReadToEnd(); Employees = JsonConvert.DeserializeObject <RootModel>(jsonString); jsonFile.Close(); //var newEmp = new Employee(); //newEmp = viewModel.Employee; var flag = 0; if (viewModel.IsEdit == true) { foreach (var department in Employees.Database.Departments.ToArray()) { // if (department.Employees == null) // { // continue; // } foreach (var employee in department.Employees.ToArray()) { if (employee.Eid == viewModel.Employee.Eid && department.Did == viewModel.Employee.Did) { employee.Name = viewModel.Employee.Name; employee.Salary = viewModel.Employee.Salary; jsonString = JsonConvert.SerializeObject(Employees); System.IO.File.WriteAllText(Server.MapPath("~/Models/DataBase.json"), jsonString); return(RedirectToAction("Index", "Home")); } if (employee.Eid == viewModel.Employee.Eid && employee.Did != viewModel.Employee.Did) { department.Employees.Remove(employee); flag = -1; break; } } } TempData["shortMessage"] = null; } if (flag != 1) { foreach (var department in Employees.Database.Departments.ToArray()) { // if (department.Employees == null) // { // continue; // } foreach (var employee in department.Employees.ToArray()) { if (employee.Eid == viewModel.Employee.Eid) { TempData["shortMessage"] = "Employee ID Already Exist"; return(RedirectToAction("Index", "Home")); } else { TempData["shortMessage"] = null; } } } Employees.Database.Departments[int.Parse(viewModel.Employee.Did) - 1].Employees.Add(viewModel.Employee); } jsonString = JsonConvert.SerializeObject(Employees); System.IO.File.WriteAllText(Server.MapPath("~/Models/DataBase.json"), jsonString); return(RedirectToAction("Index", "Home")); }
/// <summary> /// Handles the change of main output window. /// </summary> /// <param name="rootModel">The root model of new output window.</param> public void OutputWindowChanged(RootModel rootModel) { CancelRouteRecording(); StopRoutingToDestination(); _rootModel = rootModel; }
public OutputWindowViewModel(RootModel rootModel) { RootModel = rootModel; }
/// <summary> /// /// </summary> /// <param name="rootModel"></param> public override void OnCreatedOutputWindow(RootModel rootModel) { _monstersManager.OutputWindowCreated(rootModel); }
public void takeTree() { tree = chartTree.RootNode; }
/// <summary> /// /// </summary> /// <param name="rootModel"></param> public override void OnClosedOutputWindow(RootModel rootModel) { _monstersManager.OutputWindowClosed(rootModel.Uid); }
public FrmAddEditRoot(RootModel model) { InitializeComponent(); _model = model; }
private ViewResult DefaultView(RootModel rootModel) => View("Graph", rootModel);
/// <summary> /// データの保存 /// </summary> /// <param name="model"></param> public static void Save(RootModel model, string filepath) { File.WriteAllText(filepath, JsonConvert.SerializeObject(model, Formatting.Indented)); }
public ActionResult UseUserDelegatedPermissions(RootModel rootModel) { HomeController.useAppPermissions = false; rootModel.UseAppPermissions = false; return(DefaultView(rootModel)); }
void RemoveError(IErrorInfo worstError) { DesignValidationErrors.Remove(worstError); RootModel.RemoveError(worstError); }
/// <summary> /// Displays/hides status bar. /// </summary> public void SetStatusBar(string idString, string message, string colorString, bool verbose = true) { byte Id; if (!byte.TryParse(idString, out Id)) { // should never occur, but just in case return; } // If setting a status, but the status bar is hidden - display it. if (!_isDisplayingStatusBar && message != "") { DisplayStatusBar(true, false); } TextBlock textBlock; if (Id == 1) { textBlock = StatusBar1; } else if (Id == 2) { textBlock = StatusBar2; } else if (Id == 3) { textBlock = StatusBar3; } else if (Id == 4) { textBlock = StatusBar4; } else if (Id == 5) { textBlock = StatusBar5; } else { // Notify user that id number is wrong. // Print explanations about correct usage. RootModel.PushMessageToConveyor(new InfoMessage("Incorrect usage of #Status [1|2|3|4|5] {Text} [color].", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Error message: Only numbers between 1 and 5 are accepted.", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Example: #Status 1 {Hello} green", Common.Themes.TextColor.BrightYellow)); return; } textBlock.Text = message; if (colorString == "" || colorString.Length < 2) { textBlock.Foreground = new SolidColorBrush(Color.FromRgb(192, 192, 192)); //#c0c0c0 } else { if (colorString.StartsWith("#")) { if (colorString.Length == 7) { Color color = (Color)ColorConverter.ConvertFromString(colorString); textBlock.Foreground = new SolidColorBrush(color); } else { //notify user that color is wrong // print examples of colors RootModel.PushMessageToConveyor(new InfoMessage("Incorrect usage of #Status [1|2|3|4|5] {Text} [color].", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Error message: Incorrect color. Acceptable formats are: #FFFFFF (hex rgb) or plain color name (e.g. green).", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Example: #Status 1 {Hello} green", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Example: #Status 1 {Hello} #00FF00", Common.Themes.TextColor.BrightYellow)); return; } } else { colorString = colorString.ToLower(); colorString = colorString[0].ToString().ToUpper() + colorString.Substring(1); var colorProperty = typeof(Colors).GetProperty(colorString); if (colorProperty != null) { Color color = (Color)colorProperty.GetValue(this); textBlock.Foreground = new SolidColorBrush(color); } else { //notify that color is wrong // print examples of colors RootModel.PushMessageToConveyor(new InfoMessage("Incorrect usage of #Status [1|2|3|4|5] {Text} [color].", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Error message: Incorrect color. The color you entered isn't in the color table.", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Example: #Status 1 {Hello} green", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("Example: #Status 1 {Hello} #00FF00", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("For full list of acceptable colors, please refer to: ", Common.Themes.TextColor.BrightYellow)); RootModel.PushMessageToConveyor(new InfoMessage("https://i-msdn.sec.s-msft.com/en-us/library/system.windows.media.colors.43e06ea3-fdb6-448a-bb66-2e032ab1a12a(v=vs.110).jpeg", Common.Themes.TextColor.BrightYellow)); return; } } } if (verbose) { if (message == "") { RootModel.PushMessageToConveyor(new InfoMessage("#StatusBar" + Id + " emptied.", Common.Themes.TextColor.BrightWhite)); } else { RootModel.PushMessageToConveyor(new InfoMessage("#StatusBar" + Id + ": " + message, Common.Themes.TextColor.BrightWhite)); } } RootModel.SetVariableValue("statusBar" + Id, message, true); RootModel.SetVariableValue("statusBar" + Id + "Col", colorString, true); //// If all statuses are empty, hide the status bar. //if (StatusBar1.Text == "" && StatusBar2.Text == "" && StatusBar3.Text == "" && StatusBar4.Text == "" && StatusBar5.Text == "") //{ // DisplayStatusBar(false, false); //} }