Ejemplo n.º 1
0
        /// <summary>
        /// ��ȡ�������
        /// </summary>
        /// <param name="SiteID"></param>
        /// <returns></returns>
        public static string GetSmsCount(string SiteID)
        {
            string UserName = "";
            string Password = "";

            string mToUrl = "";	    //�������õ�url
            string mRtv = "";		//���õķ����ַ���

            string strSMSConfigPath = System.Web.HttpContext.Current.Server.MapPath("/Admin/Config/" + SiteID + "/SiteConfig.config");
            if (System.IO.File.Exists(strSMSConfigPath))
            {
                System.Xml.XmlDocument XDTop = new System.Xml.XmlDocument();
                XDTop.Load(strSMSConfigPath);

                UserName = XDTop.SelectSingleNode("DB/SMSConfig/SMSUserName").InnerText;
                Password = XDTop.SelectSingleNode("DB/SMSConfig/SMSPassword").InnerText;
            }

            // �û�����
            mToUrl = "http://www.139000.com/send/getfee.asp?name=" + UserName + "&pwd=" + Password;

            System.Net.HttpWebResponse rs = (System.Net.HttpWebResponse)System.Net.HttpWebRequest.Create(mToUrl).GetResponse();
            System.IO.StreamReader sr = new System.IO.StreamReader(rs.GetResponseStream(), System.Text.Encoding.Default);
            mRtv = sr.ReadToEnd();

            string[] arr = mRtv.Split(new char[] { '=', '&' });

            return arr[1];
        }
Ejemplo n.º 2
0
        public static ImageInfo toImgur(Bitmap bmp)
        {
            ImageConverter convert = new ImageConverter();
            byte[] toSend = (byte[])convert.ConvertTo(bmp, typeof(byte[]));
            using (WebClient wc = new WebClient())
            {
                NameValueCollection nvc = new NameValueCollection
                {
                    { "image", Convert.ToBase64String(toSend) }
                };
                wc.Headers.Add("Authorization", Imgur.getAuth());
                ImageInfo info = new ImageInfo();
                try  
                {
                    byte[] response = wc.UploadValues("https://api.imgur.com/3/upload.xml", nvc);
                    string res = System.Text.Encoding.Default.GetString(response);

                    var xmlDoc = new System.Xml.XmlDocument();
                    xmlDoc.LoadXml(res);
                    info.link = new Uri(xmlDoc.SelectSingleNode("data/link").InnerText);
                    info.deletehash = xmlDoc.SelectSingleNode("data/deletehash").InnerText;
                    info.id = xmlDoc.SelectSingleNode("data/id").InnerText;
                    info.success = true;
                }
                catch (Exception e)
                {
                    info.success = false;
                    info.ex = e;
                }
                return info;
            }
        }
Ejemplo n.º 3
0
        private void reload_Click(object sender, EventArgs e)
        {
            String firstNum, lastNum;

            // Gets the first 4 and last 4 numbers from the Selectionbox, and saves them to a variable
            firstNum = resolutionSelect.Text.Substring(0, 4);
            lastNum = resolutionSelect.Text.Substring(Math.Max(0, resolutionSelect.Text.Length - 4));

            // Removes any spaces from the above strings.
            firstNum = firstNum.Replace(" ", "");
            lastNum = lastNum.Replace(" ", "");

            // Loads the Application Settings XML file
            System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
            System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
            appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");

            // Sets the XML attributes to the current values of the editor
            appConfigXML.SelectSingleNode("//ScreenTitle").InnerText = windowTitleBox.Text;
            appConfigXML.SelectSingleNode("//FullScreen").InnerText = isFullScreen.Text;
            appConfigXML.SelectSingleNode("//ScreenWidth").InnerText = Convert.ToString(firstNum);
            appConfigXML.SelectSingleNode("//ScreenHeight").InnerText = Convert.ToString(lastNum);

            // Saves the Application Settings XML file
            appConfigXML.Save(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Save(Game._path + "\\Content\\ServiceSettings.xml");

            MessageBox.Show("Reload Application for changes to take effect");
            System.Diagnostics.Process.Start(Game._path + @"\\Devoxelation.exe");
            Application.Exit();
        }
Ejemplo n.º 4
0
        private static void SetNode(string cpath)
        {   
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(cpath);
            Console.WriteLine("Adding to machine.config path: {0}", cpath);

            foreach (DataProvider dp in dataproviders)
            {
                System.Xml.XmlNode node = doc.SelectSingleNode("configuration/system.data/DbProviderFactories/add[@invariant=\"" + dp.invariant + "\"]");
                if (node == null)
                {
                    System.Xml.XmlNode root = doc.SelectSingleNode("configuration/system.data/DbProviderFactories");
                    node = doc.CreateElement("add");
                    System.Xml.XmlAttribute at = doc.CreateAttribute("name");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("invariant");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("description");
                    node.Attributes.Append(at);
                    at = doc.CreateAttribute("type");
                    node.Attributes.Append(at);
                    root.AppendChild(node);
                }
                node.Attributes["name"].Value = dp.name;
                node.Attributes["invariant"].Value = dp.invariant;
                node.Attributes["description"].Value = dp.description;
                node.Attributes["type"].Value = dp.type;
                Console.WriteLine("Added Data Provider node in machine.config.");
            }            

            doc.Save(cpath);
            Console.WriteLine("machine.config saved: {0}", cpath);
        }
Ejemplo n.º 5
0
 public BG(string conffile)
     : this()
 {
     System.Xml.XmlDocument xmld = new System.Xml.XmlDocument();
     xmld.Load(conffile);
     this.prefix = xmld.SelectSingleNode("/root/instance/prefix").Attributes["val"].Value.ToString();
     this.rootDir = xmld.SelectSingleNode("/root/instance/rootDir").Attributes["val"].Value.ToString();
     Path.rootDir = this.rootDir;
 }
 private static double[] GetCoordinates(string location)
 {
     double[] result = new double[2];
     string url = "http://where.yahooapis.com/geocode?q=" +  location + "&appid=4m2kmJ3V34Gpe6hGVj8ORcMio3s44DgMDmyS8nKHNnf6PlZwjMcoluUBzwAVXGDG";
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.Load(url);
     result[0] = Convert.ToDouble(doc.SelectSingleNode("/ResultSet/Result/latitude").InnerText);
     result[1] = Convert.ToDouble(doc.SelectSingleNode("/ResultSet/Result/longitude").InnerText);
     return result;
 }
Ejemplo n.º 7
0
        public String Process(String ReqXml)
        {
            String ResXml = string.Empty;
            string ReqCode = string.Empty;
            try
            {
                com.individual.helper.LogNet4.WriteMsg(ReqXml);
                System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                xmldoc.LoadXml(ReqXml);

                //待验证数据
                string MsgData = xmldoc.SelectSingleNode("JTW91G/MsgData").OuterXml;

                //数字签名
                string Signature = xmldoc.SelectSingleNode("JTW91G/SignData/Signature").InnerText;

                //RSA公钥
                string RsaPubKey = xmldoc.SelectSingleNode("JTW91G/SignData/RsaPubKey").InnerText;

                //请求指令
                ReqCode = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/ReqCode").InnerText;

                if (com.individual.helper.RsaSha1Helper.verify(MsgData, RsaPubKey, Signature))
                {                    //系统类型
                    string OsType = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/OsType").InnerText;
                    if (string.IsNullOrEmpty(OsType) || ("0" != OsType && "1" != OsType && "2" != OsType))
                    {
                        return GssResXml.GetResXml(ReqCode, ResCode.UL037, ResCode.UL037Desc, string.Format("<DataBody></DataBody>"));
                    }
                    //反射出具体的实现类
                    Type t = Type.GetType("JtwPhone.Code." + ReqCode);
                    //获取方法
                    System.Reflection.MethodInfo minfo = t.GetMethod("AnalysisXml");
                    //执行方法
                    ResXml = minfo.Invoke(System.Activator.CreateInstance(t), new Object[] { ReqXml }).ToString();
                }
                else //验证签名失败
                {
                    ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL006, ResCode.UL006Desc, string.Format("<DataBody></DataBody>"));
                }

            }
            catch (Exception ex)
            {
                com.individual.helper.LogNet4.WriteErr(ex);

                //业务处理失败
                ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL005, ResCode.UL005Desc, string.Format("<DataBody></DataBody>"));

            }
            return ResXml;
        }
Ejemplo n.º 8
0
        private void SettingsEditor_Load(object sender, EventArgs e)
        {
            // Loads the Application Settings XML file
            System.Xml.XmlDocument appConfigXML = new System.Xml.XmlDocument();
            System.Xml.XmlDocument serConfigXML = new System.Xml.XmlDocument();
            appConfigXML.Load(Game._path + "\\Content\\ApplicationSettings.xml");
            serConfigXML.Load(Game._path + "\\Content\\ServiceSettings.xml");

            // First Tab (Application Settings)
            windowTitleBox.Text = appConfigXML.SelectSingleNode("//ScreenTitle").InnerText;
            resolutionSelect.Text = appConfigXML.SelectSingleNode("//ScreenWidth").InnerText + " x " + appConfigXML.SelectSingleNode("//ScreenHeight").InnerText;
            isFullScreen.Text = Convert.ToString(appConfigXML.SelectSingleNode("//FullScreen").InnerText);
        }
Ejemplo n.º 9
0
        public Location GeocodeLocation(string address)
        {
            var url = "http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=" + System.Web.HttpUtility.UrlEncode(address);

              var xmlString = _client.DownloadString(url);
              var xmlDoc = new System.Xml.XmlDocument();
              xmlDoc.LoadXml(xmlString);

              var loc = new Location();
              loc.Latitude = Double.Parse(xmlDoc.SelectSingleNode("//geometry/location/lat").InnerText, NumberFormatInfo.InvariantInfo);
              loc.Longitude = double.Parse(xmlDoc.SelectSingleNode("//geometry/location/lng").InnerText, NumberFormatInfo.InvariantInfo);

              return loc;
        }
Ejemplo n.º 10
0
        public static EmbeddedConfiguration GetConfigurationFromEmbeddedFile(string logicalConnectionName)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            using (System.IO.Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("ITPCfSQL.Azure.CLR.Configuration.Connections.xml"))
            {
                doc.Load(s);
            }

            string query = "ConnectionList/Connection[LogicalName='" + logicalConnectionName + "']";

            //Microsoft.SqlServer.Server.SqlContext.Pipe.Send(query);

            System.Xml.XmlNode node = doc.SelectSingleNode(query);

            if (node == null)
                throw new ArgumentException("Cannot find \"" + logicalConnectionName + "\" logical connection. Are you sure you spelled it right?");

            try
            {
                return new EmbeddedConfiguration()
            {
                LogicalName = node.SelectSingleNode("LogicalName").InnerText,
                AccountName = node.SelectSingleNode("AccountName").InnerText,
                SharedKey = node.SelectSingleNode("SharedKey").InnerText,
                UseHTTPS = bool.Parse(node.SelectSingleNode("UseHTTPS").InnerText)
            };
            }
            catch (Exception exce)
            {
                throw new ArgumentException("There is an error in the configuration file. Some node is missing.", exce);
            }
        }
