Beispiel #1
0
        private void ReadAppManifest()
        {
            string wmData = string.Empty;

            System.Xml.Linq.XElement appxml = System.Xml.Linq.XElement.Load("WMAppManifest.xml");
            var appElement = (from manifestData in appxml.Descendants("DefaultTask") select manifestData).SingleOrDefault();

            if (appElement != null)
            {
                navigationPage = appElement.Attribute("NavigationPage").Value;
            }

            appElement = (from manifestData in appxml.Descendants("PrimaryToken") select manifestData).SingleOrDefault();
        }
Beispiel #2
0
        //public String SSH_HOST = "10.1.1.196";
        //public String SSH_USER = "******";
        //public String SSH_PASSW = "srv_klj2n3mnkdlo$.&";
        //public String DB_HOST = "localhost";
        //public String DB_PORT = "6432";
        //public String DB_USER = "******";
        //public String DB_SCHEMA = "gpe";
        //public String DB_PASSWORD = "******";

        public Config(System.Xml.Linq.XElement option)
        {
            var sshOption = option.Descendants("ssh").ToList()[0];

            SSH_HOST  = sshOption.Attribute("host").Value;
            SSH_USER  = sshOption.Attribute("user").Value;
            SSH_PASSW = sshOption.Attribute("pass").Value;

            var dbOption = option.Descendants("database").ToList()[0];

            DB_HOST     = dbOption.Attribute("host").Value;
            DB_PORT     = dbOption.Attribute("port").Value;
            DB_USER     = dbOption.Attribute("user").Value;
            DB_SCHEMA   = dbOption.Attribute("schema").Value;
            DB_PASSWORD = dbOption.Attribute("pass").Value;
        }
        private static void FixStyles(string documentFolder)
        {
            string[] files = Directory.GetFiles(documentFolder, "*.tgsty", SearchOption.AllDirectories);

            Stream fixResourceStream = typeof(XmlGeoSerializationFormatter).Assembly.GetManifestResourceStream("ThinkGeo.MapSuite.Serialize.Serializer.ResolveSerializedIssue.xml");

            System.Xml.Linq.XElement fixElement = System.Xml.Linq.XElement.Load(fixResourceStream);

            foreach (var file in files)
            {
                string content  = File.ReadAllText(file);
                bool   needSave = false;
                foreach (var item in fixElement.Descendants("Pair"))
                {
                    string oldContent = item.Element("Old").Value;
                    string newContent = item.Element("New").Value;

                    if (content.Contains(oldContent))
                    {
                        content  = content.Replace(oldContent, newContent);
                        needSave = true;
                    }
                }

                if (needSave)
                {
                    File.WriteAllText(file, content);
                }
            }
        }
        private static SearchWord ParseResult(HttpResponseMessage response, string text)
        {
            var searchWord = new SearchWord {
                Word = text
            };


            string result = string.Empty;

            if (response.IsSuccessStatusCode)
            {
                System.Xml.Linq.XElement MyXElement = System.Xml.Linq.XElement.Parse(response.Content.ReadAsStringAsync().Result);

                var list = (from x in MyXElement.Descendants("result")
                            select new
                {
                    Main = x.Element("headword").Value,
                    Betekenis = x.Element("article").Value,
                });

                // DateTime.Now.DayOfWeek == DayOfWeek.
                searchWord.Results = new List <ResultWord>();

                foreach (var item in list)
                {
                    if (!item.Betekenis.ToLower().Contains("van dale"))
                    {
                        result += "<h2>" + item.Main + "</h2>" + item.Betekenis;
                        string wordResult = item.Main;
                        wordResult = ReplaceCijfers(wordResult);
                        wordResult = StripHtml(wordResult);

                        string wordBetekenis = item.Betekenis;

                        wordBetekenis = ReplaceCijfers(wordBetekenis);
                        wordBetekenis = StripHtml(wordBetekenis);

                        searchWord.Results.Add(new ResultWord()
                        {
                            Word = wordResult, Description = wordBetekenis
                        });
                    }
                }

                if (string.IsNullOrEmpty(result))
                {
                    result = "No results found.";
                }
                else if (!string.IsNullOrEmpty(result))
                {
                }
            }
            else
            {
                result = "Unable to contact server.";
                return(null);
            }

            return(searchWord);
        }
