コード例 #1
0
ファイル: Authorize.aspx.cs プロジェクト: Homory-Temp/LeYi
 protected string ForceTreeName(Department department)
 {
     var count = department.DepartmentUser.Count(
         o =>
             (o.Type == DepartmentUserType.部门主职教师 || o.Type == DepartmentUserType.部门兼职教师 || o.Type == DepartmentUserType.借调后部门主职教师) && o.State == State.启用);
     return count > 0
         ? string.Format("{0} [{1}]", department.DisplayName, count
             )
         : department.DisplayName;
 }
コード例 #2
0
 public static void Operated(this Entities db, OperationType operationType, User user, Department campus)
 {
     try
     {
         if (user == null || campus == null)
             return;
         var ol = new OperationLog();
         ol.Id = db.GetId();
         ol.Time = DateTime.Now;
         ol.Type = operationType;
         ol.UserId = user.Id;
         ol.CampusId = campus.Id;
         db.OperationLog.Add(ol);
         db.SaveChanges();
     }
     catch
     { }
 }
コード例 #3
0
ファイル: Learned.aspx.cs プロジェクト: Homory-Temp/LeYi
 protected string GenerateTreeName(Department department, int index, int level)
 {
     var part1 = level == 1 ? GenGradeName(department) : department.DisplayName;
     var part2 = level == 1
         ? (department.Learned.Count(o => o.State == State.启用) == 0
             ? " [未选择]" : string.Empty) : (department.Learned.Count(o => o.State == State.启用) > 0
             ? " ★" : string.Empty);
     return string.Format("{0}{1}", part1, part2);
 }
コード例 #4
0
ファイル: Campus.aspx.cs プロジェクト: Homory-Temp/LeYi
 protected void grid_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
 {
     if (CurrentRights.Contains(HomoryCoreConstant.RightGlobal))
     {
         foreach (var command in e.Commands)
         {
             var values = command.NewValues;
             if (NotSet(values, "Name"))
                 continue;
             var name = values["Name"].ToString();
             var code = Get(values, "Code", "");
             var ordinal = Get(values, "Ordinal", 99);
             var state = Get(values, "State", State.启用);
             var classType = Get(values, "ClassType", ClassType.其他);
             var buildType = Get(values, "BuildType", BuildType.教育部门社会集体办);
             var dingKey = Get(values, "DingKey", "");
             if (!string.IsNullOrEmpty(dingKey))
             {
                 string __k, __s;
                 dingKey = HomoryCryptor.Encrypt(dingKey, out __k, out __s);
             }
             switch (command.Type)
             {
                 case GridBatchEditingCommandType.Insert:
                     var nid = HomoryContext.Value.GetId();
                     var d = new Department
                     {
                         Id = nid,
                         Name = name,
                         TopId = nid,
                         DisplayName = name,
                         Level = 0,
                         Hidden = false,
                         Ordinal = ordinal,
                         State = state,
                         Code = code,
                         BuildType = buildType,
                         ClassType = classType,
                         Type = DepartmentType.学校,
                         DingKey = dingKey
                     };
                     HomoryContext.Value.Department.Add(d);
                     try { DepartmentHelper.InsertCampus(nid.ToString().ToUpper(), name, ordinal); } catch { Notify(panel, "办公平台学校新增失败", "warn"); }
                     HomoryContext.Value.SaveChanges();
                     LogOp(OperationType.新增);
                     break;
                 case GridBatchEditingCommandType.Update:
                     var id = Get(values, "Id", Guid.Empty);
                     HomoryContext.Value.Department.Where(o => o.Id == id).Update(o => new Homory.Model.Department
                     {
                         Name = name,
                         DisplayName = name,
                         Ordinal = ordinal,
                         Code = code,
                         State = state,
                         BuildType = buildType,
                         ClassType = classType,
                         DingKey = dingKey
                     });
                     try { DepartmentHelper.UpdateCampus(id.ToString().ToUpper(), name, ordinal, state); } catch { Notify(panel, "办公平台学校更新失败", "warn"); }
                     HomoryContext.Value.SaveChanges();
                     LogOp(state);
                     break;
             }
         }
         Notify(panel, "操作成功", "success");
     }
     else
     {
         Notify(panel, "无权限设定学校", "warn");
     }
 }
コード例 #5
0
 protected Guid? GenGradeId(Department d)
 {
     int index = d.Ordinal - __Year - 1;
     var pdt = d.DepartmentRoot.ClassType;
     switch (pdt)
     {
         case ClassType.九年一贯制:
             return index < PJ.Length && index > -1 ? PJ[index] : (Guid?)null;
         case ClassType.初中:
             return index < J.Length && index > -1 ? J[index] : (Guid?)null;
         case ClassType.小学:
             return index < P.Length && index > -1 ? P[index] : (Guid?)null;
         case ClassType.幼儿园:
             return index < K.Length && index > -1 ? K[index] : (Guid?)null;
         case ClassType.高中:
             return index < S.Length && index > -1 ? S[index] : (Guid?)null;
     }
     return null;
 }