/// <summary> /// Approves the comment. /// </summary> /// <param name="commentId">The comment identifier.</param> /// <param name="options">The options.</param> /// <returns></returns> public virtual async Task <bool> ApproveAsync(SGuid commentId, ArticleCommentOptions options) { try { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { var result = await client.PutAsync <ArticleCommentOptions, HttpStatusCode>(client.GetApiUrl(String.Format("{0}/{{0}}/approve", ModuleRelativePath), commentId), options); switch (result) { case System.Net.HttpStatusCode.Created: case System.Net.HttpStatusCode.NoContent: case System.Net.HttpStatusCode.OK: return(true); default: return(false); } } } catch (BaasicClientException ex) { if (ex.ErrorCode == (int)HttpStatusCode.NotFound) { return(false); } throw; } catch (Exception) { throw; } }
static void Main(string[] args) { var originalObject = new StoreObject() { DateTimeValue = DateTime.Now, DoubleValue = 11.33, IntegerValue = 1133, StringValue = "String message", StringList = new string[100].Select(s => SGuid.ShortUID()).ToList(), StreamValue = new MemoryStream(File.ReadAllBytes(Directory.GetFiles(".").First())) }; var objectId = $"ID-{SGuid.ShortUID()}"; var db = new SqliteStorage("obj_storage.db", "O3"); db.InitDb(); Console.WriteLine("Insert..."); db.Insert(originalObject, objectId); Console.WriteLine("Upsert..."); db.Upsert(originalObject, objectId); Console.WriteLine("Select..."); var recoveryObject = db.Select <StoreObject>(objectId); Console.WriteLine("Delete..."); db.Delete(objectId); Console.WriteLine($"Success!"); Console.ReadLine(); }
/// <summary> /// Uns the report comment asynchronous. /// </summary> /// <param name="commentId">The comment identifier.</param> /// <returns></returns> public virtual async Task <bool> UnReportAsync(SGuid commentId) { try { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { var request = new HttpRequestMessage(HttpMethod.Put, client.GetApiUrl(String.Format("{0}/{{0}}/unreport", ModuleRelativePath), commentId)); var result = await client.SendAsync(request); return(result.IsSuccessStatusCode); } } catch (BaasicClientException ex) { if (ex.ErrorCode == (int)HttpStatusCode.NotFound) { return(false); } throw; } catch (Exception) { throw; } }
public Directive(ManagedCommands type, SGuid from, SGuid to, params string[] values) { this.type = type; this.from = from; this.to = to; this.values = values; }
/// <summary> /// Deletes the comment. /// </summary> /// <param name="commentId">The comment identifier.</param> /// <returns></returns> public virtual Task <bool> DeleteAsync(SGuid commentId) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { return(client.DeleteAsync(client.GetApiUrl(String.Format("{0}/{{0}}", ModuleRelativePath), commentId))); } }
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)); }
public ValueDb(object value) { Id = SGuid.GetSSGuid(); _typeSwitch.TryGetValue(value.GetType(), out ValueType); Value = value is Symbol?value.ToString() : value; }
/// <summary> /// Patches the <see cref="T" /> asynchronous. /// </summary> /// <param name="schemaName">The schema name.</param> /// <param name="id">The identifier.</param> /// <param name="resource">The resource.</param> /// <returns>True if updated, false otherwise.</returns> public Task <bool> PatchAsync <T>(string schemaName, SGuid id, T resource) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { return(client.PatchAsync <T>(client.GetApiUrl(string.Format("{{0}}/{{1}}/{0}", id), ModuleRelativePath, schemaName), resource)); } }
/// <summary> /// Asynchronously insert the <see cref="PageFile" /> into the system. /// </summary> /// <param name="pageId">Resource instance.</param> /// <returns>Newly created <see cref="PageFile" /> .</returns> public virtual Task <PageFile> InsertAsync(string fileName, Stream file, SGuid pageId) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{1}", ModuleRelativePath, fileName))); InitializeQueryStringPair(uriBuilder, "pageId", pageId); return(client.PostFileAsync <PageFile>(uriBuilder.ToString(), file, fileName)); } }
/// <summary> /// Asynchronously gets the <see cref="T" /> by provided key. /// </summary> /// <param name="id">The identifier.</param> /// <param name="schemaName">The schema name.</param> /// <param name="embed">The embed.</param> /// <param name="fields">The fields to include in response.</param> /// <returns><see cref="T" /> .</returns> public virtual Task <T> GetAsync(string schemaName, SGuid id, string embed = ClientBase.DefaultEmbed, string fields = ClientBase.DefaultFields) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{1}/{{0}}", ModuleRelativePath, schemaName), id)); InitializeQueryString(uriBuilder, embed, fields); return(client.GetAsync <T>(uriBuilder.ToString())); } }
/// <summary> /// Gets the comment asynchronous. /// </summary> /// <typeparam name="T">Type of extended <see cref="ArticleComment" />.</typeparam> /// <param name="commentId">The comment identifier.</param> /// <param name="embed">The embed.</param> /// <param name="fields">The fields.</param> /// <returns><typeparamref name="T" /></returns> public virtual Task <T> GetAsync <T>(SGuid commentId, string embed = DefaultEmbed, string fields = DefaultFields) where T : ArticleComment { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { UrlBuilder uriBuilder = new UrlBuilder(client.GetApiUrl(String.Format("{0}/{{0}}", ModuleRelativePath), commentId)); InitializeQueryString(uriBuilder, embed, fields); return(client.GetAsync <T>(uriBuilder.ToString())); } }
internal void DeleteUser(SGuid id) { editRequest = true; waitEnumerations(); lock (registered) registered.Remove(id); trimUsers(); editRequest = false; }
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))); }
/// <summary> /// Uns the report comment asynchronous. /// </summary> /// <param name="commentId">The comment identifier.</param> /// <returns></returns> public virtual async Task <bool> UnReportAsync(SGuid commentId) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { var request = new HttpRequestMessage(HttpMethod.Put, client.GetApiUrl(String.Format("{0}/{{0}}/unreport", ModuleRelativePath), commentId)); var result = await client.SendAsync(request); return(result.IsSuccessStatusCode); } }
public override bool Equals(object obj) { var student = obj as Student; return(student != null && SGuid.Equals(student.SGuid) && StudentId == student.StudentId && Name == student.Name && Surname == student.Surname && Birthday == student.Birthday); }
protected override void applyUser(SGuid id, string data) { if (!registered.Contains(id)) { return; } if (!otherValues.ContainsKey(id)) { lock (otherValues) otherValues[id] = new T(); } otherValues[id].Renew(data); }
internal void ApplyUser(SGuid id, string data) { editRequest = true; waitEnumerations(); lock (registered) { if (!registered.Contains(id)) { registered.Add(id); } } trimUsers(); applyUser(id, data); editRequest = false; }
/// <summary> /// Reports the comment asynchronous. /// </summary> /// <param name="commentId">The comment identifier.</param> /// <param name="options">The options.</param> /// <returns></returns> public virtual async Task <bool> ReportCommentAsync(SGuid commentId, ArticleCommentOptions options) { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { var result = await client.PutAsync <ArticleCommentOptions, HttpStatusCode>(client.GetApiUrl(String.Format("{0}/{{0}}/report", ModuleRelativePath), commentId), options); switch (result) { case System.Net.HttpStatusCode.Created: case System.Net.HttpStatusCode.NoContent: case System.Net.HttpStatusCode.OK: return(true); default: return(false); } } }
/// <summary> /// Asynchronously deletes the dynamic resource of <see cref="T" /> from the system. /// </summary> /// <param name="id">The identifier.</param> /// <returns>True if dynamic resource is deleted, false otherwise.</returns> public virtual async Task <bool> DeleteAsync(SGuid id) { try { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { return(await client.DeleteAsync(client.GetApiUrl(String.Format("{0}/{1}/{{0}}", ModuleRelativePath, typeof(T).Name), id))); } } catch (BaasicClientException ex) { if (ex.ErrorCode == (int)HttpStatusCode.NotFound) { return(false); } throw; } catch (Exception) { throw; } }
/// <summary> /// Patches the <see cref="TIn" /> asynchronous. /// </summary> /// <typeparam name="TIn">The type of the resource.</typeparam> /// <param name="schemaName">The schema name.</param> /// <param name="id">The identifier.</param> /// <param name="resource">The resource.</param> /// <returns>True if updated, false otherwise.</returns> public async Task <bool> PatchAsync <TIn>(string schemaName, SGuid id, TIn resource) { try { using (IBaasicClient client = BaasicClientFactory.Create(Configuration)) { return(await client.PatchAsync <TIn>(client.GetApiUrl(string.Format("{{0}}/{{1}}/{0}", id), ModuleRelativePath, schemaName), resource)); } } catch (BaasicClientException ex) { if (ex.ErrorCode == (int)HttpStatusCode.NotFound) { return(false); } throw; } catch (Exception) { throw; } }
/// <summary> /// Patches the <see cref="TIn" /> asynchronous. /// </summary> /// <typeparam name="TIn">The type of the resource.</typeparam> /// <param name="id">The identifier.</param> /// <param name="resource">The resource.</param> /// <returns>True if updated, false otherwise.</returns> public Task <bool> PatchAsync <TIn>(SGuid id, TIn resource) { return(this.PatchAsync <TIn>(typeof(TIn).Name, id, resource)); }
protected abstract void applyUser(SGuid id, string data);
[DataMember(Order = 3)] private string _Description; // IfcText? : simplify public IfcRoot() { this._GlobalId = SGuid.New().ToString(); this._OwnerHistory = null; }
/// <summary> /// Gets the comment asynchronous. /// </summary> /// <param name="commentId">The comment identifier.</param> /// <param name="embed">The embed.</param> /// <param name="fields">The fields.</param> /// <returns></returns> public virtual Task <ArticleComment> GetAsync(SGuid commentId, string embed = DefaultEmbed, string fields = DefaultFields) { return(GetAsync <ArticleComment>(commentId, embed, fields)); }
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)); }
public override string ToString() { return(String.Concat(SGuid.ToString(), ", ", StudentId, ", ", Name, ", ", Surname, ", ", Birthday)); }
public ConsDb(string carId, string cdrId) { Id = SGuid.GetSSGuid(); CarId = carId; CdrId = cdrId; }
public T this[SGuid u] => u == connection.ID ? Value : otherValues[u];
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); } } } } }
/// <summary> /// Asynchronously gets the <see cref="T" /> by provided key. /// </summary> /// <param name="id">The identifier.</param> /// <param name="embed">The embed.</param> /// <param name="fields">The fields to include in response.</param> /// <returns><see cref="T" /> .</returns> public virtual Task <T> GetAsync(SGuid id, string embed = ClientBase.DefaultEmbed, string fields = ClientBase.DefaultFields) { return(this.GetAsync(typeof(T).Name, id, embed, fields)); }