Beispiel #5
0
        private void LoadData()
        {
            var backingFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Data", "medicineList.xml");

            System.Xml.Linq.XElement xEle = System.Xml.Linq.XElement.Load(backingFile);
            string[] dataFetch            = xEle.Descendants("Medicine").OrderBy(x => Convert.ToString(x.Element("Name").Value)).Select(x => Convert.ToString(x.Element("Name").Value)).ToArray();
            fillButton(dataFetch);
        }
Beispiel #6
0
        private void Enter_Medicine_TextChanged(object sender, TextChangedEventArgs e)
        {
            var backingFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Data", "medicineList.xml");

            System.Xml.Linq.XElement xEle = System.Xml.Linq.XElement.Load(backingFile);
            string[] dataFetch            = xEle.Descendants("Medicine").Where(x => Convert.ToString(x.Element("Name").Value).ToLower().Contains(Enter_Medicine.Text.ToLower())).OrderBy(x => Convert.ToString(x.Element("Name").Value)).Select(x => Convert.ToString(x.Element("Name").Value)).ToArray();
            fillButton(dataFetch);
        }
Beispiel #7
0
        public FolderWatcher(System.Xml.Linq.XElement rootXml, IDirig ctrl, string rootForRelativePaths)
        {
            this._ctrl              = ctrl;
            this._conditions        = X.getStringAttr(rootXml, "Conditions");
            this._relativePathsRoot = rootForRelativePaths;

            if (String.IsNullOrEmpty(rootForRelativePaths))
            {
                _relativePathsRoot = System.IO.Directory.GetCurrentDirectory();
            }
            else
            {
                _relativePathsRoot = rootForRelativePaths;
            }

            var inclSubdirs = X.getBoolAttr(rootXml, "IncludeSubdirs");
            var path        = X.getStringAttr(rootXml, "Path");
            var filter      = X.getStringAttr(rootXml, "Filter");

            if (String.IsNullOrEmpty(path))
            {
                log.Error("Path not defined or empty!");
                return;
            }

            var absPath = BuildAbsolutePath(path);

            if (!System.IO.Directory.Exists(absPath))
            {
                log.Error($"Path '{absPath}' does not exist! FolderWatcher not installed.");
                return;
            }

            _watcher.Path = absPath;
            _watcher.IncludeSubdirectories = inclSubdirs;

            if (!String.IsNullOrEmpty(filter))
            {
                _watcher.Filter = filter;
            }

            if (_conditions == "NewFile")
            {
                _watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.CreationTime | NotifyFilters.LastWrite;
                _watcher.Created     += new FileSystemEventHandler(OnFileCreated);
            }

            foreach (var actXml in rootXml.Descendants("Action"))
            {
                _actionXmls.Add(actXml);
            }

            log.DebugFormat("FolderWatcher initialized. Path={0}, Filter={1}, Conditions={2}", _watcher.Path, _watcher.Filter, _conditions);
            Initialized = true;

            _watcher.EnableRaisingEvents = true;
        }
Beispiel #8
0
 protected override SendResult ParseResponseImp(System.Xml.Linq.XElement xml)
 {
     if (null != xml.Descendants("Power_Control").FirstOrDefault())
     {
         return(SendResult.Succcess);
     }
     else
     {
         return(SendResult.Empty);
     }
 }
        private void BtnNext_Clicked(object sender, EventArgs e)
        {
            var backingFile = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Config.xml");

            System.Xml.Linq.XElement xEleList = System.Xml.Linq.XElement.Load(backingFile);
            if (swtchDoNotShowAgain.IsToggled)
            {
                xEleList.Descendants("DoNotShowAgain").First().Value = "true";
                xEleList.Save(backingFile);
            }
            Application.Current.MainPage = new NavigationPage(new MainSearchWindow());
        }
