public void GetContactCollection() { var context = new BPMonline(ServerUri) { Credentials = new NetworkCredential("Supervisor", "Supervisor") }; _allContacts = context.ContactCollection; }
public static IEnumerable <Contact> GetOdataCollection() { var context = new BPMonline(serverUri); IEnumerable <Contact> allContacts = null; context.SendingRequest += new EventHandler <SendingRequestEventArgs>(OnSendingRequestCookie); try { allContacts = (from contacts in context.ContactCollection.OrderByDescending(p => p.CreatedOn) select contacts).Take(40); } catch (Exception ex) { Debug.WriteLine(ex.Message); } return(allContacts); }
public static void DeleteEntity(Guid accountId) { var context = new BPMonline(serverUri); context.SendingRequest += new EventHandler <SendingRequestEventArgs>(LoginClass.OnSendingRequestCookie); if (context.AccountCollection.Where(c => c.Id == accountId).Count() == 0) { throw new Exception(Localize.NotExistError); } var deleteAccount = context.AccountCollection.Where(c => c.Id == accountId).First(); context.DeleteObject(deleteAccount); var responces = context.SaveChanges(SaveChangesOptions.Batch); }
public static void CreateEntity(string name, int completness, DateTime createdOn, Guid typeId) { var account = new Account() { Id = Guid.NewGuid(), Name = name, Completeness = completness, CreatedOn = createdOn, TypeId = typeId }; var context = new BPMonline(serverUri); context.SendingRequest += new EventHandler <SendingRequestEventArgs>(LoginClass.OnSendingRequestCookie); context.AddToAccountCollection(account); DataServiceResponse responces = context.SaveChanges(SaveChangesOptions.Batch); }
//request public IEnumerable <Contact> GetContacts() { WebOperationContext.Current.OutgoingResponse.Headers.Add("Cache-Control", "no-cache"); var context = new BPMonline(serverUri); context.SendingRequest += new EventHandler <SendingRequestEventArgs>(OnSendingRequestCookie); int ContactCollectionLenght = context.ContactCollection.Count(); return(from o in context.ContactCollection.Take(ContactCollectionLenght) select new Contact() { Name = o.Name, Dear = o.Dear, BirthDate = o.BirthDate.Value.ToShortDateString(), JobTitle = o.JobTitle, MobilePhone = o.MobilePhone, Id = o.Id }); }
public static IQueryable <BpmOnline.EntityDataServiceReference.Contact> GetOdataCollectioByLinq() { // Создание контекста приложения BPMonline. var context = new BPMonline(serverUri); // Определение метода, который добавляет аутентификационные cookie при создании нового запроса. context.SendingRequest += new EventHandler <SendingRequestEventArgs>(OnSendingRequestCookie); try { // Построение запроса LINQ для получение коллекции контактов. var res = from contacts in context.ContactCollection select contacts; return(res.OrderBy(c => c.Name)); } catch (Exception ex) { // Обработка ошибок. return(null); } }
public static IEnumerable <Contact> GetOdataCollectioByLinqWcfExample() { IEnumerable <Contact> allContacts = null; // Создание контекста приложения BPMonline. var context = new BPMonline(serverUri); // Определение метода, который добавляет аутентификационные cookie при создании нового запроса. context.SendingRequest += new EventHandler <SendingRequestEventArgs>(OnSendingRequestCookie); try { // Построение запроса LINQ для получение коллекции контактов. allContacts = from contacts in context.ContactCollection select contacts; } catch (Exception ex) { // Обработка ошибок. } return(allContacts); }
public static void ReadEntity(string probableName) { var context = new BPMonline(serverUri); context.SendingRequest += new EventHandler <SendingRequestEventArgs>(LoginClass.OnSendingRequestCookie); if (context.AccountCollection.Where(c => c.Name.Contains(probableName)).Count() < 1) { throw new Exception(Localize.NotExistError); } AccountType accountType = new AccountType(); var allAccounts = context.AccountCollection.Where(c => c.Name.Contains(probableName)); foreach (Account account in allAccounts) { if (account.TypeId != Guid.Empty && account.TypeId != null) { accountType = context.AccountTypeCollection.Where((c => c.Id == account.TypeId)).First(); } Console.WriteLine(String.Format(Localize.AccountOutput, account.Name, accountType.Name, account.Zip, account.Completeness, account.CreatedOn)); } }
private static BPMonline InitBpmonline() { if (bpMonline == null) { bpMonline = new BPMonline(ServerUri) { Credentials = new NetworkCredential(UserName, UserPass) }; bpmTimeAuth = DateTime.Now.AddMinutes(10); return bpMonline; } if (bpmTimeAuth < DateTime.Now) { bpMonline = new BPMonline(ServerUri) { Credentials = new NetworkCredential(UserName, UserPass) }; bpmTimeAuth = DateTime.Now.AddMinutes(10); } return bpMonline; }