Example #1
0
        private string GetStringValue(ExcelDataImportDirector excel, int row, string column)
        {
            //历史版本从0开始,这里+1修正
            var str = excel.GetCellValue(row + 1, column);

            return(str);
        }
Example #2
0
        private decimal GetDecimalValue(ExcelDataImportDirector excel, int row, string column)
        {
            //历史版本从0开始,这里+1修正
            var     str    = excel.GetCellValue(row + 1, column);
            decimal result = 0;

            try
            {
                if (str != null)
                {
                    result = decimal.Parse(str);
                }
            }
            catch
            {
                PluploadHandler.WriteErrorMsg("Sheet(PMT)中第" + (row + 1) + "行数据格式有误,只能输入数字类型的数据!");
            }
            return(result);
        }
        public IHttpActionResult UploadClosureWOCheckListTemplate(string projectid)
        {
            var request        = HttpContext.Current.Request;
            var fileCollection = request.Files;

            if (fileCollection.Count > 0)
            {
                _refId = GetRefId(projectid, ClosureWOCheckList.TableName);
                if (_refId.HasValue)
                {
                    var file          = fileCollection[0];
                    var fileExtension = Path.GetExtension(file.FileName);
                    var name          = _refId.Value.ToString() + "WriteOff";
                    var fileName      = string.Format(@"{0}UploadFiles/{1}{2}",
                                                      HttpContext.Current.Server.MapPath("~/"),
                                                      name, fileExtension);
                    file.SaveAs(fileName);

                    if (!IsMeetVersion(ExcelDataInputType.ClosureWOCheckList.ToString(), fileName))
                    {
                        PluploadHandler.WriteErrorMsg("上传的是非标准模板,请下载标准模板再上传");
                    }

                    var fileInfo       = new FileInfo(fileName);
                    var importDirector = new ExcelDataImportDirector(fileInfo, ExcelDataImportType.ClosureWOCheckList);

                    decimal RE_NBV = 0;
                    decimal.TryParse(importDirector.GetCellValue(9, "E"), out RE_NBV);
                    decimal LHI_NBV = 0;
                    decimal.TryParse(importDirector.GetCellValue(10, "E"), out LHI_NBV);
                    decimal ESSD_NBV = 0;
                    decimal.TryParse(importDirector.GetCellValue(11, "E"), out ESSD_NBV);
                    decimal Equipment_Transfer = 0;
                    decimal.TryParse(importDirector.GetCellValue(16, "E"), out Equipment_Transfer);

                    importDirector.FillEntityEvent += FillClosureWOCheckList;
                    using (TransactionScope scope = new TransactionScope())
                    {
                        importDirector.ParseAndImport();

                        AddUpdateAttachment(name + fileExtension, ClosureWOCheckList.TableName, "Template", fileCollection);

                        var currentNode = NodeInfo.GetCurrentNode(projectid, FlowCode.Closure_WOCheckList);
                        var newNode     = NodeInfo.GetNodeInfo(NodeCode.Closure_WOCheckList_ResultUpload);
                        if (newNode.Sequence > currentNode.Sequence)
                        {
                            ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_DownLoadTemplate);
                            ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_WriteOffData);
                            ProjectInfo.FinishNode(projectid, FlowCode.Closure_WOCheckList, NodeCode.Closure_WOCheckList_ResultUpload);
                        }

                        scope.Complete();
                    }

                    if (_woCheckList != null)
                    {
                        var closureToolHandler = new ClosureTool();

                        var oldRE_NBV            = _woCheckList.RE_NBV ?? 0;
                        var oldLHI_NBV           = _woCheckList.LHI_NBV ?? 0;
                        var oldESSD_NBV          = _woCheckList.ESSD_NBV ?? 0;
                        var oldEquipmentTransfer = _woCheckList.EquipmentTransfer ?? 0;

                        if ((RE_NBV != oldRE_NBV) || (LHI_NBV != oldLHI_NBV) || (ESSD_NBV != oldESSD_NBV) || (Equipment_Transfer != oldEquipmentTransfer))
                        {
                            var __woCheckList = ClosureWOCheckList.FirstOrDefault(e => e.Id.ToString().Equals(_woCheckList.Id.ToString()));
                            if (__woCheckList != null)
                            {
                                __woCheckList.RefreshClosureTool = true;
                                __woCheckList.Update();
                            }
                            //var closureToolController = new ClosureToolController();
                            //var toolEntity = ClosureTool.Get(projectid);
                            //if (toolEntity != null)
                            //{
                            //    //判断是否满足生成closureTools的条件
                            //    if (toolEntity.EnableReGenClosureTool())
                            //    {

                            //        closureToolController.GenClosureTool(toolEntity.Id, toolEntity.UserAccount, toolEntity.UserNameZHCN, toolEntity.UserNameENUS);
                            //        closureToolController.CallClosureTool(toolEntity.Id);

                            //        //通知Finance Specialist和Asset Actor
                            //        var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == projectid);
                            //        List<string> receiverList = new List<string>();
                            //        receiverList.Add(closureInfo.AssetActorAccount);
                            //        receiverList.Add(closureInfo.FinanceAccount);
                            //        var notificationMsg = new NotificationMsg()
                            //        {
                            //            FlowCode = FlowCode.Closure_WOCheckList,
                            //            ProjectId = projectid,
                            //            SenderCode = ClientCookie.UserCode,
                            //            Title = "由于WO Tool数据发生变化,Closure Tool文件已自动更新",
                            //            RefId = _woCheckList.Id,
                            //            UsCode = _woCheckList.USCode,
                            //            IsSendEmail = false,
                            //            ReceiverCodeList = receiverList
                            //        };
                            //        Notification.Send(notificationMsg);
                            //    }
                            //}
                        }
                    }
                }
            }
            return(Ok());
        }