コード例 #1
0
ファイル: PCH.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Reads role list from specified XML node to update role list
        /// </summary>
        /// <param name="propNode"></param>
        private void _RetrieveRoles(XmlNode propNode)
        {
            _Roles.Clear();

            try
            {
                XmlNode     rolesNode = propNode.SelectSingleNode(_ROLES_NODE);
                XmlNodeList allRoles  = rolesNode.SelectNodes(_ROLE_NODE);

                if (allRoles != null)
                {
                    foreach (XmlNode anotherRole in allRoles)
                    {
                        string role = anotherRole.Attributes[_WHAT_ATTRIBUTE].Value;
                        string name = Xml2.GetAttributeWithDefaultValue(anotherRole, _NAME_ATTRIBUTE, _NAME_UNKNOWN);

                        _Roles.Add(role, name);
                    }
                }
            }
            catch (Exception ex)
            {
                Exception2.PrintStackTrace(new Exception("Roles not defined in patch file! Using defaults.", ex));
            }

            // If no role is set, standard roles are set
            if (_Roles.Count == 0)
            {
                _SetStandardRoles();
            }
        }
コード例 #2
0
ファイル: frmEntity.cs プロジェクト: yusongok/Pub.Class
		private void property_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) {
			Xml2 xml = new Xml2(xmlFile);
			var info = config.OPList[listBox.SelectedIndex];
			xml.SetAttr("root//Table[@Name='" + info.Table + "']", "Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{8}|{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{9}".FormatWith(
				info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(),
				info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(),
				info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(),
				info.UpdateAndInsert.ToString().ToLower()
			));
			xml.Save();
			xml.Close();
		}
コード例 #3
0
ファイル: PCH.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Method to create an instruction from a XML node
        /// </summary>
        /// <param name="node">node to process</param>
        /// <param name="order">instruction order</param>
        /// <returns>Correponding instruction</returns>
        private PatchInstruction _ProcessInstruction(XmlNode node, int order)
        {
            PatchInstruction processedPI = null;

            if (node != null && order > 0)
            {
                // Main attributes
                string instructionType = node.Attributes[_TYPE_ATTRIBUTE].Value;
                string isFailOnError   = Xml2.GetAttributeWithDefaultValue(node, _FAIL_ON_ERROR_ATTRIBUTE, true.ToString());
                string isEnabled       = Xml2.GetAttributeWithDefaultValue(node, _ENABLED_ATTRIBUTE, true.ToString());
                string comment         = Xml2.GetAttributeWithDefaultValue(node, _COMMENT_ATTRIBUTE, "");
                string groupName       = Xml2.GetAttributeWithDefaultValue(node, _GROUP_ATTRIBUTE, REQUIRED_GROUP_NAME);

                processedPI = PatchInstruction.MakeInstruction(instructionType);

                if (processedPI != null)
                {
                    processedPI.FailOnError = bool.Parse(isFailOnError);
                    processedPI.Enabled     = bool.Parse(isEnabled);
                    processedPI.Order       = order;
                    processedPI.Comment     = comment;

                    if (string.IsNullOrEmpty(groupName))
                    {
                        groupName = REQUIRED_GROUP_NAME;
                    }

                    processedPI.Group = GetGroupFromName(groupName);

                    // Instruction parameters
                    XmlNodeList allParameterNodes = node.SelectNodes(_PARAMETER_NODE);

                    if (allParameterNodes != null)
                    {
                        foreach (XmlNode anotherParameterNode in allParameterNodes)
                        {
                            PatchInstructionParameter pip = _ProcessParameter(anotherParameterNode);

                            if (pip == null)
                            {
                                throw new Exception("Invalid parameter: " + anotherParameterNode.Value);
                            }

                            processedPI.Parameters.Add(pip.Name, pip);
                        }
                    }
                }
            }

            return(processedPI);
        }
コード例 #4
0
        /// <summary>
        /// Save xml only paper (xmlwriter)
        /// </summary>
        public void SaveXML2Paper(string output)
        {
            Xml2           wx       = new Xml2();
            List <IFigure> _tempbox = new List <IFigure>(boxoffigure.Count);

            foreach (var i in boxoffigure)
            {
                if (i is IPaper)
                {
                    _tempbox.Add(i);
                }
            }
            wx.Write(output, _tempbox);
        }
