Exemplo n.º 1
0
        public FinanceResponse Upload(HttpRequestMessage request)
        {
            try
            {
                string       relativePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
                string       path         = Path.GetFullPath(relativePath + ".Cache/") + SerialNoService.GetUUID() + ".xls";
                FileStream   fs           = new FileStream(path, FileMode.Append);
                BinaryWriter w            = new BinaryWriter(fs);
                fs.Position = fs.Length;
                request.Content.CopyToAsync(fs).Wait();
                w.Close();
                fs.Close();

                var    query = request.GetQueryNameValuePairs();
                string name  = "";
                foreach (var kv in query)
                {
                    if (kv.Key == "name")
                    {
                        name = kv.Value;
                        break;
                    }
                }

                IImportHandler dtl = null;
                switch (name)
                {
                case "BalanceSheet":
                    dtl = new BalanceSheetDTL();
                    break;

                case "ProfitSheet":
                    dtl = new ProfitSheetDTL();
                    break;
                }
                if (dtl == null)
                {
                    return(CreateResponse(FinanceResult.SYSTEM_ERROR));
                }

                dtl.SetFileName(path);
                ExcelImportor importor = new ExcelImportor(long.Parse(Tid), dtl);
                importor.Import();

                return(CreateResponse(FinanceResult.SUCCESS));
            }
            catch
            {
                return(CreateResponse(FinanceResult.SYSTEM_ERROR));
            }
        }
Exemplo n.º 2
0
 public ExcelImportor(long tid, IImportHandler dtl)
 {
     mTid = tid;
     dtl.SetTid(tid);
     m_DTL = dtl;
 }