public void ImportFromExcel(string excelFileName, string dataSheet, InsuranceType insType, bool isCashFlow) { var govs = _db.Entities .Where(e => e.Identity.Contains(string.Format("{0}(guid'", _db.Governors.RequestUri.PathAndQuery))) .Select(ed => ProxyActivator.CreateProxy <Governor, BLL.Governor>(ed.Entity as Governor)).ToList(); XlsObject <BLL.AssetValue> parser; if (isCashFlow) { parser = new AssetsCashXlsObject(govs, insType, excelFileName, dataSheet); } else { parser = new AssetsValXlsObject(govs, insType, excelFileName, dataSheet); } var list = parser.SelectAll().Select(val => Newtonsoft.Json.JsonConvert.SerializeObject(val)).ToList(); UriBuilder urib = new UriBuilder(_db.BaseUri); urib.Path = string.Format("{0}/CreateBatch", _db.Assets.RequestUri.PathAndQuery); var r = _db.Execute <bool>(urib.Uri, "POST", true , new System.Data.Services.Client.BodyOperationParameter("Values", list) ).FirstOrDefault(); if (!r) { throw new InvalidOperationException("ImportFromExcel"); } }
public IEnumerable <BLL.AssetValue> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; orderBy.PropertyNameResolver = propResolver; if (filters != null) { filters.PropertyNameResolver = propResolver; } int skip = pageIndex * pageSize; var list = _db.Assets.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); var govCtx = _db.Governors; foreach (var m in list) { //provide action like '$expand' for Governors var gov = govCtx.GetById(m.GovernorId); if (gov == null) { gov = govCtx.ToList().FirstOrDefault(g => g.Id == m.GovernorId); } m.Governor = gov; yield return(ProxyActivator.CreateProxy <AssetValue, BLL.AssetValue>(m)); } } }
public IEnumerable <BLL.Governor> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; int skip = pageIndex * pageSize; var list = _db.Governors.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); foreach (var m in list) { yield return(ProxyActivator.CreateProxy <Governor, BLL.Governor>(m)); } } }
public IEnumerable <BLL.WorkCalendar> GetList(FilterParameterCollection filters, int pageIndex, int pageSize, SortParameterCollection orderBy) { lock (_db) { orderBy.DefaultOrder = defaultSorting; int skip = pageIndex * pageSize; if (filters != null) { filters.OperatorActionResolver = opResolver; } var list = _db.Holidays.AddFilters(filters).AddOrders(orderBy).Skip(skip).Take(pageSize); foreach (var m in list) { yield return(ProxyActivator.CreateProxy <WorkCalendar, BLL.WorkCalendar>(m)); } } }
public void Update(BLL.AssetValue o) { var proxy = o as IDtoProxy; if (proxy != null) { Guid govId = o.Governor.Id; var dto = proxy.Dto as AssetValue; if (govId != dto.GovernorId) { dto.GovernorId = govId; dto.Governor = _db.Governors.GetById(govId); o.Governor = ProxyActivator.CreateProxy <Governor, BLL.Governor>(dto.Governor); //_db.SetLink(dto, "Governor", gov); } _db.UpdateObject(dto); _db.SaveChanges(System.Data.Services.Client.SaveChangesOptions.ReplaceOnUpdate); } o.GovernorId = o.Governor.Id; }