Beispiel #10
0
        public static Work GetWorkDocuments(System.Xml.Linq.XElement node, Work work)
        {
            IEnumerable <System.Xml.Linq.XElement> workDocumentElements = node.Descendants("workDocument");

            foreach (System.Xml.Linq.XElement document in workDocumentElements)
            {
                WorkDocument doc = WorkDocument.GetWorkDocumentFromNode(document);
                if (doc == null)
                {
                    continue;
                }

                Work.AddWorkDocument(work, doc);
            }
            return(work);
        }
Beispiel #11
0
        private static void ImportRow(System.Xml.Linq.XElement row
                                      , ImportResult result)
        {
            System.Collections.Generic.List <System.Xml.Linq.XElement> cells = (
                from c in row.Descendants()
                where c.Name == "{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table-cell"
                select c
                ).ToList();

            // DataDto dto = new DataDto();

            int count = cells.Count;
            int j     = -1;

            for (int i = 0; i < count; i++)
            {
                j++;
                System.Xml.Linq.XElement   cell = cells[i];
                System.Xml.Linq.XAttribute attr =
                    cell.Attribute("{urn:oasis:names:tc:opendocument:xmlns:table:1.0}number-columns-repeated");
                if (attr != null)
                {
                    int numToSkip = 0;
                    if (int.TryParse(attr.Value, out numToSkip))
                    {
                        j += numToSkip - 1;
                    }
                }

                if (i > 30)
                {
                    break;
                }
                if (j == 0)
                {
                    // dto.SomeProperty = cells[i].Value;
                }
                if (j == 1)
                {
                    // dto.SomeOtherProperty = cells[i].Value;
                }

                // some more data reading
            } // Next i

            // save data
        } // End Sub ImportRow