Ejemplo n.º 11
0
        public List<Queue> ListQueues(
            string prefix = null,
            bool IncludeMetadata = false,
            int timeoutSeconds = 0,
            Guid? xmsclientrequestId = null)
        {
            List<Queue> lQueues = new List<Queue>();
            string strNextMarker = null;
            do
            {
                string sRet = Internal.InternalMethods.ListQueues(UseHTTPS, SharedKey, AccountName, prefix, strNextMarker,
                    IncludeMetadata: IncludeMetadata, timeoutSeconds: timeoutSeconds, xmsclientrequestId: xmsclientrequestId);

                //Microsoft.SqlServer.Server.SqlContext.Pipe.Send("After Internal.InternalMethods.ListQueues = " + sRet);

                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                using (System.IO.StringReader sr = new System.IO.StringReader(sRet))
                {
                    doc.Load(sr);
                }

                foreach (System.Xml.XmlNode node in doc.SelectNodes("EnumerationResults/Queues/Queue"))
                {
                    lQueues.Add(Queue.ParseFromXmlNode(this, node));
                };

                strNextMarker = doc.SelectSingleNode("EnumerationResults/NextMarker").InnerText;

                //Microsoft.SqlServer.Server.SqlContext.Pipe.Send("strNextMarker == " + strNextMarker);

            } while (!string.IsNullOrEmpty(strNextMarker));

            return lQueues;
        }
        static void Main()
        {
            var xmlSearch = new System.Xml.XmlDocument();

            //select one of the above Query, Query1
            xmlSearch.Load(Query1);
            
            var query = xmlSearch.SelectSingleNode("/query");
            
            var author = query[Author].GetText();
            var title = query[Title].GetText();
            var isbn = query[ISBN].GetText();
         
            var dbContext = new BookstoreDbContext();

            var queryLogEntry = new SearchLogEntry
            {
                Date = DateTime.Now,
                QueryXml = query.OuterXml
            };

            var foundBooks = GenerateQuery(author, title, isbn, dbContext);

            dbContext.SearchLog.Add(queryLogEntry);
            dbContext.SaveChanges();

            PrintResult(foundBooks);
        }
Ejemplo n.º 13
0
        private void btnPublishFolder_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtFolderPath.Text))
            {
                //To Publish Folder, add Data to XML
                System.Xml.XmlDocument objXmlDocument = new System.Xml.XmlDocument();
                // Load XML
                objXmlDocument.Load(@".\Data\PublishedFolders.xml");
                System.Xml.XmlNode objXmlNode = objXmlDocument.CreateNode(System.Xml.XmlNodeType.Element,"Folder", "Folder");

                // Attribute Name
                System.Xml.XmlAttribute objXmlAttribute = objXmlDocument.CreateAttribute("Name");
                objXmlAttribute.Value = "Carpeta";
                objXmlNode.Attributes.Append(objXmlAttribute);
                // Attribute Status
                objXmlAttribute = objXmlDocument.CreateAttribute("Status");
                objXmlAttribute.Value = "Enabled";
                objXmlNode.Attributes.Append(objXmlAttribute);
                // Attribute Path
                objXmlAttribute = objXmlDocument.CreateAttribute("Path");
                objXmlAttribute.Value = txtFolderPath.Text;
                objXmlNode.Attributes.Append(objXmlAttribute);

                // Add Node
                objXmlDocument.SelectSingleNode("/PublishedFolders").AppendChild(objXmlNode);
                // Update File
                objXmlDocument.Save(@".\Data\PublishedFolders.xml");

                // Refresh List
                LoadFolders();
            }
        }
        public void TestForAdminPackageOfWebDashboardIsEmpty()
        {
#if BUILD
            string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\Project\Webdashboard\dashboard.config");
#else
            string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\..\Webdashboard\dashboard.config");
#endif           

            Assert.IsTrue(System.IO.File.Exists(configFile), "Dashboard.config not found at {0}", configFile);

            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            xdoc.Load(configFile);

            var adminPluginNode = xdoc.SelectSingleNode("/dashboard/plugins/farmPlugins/administrationPlugin");

            Assert.IsNotNull(adminPluginNode, "Admin package configuration not found in dashboard.config at {0}", configFile);

            var pwd = adminPluginNode.Attributes["password"];

            Assert.IsNotNull(pwd, "password attribute not defined in admin packackage in dashboard.config at {0}", configFile);

            Assert.AreEqual("", pwd.Value, "Password must be empty string, to force users to enter one. No default passwords allowed in distribution");


        }
        public int coverfromxml(MemoryStream xmlStream)
        {
            int answer = 0;
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                xmlStream.Position = 0;
                doc.Load(xmlStream);
                System.Xml.XmlNode nderoot = doc.SelectSingleNode("/ComicInfo/Pages");
                if (nderoot != null)
                {
                    if (nderoot.ChildNodes.Count > 1)
                    { answer = Convert.ToInt16(nderoot.FirstChild.Attributes.GetNamedItem("Image").Value); }
                    answer = MultipleCovers(answer, nderoot);
                }
                else
                {
                    answer = -1;
                }

            }
            catch (Exception ex)
                {
                    Log.Instance.Write("XML Error! ", ex);
                    answer = -1;
                }
            return answer;
        }
Ejemplo n.º 16
0
 public static int GetSessionTimeOutFromWebConfig()
 {
     System.Xml.XmlDocument x = new System.Xml.XmlDocument();
     x.Load(AppDomain.CurrentDomain.BaseDirectory + "web.config");
     System.Xml.XmlNode node = x.SelectSingleNode("/configuration/system.web/authentication/forms");
     int time_out = int.Parse(node.Attributes["timeout"].Value, System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
     return time_out;
 }
Ejemplo n.º 17
0
 public static void ChangeDFSXMLSlaveList(string dfspath, string newSlavelist)
 {
     System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
     doc.Load(dfspath);
     System.Xml.XmlNode node = doc.SelectSingleNode("//SlaveList");
     node.InnerText = newSlavelist;
     doc.Save(dfspath);
 }
Ejemplo n.º 18
0
        public static string GetSetting(string path, string key)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(path);

            System.Xml.XmlNode node = doc.SelectSingleNode("settings/" + key);
            return node.InnerText;
        }
Ejemplo n.º 19
0
        public static void SetSetting(string path, string key, string value)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(path);

            System.Xml.XmlNode node = doc.SelectSingleNode("settings/" + key);
            node.InnerText = value;
            doc.Save(path);
        }
Ejemplo n.º 20
0
 public override void DataBind()
 {
     Doc = new System.Xml.XmlDocument();
     Doc.Load(RssUrl);
     var link = Doc.SelectSingleNode("/rss/channel/link");
     if (link != null)
         ImgUrl = link.InnerText;
     base.DataBind();
 }
Ejemplo n.º 21
0
        public String AnalysisXml(string ReqXml)
        {
            string ResXml = string.Empty;
            string ReqCode = string.Empty;
            try
            {
                System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                xmldoc.LoadXml(ReqXml);

                //获取版本号
                int VersionCode = Convert.ToInt32(xmldoc.SelectSingleNode("JTW91G/MsgData/DataBody/VersionCode").InnerText);

                //请求指令
                ReqCode = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/ReqCode").InnerText;
                if (!string.IsNullOrEmpty(ComFunction.UpdateFile))
                {
                    //FileVersionInfo myFileVersion = FileVersionInfo.GetVersionInfo(ComFunction.UpdateFile);
                    Apkinfo apkinfo = GetApkInfo();
                    if (apkinfo.versionCode <= VersionCode)
                    {
                        ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL035, ResCode.UL035Desc, string.Format("<DataBody></DataBody>"));
                    }
                    else
                    {
                        ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL036, ResCode.UL036Desc,
                            string.Format("<DataBody><UpdateAddr>{0}</UpdateAddr><PackageName>{1}</PackageName><VersionCode>{2}</VersionCode><VersionName>{3}</VersionName></DataBody>",
                            ComFunction.UpdateAddr, apkinfo.packageName, apkinfo.versionCode, apkinfo.versionName));
                    }
                }
                else
                {
                    ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL035, ResCode.UL035Desc, string.Format("<DataBody></DataBody>"));
                }
            }
            catch (Exception ex)
            {
                com.individual.helper.LogNet4.WriteErr(ex);

                //业务处理失败
                ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL005, ResCode.UL005Desc, string.Format("<DataBody></DataBody>"));
            }
            return ResXml;
        }
        public static List<string> GetSettings(string WMIClassName)
        {
            string xmlFilePath = System.IO.Directory.GetCurrentDirectory() + "\\MemorySettings.xml";
              List<string> alPropertyNames = new List<string>();
              System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
              xmldoc.Load(xmlFilePath);
              System.Xml.XmlNode properties = xmldoc.SelectSingleNode("//" + WMIClassName);

              for (int i = 0; i < properties.ChildNodes.Count; i++)
            alPropertyNames.Add(properties.ChildNodes[i].InnerText);
              return alPropertyNames;
        }
Ejemplo n.º 23
0
        internal static bool IsError(string xmlResponse, out string sMessage)
        {
            System.Xml.XmlDocument objXML = new System.Xml.XmlDocument();
            objXML.LoadXml(xmlResponse);
            System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(objXML.NameTable);
            nsmgr.AddNamespace("x", objXML.DocumentElement.NamespaceURI);
            sMessage = "";

            if (objXML.SelectSingleNode("/x:error/x:code", nsmgr) != null)
            {
                //System.Windows.Forms.MessageBox.Show(objXML.SelectSingleNode("/x:error/x:code", nsmgr).InnerText);
                sMessage = objXML.SelectSingleNode("/x:error/x:code", nsmgr).InnerText + ": " + objXML.SelectSingleNode("/x:error/x:message", nsmgr).InnerText;
                if (objXML.SelectSingleNode("/x:error/detail", nsmgr) !=null) {
                    //System.Windows.Forms.MessageBox.Show("here");
                    foreach (System.Xml.XmlNode node in objXML.SelectNodes("/x:error/x:detail/validationErrors")) {
                        sMessage += ": " + node.SelectSingleNode("validationError/message").InnerText;
                    }
                }
                return true;
            }

            return false;
        }
Ejemplo n.º 24
0
        private void myCallback(object obj)
        {
            System.Threading.Thread.CurrentThread.IsBackground = false;

            lock (syncLock)
            {
                if (flag)
                    return;

                i++;
                if (i > 10)
                {
                    flag = true;
                    timer.Dispose();
                }

                var path=AppDomain.CurrentDomain.BaseDirectory + "Config\\Data.xml";
                var doc = new System.Xml.XmlDocument();
                doc.Load(path);

                var node = doc.SelectSingleNode("/Thread/Time");
                node.InnerText = DateTime.Now.ToString();
                node = doc.SelectSingleNode("/Thread/ThreadId");
                node.InnerText = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString();
                node = doc.SelectSingleNode("/Thread/Counter");
                var counter = Int32.Parse(node.InnerText);
                node.InnerText = (++counter).ToString();

                doc.Save(path);

                Console.WriteLine(string.Format("Outer Now:i={0},Current Thread:{1}",
                    i, System.Threading.Thread.CurrentThread.ManagedThreadId));
            }
            //sleep current thread
            System.Threading.Thread.Sleep(500);
        }
