示例#1
0
        public async Task <OSModel> GetOS([FromUri] int osId)
        {
            Entities.OperatingSystem os = await this._osManager.GetOS(osId);

            OSModel model = Mapper.Map <OSModel>(os);

            return(model);
        }
示例#2
0
        // 如果用户安装时选择不安装案例,则流程树、表单树和组织结构表都不存在根节点,此时需要手动添加根节点,
        // 流程设计器初始化时调用
        // 此功能应该添加到安装时,因为每次流程树加载都需要执行一次检查
        private bool TreeRootCheck()
        {
            try
            {
                // 流程树根节点校验
                string tmp = "SELECT Name FROM WF_FlowSort where ParentNo =0";
                tmp = DBAccess.RunSQLReturnString(tmp);
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "INSERT INTO WF_FlowSort(No,Name,ParentNo,TreeNo,idx,IsDir) values('99','流程树','0','',0,0)";
                    DBAccess.RunSQLReturnString(tmp);
                }

                // 表单树根节点校验
                tmp = "SELECT Name FROM Sys_FormTree where ParentNo =0";
                tmp = DBAccess.RunSQLReturnString(tmp);
                if (string.IsNullOrEmpty(tmp))
                {
                    tmp = "INSERT INTO Sys_FormTree(No,Name,ParentNo,TreeNo,idx,IsDir) values('99','表单树','0','',0,0)";
                    DBAccess.RunSQLReturnString(tmp);
                }

                // 组织结构校验
                model = (OSModel)Enum.Parse(typeof(OSModel), this.GetConfig("OSModel"), true);
                if (model == BP.Sys.OSModel.OneOne)
                {
                    BP.GPM.Depts rootDepts = new BP.GPM.Depts("0");
                    if (rootDepts == null || rootDepts.Count == 0)
                    {
                        BP.GPM.Dept rootDept = new BP.GPM.Dept();
                        rootDept.Name = "集团总部";
                        rootDept.No   = "0";
                        rootDept.Idx  = 0;
                        rootDept.Insert();
                    }
                }
                else if (model == BP.Sys.OSModel.OneOne)
                {
                    BP.Port.Depts rootDepts = new BP.Port.Depts("0");
                    if (rootDepts == null || rootDepts.Count == 0)
                    {
                        BP.GPM.Dept rootDept = new BP.GPM.Dept();
                        rootDept.Name = "集团总部";
                        rootDept.No   = "0";
                        rootDept.Idx  = 0;
                        rootDept.Insert();
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                throw new Exception("流程树根节点检查错误", e);
            }
        }
示例#3
0
        public OSModel PutOS(OSModel osm)
        {
            osm.Desc = Utils.CleanString(osm.Desc);
            osm.Version = Utils.CleanString(osm.Version);

            // ReleaseDate can NOT be after ExpirationDate
            if (osm.ExpirationDate.HasValue == true && osm.ReleaseDate.CompareTo(osm.ExpirationDate.Value) > 0)
            {
                Utils.Log(new Logger("SiteData_OSs", "PutOS", "Release date can not be after expiration date.", 56, LogType.ERROR));
                throw new Exception("Release date can not be after expiration date.");
            }

            OS tmpOS = null;
            OSModel retModel = new OSModel();

            using (CanIUpdateEFDB db = new CanIUpdateEFDB())
            {
                tmpOS = db.OSs.Where(o => o.OSId == osm.OSId).FirstOrDefault<OS>();
                if (tmpOS == null)
                {
                    // INSERT (no expiration date on new OS)
                    tmpOS = new OS();
                    tmpOS.Desc			= retModel.Desc			= osm.Desc;
                    tmpOS.ReleaseDate	= retModel.ReleaseDate	= osm.ReleaseDate;
                    tmpOS.Version		= retModel.Version		= osm.Version;
                    db.OSs.Add(tmpOS);
                }
                else
                {
                    // UPDATE
                    tmpOS.Desc			= retModel.Desc			= osm.Desc;
                    tmpOS.ReleaseDate	= retModel.ReleaseDate	= osm.ReleaseDate;
                    tmpOS.Version		= retModel.Version		= osm.Version;
                    if (osm.ExpirationDate.HasValue == true)
                        tmpOS.ExpirationDate = retModel.ExpirationDate = osm.ExpirationDate.Value;
                }
                db.SaveChanges();

                // Add mising field(s) data to model
                retModel.OSId = tmpOS.OSId;
            }

            return retModel;
        }
示例#4
0
 public async Task DeleteOS(OSModel os)
 {
     _db.OperatingSystems.Remove(os);
     await _db.SaveChangesAsync();
 }
示例#5
0
        public async Task AddOS(OSModel os)
        {
            await _db.OperatingSystems.AddAsync(os);

            await _db.SaveChangesAsync();
        }