Ejemplo n.º 1
0
Archivo: User.cs Proyecto: hnjm/NetLib
        public static User Parse(string txt)
        {
            var    grps = regx.Match(txt).Groups;
            string nick = grps[2].Value;

            return(new User(SGuid.Parse(grps[1].Value), string.IsNullOrWhiteSpace(nick) ? "<blank_nickname>" : nick));
        }
Ejemplo n.º 2
0
        public static Directive Parse(string msg)
        {
            GroupCollection grps = regx.Match(msg).Groups;

            return(new Directive(
                       StringEnum <ManagedCommands>(grps[1].Value),
                       SGuid.Parse(grps[2].Value),
                       SGuid.Parse(grps[3].Value),
                       Data.PullStrings(grps[4].Value, textSep_c)));
        }
Ejemplo n.º 3
0
        public void Load()
        {
            // prepare map
            Dictionary <string, DocPropertySet> map = new Dictionary <string, DocPropertySet>();

            foreach (DocSection docSection in this.m_project.Sections)
            {
                foreach (DocSchema docSchema in docSection.Schemas)
                {
                    foreach (DocPropertySet docEntity in docSchema.PropertySets)
                    {
                        map.Add(docEntity.Name, docEntity);
                    }
                }
            }

            // use commas for simplicity
            using (System.IO.StreamReader reader = new System.IO.StreamReader(this.m_filename))
            {
                string headerline = reader.ReadLine(); // blank

                // now rows
                while (!reader.EndOfStream)
                {
                    string rowdata = reader.ReadLine();

                    string[] rowcells = rowdata.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                    if (rowcells.Length > 1)
                    {
                        DocPropertySet docObj  = null;
                        string         ifdguid = rowcells[0];
                        string         ifdname = rowcells[1];

                        Guid guid = SGuid.Parse(ifdguid);

                        string[] nameparts = ifdname.Split('.');
                        string   psetname  = nameparts[0].Trim();
                        string   propname  = null;
                        if (nameparts.Length == 2)
                        {
                            propname = nameparts[1];
                        }

                        if (map.TryGetValue(psetname, out docObj))
                        {
                            if (propname != null)
                            {
                                foreach (DocProperty docprop in docObj.Properties)
                                {
                                    if (propname.Equals(docprop.Name))
                                    {
                                        // found it
                                        docprop.Uuid = guid;
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                docObj.Uuid = guid;
                            }
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("IFD (not found): " + psetname);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void Download(DocProject project, BackgroundWorker worker, string baseurl, string username, string password, DocModelView[] docViews)
        {
            string sessionid = Connect(project, worker, baseurl, username, password);

            if (sessionid == null)
            {
                return;
            }

            //foreach (DocModelView docView in docViews)
            string page = null;

            do
            {
                //string url = baseurl + "api/4.0/IfdContext/" + SGuid.Format(docView.Uuid);
                string url = baseurl + "api/4.0/IfdConcept/filter/SUBJECT"; // ifc-2X4
                //string url = baseurl + "api/4.0/IfdConcept/search/filter/language/1ASQw0qJqHuO00025QrE$V/*";//type/SUBJECT/*";
                if (page != null)
                {
                    url += "?page=" + page;
                }

                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
                request.Accept = "application/json";
                request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                Stream          stream   = response.GetResponseStream();

                page = response.Headers.Get("Next-Page");
                System.Diagnostics.Debug.WriteLine(page);

                ResponseSearch responseSearch = null;
                try
                {
                    DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings();
                    DataContractJsonSerializer         ser      = new DataContractJsonSerializer(typeof(ResponseSearch));
                    responseSearch = (ResponseSearch)ser.ReadObject(stream);
                    if (responseSearch != null)
                    {
                        responseSearch.ToString();

                        foreach (IfdConcept ifdConcept in responseSearch.IfdConcept)
                        {
                            DocModelView docView = new DocModelView();

                            if (ifdConcept.shortNames != null)
                            {
                                foreach (IfdName ifdName in ifdConcept.shortNames)
                                {
                                    DocLocalization docLoc = new DocLocalization();
                                    docLoc.Locale = ifdName.language.languageCode;
                                    docLoc.Name   = ifdName.name;
                                    docView.Localization.Add(docLoc);

                                    if (ifdName.language.languageCode == "en")
                                    {
                                        docView.Name = ifdName.name;
                                    }
                                }
                            }
                            else if (ifdConcept.fullNames != null)
                            {
                                ifdConcept.ToString();
                            }

                            docView.Uuid      = SGuid.Parse(ifdConcept.guid);
                            docView.Version   = ifdConcept.versionId;
                            docView.Copyright = ifdConcept.versionDate;
                            docView.Status    = ifdConcept.status;
                            //docView.Owner = ifdConcept.owner;
                            //docView.Documentation = ifdConcept.comments

                            project.ModelViews.Add(docView);

                            ifdConcept.ToString();
                        }
                        //foreach (IfdDescription ifcDesc in ifdContext.definitions)
                        {
                            // create/update concept root
                            //...
                        }
                    }
                }
                catch (Exception xx)
                {
                    xx.ToString();
                }
            }while (!String.IsNullOrEmpty(page));
        }