Ejemplo n.º 25
0
 public string GetValue(string AppKey)
 {
     System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
     xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");
     System.Xml.XmlNode xNode;
     System.Xml.XmlElement xElem1;
     xNode = xDoc.SelectSingleNode("//appSettings");
     xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
     if (xElem1 != null)
     {
         return xElem1.GetAttribute("value");
     }
     else
         return "";
 }
Ejemplo n.º 26
0
        public bool Load(string file = "config.xml")
        {
            try
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                doc.Load(file);
                System.Xml.XmlNode root = doc.SelectSingleNode("root");
                m_solutions.Clear();
                foreach (System.Xml.XmlNode xls in root.SelectNodes("excel"))
                {
                    ExcelSolution solu = new ExcelSolution(this);
                    solu.name = xls.Attributes["name"].Value;
                    solu.path = xls.Attributes["path"].Value;

                    foreach (System.Xml.XmlNode layoutNode in xls.SelectNodes("layout"))
                    {
                        ExcelXMLLayout layout = new ExcelXMLLayout(solu);
                        layout.path = layoutNode.Attributes["path"].Value;
                        layout.sheet = layoutNode.Attributes["sheet"].Value;
                        layout.name = layoutNode.Attributes["name"].Value;
                        layout.summary = layoutNode.Attributes["summary"].Value;
                        layout.typed = bool.Parse(layoutNode.Attributes["typed"].Value);
                        try { layout.primary = layoutNode.Attributes["primary"].Value; }
                        catch (Exception) { }
                        try { layout.primaryComment = layoutNode.Attributes["primary-comment"].Value; }
                        catch (Exception) { }

                        foreach (System.Xml.XmlNode column in layoutNode.SelectNodes("column"))
                        {
                            layout.Add(
                                column.InnerText,
                                (ExcelXMLLayout.KeyType)Enum.Parse(typeof(ExcelXMLLayout.KeyType), column.Attributes["type"].Value)
                            );
                        }
                        solu.AddLayout(layout);
                    }

                    AddSolution(solu);
                }
                return true;
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err.Message);
            }
            return false;
        }
Ejemplo n.º 27
0
 internal static void ChangeSetting(string name, string value)
 {
     string configFileName = System.Windows.Forms.Application.ExecutablePath + ".config";
     var doc = new System.Xml.XmlDocument();
     doc.Load(configFileName);
     string configString =
         @"configuration/applicationSettings/Script_Text_Editor.Properties.Settings/setting[@name='"
         + name + "']/value";
     System.Xml.XmlNode configNode = doc.SelectSingleNode(configString);
     if (configNode != null)
     {
         configNode.InnerText = value;
         doc.Save(configFileName);
         // 刷新应用程序设置
         Properties.Settings.Default.Reload();
     }
 }
Ejemplo n.º 28
0
        public bool Patch() {
            string home = System.Web.HttpRuntime.AppDomainAppPath;
            System.IO.DirectoryInfo folder = new System.IO.DirectoryInfo(home);
            if (folder.Exists) 
            {
                string wildcard = "config." + this.GetEnvironment().ToString() + ".*.xml";
                System.IO.FileInfo[] files = folder.GetFiles(wildcard);
                System.Collections.Generic.List<string> section = new System.Collections.Generic.List<string>();

                string webConfigFilename = System.IO.Path.Combine(home, "Web.config");
                System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                xmlDoc.Load(webConfigFilename);

                bool changed = false;

                foreach (System.IO.FileInfo file in files)
                {
                    string webConfigSectionFilename = System.IO.Path.Combine(home, file.Name);

                    string[] filename = file.Name.Split('.');
                    for (int i = 2; i < filename.Length-1; i++)
                    {
                        section.Add(filename[i]);
                    }

                    System.Xml.XmlDocument xmlDocSection = new System.Xml.XmlDocument();

                    xmlDocSection.Load(webConfigSectionFilename);

                    string xPath = System.String.Join("/", section);
                    System.Xml.XmlNode node = xmlDoc.SelectSingleNode(xPath);

                    if (node != null && node.InnerXml != xmlDocSection.ChildNodes[1].InnerXml) {
                        node.InnerXml = xmlDocSection.ChildNodes[1].InnerXml;
                        changed = true;
                    }
                }
                if (changed)
                {
                    xmlDoc.Save(webConfigFilename);
                }
            }
            return true;
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
            System.Xml.XmlNode xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", value);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", key);
                xElem2.SetAttribute("value", value);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// WinForm更新App.config中,key对应的value,没有则添加
        /// </summary>
        /// <param name="appKey">key</param>
        /// <param name="appValue">value</param>
        public static void AddOrUpdate(string appKey, string appValue)
        {
            var xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            var xNode = xDoc.SelectSingleNode("//appSettings");
            if (xNode != null)
            {
                var xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + appKey + "']");
                if (xElem1 != null) xElem1.SetAttribute("value", appValue);
                else
                {
                    var xElem2 = xDoc.CreateElement("add");
                    xElem2.SetAttribute("key", appKey);
                    xElem2.SetAttribute("value", appValue);
                    xNode.AppendChild(xElem2);
                }
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 31
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            if (listViewProdukter.SelectedItems.Count > 1)
            {
                MessageBox.Show("Välj en produkt");
            }
            else if (listViewProdukter.SelectedItems.Count == 1)
            {
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(this.produkterF);

                //Use an XPath query to find a XmlNode
                System.Xml.XmlNode deleteContact =
                    doc.SelectSingleNode("descendant::produkt[pnamn='" + listViewProdukter.SelectedItems[0].Text + "']");

                //Remove the XmlNode from the Document
                doc.DocumentElement.RemoveChild(deleteContact);
                //Save the Document

                doc.Save(this.produkterF);
                listViewProdukter.SelectedItems[0].Remove();
            }
        }
Ejemplo n.º 32
0
        /// <summary>
        /// 根据Key修改Value
        /// </summary>
        /// <param name="key">要修改的Key</param>
        /// <param name="value">要修改为的值</param>
        public static void SetValue(string key, string value)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
            System.Xml.XmlNode    xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
            if (xElem1 != null)
            {
                xElem1.SetAttribute("value", value);
            }
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", key);
                xElem2.SetAttribute("value", value);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(HttpContext.Current.Server.MapPath("/XmlConfig/Config.xml"));
        }
Ejemplo n.º 33
0
        public void TestForAdminPackageOfWebDashboardIsEmpty()
        {
#if BUILD
            string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\Project\Webdashboard\dashboard.config");
#else
            string configFile = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), @"..\..\..\Webdashboard\dashboard.config");
#endif

            Assert.IsTrue(System.IO.File.Exists(configFile), "Dashboard.config not found at {0}", configFile);

            System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
            xdoc.Load(configFile);

            var adminPluginNode = xdoc.SelectSingleNode("/dashboard/plugins/farmPlugins/administrationPlugin");

            Assert.IsNotNull(adminPluginNode, "Admin package configuration not found in dashboard.config at {0}", configFile);

            var pwd = adminPluginNode.Attributes["password"];

            Assert.IsNotNull(pwd, "password attribute not defined in admin packackage in dashboard.config at {0}", configFile);

            Assert.AreEqual("", pwd.Value, "Password must be empty string, to force users to enter one. No default passwords allowed in distribution");
        }
Ejemplo n.º 34
0
        private void MyXml(Advisory.OpinionRow r, System.Xml.XmlDocument xd)
        {
            System.Xml.XmlElement xe = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@type='opinion' and @id=" + r.OpinionId.ToString() + "]");
            if (xe == null)
            {
                xe = xd.CreateElement("toc");
                xe.SetAttribute("type", "opinion");
            }
            xe.SetAttribute("id", r.OpinionId.ToString());

            //if(! r.IsOfficerCodeNull())
            //    xe.SetAttribute("assignedtocode",r.OfficerCode.ToString());

            string title = "";

            if (!r.IsNumberNull())
            {
                title = r.Number.ToString();
            }

            if (!r.IsCompletedDateNull())
            {
                title += "(" + atriumRes.OpinionCompletedDate + ": " + r.CompletedDate.ToString("yyyy/MM/dd") + ")";
            }
            else if (!r.IsRequestDateNull())
            {
                title += atriumRes.OpinionRequestDate + ": " + r.RequestDate.ToString("yyyy/MM/dd");
            }

            xe.SetAttribute("titlee", title);
            xe.SetAttribute("titlef", title);
            if (xe.ParentNode == null)
            {
                System.Xml.XmlElement xes = EFileBE.XmlAddFld(xd, "opinions", "Opinions", "Opinions", 150);
                xes.AppendChild(xe);
            }
        }
Ejemplo n.º 35
0
        public static void AddCustomParameter(string strFilename, string strParameterName, string strAppendAfterParameter, string strXmlFragment)
        {
            System.Xml.XmlDocument         doc   = XmlTools.File2XmlDocument(strFilename);
            System.Xml.XmlNamespaceManager nsmgr = GetReportNamespaceManager(doc);

            if (HasParameter(doc, strParameterName))
            {
                return;
            }


            System.Xml.XmlNode xnParameters = doc.SelectSingleNode("/dft:Report/dft:ReportParameters", nsmgr);

            if (xnParameters == null)
            {
                return;
            }


            bool bFirst = StringComparer.OrdinalIgnoreCase.Equals(strAppendAfterParameter, "first");
            bool bLast  = StringComparer.OrdinalIgnoreCase.Equals(strAppendAfterParameter, "last");


            System.Xml.XmlNode xnAppendAfterThis = null;

            if (bFirst || bLast)
            {
                xnAppendAfterThis = xnParameters;
            }
            else
            {
                xnAppendAfterThis = GetParameter(doc, strAppendAfterParameter);
            }


            AddCustomParameter(strFilename, xnAppendAfterThis, bFirst, bLast, strXmlFragment);
        } // End Function AddCustomParameter
