public ActionResult PackageBody_Modify(PackageBodyViewModel packagebody) { if (!ModelState.IsValid) { return(PartialView("_packagebody", packagebody)); } var packagebodyDetails = new PackageBody { No = packagebody.pbodyKey, p_id = packagebody.package_Id, //mainCourse = packagebody.mainCourse, //sea_vegi = packagebody.sea_vegi, //noodlepasta = packagebody.noodlepasta, //salad = packagebody.salad, //dessert = packagebody.dessert, //pineapple = packagebody.pineapple, //drinks = packagebody.drinks, //rice = packagebody.rice }; _dbcontext.PackageBodies.Attach(packagebodyDetails); _dbcontext.Entry(packagebodyDetails).State = EntityState.Modified; _dbcontext.SaveChanges(); //Utilities.ActiveForm = ""; //ViewBag.ActiveForm = Utilities.ActiveForm; //var package_id = packagebodyDetails.p_id; return(Json(new { success = true, packageId = packagebody.package_Id }, JsonRequestBehavior.AllowGet)); }
public ActionResult CreatePackage(PackageBodyViewModel p_bodyViewModel) { if (!ModelState.IsValid) { return(PartialView("_packagebody", p_bodyViewModel)); } var packagebodyDetails = new PackageBody { p_id = p_bodyViewModel.package_Id, //mainCourse = p_bodyViewModel.mainCourse, //sea_vegi = p_bodyViewModel.sea_vegi, //noodlepasta = p_bodyViewModel.noodlepasta, //salad = p_bodyViewModel.salad, //dessert = p_bodyViewModel.dessert, //pineapple = p_bodyViewModel.pineapple, //drinks = p_bodyViewModel.drinks, //rice = p_bodyViewModel.rice }; _dbcontext.PackageBodies.Add(packagebodyDetails); _dbcontext.SaveChanges(); Utilities.ActiveForm = ""; ViewBag.ActiveForm = Utilities.ActiveForm; //var package_id = packagebodyDetails.p_id; return(Json(new { success = true, packageId = packagebodyDetails.p_id }, JsonRequestBehavior.AllowGet)); }
public override CommandResult Do(IExecutionContext context) { context.ControlContainer.Invoke(new Action(() => { if (context.ControlContainer == null) { context.Log.AddLogWarning("Пакет содержит команду отображения списка пользовательских событий, однако в контексте выполнения отсутствует родительский компонент для его отображения"); return; } ListView list = new ListView(); list.Dock = DockStyle.Fill; list.View = View.List; ImageList imageList = new ImageList(); imageList.ImageSize = new System.Drawing.Size(24, 24); imageList.Images.Add(Properties.Resources.running); imageList.Images.Add(Properties.Resources.success); imageList.Images.Add(Properties.Resources.error); imageList.Images.Add(Properties.Resources.dismiss); list.SmallImageList = imageList; PackageBody body = context.ExecutedPackage.GetBody(); List <UserInfoEmbedded> infos = body.GetUserInfos(); foreach (UserInfoEmbedded info in infos) { list.Items.Add(info.MessageGuid, info.MessageText, -1); } context.Log.AddLogger(new ExecutionLoggerUserInfo(list)); context.ControlContainer.Controls.Clear(); context.ControlContainer.Controls.Add(list); })); return(CommandResult.Next); }
public void LoadTree(PackageBody body) { CommandTreeNode node = Root; _packageBody = body; FillTreeNode(node, body.Command, null); }
protected void SelectCommandTreeNodeHandler(CommandTreeNode node, PackageBody body, Command command, PropertyInfo property) { if (SelectCommandTreeNode != null) { SelectCommandTreeNode(node, body, command, property); } }
public static PackageContentType GetContentType(string filePath) { FileStream fs = null; int firstByte; try { fs = new FileStream(filePath, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); firstByte = sr.Read(); } catch { return(PackageContentType.Wrong); } finally { if (fs != null) { fs.Close(); } } if (firstByte == 60) { PackageBody body = GinSerializer.Deserialize <PackageBody>(filePath); return(body.ContentType); } if (firstByte == 31) { return(PackageContentType.Packed); } return(PackageContentType.Wrong); }
void TreeSelectCommandTreeNode(CommandTreeNode node, PackageBody body, Command command, PropertyInfo property) { argumentHelp.SetHelp("", "", "", false, null, null); panelCommandProperties.SuspendLayout(); panelCommandProperties.Controls.Clear(); if (property == null) { panelCommandProperties.SuspendLayout(); try { if (command == null) { FormsHelper.CreateNodeEditor(node, body, panelCommandProperties, _tree.Body, (propertyProgramName, propertyName, propertyDescription, allowTemplates, editor) => argumentHelp.SetHelp(propertyProgramName, propertyName, propertyDescription, allowTemplates, editor, _tree.Body.GetResultInfos())); } else { FormsHelper.CreateNodeEditor(node, command, panelCommandProperties, _tree.Body, (propertyProgramName, propertyName, propertyDescription, allowTemplates, editor) => argumentHelp.SetHelp(propertyProgramName, propertyName, propertyDescription, allowTemplates, editor, _tree.Body.GetResultInfos())); } } finally { panelCommandProperties.ResumeLayout(); } } ResizePropertiesPanelItems(); panelCommandProperties.ResumeLayout(); }
/// <summary> /// Сериализация декларации в файл /// </summary> /// <param name="declarationLibPath"></param> /// <param name="declaration"></param> private static void SaveBody(string bodyLibPath, PackageBody body) { Stream stream = new FileStream(bodyLibPath, FileMode.Create); BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(stream, body); stream.Close(); }
public void InitEditors(object initialValue, PackageBody body) { FormsHelper.CreateNodeEditor(null, initialValue, propertiesPanel, body, new PropertyHelpCallback((progName, argName, argDescr, allowTemplates, editor) => { argumentHelpControl.SetHelp(progName, argName, argDescr, allowTemplates, editor, body.GetResultInfos()); })); AdjustControlsSize(); }
public static void CreateNodeEditor(CommandTreeNode node, object editedObject, Control container, PackageBody body, PropertyHelpCallback helpCallback) { container.Controls.Clear(); FlowLayoutPanel flowPanel; if (container is FlowLayoutPanel) { flowPanel = (FlowLayoutPanel)container; } else { flowPanel = new FlowLayoutPanel(); container.Controls.Add(flowPanel); flowPanel.FlowDirection = FlowDirection.TopDown; flowPanel.Dock = DockStyle.Fill; } Type type = editedObject.GetType(); var properties = type.GetProperties(); foreach (var currentProperty in properties) { GinArgumentAttribute argumentAttr = (GinArgumentAttribute)currentProperty.GetCustomAttributes(typeof(GinArgumentAttribute), false).FirstOrDefault(); bool isArgument = argumentAttr != null; if (isArgument) { object value = currentProperty.GetValue(editedObject, null); Control control = null; control = argumentAttr.GetEditor(value, currentProperty.Name, body, new PropertyChangedDelegate( (propertyName, propertyValue) => { PropertyInfo changedProperty = type.GetProperty(propertyName); if (changedProperty != null) { changedProperty.SetValue(editedObject, propertyValue, null); if (editedObject is Command) { string name = ((Command)editedObject).GetHumanReadableName(); if (name != node.NodeName) { node.NodeName = name; } } } }), new PropertyActivatedDelegate(propertyName => { if (helpCallback != null) { helpCallback(propertyName, argumentAttr.Name, argumentAttr.Description, argumentAttr.AllowTemplates, control as ITemplatedEditor); } })); if (control != null) { control.Tag = currentProperty; flowPanel.Controls.Add(control); } } } }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var dateTime = (DateTime)value; if (dateTime <= DateTime.MinValue || dateTime >= DateTime.MaxValue) { dateTime = DateTime.Now; } Control control = new Editors.DateTimeEditor(Name, dateTime, AllowTemplates, propertyName, onChange, onActivate); return control; }
public ListEditor(string title, IEnumerable <ComboBoxItem> list, Type listType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _listType = listType; _itemType = _listType.GetProperty("Item").PropertyType; _body = body; InitializeComponent(); labelTitle.Text = title; PopulateList(list); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var dateTime = (DateTime)value; if (dateTime <= DateTime.MinValue || dateTime >= DateTime.MaxValue) { dateTime = DateTime.Now; } Control control = new Editors.DateTimeEditor(Name, dateTime, AllowTemplates, propertyName, onChange, onActivate); return(control); }
public ListEditor(string title, IEnumerable<ComboBoxItem> list, Type listType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _listType = listType; _itemType = _listType.GetProperty("Item").PropertyType; _body = body; InitializeComponent(); labelTitle.Text = title; PopulateList(list); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (Multiline) { control = new Editors.MultilineTextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } else { control = new Editors.TextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } return control; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (Multiline) { control = new Editors.MultilineTextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } else { control = new Editors.TextEditor(Name, (string)value, MaxLength, propertyName, onChange, onActivate); } return(control); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var fields = ListEnum.GetFields().Where(f => f.FieldType == ListEnum).ToList(); var list = new List<Editors.ComboBoxItem>(); foreach (var f in fields) { var nameAttr = f.GetCustomAttributes(true).OfType<GinNameAttribute>().FirstOrDefault(); list.Add(new Editors.ComboBoxItem { Display = nameAttr != null ? nameAttr.Name : f.Name, Value = f.GetValue(null) }); } Control control = new Editors.ComboBoxEditor(Name, value, true, list, propertyName, onChange, onActivate); return control; }
private void SavePackage(string filePath, PackageContentType type) { bool isDevelopment = ConfigurationManager.AppSettings.AllKeys.Contains("DEVELOPER") && ConfigurationManager.AppSettings["DEVELOPER"] == "true"; string templatesPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), FOLDER_TEMPLATES); bool isTemplate = filePath.StartsWith(templatesPath); string newFilePath = CorrectPackageFilePath(filePath); bool saveFile = true; if (!isDevelopment && isTemplate) { if (MessageBox.Show("Нельзя сохранять пакет в папку с шаблонами. Хотите вместо этого сохранить пакет а папку <" + newFilePath + ">?", "Недопустимое расположение файла", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { filePath = newFilePath; CreateNewPackageDirectory(filePath); saveFile = true; } else { MessageBox.Show("Пакет не сохранен", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); saveFile = false; } } if (saveFile) { _packageFilePath = filePath; SetFilePathStatus(_packageFilePath); PackageBody body = _tree.Body; body.ContentType = type; PackageBuilder builder = new PackageBuilder(body, type); bool saveSuccess = false; ExecuteAsyncWithWait((() => { saveSuccess = builder.Save(_packageFilePath, true); }), null, "Сохранение пакета"); if (!saveSuccess) { string message = ""; foreach (PackageErrorInfo error in builder.Errors) { message += error.Description + "\r\n"; } MessageBox.Show(this, "Пакет не сохранен. Обнаружены ошибки: \r\n" + message, "Пакет не сохранен", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
protected override void visitPackageBody(PackageBody packageBody) { writer.Append(KeywordEnum.PACKAGE.ToString()).Append(KeywordEnum.BODY.ToString()).Append(' '); writer.AppendIdentifier(packageBody.Package).Append(' '); writer.Append(KeywordEnum.IS.ToString()).NewLine(); writer.Indent(); output.writeDeclarationMarkers(packageBody.Declarations); writer.Dedent(); writer.Append(KeywordEnum.END.ToString()); if (writer.Format.RepeatLabels) { writer.Append(' ').Append(KeywordEnum.PACKAGE.ToString()).Append(KeywordEnum.BODY.ToString()); writer.Append(' ').AppendIdentifier(packageBody.Package); } writer.Append(";").NewLine(); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (AllowTemplates) { control = new Editors.CheckBoxTemplateEditor(Name, value, propertyName, onChange, onActivate); } else { var boolValue = false; if (value is bool) { boolValue = (bool)value; } control = new Editors.CheckBoxEditor(Name, boolValue, propertyName, onChange, onActivate); } return control; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { var fields = ListEnum.GetFields().Where(f => f.FieldType == ListEnum).ToList(); var list = new List <Editors.ComboBoxItem>(); foreach (var f in fields) { var nameAttr = f.GetCustomAttributes(true).OfType <GinNameAttribute>().FirstOrDefault(); list.Add(new Editors.ComboBoxItem { Display = nameAttr != null ? nameAttr.Name : f.Name, Value = f.GetValue(null) }); } Control control = new Editors.ComboBoxEditor(Name, value, true, list, propertyName, onChange, onActivate); return(control); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = null; var iList = value as IList; if (iList != null) { var list = new List<ComboBoxItem>(); foreach (var item in iList) { list.Add(new ComboBoxItem { Display = item.ToString(), Value = item }); } control = new ListEditor(Name, list, ListType, propertyName, body, onChange, onActivate); } return control; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control; if (AllowTemplates) { control = new Editors.CheckBoxTemplateEditor(Name, value, propertyName, onChange, onActivate); } else { var boolValue = false; if (value is bool) { boolValue = (bool)value; } control = new Editors.CheckBoxEditor(Name, boolValue, propertyName, onChange, onActivate); } return(control); }
public ComplexValueEditor(string title, object value, Type valueType, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { if (value == null) { value = GetDefaultValueOrNull(valueType); } _onChange = onChange; _onActivate = onActivate; _propertyName = propertyName; _valueType = valueType; _value = value; _body = body; InitializeComponent(); labelTitle.Text = title; if (value != null) { labelValue.Text = value.ToString(); } }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = null; var iList = value as IList; if (iList != null) { var list = new List <ComboBoxItem>(); foreach (var item in iList) { list.Add(new ComboBoxItem { Display = item.ToString(), Value = item }); } control = new ListEditor(Name, list, ListType, propertyName, body, onChange, onActivate); } return(control); }
public ActionResult AddCoursetoPackageBody(int packageId, int courseId) { bool isrecordexist = false; string _url = String.Empty; try { //check if course id exist in package var is_course_exist = _dbcontext.PackageBodies.FirstOrDefault(x => x.p_id == packageId && x.courseId == courseId); if (is_course_exist != null) { isrecordexist = true; } else { var coursepackagebody = new PackageBody() { p_id = packageId, courseId = courseId }; _dbcontext.PackageBodies.Add(coursepackagebody); _dbcontext.SaveChanges(); _url = Url.Action("DisplaySelectedMenus", "Packages", new { _packageId = packageId }); } } catch (Exception e) { Console.WriteLine(e); throw; } return(Json(new { is_recordexist = isrecordexist, url = _url }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Статическая функция для загрузки тела пакета /// </summary> /// <param name="declarationLibPath"></param> /// <returns></returns> private static PackageBody LoadBody(string bodyLibPath) { if (File.Exists(bodyLibPath)) { try { Stream stream = new FileStream(bodyLibPath, FileMode.Open); BinaryFormatter deserializer = new BinaryFormatter(); PackageBody res = (PackageBody)deserializer.Deserialize(stream); stream.Close(); return(res); } catch (Exception ex) { return(null); } } else { return(null); } }
private void menuItemNewPackage_Click(object sender, EventArgs e) { try { PackageBody body = new PackageBody(); body.Command = new CommandSequence(); if (_tree != null) { ((IDisposable)_tree).Dispose(); } _tree = new TreeViewCommandTree(treeCommands); _tree.LoadTree(body); _tree.ExpandAll(); _tree.SelectCommandTreeNode += new SelectCommandTreeNodeDelegate(TreeSelectCommandTreeNode); _packageFilePath = null; SetFilePathStatus(_packageFilePath); } catch (Exception ex) { Win32Util.ShowError(this, "Не удалось создать новый пакет. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace); } }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.IntEditor(Name, (int)value, AllowTemplates, propertyName, onChange, onActivate); return control; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.ComplexValueEditor(Name, value, ValueType, propertyName, body, onChange, onActivate); return(control); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.ComplexValueEditor(Name, value, ValueType, propertyName, body, onChange, onActivate); return control; }
public CheckPackageVisitor(PackageBody body) { _body = body; }
/// <summary> /// Returns the UI-editor for this property /// </summary> /// <param name="value">Initial value for editor</param> /// <param name="propertyName">Property name</param> /// <param name="body">The PackageBody of current package</param> /// <param name="onChange">PropertyChanged delegate</param> /// <param name="onActivate">PropertyActivated delegate</param> /// <returns>Windows Forms Control, which supplies the edit value function for this class property</returns> public abstract Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate);
/// <summary> /// Returns null, 'cause it has no standard editor /// </summary> /// <returns>null</returns> public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return(null); }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { Control control = new Editors.IntEditor(Name, (int)value, AllowTemplates, propertyName, onChange, onActivate); return(control); }
/// <summary> /// Компиляция файла /// </summary> /// <param name="file"></param> private void CompileFile(LibraryFileInfo file, VhdlParserSettings settings, RootDeclarativeRegion rootScope) { LibraryInfo currentLibrary = null; foreach (LibraryInfo inf in parsedLibraries) { if (inf.Name.EqualsIgnoreCase(file.LibraryName)) { currentLibrary = inf; break; } } if (currentLibrary == null) { currentLibrary = new LibraryInfo(file.LibraryName); parsedLibraries.Add(currentLibrary); rootScope.Libraries.Add(currentLibrary.LibraryScope); } try { Console.WriteLine("parsing file {0} ", file.Path); VhdlFile vhdfile = VhdlParserWrapper.parseFile(file.Path, settings, rootScope, currentLibrary.LibraryScope, libraryManager); foreach (LibraryUnit unit in vhdfile.Elements) { if (unit is PackageDeclaration) { PackageDeclaration pd = unit as PackageDeclaration; pd.Parent = null; bool foundPackage = false; foreach (PackageInfo inf in currentLibrary.Packages) { if (inf.Name.EqualsIdentifier(pd.Identifier)) { inf.DeclarationPath = file.Path; string path = FormCompilePath(file.Path, "decl"); inf.DeclarationLibPath = path; inf.Declaration = pd; foundPackage = true; break; } } if (foundPackage == false) { PackageInfo pi = new PackageInfo(pd.Identifier, currentLibrary.Name, file.Path); pi.DeclarationPath = file.Path; string path = FormCompilePath(file.Path, "decl"); pi.DeclarationLibPath = path; pi.BodyLibPath = path; pi.Declaration = pd; currentLibrary.Packages.Add(pi); } } if (unit is PackageBody) { PackageBody pb = unit as PackageBody; pb.Parent = null; bool foundPackage = false; foreach (PackageInfo inf in currentLibrary.Packages) { if (inf.Name.EqualsIdentifier(pb.Package.Identifier)) { inf.BodyPath = file.Path; string path = FormCompilePath(file.Path, "body"); inf.BodyLibPath = path; inf.Body = pb; foundPackage = true; break; } } if (foundPackage == false) { PackageInfo pi = new PackageInfo(pb.Package.Identifier, currentLibrary.Name, file.Path); pi.BodyPath = file.Path; string path = FormCompilePath(file.Path, "body"); pi.BodyLibPath = path; pi.Body = pb; currentLibrary.Packages.Add(pi); } } } } catch (Exception ex) { logger.WriteLineFormat("parsing {0} failed", file.Path); logger.WriteLine(ex.Message); logger.WriteLine(LoggerMessageVerbosity.Error, ex.Message); } }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return new Editors.BrowseFolderEditor(Name, (string)value, propertyName, onChange, onActivate); }
/// <summary> /// Returns null, 'cause it has no standard editor /// </summary> /// <returns>null</returns> public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return null; }
public override Control GetEditor(object value, string propertyName, PackageBody body, PropertyChangedDelegate onChange, PropertyActivatedDelegate onActivate) { return(new Editors.BrowseFileEditor(IsNewFile, Name, (string)value, propertyName, onChange, onActivate)); }