Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
        public void ImportFromExcel(string excelFileName, string dataSheet, Model.Enums.InsuranceType insType, bool isCashFlow)
        {
            XlsObject <AssetValue> parser;

            if (isCashFlow)
            {
                parser = new AssetsCashXlsObject(_govRep.GetList(null, 0, int.MaxValue, new SortParameterCollection()), insType, excelFileName, dataSheet);
            }
            else
            {
                parser = new AssetsValXlsObject(_govRep.GetList(null, 0, int.MaxValue, new SortParameterCollection()), insType, excelFileName, dataSheet);
            }

            using (var trans = Transactions.StartNew())
            {
                foreach (var o in parser.SelectAll())
                {
                    this.Create(o);
                }
                trans.Complete();
            }
        }
Ejemplo n.º 3
0
        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");
        }