Ejemplo n.º 36
0
        /// <summary>
        /// 写入,更新配置文件节点
        /// </summary>
        /// <param name="SectionName">节点名称</param>
        /// <parma name="key">键名</param>
        /// <parma name="value">键值</param>
        public static void SetConfigKeyValue(string SectionName, string key, string keyvalue)
        {
            //导入配置文件
            System.Xml.XmlDocument doc = loadConfigDocument();
            //重新取得 节点名
            System.Xml.XmlNode node = doc.SelectSingleNode("//" + SectionName);
            if (node == null)
            {
                throw new InvalidOperationException(SectionName + " section not found in config file.");
            }

            try
            {
                // 用 'add'元件 格式化是否包含键名
                // select the 'add' element that contains the key
                System.Xml.XmlElement elem = (System.Xml.XmlElement)node.SelectSingleNode(string.Format("//add[@key='{0}']", key));

                if (elem != null)
                {
                    //修改或添加键值
                    elem.SetAttribute("value", keyvalue);
                }
                else
                {
                    //如果没有发现键名则进行添加设置键名和键值
                    elem = doc.CreateElement("add");
                    elem.SetAttribute("key", key);
                    elem.SetAttribute("value", keyvalue);
                    node.AppendChild(elem);
                }
                doc.Save(getConfigFilePath());
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 37
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                dtConfig.AcceptChanges();

                string path = Application.ExecutablePath + ".config";
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();

                if (File.Exists(path))
                {
                    doc.Load(path);

                    foreach (DataRow row in dtConfig.Rows)
                    {
                        string configString = @"configuration/applicationSettings/" + DoService.pubService
                                              + ".Properties.Settings/setting[@name='" + row["ColumnTitle"].ToString() + "']/value";

                        System.Xml.XmlNode configNode = doc.SelectSingleNode(configString);
                        if (configNode != null)
                        {
                            configNode.InnerText = row["ColumnValue"].ToString();
                        }
                    }
                    doc.Save(path);
                    Properties.Settings.Default.Reload();
                }

                DoService.WriteEventLog(DoService.pubService + " Save Config Success!");
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                DoService.WriteEventLog(DoService.pubService + " Save Config Failed!" + ex.Message);
                this.DialogResult = DialogResult.Cancel;
            }
        }
Ejemplo n.º 38
0
        private void LoadBasicTree(string xml)
        {
            this.progressBar1.Value = 0;

            this.IncrementBar();
            treeView2.Nodes.Clear();
            Application.DoEvents();
            this.IncrementBar();
            Application.DoEvents();

            this.IncrementBar();
            Application.DoEvents();
            System.Xml.XmlDocument x = new System.Xml.XmlDocument();
            try
            {
                x.LoadXml(xml);
            }
            catch (Exception xexc)
            {
                Terminals.Logging.Error("Load Basic Tree Failed", xexc);
            }

            System.Xml.XmlNode            n    = x.SelectSingleNode("/tree");
            System.Windows.Forms.TreeNode root = new System.Windows.Forms.TreeNode();
            this.treeView2.Nodes.Add(root);
            Application.DoEvents();

            this.LoadNode(n, root);

            root.Expand();
            if (root.Nodes != null && root.Nodes.Count > 0)
            {
                root.Nodes[0].Expand();
            }

            this.progressBar1.Value = 0;
        }
Ejemplo n.º 39
0
        private static bool GenerateDfsFile(string fname, string dfspath, string dspacedir, ref string fpath)
        {
            string exe = Exec.GetQizmtExe();

            Exec.Shell(exe + @" del " + fname);
            Exec.Shell(exe + @" gen " + fname + " 100B");

            System.Xml.XmlDocument dfs = new System.Xml.XmlDocument();
            try
            {
                dfs.Load(dfspath);
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error loading dfs.xml: {0}", e.Message);
                return(false);
            }

            System.Xml.XmlNode fnode = dfs.SelectSingleNode(@"//DfsFile[Name='" + fname + @"']/Nodes/FileNode[1]");
            if (fnode == null)
            {
                Console.Error.WriteLine("File node of generated file not found in dfs.xml");
                return(false);
            }

            string name = fnode["Name"].InnerText;
            string host = fnode["Host"].InnerText.Split(';')[0];

            fpath = @"\\" + host + @"\" + dspacedir + name;

            if (!System.IO.File.Exists(fpath))
            {
                Console.Error.WriteLine("Cannot find the file that was just generated.");
                return(false);
            }
            return(true);
        }
