示例#1
0
        public async Task <ActionMessage> Put(int id, [FromForm] NegotiationInfo _Negotiation, [FromForm] List <IFormFile> files, string _userID)
        {
            ActionMessage ret = new ActionMessage();

            try
            {
                ret = NegotiationService.GetInstance().editNegotiation(id, _Negotiation, GetUserId(), _userID);
                //update list file

                DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_Negotiation.ListDocument, TableFile.Negotiation.ToString(), id);
                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Negotiation.ToString();
                    documentInfo.PreferId  = id.ToString();
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.Negotiation.ToString(), _Negotiation.NegotiationID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#2
0
        public async Task <ActionMessage> EditExplanation(int id, ExplanationInfo _Explanation, string _userU, [FromForm] List <IFormFile> files)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();



            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    UserLogInfo info = new UserLogInfo();
                    info.Action      = "Edit";
                    info.Description = "ngày : " + _Explanation.InTime + " code : " + _Explanation.ExplanationCode
                                       + " trạng thái : " + _Explanation.Status;
                    info.Feature  = TableFile.Proposal.ToString();
                    info.Time     = DateTime.Now;
                    info.UserName = _userU;
                    info.UserID   = 1;
                    UserService.GetInstance().TrackUserAction(info);
                    ExplanationDataLayer.GetInstance().UpdateExplanation(connection, id, _Explanation, _userU);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_Explanation.ListDocument, TableFile.Explanation.ToString(), id);

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    foreach (ItemPropsalInfo item in _Explanation.Items)
                    {
                        ProposalDataLayer.GetInstance().UpdateItemExplanation(connection, item, _userU);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            foreach (var item in files)
            {
                DocumentInfo documentInfo = new DocumentInfo();
                documentInfo.TableName = TableFile.Explanation.ToString();
                documentInfo.PreferId  = id.ToString();
                documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                documentInfo.FileName  = item.FileName;
                documentInfo.Length    = item.Length.ToString();
                documentInfo.Type      = item.ContentType;
                ret = await FilesHelpers.UploadFile(TableFile.Explanation.ToString(), id.ToString(), item, documentInfo.Link);

                DocumentService.GetInstance().InsertDocument(documentInfo, _userU.ToString());
            }
            ret.isSuccess = true;
            return(ret);
        }
示例#3
0
        public async Task <ActionMessage> PostwithAttFile([FromForm] NegotiationInfo NegotiationObj, [FromForm] List <IFormFile> files)
        {
            ActionMessage ret     = new ActionMessage();
            int           insetId = -1;

            try
            {
                insetId       = NegotiationService.GetInstance().createNegotiation2(NegotiationObj, GetUserId());
                ret.isSuccess = true;
                if (insetId > -1)
                {
                    ret.id = insetId;
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Negotiation.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                        documentInfo.FileName  = item.FileName;
                        documentInfo.Length    = item.Length.ToString();
                        documentInfo.Type      = item.ContentType;
                        ret = await FilesHelpers.UploadFile(TableFile.Negotiation.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                    }
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#4
0
        public async Task <ActionMessage> Create(AcceptanceInfo obj, [FromForm] List <IFormFile> files, string _userI)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    insetId = AcceptanceDataLayer.GetInstance().Create(connection, obj, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insetId > -1)
            {
                ret.id = insetId;
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        foreach (DeliveryReceiptItemInfoNew item in obj.Items)
                        {
                            ProposalDataLayer.GetInstance().UpdateItemAcceptance(connection, item, _userI);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                if (files != null)
                {
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Acceptance.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                        documentInfo.FileName  = item.FileName;
                        documentInfo.Length    = item.Length.ToString();
                        documentInfo.Type      = item.ContentType;
                        ret = await FilesHelpers.UploadFile(TableFile.Acceptance.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                    }
                }
                ret.isSuccess = true;
            }
            else
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "lỗi thêm phiếu nghiệm thu";
                ret.err.msgString = "lỗi thêm phiếu nghiệm thu";
            }
            return(ret);
        }
示例#5
0
        public async Task <ActionMessage> editBidPlan(int id, BidPlanInfo _BidPlan, string _userU, IList <IFormFile> files, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                var chkBidPlanInfo = BidPlanDataLayer.GetInstance().getBidPlan(connection, id, _userID);
                if (chkBidPlanInfo != null)
                {
                    try
                    {
                        QuoteInfo quoteInfo = QuoteDataLayer.GetInstance().getQuote(connection, _BidPlan.QuoteID, _userID);
                        if (quoteInfo != null)
                        {
                            _BidPlan.QuoteID = quoteInfo.QuoteID;

                            //var ProposalInfo = ProposalDataLayer.GetInstance().getProposalDetail(connection, _BidPlan.ProposalID);
                            //if (ProposalInfo != null)
                            //{
                            //    _BidPlan.ProposalCode = ProposalInfo.ProposalCode;
                            //}
                        }
                        else
                        {
                            _BidPlan.QuoteID /*= _BidPlan.ProposalID*/ = 0;
                        }
                        BidPlanDataLayer.GetInstance().UpdateBidPlan(connection, id, _BidPlan, _userU);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
                DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_BidPlan.ListDocument, TableFile.BidPlan.ToString(), _BidPlan.BidPlanID);

                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.BidPlan.ToString();
                    documentInfo.PreferId  = _BidPlan.BidPlanID.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.BidPlan.ToString(), _BidPlan.BidPlanID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userU);
                }
                ret.isSuccess = true;


                return(ret);
            }
        }
