private void addNewRowToDT(DataTable toInsertDT, DataRow nodeRow, List <string> updateCols,
                                   S_DOC_Space space, S_DOC_Node nodeConfig)
        {
            var newRow = toInsertDT.NewRow();

            newRow["ID"]              = FormulaHelper.CreateGuid();
            newRow["CreateDate"]      = DateTime.Now;
            newRow["ModifyDate"]      = DateTime.Now;
            newRow["CreateUserID"]    = this.CurrentUserInfo.UserID;
            newRow["CreateUser"]      = this.CurrentUserInfo.UserName;
            newRow["ModifyUserID"]    = this.CurrentUserInfo.UserID;
            newRow["ModifyUser"]      = this.CurrentUserInfo.UserName;
            newRow["OrgID"]           = this.CurrentUserInfo.UserOrgID;
            newRow["CompanyID"]       = this.CurrentUserInfo.UserCompanyID;
            newRow["State"]           = IdentifyState.Create.ToString();
            newRow["SpaceID"]         = space.ID;
            newRow["SpaceName"]       = space.Name;
            newRow["NodeID"]          = nodeRow["ID"].ToString();
            newRow["ConfigID"]        = nodeConfig.ID;
            newRow["DataType"]        = nodeConfig.Name;
            newRow["KeepYearToToday"] = GetKeepYearToToday(Convert.ToDateTime(nodeRow["ArchiveDate"]));

            foreach (var item in updateCols)
            {
                newRow[item] = nodeRow[item];
            }

            toInsertDT.Rows.Add(newRow);
        }
Beispiel #2
0
 //遗失损毁校验
 public void LostDamageVerifica(Dictionary <string, string> dic, List <Dictionary <string, object> > lostReplenishList)
 {
     foreach (var lostReplenishDetail in lostReplenishList)
     {
         string      relateID      = lostReplenishDetail.ContainsKey("RelateDocID") ? lostReplenishDetail["RelateDocID"].ToString() : "";//文件或节点ID
         string      spaceID       = lostReplenishDetail.ContainsKey("SpaceID") ? lostReplenishDetail["SpaceID"].ToString() : "";
         S_DOC_Space space         = Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID));
         string      relateDocType = lostReplenishDetail.ContainsKey("RelateDocType") ? lostReplenishDetail["RelateDocType"].ToString() : "";//文件或结点
         string      state         = "";
         if (dic.ContainsKey("LostDetail"))
         {
             state = lostReplenishDetail.ContainsKey("LoseDamageState") ? lostReplenishDetail["LoseDamageState"].ToString() : "";//遗失损毁状态
         }
         int lostReplenishCount = lostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]);
         if (relateDocType.ToLower() == "node")
         {
             S_NodeInfo node       = new S_NodeInfo(relateID, space);
             object     storageNum = null;
             node.DataEntity.TryGetValue("StorageNum", out storageNum);
             if (lostReplenishCount > Convert.ToInt32(storageNum))
             {
                 throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写");
             }
             continue;
         }
         else
         {
             S_FileInfo file       = new S_FileInfo(relateID, space);
             object     storageNum = null;
             file.DataEntity.TryGetValue("StorageNum", out storageNum);
             if (lostReplenishCount > Convert.ToInt32(storageNum))
             {
                 throw new Formula.Exceptions.BusinessException("遗失份数大于库存,请重新填写");
             }
             continue;
         }
     }
 }