Ejemplo n.º 40
0
        static void Main(string[] args)
        {
            string localConfigFile = @".\config\SourceMap.xml";

            try
            {
                if (System.IO.File.Exists(localConfigFile))
                {
                    System.Xml.XmlDocument xmlDocument = new System.Xml.XmlDocument();
                    xmlDocument.Load(localConfigFile);

                    System.Xml.XmlNode xmlNode = xmlDocument.SelectSingleNode("SourceMap/Map");

                    if (xmlNode.Attributes[0].Value != null)
                    {
                        //New object can be provided through a Dependency inject module.
                        ICreateGraph createGraph = new CreateGraph();
                        if (createGraph.CreateGraph(xmlNode.Attributes[0].Value))
                        {
                            DefineRoutes app = new DefineRoutes();
                            app.Start(createGraph);
                        }
                    }
                    else
                    {
                        throw new InvalidOperationException("Should have valid config. for Source Map");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading the config File, Exception: ", ex.Message);
            }
            Console.WriteLine("To exit the application press Any Key");
            Console.ReadKey();
        }
Ejemplo n.º 41
0
        private bool IsXpathMatched_xmlDoc(string fileName, string xpath)
        {
            bool   isMatched = false;
            string txt       = File.ReadAllText(fileName);

            System.Xml.XmlDocument xDoc = null;
            MatchCollection        mc   = null;

            if (string.IsNullOrEmpty(xpath))
            {
                return(_searchXML.IsMatch(txt));                             // if no present xpath - search XML
            }
            mc = _searchXML.Matches(txt);
            //if (mc.Count==0) return  false;
            for (int i = 0; i < mc.Count && isMatched == false; i++)
            {
                xDoc = new System.Xml.XmlDocument();
                try
                {
                    xDoc.LoadXml(mc[i].Value);
                }
                catch (System.Xml.XmlException)
                {
                    continue;
                }
                try
                {
                    isMatched = (xDoc != null && xDoc.SelectSingleNode(xpath) != null);
                }
                catch (System.Xml.XPath.XPathException ex)
                {
                    continue;
                }
            }
            return(isMatched);
        }
Ejemplo n.º 42
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (b_start.Content.ToString().Equals("Stop"))
            {
                b_start.Content = "Start";

                audio.sourceStream.StopRecording();

                foreach (var ip in vp.Values)
                {
                    if (ip.canRecord == true)
                    {
                        ip.Record_Click(null, null);
                    }
                }
                //writer.Close();
                //waveWriter.Close();
            }
            else
            {
                System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                document.Load(AppDomain.CurrentDomain.BaseDirectory + "\\UserSettings.xml");
                System.Xml.XmlNode Microphone = document.SelectSingleNode("UserProfile/Conference/Microphone");

                int           index       = 0;
                List <string> productName = audio.sources.Select(x => x.ProductName).ToList();

                index = productName.FindIndex(x => x == Microphone.InnerText);
                audio.init(index);
                //   waveWriter = new WaveFileWriter("test.wav",audio.sourceStream.WaveFormat);
                timer.Start();

                audio.sourceStream.StartRecording();
                b_start.Content = "Stop";
            }
        }
Ejemplo n.º 43
0
        public static void SetValue(string AppKey, string AppValue)
        {
            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            System.Xml.XmlNode    xNode;
            System.Xml.XmlElement xElem1;
            System.Xml.XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (System.Xml.XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
            if (xElem1 != null)
            {
                xElem1.SetAttribute("value", AppValue);
            }
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", AppKey);
                xElem2.SetAttribute("value", AppValue);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }
Ejemplo n.º 44
0
        //获取默认交易单据
        private Hashtable GetDefaultTransType()
        {
            Hashtable _ht = new Hashtable();

            try
            {
                string strFile             = this.MapPath("TransTypeMoStock.xml");
                System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
                doc.Load(strFile);
                System.Xml.XmlNode node = doc.SelectSingleNode(string.Format("//TransTypeName"));
                if (node != null)
                {
                    foreach (System.Xml.XmlNode _childnode in node.SelectNodes("TransType"))
                    {
                        _ht.Add(_childnode.Attributes["Code"].Value, _childnode.Attributes["Name"].Value);
                    }
                }
                node = null;
                doc  = null;
            }
            catch
            {}
            return(_ht);
        }
Ejemplo n.º 45
0
        public String AnalysisXml(string ReqXml)
        {
            string ResXml  = string.Empty;
            string ReqCode = string.Empty;

            try
            {
                System.Xml.XmlDocument xmldoc = new System.Xml.XmlDocument();
                xmldoc.LoadXml(ReqXml);

                //请求指令
                ReqCode = xmldoc.SelectSingleNode("JTW91G/MsgData/ReqHeader/ReqCode").InnerText;

                ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL007, ResCode.UL007Desc, string.Format("<DataBody></DataBody>"));
            }
            catch (Exception ex)
            {
                com.individual.helper.LogNet4.WriteErr(ex);

                //业务处理失败
                ResXml = GssResXml.GetResXml(ReqCode, ResCode.UL005, ResCode.UL005Desc, string.Format("<DataBody></DataBody>"));
            }
            return(ResXml);
        }
Ejemplo n.º 46
0
        public override void Install(System.Collections.IDictionary stateSaver)
        {
            base.Install(stateSaver);

            string targetDirectory     = Context.Parameters["targetdir"];
            string paramServiceAddress = Context.Parameters["Param1"];
            string paramLogFilePath    = Context.Parameters["Param2"];
            string paramPathToVLC      = Context.Parameters["Param3"];

            string paramZWaveConfigPath   = Context.Parameters["Param4"];
            string paramZWaveSerialPort   = Context.Parameters["Param5"];
            string paramZWavePollInterval = Context.Parameters["Param6"];


            // Make sure the baseAddress path ends with a slash
            if (paramServiceAddress.EndsWith("/") == false)
            {
                paramServiceAddress = String.Concat(paramServiceAddress, "/");
            }

            string path = System.IO.Path.Combine(targetDirectory, "Niviane_Service.exe.config");

            System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();

            xDoc.Load(path);

            System.Xml.XmlNode node;
            node           = xDoc.SelectSingleNode("/configuration/system.serviceModel/services/service/host/baseAddresses");
            node.InnerXml  = String.Concat("<add baseAddress=\"", paramServiceAddress, "\" />");
            node           = xDoc.SelectSingleNode("/configuration/userSettings/Niviane_Service.Properties.Settings/setting[@name='LogFilePath']/value");
            node.InnerText = paramLogFilePath;
            node           = xDoc.SelectSingleNode("/configuration/userSettings/Niviane_Service.Properties.Settings/setting[@name='VLCPathToExe']/value");
            node.InnerText = paramPathToVLC;

            node           = xDoc.SelectSingleNode("/configuration/userSettings/Niviane_Service.Properties.Settings/setting[@name='ZWaveConfigPath']/value");
            node.InnerText = paramZWaveConfigPath;
            node           = xDoc.SelectSingleNode("/configuration/userSettings/Niviane_Service.Properties.Settings/setting[@name='ZWaveSerialPort']/value");
            node.InnerText = paramZWaveSerialPort;
            node           = xDoc.SelectSingleNode("/configuration/userSettings/Niviane_Service.Properties.Settings/setting[@name='ZWavePollInterval']/value");
            node.InnerText = paramZWavePollInterval;

            xDoc.Save(path); // saves the config file
        }
Ejemplo n.º 47
0
        public FGDData Make(string filename)
        {
            System.Xml.XmlDocument myXmlDocument = new System.Xml.XmlDocument();
            myXmlDocument.Load(filename);
            System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(myXmlDocument.NameTable);
            nsmgr.AddNamespace("fgd", "http://fgd.gsi.go.jp/spec/2008/FGD_GMLSchema");
            nsmgr.AddNamespace("gml", "http://www.opengis.net/gml/3.2");
            nsmgr.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
            nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
            nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");

            return(new FGDData
                   (
                       Swap <float>(Split <float>(myXmlDocument.SelectSingleNode("/fgd:Dataset/fgd:DEM/fgd:coverage/gml:boundedBy/gml:Envelope/gml:lowerCorner", nsmgr).InnerText)),
                       Swap <float>(Split <float>(myXmlDocument.SelectSingleNode("/fgd:Dataset/fgd:DEM/fgd:coverage/gml:boundedBy/gml:Envelope/gml:upperCorner", nsmgr).InnerText)),
                       Split <int>(myXmlDocument.SelectSingleNode("/fgd:Dataset/fgd:DEM/fgd:coverage/gml:gridDomain/gml:Grid/gml:limits/gml:GridEnvelope/gml:low", nsmgr).InnerText),
                       Split <int>(myXmlDocument.SelectSingleNode("/fgd:Dataset/fgd:DEM/fgd:coverage/gml:gridDomain/gml:Grid/gml:limits/gml:GridEnvelope/gml:high", nsmgr).InnerText),
                       Split <int>(myXmlDocument.SelectSingleNode("/fgd:Dataset/fgd:DEM/fgd:coverage/gml:coverageFunction/gml:GridFunction/gml:startPoint", nsmgr).InnerText),
                       SplitStrings(myXmlDocument.SelectSingleNode("/fgd:Dataset/fgd:DEM/fgd:coverage/gml:rangeSet/gml:DataBlock/gml:tupleList", nsmgr).InnerText)
                   ));
        }
Ejemplo n.º 48
0
        /// <summary>
        /// Fp格式设置
        /// </summary>
        /// <returns></returns>
        private int GetFpSetting(bool isDetail)
        {
            if (this.hsFpPathConfig.ContainsKey(this.privIndex))
            {
                System.Xml.XmlDocument hsDoc = this.hsFpPathConfig[this.privIndex] as System.Xml.XmlDocument;

                if (!isDetail)
                {
                    frmSetConfig.SetFpByConfig(this.neuSpread1_Sheet1, hsDoc);
                }
                else
                {
                    frmSetConfig.SetFpByConfig(this.neuSpread2_Sheet1, hsDoc);
                }

                return(1);
            }

            string pathName = "";

            if (this.hsSqlFpPath.ContainsKey(this.privIndex))
            {
                pathName = this.hsSqlFpPath[this.privIndex] as string;

                if (pathName.IndexOf(".xml") == -1)
                {
                    pathName = pathName + ".xml";
                }
            }
            else
            {
                return(-1);
            }

            #region 获取配置文件路径

            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.Load(Application.StartupPath + "\\url.xml");

            System.Xml.XmlNode node = doc.SelectSingleNode("//dir");
            if (node == null)
            {
                MessageBox.Show(Language.Msg("url中找dir结点出错!"));
                return(-1);
            }

            this.serverPath = node.InnerText;

            this.configPath = "FpSetting/" + pathName; //远程配置文件名

            #endregion

            try
            {
                doc.Load(serverPath + configPath);

                if (!isDetail)
                {
                    frmSetConfig.SetFpByConfig(this.neuSpread1_Sheet1, doc);
                }
                else
                {
                    frmSetConfig.SetFpByConfig(this.neuSpread2_Sheet1, doc);
                }

                this.hsFpPathConfig.Add(this.privIndex, doc);
            }
            catch (Exception ex)
            {
                MessageBox.Show(Language.Msg("装载HisProfile.xml失败!\n" + ex.Message));
                return(-1);
            }

            return(1);
        }
Ejemplo n.º 49
0
        public void LoadXML(string xml)
        {
            var doc = new System.Xml.XmlDocument();

            doc.LoadXml(xml);

            Name = doc.SelectSingleNode("Output/Name").InnerText;
            Boolean.TryParse(doc.SelectSingleNode("Output/Enabled").InnerText, out Enabled);
            Int32.TryParse(doc.SelectSingleNode("Output/MidiChannel").InnerText, out MidiChannel);
            Int32.TryParse(doc.SelectSingleNode("Output/CCNumber").InnerText, out CCNumber);
            Boolean.TryParse(doc.SelectSingleNode("Output/IsNote").InnerText, out IsNote);
            Boolean.TryParse(doc.SelectSingleNode("Output/FilterEnabled").InnerText, out FilterEnabled);


            double fMin   = 0.0;
            var    parsed = Double.TryParse(doc.SelectSingleNode("Output/FilterMin").InnerText, out fMin);

            if (parsed)
            {
                FilterMin = fMin;
            }
            else
            {
                FilterMin = null;
            }

            double fMax = 0.0;

            parsed = Double.TryParse(doc.SelectSingleNode("Output/FilterMax").InnerText, out fMax);
            if (parsed)
            {
                FilterMax = fMax;
            }
            else
            {
                FilterMax = null;
            }

            var veloMap = doc.SelectSingleNode("Output/VelocityMap").OuterXml;

            VelocityMap = (VelocityMap)Serializer.DeserializeToXML(veloMap, typeof(VelocityMap));

            var Signals = Brain.KB.Sources.GetAllSignals();
            var Events  = Brain.KB.Sources.GetAllEvents();

            try
            {
                var nodeName  = doc.SelectSingleNode("Output/Signal/Name");
                var nodeOwner = doc.SelectSingleNode("Output/Signal/Owner");
                if (nodeName != null && nodeOwner != null)
                {
                    Signal = Signals.First(
                        x => x.Name == doc.SelectSingleNode("Output/Signal/Name").InnerText&&
                        x.Owner.ChannelName == doc.SelectSingleNode("Output/Signal/Owner").InnerText
                        );
                }
            }
            catch (Exception e)
            {
                Brain.KB.ShowError("Unable to load signal "
                                   + doc.SelectSingleNode("Output/Signal/Name").InnerText
                                   + " from channel "
                                   + doc.SelectSingleNode("Output/Signal/Owner").InnerText);
            }

            try
            {
                var nodeName  = doc.SelectSingleNode("Output/Filter/Signal/Name");
                var nodeOwner = doc.SelectSingleNode("Output/Filter/Signal/Owner");
                if (nodeName != null && nodeOwner != null)
                {
                    Filter = Signals.First(
                        x => x.Name == doc.SelectSingleNode("Output/Filter/Signal/Name").InnerText&&
                        x.Owner.ChannelName == doc.SelectSingleNode("Output/Filter/Signal/Owner").InnerText
                        );
                }
            }
            catch (Exception e)
            {
                Brain.KB.ShowError("Unable to load signal "
                                   + doc.SelectSingleNode("Output/Filter/Signal/Name").InnerText
                                   + " from channel "
                                   + doc.SelectSingleNode("Output/Filter/Signal/Owner").InnerText);
            }

            try
            {
                var nodeName  = doc.SelectSingleNode("Output/Event/Name");
                var nodeOwner = doc.SelectSingleNode("Output/Event/Owner");
                if (nodeName != null && nodeOwner != null)
                {
                    Event = Events.First(
                        x => x.Name == doc.SelectSingleNode("Output/Event/Name").InnerText&&
                        x.Owner.ChannelName == doc.SelectSingleNode("Output/Event/Owner").InnerText
                        );
                }
            }
            catch (Exception e)
            {
                Brain.KB.ShowError("Unable to load event "
                                   + doc.SelectSingleNode("Output/Event/Name").InnerText
                                   + " from channel "
                                   + doc.SelectSingleNode("Output/Event/Owner").InnerText);
            }

            var xtalkSignals = doc.SelectNodes("Output/CrosstalkSignals");

            if (xtalkSignals == null)
            {
                return;
            }

            for (int i = 0; i < xtalkSignals.Count; i++)
            {
                var signal = xtalkSignals[i];

                try
                {
                    var nodeName   = signal.SelectSingleNode("Crosstalk/Signal/Name");
                    var nodeOwner  = signal.SelectSingleNode("Crosstalk/Signal/Owner");
                    var nodeFactor = signal.SelectSingleNode("Crosstalk/Factor");

                    if (nodeName != null && nodeOwner != null && nodeFactor != null)
                    {
                        var sig = Signals.First(
                            x => x.Name == signal.SelectSingleNode("Crosstalk/Signal/Name").InnerText&&
                            x.Owner.ChannelName == signal.SelectSingleNode("Crosstalk/Signal/Owner").InnerText
                            );

                        double factor = Convert.ToDouble(signal.SelectSingleNode("Crosstalk/Factor").InnerText);
                        CrosstalkSignals.Add(new Crosstalk(sig, factor));
                    }
                }
                catch (Exception e)
                {
                    Brain.KB.ShowError("Unable to load signal "
                                       + signal.SelectSingleNode("Crosstalk/Signal/Name").InnerText
                                       + " from channel "
                                       + signal.SelectSingleNode("Crosstalk/Signal/Owner").InnerText);
                }
            }
        }
Ejemplo n.º 50
0
        private static void GetSplitConfig()
        {
            var config = new System.Xml.XmlDocument();

            config.Load(_configPath);

            var split = config.SelectSingleNode("/config/split");

            if (split == null)
            {
                throw new Exception("No <split> element defined in config.");
            }

            if (split.Attributes["type"] == null || split.Attributes["size"] == null)
            {
                throw new Exception("type, size, directoryname attributes were not defined for <split> element in config");
            }

            //get config
            switch (split.Attributes["type"].Value.ToLower())
            {
            case "elementcount":
                _splitType = ESplitType.ElementCount;
                break;

            case "filesize":
                _splitType = ESplitType.Filesize;
                break;

            default:
                throw new Exception("Unrecognized split type --> must be elementcount or filesize");
            }

            if (!int.TryParse(split.Attributes["size"].Value, out _splitSize))
            {
                throw new Exception("size attribute not integer value");
            }

            //now all config parameters obtained need to:
            //1) create a folder to place all of the chunks of origial data
            //2) find the folder for the output and name appropriately for each one

            if (split.Attributes["inputdirectoryname"] != null)
            {
                _inputDirectoryName = split.Attributes["inputdirectoryname"].Value;
            }
            if (split.Attributes["outputdirectoryname"] != null)
            {
                _outputDirectoryName = split.Attributes["outputdirectoryname"].Value;
            }
            if (split.Attributes["filesuffix"] != null)
            {
                _fileSuffixXpath = split.Attributes["filesuffix"].Value;
            }

            //input chunks folder - get the folder of the _dataPath
            FileInfo _dataFileInfo = new FileInfo(_dataPath);

            //_inputChunkingFolder =  _dataFileInfo.Directory.FullName + "\\" + _inputDirectoryName;
            _inputChunkingFolder = Path.Combine(_dataFileInfo.Directory.FullName, _inputDirectoryName);

            Directory.CreateDirectory(_inputChunkingFolder);

            //rdf output chunks folder - get the folder of the _outputPath
            _outputChunkingFolder = Path.Combine(_outputPath, _outputDirectoryName);
            Directory.CreateDirectory(_outputChunkingFolder);
        }
Ejemplo n.º 51
0
        /// <summary>
        /// Downloads the Android SDK
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="destinationDirectory">Destination directory, or ./tools/androidsdk if none is specified.</param>
        /// <param name="specificVersion">Specific version, or latest if none is specified.</param>
        public async Task DownloadSdk(DirectoryInfo destinationDirectory = null, string specificVersion = null, Action <int> progressHandler = null)
        {
            if (destinationDirectory == null)
            {
                destinationDirectory = AndroidSdkHome;
            }

            if (destinationDirectory == null)
            {
                throw new DirectoryNotFoundException("Android SDK Directory Not specified.");
            }

            if (!destinationDirectory.Exists)
            {
                destinationDirectory.Create();
            }

            var http = new HttpClient();

            http.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml");
            http.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate");
            http.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");
            http.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "ISO-8859-1");

            string platformStr;

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                platformStr = "win";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                platformStr = "mac";
            }
            else
            {
                platformStr = "linux";
            }

            // Use the default known version
            string sdkUrl = "";

            if (string.IsNullOrWhiteSpace(specificVersion))
            {
                try
                {
                    var data = await http.GetStringAsync(REPOSITORY_URL);

                    var xdoc = new System.Xml.XmlDocument();
                    xdoc.LoadXml(data);

                    var urlNode = xdoc.SelectSingleNode($"//remotePackage[@path='cmdline-tools;{ANDROID_SDKMANAGER_DEFAULT_ACQUIRE_VERSION}']/archives/archive/complete/url[contains(text(),'{platformStr}')]");

                    sdkUrl = REPOSITORY_URL_BASE + urlNode.InnerText;
                }
                catch
                {
                }
            }
            else
            {
                // User passed a specific version to use
                sdkUrl = string.Format(REPOSITORY_SDK_PATTERN, platformStr, specificVersion);
            }

            if (string.IsNullOrWhiteSpace(sdkUrl))
            {
                sdkUrl = string.Format(REPOSITORY_SDK_PATTERN, platformStr, REPOSITORY_SDK_DEFAULT_VERSION);
            }


            var sdkDir = new DirectoryInfo(destinationDirectory.FullName);

            if (!sdkDir.Exists)
            {
                sdkDir.Create();
            }

            var sdkZipFile = new FileInfo(Path.Combine(destinationDirectory.FullName, "androidsdk.zip"));


            if (!sdkZipFile.Exists)
            {
                int prevProgress = 0;
                var webClient    = new System.Net.WebClient();

                webClient.DownloadProgressChanged += (s, e) =>
                {
                    var progress = e.ProgressPercentage;

                    if (progress > prevProgress)
                    {
                        progressHandler?.Invoke(progress);
                    }

                    prevProgress = progress;
                };
                await webClient.DownloadFileTaskAsync(sdkUrl, sdkZipFile.FullName);
            }

            ZipFile.ExtractToDirectory(sdkZipFile.FullName, sdkDir.FullName);
        }