示例#6
0
        public async Task <ActionMessage> Update(AcceptanceInfo obj, [FromForm] List <IFormFile> files, string _userI)
        {
            ActionMessage ret = new ActionMessage();

            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    AcceptanceDataLayer.GetInstance().Update(connection, obj, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            DocumentService.GetInstance().DeleteDocumentsNotExitsInList(obj.ListDocument, TableFile.Acceptance.ToString(), obj.AcceptanceID);

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    foreach (DeliveryReceiptItemInfoNew item in obj.Items)
                    {
                        ProposalDataLayer.GetInstance().UpdateItemAcceptance(connection, item, _userI);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (files != null)
            {
                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Acceptance.ToString();
                    documentInfo.PreferId  = obj.AcceptanceID.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.Acceptance.ToString(), obj.AcceptanceID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                }
            }
            ret.isSuccess = true;


            return(ret);
        }
示例#7
0
        public async Task <ActionMessage> createBidPlan2(BidPlanInfo _BidPlan, string _userI, IList <IFormFile> files, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    QuoteInfo quoteInfo = QuoteDataLayer.GetInstance().getQuote(connection, _BidPlan.QuoteID, _userID);
                    if (quoteInfo != null)
                    {
                        _BidPlan.QuoteID = quoteInfo.QuoteID;
                    }
                    else
                    {
                        _BidPlan.QuoteID /*= _BidPlan.ProposalID*/ = 0;
                    }
                    insetId = BidPlanDataLayer.GetInstance().InsertBidPlan(connection, _BidPlan, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                if (insetId > -1)
                {
                    ret.id = insetId;
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.BidPlan.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                        documentInfo.FileName  = item.FileName;
                        documentInfo.Length    = item.Length.ToString();
                        documentInfo.Type      = item.ContentType;
                        ret = await FilesHelpers.UploadFile(TableFile.BidPlan.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                    }
                    ret.isSuccess = true;
                }
                else
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "lỗi thêm biên bản họp giá";
                    ret.err.msgString = "lỗi thêm biên bản họp giá";
                }
                return(ret);
            }
        }