Beispiel #3
0
        void _archiveDBS(S_D_DBS parentDBS, List <S_D_DBS> archiveDbsList, S_NodeInfo parentNode, S_DOC_Space docSpace, bool archiveFiles = true, bool isAll = true)
        {
            var folders = archiveDbsList.Where(d => d.ParentID == parentDBS.ID).ToList();

            foreach (var folder in folders)
            {
                if (String.IsNullOrEmpty(folder.ArchiveFolder))
                {
                    continue;
                }
                S_NodeInfo node = S_NodeInfo.GetNode(docSpace.ID, folder.ArchiveFolder, " where Name='" + folder.Name + "' and ParentID='" + parentNode.ID + "' ");
                if (node == null)
                {
                    node = new DocSystem.Logic.Domain.S_NodeInfo(docSpace.ID, folder.ArchiveFolder);
                    this.SetAttr <S_D_DBS>(node, folder);
                    node.Name = folder.Name;
                    node.DataEntity.SetValue("State", DocState.Normal.ToString());
                    node.DataEntity.SetValue("RelateID", folder.ID);
                    parentNode.AddChild(node, true);
                }
                else
                {
                    this.SetAttr <S_D_DBS>(node, folder);
                    node.Name = folder.Name;
                    node.DataEntity.SetValue("State", DocState.Normal.ToString());
                    node.DataEntity.SetValue("RelateID", folder.ID);
                    node.Save();
                }
                if (archiveFiles && node.ConfigInfo.S_DOC_FileNodeRelation.Count > 0 && node.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault().S_DOC_File != null)
                {
                    #region 归档文件
                    var fileConfig = node.ConfigInfo.S_DOC_FileNodeRelation.FirstOrDefault().S_DOC_File;
                    var docList    = folder.S_D_Document.ToList();
                    var _group     = docList.GroupBy(a => a.RelateID).Select(a =>
                                                                             new { a.Key, MaxVersion = a.Max(b => (string.IsNullOrEmpty(b.Version) ? 0d : Convert.ToDouble(b.Version))) }
                                                                             ).ToList();
                    if (!isAll)
                    {
                        docList = docList.Where(a => _group.Any(g => g.Key == a.RelateID && g.MaxVersion == (string.IsNullOrEmpty(a.Version) ? 0d : Convert.ToDouble(a.Version)))).ToList();
                    }
                    foreach (var doc in docList)
                    {
                        var file = S_FileInfo.GetFile(docSpace.ID, fileConfig.ID, " NodeID='" + node.ID + "' and RelateID='" + doc.ID + "' ");
                        if (file == null)
                        {
                            file = new DocSystem.Logic.Domain.S_FileInfo(docSpace.ID, fileConfig.ID);
                            if (!String.IsNullOrEmpty(doc.Attr))
                            {
                                this.SetFileAttr(file, doc.Attr);
                            }
                            file.DataEntity.SetValue("Name", doc.Name);
                            file.DataEntity.SetValue("Code", doc.Code);
                            file.DataEntity.SetValue("RelateID", doc.ID);
                            file.DataEntity.SetValue("State", DocState.Normal);
                            if (!String.IsNullOrEmpty(doc.MainFiles) || !String.IsNullOrEmpty(doc.PDFFile) ||
                                !String.IsNullOrEmpty(doc.PlotFile) || !String.IsNullOrEmpty(doc.XrefFile) ||
                                !String.IsNullOrEmpty(doc.DwfFile) || !String.IsNullOrEmpty(doc.TiffFile) ||
                                !String.IsNullOrEmpty(doc.SignPdfFile))
                            {
                                var attachment = new S_Attachment(docSpace.ID);
                                attachment.DataEntity.SetValue("MainFile", doc.MainFiles);
                                attachment.DataEntity.SetValue("PDFFile", doc.PDFFile);
                                attachment.DataEntity.SetValue("PlotFile", doc.PlotFile);
                                attachment.DataEntity.SetValue("XrefFile", doc.XrefFile);
                                attachment.DataEntity.SetValue("DwfFile", doc.DwfFile);
                                attachment.DataEntity.SetValue("TiffFile", doc.TiffFile);
                                attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile);
                                attachment.DataEntity.SetValue("CreateUser", this.CurrentUserInfo.UserID);
                                attachment.DataEntity.SetValue("CreateUserName", this.CurrentUserInfo.UserName);
                                file.AddAttachment(attachment);
                            }
                            node.AddFile(file, true);
                        }
                        else
                        {
                            if (!String.IsNullOrEmpty(doc.Attr))
                            {
                                this.SetFileAttr(file, doc.Attr);
                            }
                            file.Save();
                            var attachment = new S_Attachment(docSpace.ID);
                            attachment.DataEntity.SetValue("MainFile", doc.MainFiles);
                            attachment.DataEntity.SetValue("PDFFile", doc.PDFFile);
                            attachment.DataEntity.SetValue("PlotFile", doc.PlotFile);
                            attachment.DataEntity.SetValue("XrefFile", doc.XrefFile);
                            attachment.DataEntity.SetValue("DwfFile", doc.DwfFile);
                            attachment.DataEntity.SetValue("TiffFile", doc.TiffFile);
                            attachment.DataEntity.SetValue("SignPdfFile", doc.SignPdfFile);
                            attachment.DataEntity.SetValue("CreateUser", this.CurrentUserInfo.UserID);
                            attachment.DataEntity.SetValue("CreateUserName", this.CurrentUserInfo.UserName);
                            file.AddAttachment(attachment);
                        }
                        doc.State       = "Archive";
                        doc.ArchiveDate = DateTime.Now;
                        if (doc.RelateTable == "S_E_Product")
                        {
                            //string update = "Update S_E_Product Set ArchiveState='True', ArchiveDate='" + DateTime.Now.ToString() + "' where ID='" + doc.RelateID + "'";
                            string update = string.Format(@"update S_E_Product set ArchiveState='True', ArchiveDate='{2}' where ID='{0}'
update S_E_ProductVersion set ArchiveState='True', ArchiveDate='{2}' where ProductID='{0}' and Version='{1}'", doc.RelateID, doc.Version, DateTime.Now.ToString());
                            this.entities.Database.ExecuteSqlCommand(update);
                        }
                    }
                    #endregion
                }
                _archiveDBS(folder, archiveDbsList, node, docSpace, archiveFiles, isAll);
            }
        }