Beispiel #12
0
        /// <summary>
        /// Add workArtists from XElement workItem and add to Work object
        /// </summary>
        /// <param name="node"></param>
        /// <param name="work"></param>
        /// <remarks>
        /// Gets the WorkArtist objects information from the XElement node and
        /// gets the WorkArtist object. Then adds it to Work's WorkArtists collection.
        /// </remarks>
        /// <returns></returns>
        public static Work GetWorkArtists(System.Xml.Linq.XElement node, Work work)
        {
            IEnumerable <System.Xml.Linq.XElement> workArtistElements = node.Descendants("workArtist");

            foreach (System.Xml.Linq.XElement workArtist in workArtistElements)
            {
                WorkArtist artist = WorkArtist.GetWorkArtistFromNode(workArtist);

                if (artist == null)
                {
                    continue;
                }

                Work.AddWorkArtist(work, artist);
            }
            return(work);
        }
        void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            string result = string.Empty;
            bool   succes = false;

            if (e.Error == null && e.Result != null)
            {
                System.Xml.Linq.XElement MyXElement = System.Xml.Linq.XElement.Parse(e.Result);

                var list = (from x in MyXElement.Descendants("result")
                            select new
                {
                    Main = x.Element("headword").Value,
                    Betekenis = x.Element("article").Value,
                });

                // DateTime.Now.DayOfWeek == DayOfWeek.

                foreach (var item in list)
                {
                    if (!item.Betekenis.ToLower().Contains("van dale"))
                    {
                        result += "<h2>" + item.Main + "</h2>" + item.Betekenis;
                    }
                }

                if (string.IsNullOrEmpty(result))
                {
                    result = "No results found.";
                }
                else
                {
                    succes = true;
                }
            }
            else
            {
                result = "Unable to contact server.";
            }

            if (ReadFinished != null)
            {
                ReadFinished(result, succes);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Permet de parser une liste d'objets XML en une liste d'objet C#
        /// </summary>
        /// <typeparam name="T">Type de l'objet rocrail à traiter</typeparam>
        /// <param name="list">Liste d'objets C#</param>
        /// <param name="xml">Code XML à traiter</param>
        /// <param name="element">Elément à traiter</param>
        /// <param name="action">Méthode Parse de l'élément traité</param>
        /// <param name="rocrailClient">Connexion au serveur Rocrail</param>
        public static void ParseList <T>(List <T> list, System.Xml.Linq.XElement xml, string element, Func <System.Xml.Linq.XElement, CRocrailClient, T> action, CRocrailClient rocrailClient)
        {
            // Si le code xml est null, on ne continue pas
            if (xml == null)
            {
                return;
            }

            // Récupère tous les éléments
            var _elements = xml.Descendants(element);

            if (_elements.Count() == 0)
            {
                return;
            }

            _elements.ToList().ForEach(e => list.Add(action(e, rocrailClient)));
        }
Beispiel #15
0
        public static IList <WebcastRssItem> ListWithoutPage(int topCount = 10)
        {
            var list = new List <WebcastRssItem>();

            string xmlHtml = string.Empty;
            string url     = string.Format("http://webcast.planteng.cn/MeetingList.aspx?&PageSize={0}&SortType=DESC", topCount);

            try
            {
                string KEY = string.Format("WEBCAST_MODULE_INDEX_XMLHTML_{0}", topCount);
                xmlHtml = (string)CacheHelper.Get(KEY);
                if (string.IsNullOrEmpty(xmlHtml))
                {
                    //添加缓存
                    //10小时缓存
                    xmlHtml = Goodspeed.Common.CharHelper.GetWebPage(url);
                    CacheHelper.Add(KEY, xmlHtml, DateTime.Now.AddHours(10));
                }


                if (!string.IsNullOrEmpty(xmlHtml))
                {
                    System.Xml.Linq.XElement elements = System.Xml.Linq.XElement.Parse(xmlHtml);
                    var listItem = from el in elements.Descendants("item")
                                   select el;
                    WebcastRssItem webcastItem = null;
                    foreach (var item in listItem)
                    {
                        webcastItem             = new WebcastRssItem();
                        webcastItem.Url         = (string)item.Element("guid");
                        webcastItem.Title       = (string)item.Element("title");
                        webcastItem.Description = (string)item.Element("description");
                        webcastItem.ImageUrl    = (string)item.Element("ImgUrl");
                        webcastItem.StartTime   = (DateTime)item.Element("StartTime");
                        webcastItem.EndTime     = (DateTime)item.Element("EndTime");
                        list.Add(webcastItem);
                    }
                }
            }
            catch {}
            return(list);
        }
Beispiel #16
0
        public static string GetSeriesFromNode(System.Xml.Linq.XElement node)
        {
            var seriesNodes = node.Descendants(Constants.Series.seriesElement);

            StringBuilder seriesNames = new StringBuilder();

            foreach (var seriesNode in seriesNodes)
            {
                string seriesName = (string)seriesNode.Element(Constants.Series.seriesName);
                if (!string.IsNullOrEmpty(seriesName))
                {
                    seriesNames.Append(string.Format("{0}; ", seriesName));
                }
            }

            if (seriesNames.Length > 2)
            {
                seriesNames = seriesNames.Remove(seriesNames.Length - 2, 2);
            }

            return(seriesNames.ToString());
        }
Beispiel #17
0
        public static void WriteFixedWidth(System.Xml.Linq.XElement CommandNode, DataTable Table, string outputStream)
        {
            StreamWriter Output  = new StreamWriter(outputStream, true);
            int          StartAt = CommandNode.Attribute("StartAt") != null?int.Parse(CommandNode.Attribute("StartAt").Value) : 0;

            var positions = from c in CommandNode.Descendants("Position")
                            orderby int.Parse(c.Attribute("Start").Value) ascending
                            select new
            {
                Name   = c.Attribute("Name").Value,
                Start  = int.Parse(c.Attribute("Start").Value) - StartAt,
                Length = int.Parse(c.Attribute("Length").Value)
            };

            int lineLength = positions.Last().Start + positions.Last().Length;



            foreach (DataRow row in Table.Rows)
            {
                StringBuilder line = new StringBuilder(lineLength);
                foreach (var p in positions)

                {
                    //check if the column exists in the datatable
                    if (row.Table.Columns.Contains(p.Name))
                    {
                        line.Insert(p.Start, (row[p.Name] ?? "").ToString().PadRight(p.Length, ' ')

                                    );
                    }
                }
                Output.WriteLine(line.ToString());
            }
            Output.Flush();
        }
Beispiel #18
0
        public async Task <IActionResult> Create([Bind("Id,UserName,FirstName,LastName,Profil,IsActive")] ListUsers listUsers)
        {
            try
            {
                TPFAuthenticationSoapClient.EndpointConfiguration endpointConfiguration = new TPFAuthenticationSoapClient.EndpointConfiguration();
                TPFAuthenticationSoapClient servAuth = new TPFAuthenticationSoapClient(endpointConfiguration);
                if ((Boolean)TempData["isValid"] == false)
                {
                    IdentityUser u = await userManager.FindByNameAsync(listUsers.UserName);

                    if (u != null)
                    {
                        ViewBag.IsValid = false;
                        ModelState.AddModelError(string.Empty, "Ce Compte existe déja");
                    }

                    else
                    {
                        GetEmployeeByLoginResponseGetEmployeeByLoginResult x = await servAuth.GetEmployeeByLoginAsync(configuration.GetSection("MySettings").GetSection("login").Value, configuration.GetSection("MySettings").GetSection("pwd").Value, listUsers.UserName);


                        if (x != null)
                        {
                            System.Xml.Linq.XElement b = x.Any1;
                            ViewBag.Result1 = b.Descendants("employee_common_name").First().Value;
                            ViewBag.IsValid = true;

                            listUsers.Id        = b.Descendants("employee_ident").First().Value;
                            listUsers.FirstName = b.Descendants("employee_first_name").First().Value;
                            listUsers.LastName  = b.Descendants("employee_last_name").First().Value;
                            //listUsers.FullName = b.Descendants("employee_common_name").First().Value;
                            //listUsers.Email = b.Descendants("email1").First().Value;


                            return(View(listUsers));
                        }
                        else
                        {
                            Tools.Log(listUsers.UserName);
                            ViewBag.IsValid = false;
                            ModelState.AddModelError(string.Empty, "Compte Inexistant!");
                            //return View(user);
                        }
                    }
                }
                else
                {
                    ListUsers myuser = new ListUsers {
                        UserName = listUsers.UserName, Email = listUsers.Email, Id = listUsers.Id, FirstName = listUsers.FirstName, LastName = listUsers.LastName
                    };
                    await userManager.CreateAsync(myuser);

                    await userManager.AddToRoleAsync(myuser, "Manager");

                    Tools.Historique(User.Identity.Name, "Creation d'utilisateur", "Success", "", myuser.UserName);
                    return(RedirectToAction(nameof(Index)));
                }
                return(View(listUsers));
            }
            catch (Exception ex)
            {
                Tools.Log("UsersController, Post Create, Utilisateur (" + User.Identity.Name + ") : " + ex.ToString());
                TempData["errorMessage"] = "Impossible de creer l'utilisateur";
                return(RedirectToAction(nameof(Create)));
            }
        }
 protected override Rfc6238AppendixBData Fill(System.Xml.Linq.XElement e)
 {
     return(new Rfc6238AppendixBData(e.Descendants("totp").First().Value,
                                     e.Descendants("mode").First().Value,
                                     e.Descendants("time").First().Value));
 }
Beispiel #20
0
        public async Task <HttpResponseMessage> InsertOrUpdate(UpdateDataMartInstalledModelsDTO updateInfo)
        {
            // All installed models have the same datamart id.
            var datamartID = updateInfo.DataMartID;

            var datamart = await DataContext.Secure <DataMart>(Identity, PermissionIdentifiers.DataMart.Edit).FirstOrDefaultAsync(dm => dm.ID == datamartID);

            if (datamart == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Forbidden, "You do not have permission to alter one or more DataMarts referenced."));
            }

            await DataContext.Entry(datamart).Collection(dm => dm.Models).LoadAsync();

            var modelsToDelete = datamart.Models.Where(m => !updateInfo.Models.Any(um => um.ModelID == m.ModelID)).ToArray();

            if (datamart.AdapterID.HasValue)
            {
                //if an adapter has been set on the datamart, make sure that QueryComposer is the only installed model,
                //add if missing, and remove any others.

                modelsToDelete    = datamart.Models.Where(m => m.ModelID != QueryComposerModelID).ToArray();
                updateInfo.Models = updateInfo.Models.Where(m => m.ModelID == QueryComposerModelID).ToArray();

                if (!updateInfo.Models.Any(m => m.ModelID == QueryComposerModelID))
                {
                    updateInfo.Models = new[]
                    {
                        new DataMartInstalledModelDTO
                        {
                            DataMartID = datamart.ID,
                            ModelID    = QueryComposerModelID,
                            Properties = "<Properties><Property Name=\"ModelID\" Value=\"" + datamart.AdapterID + "\" /></Properties>"
                        }
                    };
                }
            }

            if (modelsToDelete.Length > 0)
            {
                var modelsToDeleteID = modelsToDelete.Select(m => m.ModelID).ToArray();

                var datamartRequestTypeAcls = from a in DataContext.DataMartRequestTypeAcls
                                              where a.DataMartID == datamartID &&
                                              a.RequestType.Models.Any(m => modelsToDeleteID.Contains(m.DataModelID))
                                              select a;
                DataContext.DataMartRequestTypeAcls.RemoveRange(datamartRequestTypeAcls);

                var projectDatamartRequestTypeAcls = from a in DataContext.ProjectDataMartRequestTypeAcls
                                                     where a.DataMartID == datamartID &&
                                                     a.RequestType.Models.Any(m => modelsToDeleteID.Contains(m.DataModelID)) &&
                                                     !a.RequestType.Models.Any(m => !modelsToDeleteID.Contains(m.DataModelID))
                                                     select a;
                DataContext.ProjectDataMartRequestTypeAcls.RemoveRange(projectDatamartRequestTypeAcls);

                var projectRequestTypeAcls = from a in DataContext.ProjectRequestTypeAcls
                                             where a.RequestType.Models.Any(m => modelsToDeleteID.Contains(m.DataModelID)) &&
                                             a.Project.DataMarts.Any(dm => dm.DataMartID == datamartID) &&
                                             !a.Project.DataMarts.Any(dm => dm.DataMartID != datamartID &&
                                                                      dm.DataMart.Models.Any(m => modelsToDeleteID.Contains(m.ModelID)))
                                             select a;
                DataContext.ProjectRequestTypeAcls.RemoveRange(projectRequestTypeAcls);

                foreach (var md in modelsToDelete)
                {
                    datamart.Models.Remove(md);
                }
            }

            var modelID = updateInfo.Models.Select(m => m.ModelID).ToArray();
            var models  = await DataContext.DataModels.Where(m => modelID.Contains(m.ID)).ToArrayAsync();

            foreach (var im in updateInfo.Models)
            {
                var modelInfo = datamart.Models.FirstOrDefault(m => m.ModelID == im.ModelID);
                if (modelInfo == null)
                {
                    modelInfo = new DataMartInstalledModel
                    {
                        DataMartID = datamart.ID,
                        ModelID    = im.ModelID,
                        Properties = im.Properties
                    };
                    datamart.Models.Add(modelInfo);
                }
                else
                {
                    modelInfo.Properties = im.Properties;
                }

                var model = models.Single(m => m.ID == modelInfo.ModelID);
                if (model.QueryComposer)
                {
                    //make sure the ModelID property has been set to the datamart.AdapterID

                    if (string.IsNullOrEmpty(modelInfo.Properties))
                    {
                        modelInfo.Properties = "<Properties><Property Name=\"ModelID\" Value=\"" + datamart.AdapterID + "\" /></Properties>";
                    }
                    else
                    {
                        System.Xml.Linq.XElement doc = System.Xml.Linq.XElement.Parse(modelInfo.Properties);
                        var modelNode = doc.Descendants("Property").Where(n => n.Attributes("Name").Any(a => a.Value == "ModelID")).FirstOrDefault();
                        if (modelNode != null)
                        {
                            modelNode.Attribute("Value").Value = datamart.AdapterID.HasValue ? datamart.AdapterID.Value.ToString() : string.Empty;
                        }
                        else
                        {
                            doc.Add(new System.Xml.Linq.XElement("Property", new System.Xml.Linq.XAttribute("Name", "ModelID"), new System.Xml.Linq.XAttribute("Value", datamart.AdapterID)));
                        }

                        modelInfo.Properties = doc.ToString();
                    }
                }
            }

            await DataContext.SaveChangesAsync();

            return(Request.CreateResponse(HttpStatusCode.Accepted));
        }