public void GetContact(Guid id) { using (var response = BpmOnline.CreateAuthRequest()) { var dataRequest = HttpWebRequest.Create(BpmOnline.ServerUri + "ContactCollection(guid'" + id + "')") as HttpWebRequest; dataRequest.Method = "GET"; dataRequest.CookieContainer = BpmOnline.AuthCookie; CookieCollection cookieCollection = BpmOnline.AuthCookie.GetCookies(new Uri(BpmOnline.AuthServiceUri)); string csrfToken = cookieCollection["BPMCSRF"].Value; ((HttpWebRequest)dataRequest).Headers.Add("BPMCSRF", csrfToken); using (var dataResponse = (HttpWebResponse)dataRequest.GetResponse()) { XDocument xmlDoc = XDocument.Load(dataResponse.GetResponseStream()); var task = from entry in xmlDoc.Descendants(atom + "entry") select new { id = new Guid(entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Id").Value), name = entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Name").Value }; Id = task.FirstOrDefault().id; Name = task.FirstOrDefault().name; } } }
public List <Case> GetAllCasesByOwner(Guid ownerid) { //dataGridView1.Invoke(new Action(() => dataGridView1.Rows.Clear())); using (var response = BpmOnline.CreateAuthRequest()) { var dataRequest = HttpWebRequest.Create(BpmOnline.ServerUri + "CaseCollection?$select=Id,Number,Subject,RegisteredOn,SolutionDate&$filter=Owner/Id eq guid'" + ownerid + "' and Status/Id ne guid'3E7F420C-F46B-1410-FC9A-0050BA5D6C38' and Status/Id ne guid'AE7F411E-F46B-1410-009B-0050BA5D6C38' and Status/Id ne guid'6E5F4218-F46B-1410-FE9A-0050BA5D6C38'") as HttpWebRequest; dataRequest.Method = "GET"; dataRequest.CookieContainer = BpmOnline.AuthCookie; CookieCollection cookieCollection = BpmOnline.AuthCookie.GetCookies(new Uri(BpmOnline.AuthServiceUri)); string csrfToken = cookieCollection["BPMCSRF"].Value; ((HttpWebRequest)dataRequest).Headers.Add("BPMCSRF", csrfToken); using (var dataResponse = (HttpWebResponse)dataRequest.GetResponse()) { XDocument xmlDoc = XDocument.Load(dataResponse.GetResponseStream()); var cases = from entry in xmlDoc.Descendants(atom + "entry") select new { id = new Guid(entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Id").Value), number = entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Number").Value, subject = entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Subject").Value, registeredOn = entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "RegisteredOn").Value, solutionDate = entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "SolutionDate").Value }; List <Case> caseslist = new List <Case>(); foreach (var incase in cases) { caseslist.Add(new Case() { Id = incase.id, Number = incase.number, Subject = incase.subject, RegisteredOn = DateTime.Parse(incase.registeredOn), SolutionDate = DateTime.Parse(incase.solutionDate), //Url = "https://nlmk.bpmonline.com/0/Nui/ViewModule.aspx#CardModuleV2/CasePage/edit/" + incase.id }); } return(caseslist); } } }
public void GetSysAdminUnit(string name) { using (var response = BpmOnline.CreateAuthRequest()) { //https://metanit.com/sharp/net/2.2.php //HttpWebRequest request = (HttpWebRequest)WebRequest.Create(BpmOnline.ServerUri + "SysAdminUnitCollection?$select=Id,Name,ContactId&$filter=Name eq '" + name + "'"); //request.Method = "GET"; //request.CookieContainer = BpmOnline.AuthCookie; //CookieCollection cookieCollection = BpmOnline.AuthCookie.GetCookies(new Uri(BpmOnline.AuthServiceUri)); //HttpWebResponse response2 = (HttpWebResponse)await request.GetResponseAsync(); //string csrfToken = cookieCollection["BPMCSRF"].Value; //((HttpWebRequest)request).Headers.Add("BPMCSRF", csrfToken); //using (var dataResponse = (HttpWebResponse)await request.GetResponseAsync()) //{ // XDocument xmlDoc = XDocument.Load(dataResponse.GetResponseStream()); // var field = from entry in xmlDoc.Descendants(atom + "entry") // select new // { // id = new Guid(entry.Element(atom + "content") // .Element(dsmd + "properties") // .Element(ds + "Id").Value), // name = entry.Element(atom + "content") // .Element(dsmd + "properties") // .Element(ds + "Name").Value, // contactId = new Guid(entry.Element(atom + "content") // .Element(dsmd + "properties") // .Element(ds + "ContactId").Value) // }; // Id = field.FirstOrDefault().id; // Name = field.FirstOrDefault().name; // ContactId = field.FirstOrDefault().contactId; //} var dataRequest = HttpWebRequest.Create(BpmOnline.ServerUri + "SysAdminUnitCollection?$select=Id,Name,ContactId&$filter=Name eq '" + name + "'") as HttpWebRequest; dataRequest.Method = "GET"; dataRequest.CookieContainer = BpmOnline.AuthCookie; CookieCollection cookieCollection = BpmOnline.AuthCookie.GetCookies(new Uri(BpmOnline.AuthServiceUri)); string csrfToken = cookieCollection["BPMCSRF"].Value; ((HttpWebRequest)dataRequest).Headers.Add("BPMCSRF", csrfToken); using (var dataResponse = (HttpWebResponse)dataRequest.GetResponse()) { XDocument xmlDoc = XDocument.Load(dataResponse.GetResponseStream()); var field = from entry in xmlDoc.Descendants(atom + "entry") select new { id = new Guid(entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Id").Value), name = entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "Name").Value, contactId = new Guid(entry.Element(atom + "content") .Element(dsmd + "properties") .Element(ds + "ContactId").Value) }; Id = field.FirstOrDefault().id; Name = field.FirstOrDefault().name; ContactId = field.FirstOrDefault().contactId; } } }