コード例 #5
0
ファイル: frmEntity.cs プロジェクト: AdvanceEnemy/pub.class
        private void CreateXML(string fileName)
        {
            Xml2.Create(fileName, "", "", "utf-8", "<root></root>");
            Xml2 xml = new Xml2(fileName);

            foreach (var info in OPList)
            {
                xml.AddNode("root", "Table", "Name|Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{0}|{9}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{10}".FormatWith(
                                info.Table, info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(),
                                info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(),
                                info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(),
                                info.UpdateAndInsert.ToString().ToLower()
                                ));
            }
            xml.Save();
            xml.Close();
        }
コード例 #6
0
ファイル: PCH.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Reads group dependency and exclusion from specified XML node to update list
        /// </summary>
        /// <param name="propNode"></param>
        private void _RetrieveGroups(XmlNode propNode)
        {
            _Groups.Clear();

            try
            {
                XmlNode groupsNode = propNode.SelectSingleNode(_GROUPS_NODE);

                if (groupsNode != null)
                {
                    // Custom required group name
                    _CustomRequiredName = Xml2.GetAttributeWithDefaultValue(groupsNode, _CUSTOM_REQUIRED_ATTRIBUTE,
                                                                            REQUIRED_GROUP_NAME);

                    // Dependencies and exclusions
                    XmlNodeList allDependancies = groupsNode.SelectNodes(_DEPENDENCY_NODE);

                    if (allDependancies != null)
                    {
                        foreach (XmlNode anotherDep in allDependancies)
                        {
                            string groupName                   = anotherDep.Attributes[_GROUP_ATTRIBUTE].Value;
                            string requiredName                = Xml2.GetAttributeWithDefaultValue(anotherDep, _REQUIRED_ATTRIBUTE, null);
                            bool   isDefaultChecked            = bool.Parse(Xml2.GetAttributeWithDefaultValue(anotherDep, _CHECKED_ATTRIBUTE, "false"));
                            Collection <string> excludedGroups = _RetrieveExcludedGroups(anotherDep);

                            _Groups.Add(new InstallGroup {
                                name = groupName, parentName = requiredName, isDefaultChecked = isDefaultChecked, excludedGroupNames = excludedGroups, exists = true
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exception2.PrintStackTrace(new Exception("Roles not defined in patch file! Using defaults.", ex));
            }

            // If no role is set, standard roles are set
            if (_Roles.Count == 0)
            {
                _SetStandardRoles();
            }
        }
コード例 #7
0
ファイル: VehicleSlotsHelper.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Initializes vehicle reference according to specified XML file.
        /// </summary>
        /// <param name="referenceFilePath">Path of XML reference file (just path, not filename)</param>
        public static void InitReference(string referenceFilePath)
        {
            // Is init needed ?
            if (!_IsReady && !string.IsNullOrEmpty(referenceFilePath) && Directory.Exists(referenceFilePath))
            {
                // Parsing ref XML file and writing to reference
                XmlDocument doc = new XmlDocument();

                doc.Load(referenceFilePath + FILE_SLOTS_REF_XML);

                XmlNode slotsNode = doc.DocumentElement;

                if (slotsNode != null)
                {
                    XmlNodeList allVehicles = slotsNode.SelectNodes(_VEHICLE_NODE);

                    if (allVehicles != null)
                    {
                        foreach (XmlNode anotherNode in allVehicles)
                        {
                            string name       = anotherNode.Attributes[_NAME_ATTRIBUTE].Value;
                            string vehicleRef = anotherNode.Attributes[_REF_ATTRIBUTE].Value;
                            string defaultCam = anotherNode.Attributes[_CAMERA_ATTRIBUTE].Value;
                            string defaultIK  = anotherNode.Attributes[_IK_ATTRIBUTE].Value;

                            // New camera ?
                            string newCam = Xml2.GetAttributeWithDefaultValue(anotherNode, _NEW_CAMERA_ATTRIBUTE, null);

                            // Top speed (km/h)
                            string topSpeed = Xml2.GetAttributeWithDefaultValue(anotherNode, _TOP_SPEED_ATTRIBUTE, "0");

                            // Addon car ?
                            bool isAddon =
                                bool.Parse(Xml2.GetAttributeWithDefaultValue(anotherNode, _ADDON_ATTRIBUTE, "false"));

                            // Is it a bike ?
                            bool isBike =
                                bool.Parse(Xml2.GetAttributeWithDefaultValue(anotherNode, _BIKE_ATTRIBUTE, "false"));

                            // Moddable vehicle ?
                            bool isModdable =
                                bool.Parse(Xml2.GetAttributeWithDefaultValue(anotherNode, _MODDABLE_ATTRIBUTE, "true"));

                            _SlotReference.Add(name, vehicleRef);
                            _SlotReferenceReverse.Add(vehicleRef, name);
                            _CamReferenceReverse.Add(name, defaultCam);
                            _IKReferenceReverse.Add(name, defaultIK);

                            if (!_CamReference.ContainsKey(defaultCam))
                            {
                                _CamReference.Add(defaultCam, name);
                            }
                            if (newCam != null && !_NewCamReference.ContainsKey(newCam))
                            {
                                _NewCamReference.Add(newCam, name);
                            }
                            if (!_IKReference.ContainsKey(defaultIK))
                            {
                                _IKReference.Add(defaultIK, name);
                            }

                            // Vehicle information
                            VehicleInfo info = new VehicleInfo
                            {
                                isAddon       = isAddon,
                                isBike        = isBike,
                                defaultCamera = defaultCam,
                                newCamera     = newCam,
                                defaultIK     = defaultIK,
                                isModdable    = isModdable,
                                topSpeed      = ushort.Parse(topSpeed)
                            };

                            // Updating reference
                            _VehicleInformation.Add(vehicleRef, info);
                        }
                    }
                }

                // Loads default camera
                string defaultCamerasFileName = referenceFilePath + LibraryConstants.FOLDER_DEFAULT +
                                                Cameras.FILE_CAMERAS_BIN;
                _DefaultCameras = (Cameras)TduFile.GetFile(defaultCamerasFileName);

                if (_DefaultCameras == null || !_DefaultCameras.Exists)
                {
                    throw new Exception("Default camera file invalid or not found: " + defaultCamerasFileName);
                }

                // OK !
                _IsReady = true;
            }
        }
コード例 #8
0
ファイル: frmEntity.cs プロジェクト: AdvanceEnemy/pub.class
        private void frmEntity_Load(object sender, EventArgs e)
        {
            //Data.ConnString = WebConfig.GetConn("ConnString");
            textBox1.Text = string.IsNullOrEmpty(WebConfig.GetApp("Project")) ? "Test" : WebConfig.GetApp("Project");
            xmlFile       = "".GetMapPath() + textBox1.Text + ".xml";
            bool xmlExist            = FileDirectory.FileExists(xmlFile);
            IList <TableEntity> list = TableFactory.GetTable();

            foreach (TableEntity entity in list)
            {
                listBox.Items.Add((entity.isView ? "* " : "") + entity.Name, entity.isView ? false : true);
                if (!xmlExist)
                {
                    OPList.Add(new TableOperator()
                    {
                        Table = entity.Name
                    });
                }
                else
                {
                    Xml2     xml   = new Xml2(xmlFile);
                    string[] attrs = xml.GetAttr("root//Table[@Name='" + entity.Name + "']", "Name|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|Entity|UpdateAndInsert").Split('|');
                    if (attrs[0].IsNullEmpty())
                    {
                        OPList.Add(new TableOperator()
                        {
                            Table = entity.Name
                        });
                        var info = OPList[OPList.Count - 1];
                        xml.AddNode("root", "Table", "Name|Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{0}|{9}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{10}".FormatWith(
                                        info.Table, info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(),
                                        info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(),
                                        info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(),
                                        info.UpdateAndInsert.ToString().ToLower()
                                        ));
                        xml.Save();
                    }
                    else
                    {
                        OPList.Add(new TableOperator()
                        {
                            Table           = entity.Name,
                            Insert          = attrs[1] == "true" ? true : false,
                            Update          = attrs[2] == "true" ? true : false,
                            DeleteByID      = attrs[3] == "true" ? true : false,
                            IsExistByID     = attrs[4] == "true" ? true : false,
                            SelectByID      = attrs[5] == "true" ? true : false,
                            SelectPageList  = attrs[6] == "true" ? true : false,
                            SelectListByFK  = attrs[7] == "true" ? true : false,
                            SelectListByAll = attrs[8] == "true" ? true : false,
                            Entity          = attrs[9] == "true" ? true : false,
                            UpdateAndInsert = attrs[10] == "true" ? true : false,
                        });
                    }
                    xml.Close();
                }
            }
            if (!xmlExist)
            {
                CreateXML(xmlFile);
            }
            if (listBox.Items.Count > 0)
            {
                listBox.SelectedIndex = 0;
            }
            this.Text = "Entity Tool [{2}] - {1}连接共有{0}个表".FormatWith(listBox.Items.Count, Data.DBType, TemplateName);
        }
コード例 #9
0
        /// <summary>
        /// load xml (xmlreader)
        /// </summary>
        public void LoadXML2(string input)
        {
            Xml2 t1 = new Xml2();

            boxoffigure = t1.Read(input);
        }
コード例 #10
0
        /// <summary>
        /// Save xml (xmlwriter)
        /// </summary>
        public void SaveXML2All(string output)
        {
            Xml2 wx = new Xml2();

            wx.Write(output, boxoffigure);
        }
コード例 #11
0
ファイル: PCH.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Reads patch from a PCH (XML format) file
        /// </summary>
        protected override sealed void _ReadData()
        {
            XmlDocument doc = new XmlDocument();

            try
            {
                doc.Load(FileName);

                // Properties
                XmlElement docElement = doc.DocumentElement;

                if (docElement != null)
                {
                    XmlNode propNode = docElement.SelectSingleNode(_PROPERTIES_NODE);

                    _Name              = propNode.Attributes[_NAME_ATTRIBUTE].Value;
                    _Version           = propNode.Attributes[_VERSION_ATTRIBUTE].Value;
                    _Author            = propNode.Attributes[_AUTHOR_ATTRIBUTE].Value;
                    _Date              = propNode.Attributes[_DATE_ATTRIBUTE].Value;
                    _Free              = Xml2.GetAttributeWithDefaultValue(propNode, _FREE_ATTRIBUTE, "");
                    _InstallerFileName = Xml2.GetAttributeWithDefaultValue(propNode, _INSTALLER_FILE_NAME_ATTRIBUTE,
                                                                           INSTALLER_FILE_NAME);

                    // EVO_131: roles
                    _RetrieveRoles(propNode);

                    // EVO_134: groups
                    _RetrieveGroups(propNode);

                    // New attributes
                    _SlotRef = Xml2.GetAttributeWithDefaultValue(propNode, _SLOT_REF_ATTRIBUTE, "");
                    InfoURL  = Xml2.GetAttributeWithDefaultValue(propNode, _INFO_URL_ATTRIBUTE, "");

                    // Instructions
                    XmlNode     instrNode           = docElement.SelectSingleNode(_INSTRUCTIONS_NODE);
                    XmlNodeList allInstructionNodes = instrNode.SelectNodes(_SINGLE_INSTRUCTION_NODE);
                    int         order = 1;

                    if (allInstructionNodes != null)
                    {
                        foreach (XmlNode anotherInstructionNode in allInstructionNodes)
                        {
                            try
                            {
                                PatchInstruction pi = _ProcessInstruction(anotherInstructionNode, order);

                                if (pi == null)
                                {
                                    throw new Exception();
                                }
                                _PatchInstructions.Add(pi);

                                // Groups update
                                if (!_Groups.Contains(pi.Group))
                                {
                                    _Groups.Add(pi.Group);
                                }

                                order++;
                            }
                            catch (Exception ex)
                            {
                                // Current instruction won't be added
                                Exception2.PrintStackTrace(new Exception("Invalid instruction.", ex));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Silent exception
                Exception2.PrintStackTrace(new Exception(_ERROR_LOADING_PATCH, ex));
            }

            // EVO_65: Properties
            Property.ComputeValueDelegate instructionCountDelegate = () => PatchInstructions.Count.ToString();
            Property.ComputeValueDelegate nameDelegate             = () => Name;
            Property.ComputeValueDelegate authorDelegate           = () => Author;
            Property.ComputeValueDelegate dateDelegate             = () => Date;
            Property.ComputeValueDelegate versionDelegate          = () => Version;
            Property.ComputeValueDelegate slotDelegate             = () => SlotRef;
            Property.ComputeValueDelegate groupCountDelegate       = () => Groups.Count.ToString();
            Property.ComputeValueDelegate installerDelegate        = () => InstallerFileName;
            Property.ComputeValueDelegate urlDelegate = () => InfoURL;

            Properties.Add(new Property("Patch name", "Patch", nameDelegate));
            Properties.Add(new Property("Author", "Patch", authorDelegate));
            Properties.Add(new Property("Date", "Patch", dateDelegate));
            Properties.Add(new Property("Version", "Patch", versionDelegate));
            Properties.Add(new Property("Group count", "Patch", groupCountDelegate));
            Properties.Add(new Property("Instruction count", "Patch", instructionCountDelegate));
            Properties.Add(new Property("Slot reference", "Patch", slotDelegate));
            Properties.Add(new Property("Installer file name", "Patch", installerDelegate));
            Properties.Add(new Property("Information URL", "Patch", urlDelegate));
        }