Ejemplo n.º 52
0
        public string Upload(ref string filePath, ref string message, long reply_to, bool isDraft, TweenMain owner)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return("Err:File isn't specified.");
            }
            if (string.IsNullOrEmpty(message))
            {
                message = "";
            }

            FileInfo mediaFile;

            try
            {
                mediaFile = new FileInfo(filePath);
            }
            catch (NotSupportedException ex)
            {
                return("Err:" + ex.Message);
            }
            if (mediaFile == null || !mediaFile.Exists)
            {
                return("Err:File isn't exists.");
            }

            string         content = "";
            HttpStatusCode ret;

            // img.lyへの投稿
            try
            {
                ret = this.UploadFile(mediaFile, message, ref content);
            }
            catch (Exception ex)
            {
                return("Err:" + ex.Message);
            }

            string url = "";

            if (ret == HttpStatusCode.OK)
            {
                XmlDocument xd = new XmlDocument();
                try
                {
                    xd.LoadXml(content);
                    // URLの取得
                    url = xd.SelectSingleNode("/image/url").InnerText;
                }
                catch (XmlException ex)
                {
                    return("Err:" + ex.Message);
                }
                catch (Exception ex)
                {
                    return("Err:" + ex.Message);
                }
            }
            else
            {
                return("Err:" + ret.ToString());
            }
            // アップロードまでは成功
            filePath = "";
            if (string.IsNullOrEmpty(url))
            {
                url = "";
            }
            // Twitterへの投稿
            // 投稿メッセージの再構成
            if (string.IsNullOrEmpty(message))
            {
                message = "";
            }
            if (message.Length + AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia + 1 > 140)
            {
                message = message.Substring(0, 140 - AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia - 1) + " " + url;
            }
            else
            {
                message += " " + url;
            }

            return(tw.PostStatusRetry(message, reply_to, isDraft, owner));
        }
