Exemplo n.º 1
0
        ///存到資料庫- CommunRecord
        public void CommunCreate(ISheet sheet, Attachment attach)
        {
            IRow row = null;

            if (sheet != null)
            {
                int rowCount = sheet.LastRowNum;
                if (rowCount > 0)
                {
                    IRow firstRow  = sheet.GetRow(0);       //NPOI row
                    int  cellCount = firstRow.LastCellNum;

                    for (int i = 0; i <= rowCount; i++)
                    {
                        row = sheet.GetRow(i);
                        if (row == null)
                        {
                            continue;
                        }
                        CommunRecord rec = new CommunRecord();
                        rec = CommunMapper(rec, row);
                        if (rec != null)
                        {
                            rec.GetType().GetProperty("AttachmentId").SetValue(rec, attach.AttachmentId);
                            commCrud.Create(rec);
                        }
                    }
                }
            }
        }
 public ActionResult Edit(CommunRecord com)
 {
     // TODO: Add update logic here
     if (ModelState.IsValid)
     {
         communSrv.commCrud.Update(com);
     }
     return(RedirectToAction("Index", new { id = com.AttachmentId }));
 }
Exemplo n.º 3
0
        //map table欄位 - CommunRecord
        public CommunRecord CommunMapper(CommunRecord rec, IRow row)
        {
            DataFormatter Formatter = new DataFormatter(CultureInfo.CurrentCulture);

            string[] conArray  = { "受話", "發話", "簡訊", "轉接" };
            string   firstCell = Formatter.FormatCellValue(row.GetCell(0));

            //判斷是否通聯記錄內容
            if (conArray.Where(c => firstCell.Contains(c)).Any() && firstCell != "")
            {
                rec.CType          = Formatter.FormatCellValue(row.GetCell(0));
                rec.CPhoneNum      = Formatter.FormatCellValue(row.GetCell(1));
                rec.CCorrePhoneNum = Formatter.FormatCellValue(row.GetCell(2));

                //將字串轉換成時間
                rec.CStartTime = ParseHelper.ParseDateTime(Formatter.FormatCellValue(row.GetCell(3)));
                rec.CEndTime   = ((DateTime)rec.CStartTime).AddSeconds(row.GetCell(4).NumericCellValue);


                rec.CIMEI            = Formatter.FormatCellValue(row.GetCell(5));
                rec.CThroughPhoneNum = Formatter.FormatCellValue(row.GetCell(6));

                //基地台編號和地址分離
                string   station       = Formatter.FormatCellValue(row.GetCell(7));
                string[] stationDetail = station.Split('/');
                if (stationDetail.Length >= 2)
                {
                    rec.CStationNum     = stationDetail[0];
                    rec.CStationAddress = stationDetail[1];
                }

                rec.isDeleted = false;
                return(rec);
            }
            else
            {
                return(null);
            }
        }
        // GET: CommunRecords/Edit/5
        public ActionResult Edit(int id)
        {
            CommunRecord com = communSrv.commCrud.Get(c => c.CPhoneRecordId == id);

            return(View(com));
        }