Beispiel #4
0
        protected override void BeforeSave(Dictionary <string, string> dic, Base.Logic.Domain.S_UI_Form formInfo, bool isNew)
        {
            List <Dictionary <string, object> > lostReplenishList = null;
            List <Dictionary <string, object> > replenishList     = new List <Dictionary <string, object> >();
            S_NodeInfo nodeInfo = null;
            S_FileInfo fileInfo = null;

            //遗失登记
            if (dic.ContainsKey("LostDetail"))
            {
                lostReplenishList = JsonHelper.ToList(dic["LostDetail"]);
                //遗失损毁数量校验
                LostDamageVerifica(dic, lostReplenishList);
            }
            else
            {
                lostReplenishList = JsonHelper.ToList(dic["Detail"]);//补录
            }
            if (lostReplenishList.Count <= 0)
            {
                throw new Formula.Exceptions.BusinessException("请添加内容之后,再保存!");
            }
            var           entities  = Formula.FormulaHelper.GetEntities <DocConstEntities>();
            InventoryType stateType = new InventoryType();

            foreach (var lostReplenishDetail in lostReplenishList)
            {
                string      relateID      = lostReplenishDetail.ContainsKey("RelateDocID") ? lostReplenishDetail["RelateDocID"].ToString() : "";//文件或节点ID
                string      spaceID       = lostReplenishDetail.ContainsKey("SpaceID") ? lostReplenishDetail["SpaceID"].ToString() : "";
                S_DOC_Space space         = Formula.FormulaHelper.GetEntities <DocConfigEntities>().S_DOC_Space.FirstOrDefault(a => a.ID.Equals(spaceID));
                string      relateDocType = lostReplenishDetail.ContainsKey("RelateDocType") ? lostReplenishDetail["RelateDocType"].ToString() : "";//文件或结点
                string      state         = "";
                if (dic.ContainsKey("LostDetail"))
                {
                    state = lostReplenishDetail.ContainsKey("LoseDamageState") ? lostReplenishDetail["LoseDamageState"].ToString() : "";//遗失损毁状态
                }
                //遗失或损毁补录份数
                #region 库存数量的增减
                int LostReplenishCount = 0;
                int datilCount         = 0;//补录份数可能为负数
                if (state.Equals(InventoryType.Destroy.ToString()) || state.Equals(InventoryType.Lose.ToString()))
                {
                    stateType          = state.Equals(InventoryType.Destroy.ToString()) ? InventoryType.Destroy : InventoryType.Lose;
                    LostReplenishCount = Convert.ToInt32(lostReplenishDetail["LoseCount"]);
                    LostReplenishCount = -LostReplenishCount;
                }
                else
                {
                    stateType          = InventoryType.Replenish;
                    LostReplenishCount = Convert.ToInt32(lostReplenishDetail["ReplenishCount"]);
                }
                datilCount = stateType == InventoryType.Replenish? LostReplenishCount:-LostReplenishCount;
                if (relateDocType == "Node")
                {
                    nodeInfo = new S_NodeInfo(relateID, space);
                    InventoryFO.CreateInventoryLedger(nodeInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份");//入库
                }
                else
                {
                    fileInfo = new S_FileInfo(relateID, space);
                    InventoryFO.CreateInventoryLedger(fileInfo, stateType, LostReplenishCount, LostReplenishCount, "", "", "", EnumBaseHelper.GetEnumDescription(stateType.GetType(), stateType.ToString()) + "份数:" + datilCount + "份");
                }
                #endregion
                if (dic.ContainsKey("LostDetail"))
                {
                    AddLostDamage(dic, lostReplenishDetail, entities);//遗失
                }
                else
                {
                    AddReplenish(dic, lostReplenishDetail, entities, ref replenishList);//补录
                }
            }
            if (dic.ContainsKey("Detail"))
            {
                dic["Detail"] = JsonHelper.ToJson(replenishList).ToString();
            }
            entities.SaveChanges();
        }