Ejemplo n.º 53
0
        private void MyXml(atriumDB.FileContactRow fcr, System.Xml.XmlDocument xd)
        {
            try
            {
                //JLL: MODIFIED 2009/07/24: take FileContact.Active into account - remove where not active
                bool removeNode = false;
                if (!fcr.HideInToc)
                {
                    System.Xml.XmlElement xe = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@supertype='contact' and @id=" + fcr.FileContactid.ToString() + "]");

                    if (!fcr.Active)
                    {
                        removeNode = true;
                    }
                    else if (xe == null)
                    {
                        xe = xd.CreateElement("toc");
                        xe.SetAttribute("supertype", "contact");
                    }


                    if (removeNode)
                    {
                        RemoveFileContactFromXML(xe);
                    }
                    else
                    {
                        xe.SetAttribute("id", fcr.FileContactid.ToString());
                        //if (fcr.IsLastNameNull())
                        //{
                        //    xe.SetAttribute("titlee", String.Format(atriumRes.FileContactXmlTitle + " (" + fcr.ContactTypeDescEng.ToString() + ")", fcr.LegalName, ""));
                        //    xe.SetAttribute("titlef", String.Format(atriumRes.FileContactXmlTitle + " (" + fcr.ContactTypeDescFre.ToString() + ")", fcr.LegalName, ""));
                        //}
                        //else
                        //{
                        //    xe.SetAttribute("titlee", String.Format(atriumRes.FileContactXmlTitle + " (" + fcr.ContactTypeDescEng.ToString() + ")", fcr.LastName, fcr.FirstName));
                        //    xe.SetAttribute("titlef", String.Format(atriumRes.FileContactXmlTitle + " (" + fcr.ContactTypeDescFre.ToString() + ")", fcr.LastName, fcr.FirstName));
                        //}

                        xe.SetAttribute("titlee", String.Format(atriumRes.FileContactXmlTitle + " (" + fcr.ContactTypeDescEng.ToString() + ")", fcr.DisplayName, ""));
                        xe.SetAttribute("titlef", String.Format(atriumRes.FileContactXmlTitle + " (" + fcr.ContactTypeDescFre.ToString() + ")", fcr.DisplayName, ""));

                        if (fcr.ContactType == "FDB")
                        {
                            CLAS.DebtorRow debtor = myA.GetCLASMng().GetDebtor().CurrentDebtor;

                            xe.SetAttribute("type", "opponent");
                            //check for Contact/Notes
                            if (debtor != null && !debtor.IsNotesNull())
                            {
                                //tweek title
                                xe.SetAttribute("titlee", "*** " + xe.GetAttribute("titlee") + " ***");
                                xe.SetAttribute("titlef", "*** " + xe.GetAttribute("titlef") + " ***");
                                xe.SetAttribute("bold", "true");
                                xe.SetAttribute("tooltipe", "There are notes");
                                xe.SetAttribute("tooltipf", "Il y a des notes");
                            }
                            else
                            {
                                xe.SetAttribute("bold", "false");
                                xe.SetAttribute("tooltipe", "");
                                xe.SetAttribute("tooltipf", "");
                            }
                            //2014-06-11
                            //JLL
                            //calculate address country to determine icon
                            //assumes data is already loaded
                            //DOES NOT WORK WHEN OPENING A FILE; CONTACT ROW IS NULL ... ARG
                            if (debtor != null && !debtor.IsAddressCurrentIDNull())
                            {
                                atriumDB.AddressRow dbAddress = myA.DB.Address.FindByAddressId(debtor.AddressCurrentID);
                                if (dbAddress != null)
                                {
                                    string country = dbAddress.CountryCode;
                                    switch (country)
                                    {
                                    case "CDN":
                                        xe.SetAttribute("icon", "34");
                                        break;

                                    case "USA":
                                        xe.SetAttribute("icon", "35");
                                        break;

                                    default:
                                        xe.SetAttribute("icon", "36");
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            xe.SetAttribute("type", "contact");
                        }

                        if (xe.GetAttribute("isParticipant") != "true" && !fcr.IsOfficeIdNull())
                        {
                            xe.SetAttribute("icon", "43"); //atrium officer; not necessarily a user
                        }
                        if (xe.ParentNode == null)
                        {
                            System.Xml.XmlElement xes = null;
                            if (fcr.IsOfficeIdNull())
                            {
                                xes = EFileBE.XmlAddFld(xd, "basecontacts", "Contacts", "Contacts", 210);
                                xes.AppendChild(xe);
                            }
                            else
                            {
                                System.Xml.XmlElement xe1 = (System.Xml.XmlElement)xd.SelectSingleNode("//toc[@type='fileoffice' and @officeid=" + fcr.OfficeId.ToString() + "]");
                                if (xe1 != null)
                                {
                                    xe1.AppendChild(xe);
                                }
                                else
                                {
                                    xes = EFileBE.XmlAddFld(xd, "basecontacts", "Contacts", "Contacts", 210);
                                    xes.AppendChild(xe);
                                }
                                //xes.AppendChild(xe);

                                //xes = EFileBE.XmlAddFld(xe1, "contacts", "Contacts", "Contacts", 320);
                                //else

                                //{
                                //JLL: Bug 2009/07/24
                                //When new contact is added through process (CM03.02), and no File Office record is present,
                                // it sticks File Contact record on first "contact" match on filestructxml document
                                //    xes = EFileBE.XmlAddFld(xd, "contacts", "Contacts", "Contacts", 320);
                                //}
                            }
                            //xes.AppendChild(xe);
                        }
                    }
                }
            }
            catch (Exception x)
            { }
        }
Ejemplo n.º 54
0
        private void cxBtnOk_Click(object sender, EventArgs e)
        {
            string sSQLServOldPwd, sSQLServNewPwd;

            if (cxTextEditOldPwd.EditValue == null || Convert.ToString(cxTextEditOldPwd.EditValue).Trim() == "")
            {
                oSecMainFrm.MessageDlg("Old Password cannot be blank...", "mtWarning", "mbOk", 0);
                return;
            }
            if (cxTextEditNewPwd.EditValue == null || Convert.ToString(cxTextEditNewPwd.EditValue).Trim() == "")
            {
                oSecMainFrm.MessageDlg("Please enter the new password.", "mtWarning", "mbOk", 0);
                return;
            }
            if (cxTextEditConfirmPwd.EditValue == null || Convert.ToString(cxTextEditConfirmPwd.EditValue).Trim() == "")
            {
                oSecMainFrm.MessageDlg("Please enter the confirm password.", "mtWarning", "mbOk", 0);
                return;
            }

            try
            {
                sSQLServOldPwd = XpedeonCrypto.XpedeonServerDecrypt(PCFSecurity.oSecDM.sSuperUserPassword);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (!Convert.ToString(cxTextEditOldPwd.EditValue).Equals(sSQLServOldPwd, StringComparison.InvariantCulture))
            {
                oSecMainFrm.MessageDlg("Old Password does not match.", "mtWarning", "mbOk", 0);
                return;
            }
            if (Convert.ToString(cxTextEditNewPwd.EditValue) != Convert.ToString(cxTextEditConfirmPwd.EditValue))
            {
                oSecMainFrm.MessageDlg("New Password and Confirm Password dont match.", "mtWarning", "mbOk", 0);
                return;
            }

            try
            {
                sSQLServNewPwd = XpedeonCrypto.XpedeonServerEncrypt(Convert.ToString(cxTextEditNewPwd.EditValue));
                UpdateSQLServPassword(Convert.ToString(cxTextEditUserName.EditValue), Convert.ToString(cxTextEditNewPwd.EditValue), Convert.ToString(cxTextEditOldPwd.EditValue));

                string sAppPath = Application.StartupPath.ToString();
                System.Xml.XmlDocument xdDataBaseConnection = new System.Xml.XmlDocument();
                xdDataBaseConnection.Load(@sAppPath + "\\PCFSecurityAccessInfo.xml");
                if (xdDataBaseConnection.GetElementsByTagName("PASSWORD").Count > 0)
                {
                    // Get the target node using XPath
                    System.Xml.XmlNode xnOldPwd = xdDataBaseConnection.SelectSingleNode("//PASSWORD");
                    // Create a new comment node with XML content of the target node
                    System.Xml.XmlComment xcOldPwd = xdDataBaseConnection.CreateComment(xnOldPwd.OuterXml);
                    // Replace the target node with the comment
                    xdDataBaseConnection.DocumentElement.ReplaceChild(xcOldPwd, xnOldPwd);

                    // Create a new node
                    System.Xml.XmlElement xeNewPwd = xdDataBaseConnection.CreateElement("PASSWORD");
                    xeNewPwd.InnerText = sSQLServNewPwd;
                    // Add the node to the document
                    xdDataBaseConnection.DocumentElement.AppendChild(xeNewPwd);
                }
                xdDataBaseConnection.Save(@sAppPath + "\\PCFSecurityAccessInfo.xml");

                PCFSecurity.oSecDM.DataModuleCreate();

                oSecMainFrm.MessageDlg("Password Changed Successfully.", "mtConfirmation", "mbOk", 0);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 55
0
        internal void DownloadUpdatesInformation()
        {
            this.Updater.Progress.ChangeStatus("Descargando información de versiones de " + this.Name);

            if (this.Files == null)
            {
                this.Files = new FileCollection();
            }

            try {
                using (WebClient Cliente = new WebClient()) {
                    Cliente.Encoding = System.Text.Encoding.UTF8;
                    string VerFileUrl  = this.GetFullUrl() + this.Name + ".ver";
                    byte[] VersionInfo = Cliente.DownloadData(VerFileUrl + "?dm=" + new Random().Next().ToString());

                    System.Xml.XmlDocument ArchivoVer = new System.Xml.XmlDocument();
                    System.IO.MemoryStream ms         = new System.IO.MemoryStream(VersionInfo);
                    ArchivoVer.Load(ms);

                    System.Xml.XmlNodeList PackageList = ArchivoVer.GetElementsByTagName("Package");
                    foreach (System.Xml.XmlNode Pkg in PackageList)
                    {
                        string             PkgName = Pkg.Attributes["name"].Value;
                        System.Xml.XmlNode Comp    = ArchivoVer.SelectSingleNode("/VersionInfo/Package[@name='" + PkgName + "']");
                        foreach (System.Xml.XmlNode FileVers in Comp.ChildNodes)
                        {
                            if (FileVers.Name == "File")
                            {
                                if (FileVers.Attributes["name"] != null && FileVers.Attributes["name"].Value != null)
                                {
                                    File   FileVersionInfo;
                                    string FileName = FileVers.Attributes["name"].Value;
                                    if (this.Files.ContainsKey(FileName))
                                    {
                                        // Ya existe en la lista de archivos
                                        FileVersionInfo = this.Files[FileName];
                                    }
                                    else
                                    {
                                        // Lo agrego
                                        FileVersionInfo = new File(this);
                                        this.Files.Add(FileVersionInfo);
                                    }
                                    FileVersionInfo.Name = FileName;
                                    DateTime Fecha;
                                    try {
                                        DateTime.TryParseExact(FileVers.Attributes["version"].Value, Lfx.Types.Formatting.DateTime.SqlDateTimeFormat, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeUniversal | System.Globalization.DateTimeStyles.AllowWhiteSpaces, out Fecha);
                                    } catch {
                                        Fecha = DateTime.MinValue;
                                    }
                                    FileVersionInfo.NewVersion = Fecha;

                                    if (FileVers.Attributes["compression"] != null && FileVers.Attributes["compression"].Value != null)
                                    {
                                        switch (FileVers.Attributes["compression"].Value)
                                        {
                                        case "none":
                                        case "":
                                            FileVersionInfo.Compression = CompressionFormats.None;
                                            break;

                                        case "bz2":
                                            FileVersionInfo.Compression = CompressionFormats.Bz2;
                                            break;

                                        default:
                                            FileVersionInfo.Compression = CompressionFormats.OtherUnsupported;
                                            break;
                                        }
                                    }
                                    if (FileVers.Attributes["size"] != null && FileVers.Attributes["size"].Value != null)
                                    {
                                        FileVersionInfo.NewSize = int.Parse(FileVers.Attributes["size"].Value);
                                    }
                                    if (FileVers.Attributes["compsize"] != null && FileVers.Attributes["compsize"].Value != null)
                                    {
                                        FileVersionInfo.NewCompSize = int.Parse(FileVers.Attributes["compsize"].Value);
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                // No pude descargar
                System.Console.WriteLine("Updater: " + ex.Message);
            }
        }
Ejemplo n.º 56
0
        /// <summary>
        /// For given Hyper-V guest it enumerate all associated VHD files using WMI data
        /// </summary>
        /// <param name="vmID">ID of VM to get paths for</param>
        /// <returns>A collection of VHD paths</returns>
        private List <string> GetVMVhdPathsWMI(string vmID)
        {
            var result = new List <string>();

            using (var vm = new ManagementObjectSearcher(_wmiScope, new ObjectQuery(string.Format("select * from Msvm_ComputerSystem where Name = '{0}'", vmID)))
                            .Get().OfType <ManagementObject>().First())
            {
                foreach (var sysSettings in vm.GetRelated("MsVM_VirtualSystemSettingData"))
                {
                    using (var systemObjCollection = ((ManagementObject)sysSettings).GetRelated(_wmiv2Namespace ? "MsVM_StorageAllocationSettingData" : "MsVM_ResourceAllocationSettingData"))
                    {
                        List <string> tempvhd;

                        if (_wmiv2Namespace)
                        {
                            tempvhd = (from ManagementBaseObject systemBaseObj in systemObjCollection
                                       where ((UInt16)systemBaseObj["ResourceType"] == 31 &&
                                              (string)systemBaseObj["ResourceSubType"] == "Microsoft:Hyper-V:Virtual Hard Disk")
                                       select((string[])systemBaseObj["HostResource"])[0]).ToList();
                        }
                        else
                        {
                            tempvhd = (from ManagementBaseObject systemBaseObj in systemObjCollection
                                       where ((UInt16)systemBaseObj["ResourceType"] == 21 &&
                                              (string)systemBaseObj["ResourceSubType"] == "Microsoft Virtual Hard Disk")
                                       select((string[])systemBaseObj["Connection"])[0]).ToList();
                        }

                        foreach (var vhd in tempvhd)
                        {
                            result.Add(vhd);
                        }
                    }
                }
            }

            using (var imgMan = new ManagementObjectSearcher(_wmiScope, new ObjectQuery("select * from MsVM_ImageManagementService")).Get().OfType <ManagementObject>().First())
            {
                var ParentPaths = new List <string>();
                var inParams    = imgMan.GetMethodParameters(_wmiv2Namespace ? "GetVirtualHardDiskSettingData" : "GetVirtualHardDiskInfo");

                foreach (var vhdPath in result)
                {
                    inParams["Path"] = vhdPath;
                    using (var outParams = imgMan.InvokeMethod(_wmiv2Namespace ? "GetVirtualHardDiskSettingData" : "GetVirtualHardDiskInfo", inParams, null))
                    {
                        if (outParams != null)
                        {
                            var doc = new System.Xml.XmlDocument();
                            doc.LoadXml((string)outParams[_wmiv2Namespace ? "SettingData" : "Info"]);
                            var node = doc.SelectSingleNode("//PROPERTY[@NAME = 'ParentPath']/VALUE/child::text()");

                            if (node != null && File.Exists(node.Value))
                            {
                                ParentPaths.Add(node.Value);
                            }
                        }
                    }
                }

                result.AddRange(ParentPaths);
            }

            return(result);
        }
Ejemplo n.º 57
0
        public static void Main(string[] args)
        {
            //SCHROTT, nicht nachmachen :D
            //Ja NIEMALS

            string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + @"\AccountSchrott.xml";

            if (!File.Exists(path))
            {
                string XmlText = (
                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + Environment.NewLine +
                    "<accounts>" + Environment.NewLine +
                    "<account name=\"UserName\" password=\"Password\" server=\"uni###.ogame.de\" />" + Environment.NewLine +
                    "</accounts>");
                File.WriteAllText(path, XmlText);
                Console.WriteLine("Bitte zuerst deine " + path + " bearbeiten! Drücke eine Taste zum fortfahren...");
                Console.ReadKey();
            }

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.Load("AccountSchrott.xml");
            System.Xml.XmlNode accNode = xmlDoc.SelectSingleNode("//account[@name]");
            //SCHROTT ENDE

            FROHGAME.Core.FrohgameSession session = new FROHGAME.Core.FrohgameSession(accNode.Attributes ["name"].Value, accNode.Attributes ["password"].Value, accNode.Attributes ["server"].Value);

            //session.HttpHandler.Proxy = "127.0.0.1:8888";
            session.Logger.OnStringLogged    += new FROHGAME.Logger.OnLoggedStringDelegate(Logger_OnStringLogged);
            session.HttpHandler.OnNavigating += new FROHGAME.Http.HttpHandler.OnNavigatingDelegate(HttpHandler_OnNavigating);
            session.HttpHandler.OnNavigated  += new FROHGAME.Http.HttpHandler.OnNavigatedDelegate(HttpHandler_OnNavigated);


            session.Calculator.CalculateCosts((int)FROHGAME.Core.SupplyBuildings.Metalmine, 12);
            Console.ReadKey();
            session.Login();

            string str = (
                "METALL: " + session.Metal + " - " + session.MetalPerHour + "/h" +
                " - KRISTALL: " + session.Crystal + " - " + session.CrystalPerHour + "/h" +
                " - DEUTERIUM: " + session.Deuterium + " - " + session.DeuteriumPerHour + "/h" +
                " - DUNKLE MATERIE: " + session.DarkMatter +
                " - ENERGIE: " + session.Energy);

            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine(str);

            Console.WriteLine("PLANETEN:");
            foreach (FROHGAME.Core.Planet p in session.PlanetList)
            {
                Console.WriteLine("PLANET: " + p.Name + " - " + p.Id + " - [" + p.Coords.Galaxy.ToString() + ":" + p.Coords.SunSystem.ToString() + ":" + p.Coords.Place.ToString() + "]");
            }

            //Zeit bis 100.000 Metall:
            string time = FROHGAME.Core.Mathemathics.CalcMaxTimeForRes(
                session.Metal,
                session.Crystal,
                session.Deuterium,
                2000, 0, 0,
                session.MetalPerHour,
                session.CrystalPerHour,
                session.DeuteriumPerHour).ToString();

            //int time = FROHGAME.Core.Mathemathics.CalcTimeForRes(100000, session.Metal, session.MetalPerHour);

            //test

            Console.WriteLine("TIME: " + time);

            session.NagivateToIndexPage(FROHGAME.Core.IndexPages.Resources);
            System.Collections.Generic.Dictionary <FROHGAME.Core.SupplyBuildings, int> levels = session.SupplyBuildingLevels;

            Console.WriteLine("Metallmine level: " + levels[FROHGAME.Core.SupplyBuildings.Metalmine]);

            Console.ReadKey();
        }
Ejemplo n.º 58
0
        public void Load(System.IO.TextReader input)
        {
            int count;

            var xmlDoc = new System.Xml.XmlDocument();

            xmlDoc.Load(input);
            SchemaObjectXmlImporter importer = new SchemaObjectXmlImporter();

            var nodeContext = xmlDoc.SelectSingleNode("/sc/context");

            if (nodeContext != null)
            {
                var attrTime = nodeContext.Attributes["timeContext"];
                if (attrTime != null && attrTime.Specified)
                {
                    this.timeContext = System.Xml.XmlConvert.ToDateTime(attrTime.Value, System.Xml.XmlDateTimeSerializationMode.Local);
                }

                var scope = nodeContext.Attributes["scope"];
                if (scope != null && scope.Specified)
                {
                    this.Scope = scope.Value;
                }
            }

            var nodeObjects = xmlDoc.SelectNodes("/sc/objects/Object");

            this.objects = null;
            count        = nodeObjects.Count;

            if (count > 0)
            {
                this.objects = new SchemaObjectCollection();

                for (int i = 0; i < count; i++)
                {
                    var xml        = nodeObjects[i].OuterXml;
                    var schemaType = nodeObjects[i].Attributes["SchemaType"].Value;
                    this.objects.Add(importer.XmlToObject(xml, schemaType));
                }
            }

            nodeObjects    = xmlDoc.SelectNodes("/sc/relations/Object");
            this.relations = null;
            count          = nodeObjects.Count;

            if (count > 0)
            {
                this.relations = new SCRelationObjectCollection();

                for (int i = 0; i < count; i++)
                {
                    var xml        = nodeObjects[i].OuterXml;
                    var schemaType = nodeObjects[i].Attributes["SchemaType"].Value;
                    this.relations.Add((SCRelationObject)importer.XmlToObject(xml, schemaType));
                }
            }

            nodeObjects     = xmlDoc.SelectNodes("/sc/membership/Object");
            this.membership = null;
            count           = nodeObjects.Count;

            if (count > 0)
            {
                this.membership = new SCMemberRelationCollection();

                for (int i = 0; i < count; i++)
                {
                    var xml        = nodeObjects[i].OuterXml;
                    var schemaType = nodeObjects[i].Attributes["SchemaType"].Value;
                    this.membership.Add((SCSimpleRelationBase)importer.XmlToObject(xml, schemaType));
                }
            }

            nodeObjects     = xmlDoc.SelectNodes("/sc/conditions/condition");
            this.conditions = null;
            count           = nodeObjects.Count;

            if (count > 0)
            {
                this.conditions = new MCS.Library.SOA.DataObjects.Security.Conditions.SCConditionCollection();

                for (int i = 0; i < count; i++)
                {
                    var xml = nodeObjects[i];

                    var condition = LoadCondition(xml);

                    this.conditions.Add(condition);
                }
            }

            nodeObjects = xmlDoc.SelectNodes("/sc/acls/acl");
            this.acls   = null;
            count       = nodeObjects.Count;

            if (count > 0)
            {
                this.acls = new SCAclContainerCollection();

                for (int i = 0; i < count; i++)
                {
                    var xml = nodeObjects[i];

                    var acl = LoadAcl(xml);

                    this.acls.Add(acl);
                }
            }
        }
        private VirtualMachine SetAzureVMDiagnosticsExtensionC(VirtualMachine vm, VirtualMachineInstanceView vmStatus, string storageAccountName, string storageAccountKey)
        {
            System.Xml.XmlDocument xpublicConfig = null;

            var extensionName = AEMExtensionConstants.WADExtensionDefaultName[this.OSType];

            var extTemp = this._Helper.GetExtension(vm,
                                                    AEMExtensionConstants.WADExtensionType[this.OSType], AEMExtensionConstants.WADExtensionPublisher[OSType]);
            object publicConf = null;

            if (extTemp != null)
            {
                publicConf    = extTemp.Settings;
                extensionName = extTemp.Name;
            }

            if (publicConf != null)
            {
                var jpublicConf = publicConf as Newtonsoft.Json.Linq.JObject;
                if (jpublicConf == null)
                {
                    throw new ArgumentException();
                }

                var base64 = jpublicConf["xmlCfg"] as Newtonsoft.Json.Linq.JValue;
                if (base64 == null)
                {
                    throw new ArgumentException();
                }

                System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
                xDoc.LoadXml(Encoding.UTF8.GetString(System.Convert.FromBase64String(base64.Value.ToString())));

                if (xDoc.SelectSingleNode("/WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters") != null)
                {
                    xDoc.SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration").Attributes["overallQuotaInMB"].Value = "4096";
                    xDoc.SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters").Attributes["scheduledTransferPeriod"].Value = "PT1M";

                    xpublicConfig = xDoc;
                }
            }

            if (xpublicConfig == null)
            {
                xpublicConfig = new System.Xml.XmlDocument();
                xpublicConfig.LoadXml(AEMExtensionConstants.WADConfigXML);
            }

            foreach (var perfCounter in AEMExtensionConstants.PerformanceCounters[OSType])
            {
                var currentCounter = xpublicConfig.
                                     SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters/PerformanceCounterConfiguration[@counterSpecifier = '" + perfCounter.counterSpecifier + "']");
                if (currentCounter == null)
                {
                    var node = xpublicConfig.CreateElement("PerformanceCounterConfiguration");
                    xpublicConfig.SelectSingleNode("WadCfg/DiagnosticMonitorConfiguration/PerformanceCounters").AppendChild(node);
                    node.SetAttribute("counterSpecifier", perfCounter.counterSpecifier);
                    node.SetAttribute("sampleRate", perfCounter.sampleRate);
                }
            }

            var endpoint = this._Helper.GetCoreEndpoint(storageAccountName);

            endpoint = "https://" + endpoint;

            Newtonsoft.Json.Linq.JObject jPublicConfig = new Newtonsoft.Json.Linq.JObject();
            jPublicConfig.Add("xmlCfg", new Newtonsoft.Json.Linq.JValue(System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(xpublicConfig.InnerXml))));

            Newtonsoft.Json.Linq.JObject jPrivateConfig = new Newtonsoft.Json.Linq.JObject();
            jPrivateConfig.Add("storageAccountName", new Newtonsoft.Json.Linq.JValue(storageAccountName));
            jPrivateConfig.Add("storageAccountKey", new Newtonsoft.Json.Linq.JValue(storageAccountKey));
            jPrivateConfig.Add("storageAccountEndPoint", new Newtonsoft.Json.Linq.JValue(endpoint));

            WriteVerbose("Installing WAD extension");

            Version wadVersion = this._Helper.GetExtensionVersion(vm, vmStatus, OSType,
                                                                  AEMExtensionConstants.WADExtensionType[this.OSType], AEMExtensionConstants.WADExtensionPublisher[this.OSType]);

            VirtualMachineExtension vmExtParameters = new VirtualMachineExtension();

            vmExtParameters.Publisher = AEMExtensionConstants.WADExtensionPublisher[this.OSType];
            vmExtParameters.VirtualMachineExtensionType = AEMExtensionConstants.WADExtensionType[this.OSType];
            vmExtParameters.TypeHandlerVersion          = wadVersion.ToString(2);
            vmExtParameters.Settings                = jPublicConfig;
            vmExtParameters.ProtectedSettings       = jPrivateConfig;
            vmExtParameters.Location                = vm.Location;
            vmExtParameters.AutoUpgradeMinorVersion = true;
            vmExtParameters.ForceUpdateTag          = DateTime.Now.Ticks.ToString();

            this.VirtualMachineExtensionClient.CreateOrUpdate(ResourceGroupName, vm.Name, extensionName, vmExtParameters);

            return(this.ComputeClient.ComputeManagementClient.VirtualMachines.Get(ResourceGroupName, vm.Name));
        }
Ejemplo n.º 60
0
        public void AddCard2Zone(string zonename, string group, string type, int count = -1)
        {
            System.Xml.XmlNodeList nl  = null;
            System.Xml.XmlDocument doc = Container.doc;
            string xpath = string.Empty;
            int    cnt   = 1;

            if (group == null)
            {
                return;
            }
            if (count == -1)
            {
                count = 100;
            }
            xpath = "//card[";
            if (group != string.Empty)
            {
                xpath += "@group='" + group + "'";
                if (type != string.Empty)
                {
                    xpath += " and ";
                }
            }
            if (type != string.Empty)
            {
                xpath += "@type='" + type + "']";
            }
            nl = doc.SelectNodes(xpath);
            string p = Container.Path + doc.SelectSingleNode("/xml/Cards/set/@path").Value;

            foreach (System.Xml.XmlNode c in nl)
            {
                if (c.Attributes.GetNamedItem("count") != null)
                {
                    cnt = Convert.ToInt32(c.Attributes.GetNamedItem("count").Value);
                }
                else
                {
                    cnt = 1;
                }
                for (int i = 0; i < cnt; i++)
                {
                    clsCard card = new clsCard(c, p);
                    Container.frm.Controls.Add(card.CardFront);
                    Container.frm.Controls.Add(card.CardBack);
                    Values[zonename].addCard(card);
                    card.Card.BringToFront();
                    card.Card.Refresh();
                    card.CardFront.MouseDown += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseDown);
                    card.CardFront.MouseMove += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseMove);
                    card.CardFront.MouseUp   += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MouseUp);
                    card.CardBack.Tag         = card;
                    card.CardBack.MouseMove  += new System.Windows.Forms.MouseEventHandler(Container.frm.Card_MM_Count);
                }
                count--;
                if (count == 0)
                {
                    break;
                }
            }
        }