示例#8
0
        public async Task <ActionMessage> Put(int id, [FromForm] ProposalInfo _proposal, [FromForm] List <IFormFile> files)
        {
            ActionMessage ret = new ActionMessage();

            ret.isSuccess = true;
            try
            {
                ret = ProposalService.GetInstance().editProposal(id, _proposal, GetUserId());
                //update list file
                //ProposalService.GetInstance().DelteDocument(id.ToString());
                if (ret.isSuccess == false)
                {
                    return(ret);
                }
                //++edit item
                ret = ProposalService.GetInstance().EditItems(id, _proposal.Items);
                if (ret.isSuccess == false)
                {
                    return(ret);
                }


                //++EDIT document
                //delete old document
                DocumentService.GetInstance().DeleteDocumentsNotExitsInList(_proposal.Documents, TableFile.Proposal.ToString(), id);
                //add new document
                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Proposal.ToString();
                    documentInfo.PreferId  = id.ToString();
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.Proposal.ToString(), _proposal.ProposalID.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                }
                //--EDIT document
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#9
0
        public async Task <ActionMessage> PostwithAttFile([FromForm] ProposalInfo propsalObj, [FromForm] List <IFormFile> files)
        {
            ActionMessage ret     = new ActionMessage();
            int           insetId = -1;

            try
            {
                ret.isSuccess = true;
                insetId       = ProposalService.GetInstance().createProposal2(propsalObj, GetUserId());
                if (insetId > -1)
                {
                    // upload file
                    //ret = await FilesHelpers.UploadFiles("proposal", insetId.ToString(), files);
                    // update list file
                    ret = ProposalService.GetInstance().insertItems(insetId, propsalObj.Items, propsalObj.DateIn, propsalObj.DepartmentID);
                    if (ret.isSuccess == false)
                    {
                        return(ret);
                    }
                    foreach (var item in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Proposal.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                        documentInfo.FileName  = item.FileName;
                        documentInfo.Length    = item.Length.ToString();
                        documentInfo.Type      = item.ContentType;
                        ret = await FilesHelpers.UploadFile(TableFile.Proposal.ToString(), insetId.ToString(), item, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                    }
                }
                else
                {
                    ret.isSuccess     = false;
                    ret.err.msgCode   = "lỗi thêm proposal";
                    ret.err.msgString = "lỗi thêm proposal";
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Internal Error !!!";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#10
0
        public async Task <ActionMessage> AddComment([FromForm] string preferId, [FromForm] string comment, [FromForm] string feature, [FromForm] List <IFormFile> files)
        {
            int           insetId = -1;
            ActionMessage ret     = new ActionMessage();

            try
            {
                CommentInfo commentInfo = new CommentInfo();
                commentInfo.TableName = feature;
                commentInfo.PreferId  = preferId;
                commentInfo.Comment   = comment;
                insetId       = CommentService.GetInstance().InsertComment(commentInfo, GetUserId());
                ret.isSuccess = true;
                if (insetId > -1)
                {
                    foreach (var file in files)
                    {
                        DocumentInfo documentInfo = new DocumentInfo();
                        documentInfo.TableName = TableFile.Comment.ToString();
                        documentInfo.PreferId  = insetId.ToString();
                        documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(file.FileName);
                        documentInfo.FileName  = file.FileName;
                        documentInfo.Length    = file.Length.ToString();
                        documentInfo.Type      = file.ContentType;
                        ret = await FilesHelpers.UploadFile(documentInfo.TableName, insetId.ToString(), file, documentInfo.Link);

                        DocumentService.GetInstance().InsertDocument(documentInfo, GetUserId());
                    }
                }
            }
            catch (Exception ex)
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "Lỗi thêm comment";
                ret.err.msgString = ex.ToString();
            }
            return(ret);
        }
示例#11
0
        public async Task <ActionMessage> Create(DeliveryReceiptInfo obj, [FromForm] List <IFormFile> files, string _userI, string _userID)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();

            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    insetId = DeliveryReceiptDataLayer.GetInstance().Create(connection, obj, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insetId > -1)
            {
                ret.id = insetId;
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        if (obj.Items != null)
                        {
                            // insertEmployees(insetId, obj.Employees);
                            foreach (DeliveryReceiptItemInfoNew item in obj.Items)
                            {
                                item.DeliveryReceiptID = insetId;
                                if (item.Amount > 0)
                                {
                                    //input tai san
                                    DeliveryReceiptWithDepartment deliveryReceipt = DeliveryReceiptDataLayer.GetInstance().getItemCreateAna(connection, item.DeliveryReceiptID, _userID);
                                    AnalyzerInfo analyzerInfo = new AnalyzerInfo()
                                    {
                                        AnalyzerAccountantCode = "",
                                        AnalyzerName           = item.ItemName,
                                        AnalyzerType           = 0,

                                        QuoteItemID = item.QuoteItemID,
                                        Description = "",

                                        Amount           = item.Amount,
                                        ItemPrice        = item.ItemPrice,
                                        TotalPrice       = item.TotalPrice,
                                        DepartmentRootID = deliveryReceipt.DepartmentID,
                                        DepartmentID     = deliveryReceipt.DepartmentID,

                                        ContractCode  = deliveryReceipt.ContractCode,
                                        UserIContract = deliveryReceipt.UserIContract,
                                        CustomerID    = deliveryReceipt.CustomerID,
                                        CustomerName  = deliveryReceipt.CustomerName,

                                        ExpirationDate    = DateTime.Now,
                                        DateIn            = obj.DeliveryReceiptDate,
                                        DeliveryReceiptID = item.DeliveryReceiptID,
                                        Serial            = "",
                                    };

                                    int seq      = AnalyzerDataLayer.GetInstance().GetMaxPropCode(connection, analyzerInfo.DateIn.Year);
                                    int insertID = AnalyzerDataLayer.GetInstance().InsertAnalyzer(connection, analyzerInfo, seq, _userI);

                                    string[] _anaNamesSplit = analyzerInfo.AnalyzerName.Split(' ');
                                    string   _anaNameSplit  = "";
                                    for (int i = 0; i < _anaNamesSplit.Count(); i++)
                                    {
                                        if (i == 4)
                                        {
                                            break;
                                        }
                                        else
                                        {
                                            _anaNameSplit += (_anaNamesSplit[i][0]).ToString().ToUpper();
                                        }
                                    }
                                    string anacode = _anaNameSplit + "." + analyzerInfo.DateIn.Year + "." + String.Format("{0:000000}", seq);
                                    AnalyzerDataLayer.GetInstance().UpdateAnalyzer(connection, insertID, anacode);
                                    // end insert
                                    DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItem(connection, item, _userI);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        if (obj.Employees != null)
                        {
                            foreach (DeliveryReceiptEmployeeInfo item in obj.Employees)
                            {
                                item.DeliveryReceiptID = insetId;
                                DeliveryReceiptDataLayer.GetInstance().CreateDeliveryReceiptItemUser(connection, item, _userI);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.DeliveryReceipt.ToString();
                    documentInfo.PreferId  = insetId.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    ret = await FilesHelpers.UploadFile(TableFile.DeliveryReceipt.ToString(), insetId.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                }
                ret.isSuccess = true;
            }
            else
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "lỗi thêm phiếu nghiệm thu";
                ret.err.msgString = "lỗi thêm phiếu nghiệm thu";
            }
            return(ret);
        }
示例#12
0
        public async Task <ActionMessage> CreateExplanation2(ExplanationInfo _Explanation, string _userI, [FromForm] List <IFormFile> files)
        {
            ActionMessage        ret           = new ActionMessage();
            int                  insetId       = -1;
            SqlConnectionFactory sqlConnection = new SqlConnectionFactory();



            using (SqlConnection connection = sqlConnection.GetConnection())
            {
                try
                {
                    UserLogInfo info = new UserLogInfo();
                    info.Action      = "Insert";
                    info.Description = "ngày : " + _Explanation.InTime + " code : GTMS-" + _Explanation.ProposalCode
                                       + " trạng thái : " + _Explanation.Status;
                    info.Feature  = TableFile.Proposal.ToString();
                    info.Time     = DateTime.Now;
                    info.UserName = _userI;
                    info.UserID   = 1;
                    UserService.GetInstance().TrackUserAction(info);
                    insetId = ExplanationDataLayer.GetInstance().InsertExplanation(connection, _Explanation, _userI);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (insetId > -1)
            {
                ret.id = insetId;
                using (SqlConnection connection = sqlConnection.GetConnection())
                {
                    try
                    {
                        foreach (ItemPropsalInfo item in _Explanation.Items)
                        {
                            ProposalDataLayer.GetInstance().UpdateItemExplanation(connection, item, _userI);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }

                foreach (var item in files)
                {
                    DocumentInfo documentInfo = new DocumentInfo();
                    documentInfo.TableName = TableFile.Explanation.ToString();
                    documentInfo.PreferId  = insetId.ToString();
                    documentInfo.Link      = DateTime.Now.ToString("yyMMddHHmmssfff") + "-" + Utils.ChuyenTVKhongDau(item.FileName);
                    documentInfo.FileName  = item.FileName;
                    documentInfo.Length    = item.Length.ToString();
                    documentInfo.Type      = item.ContentType;
                    await FilesHelpers.UploadFile(TableFile.Explanation.ToString(), insetId.ToString(), item, documentInfo.Link);

                    DocumentService.GetInstance().InsertDocument(documentInfo, _userI.ToString());
                }
                ret.isSuccess = true;
            }
            else
            {
                ret.isSuccess     = false;
                ret.err.msgCode   = "lỗi thêm phiếu giải trình";
                ret.err.msgString = "lỗi thêm phiếu giải trình";
            }
            return(ret);
        }