Esempio n. 1
0
 public static void AddPrivilege(IList <string> userCodes, plus_progress progress, pm2Entities context)
 {
     if (userCodes != null)
     {
         using (IEnumerator <string> enumerator = userCodes.GetEnumerator())
         {
             string userCode;
             while (enumerator.MoveNext())
             {
                 userCode = enumerator.Current;
                 if (!IsExist(progress.ProgressId, userCode))
                 {
                     string str = Guid.NewGuid().ToString();
                     plus_progress_privilege _privilege = new plus_progress_privilege {
                         PrivilegeId   = str,
                         plus_progress = progress,
                         PT_yhmc       = (from m in context.PT_yhmc
                                          where m.v_yhdm == userCode
                                          select m).FirstOrDefault <PT_yhmc>()
                     };
                     context.AddToplus_progress_privilege(_privilege);
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public static void UpdateLatest(string progressVersionId)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         if (!string.IsNullOrEmpty(progressVersionId))
         {
             plus_progress progress = (from m in entities.plus_progress_version
                                       where m.ProgressVersionId == progressVersionId
                                       select m.plus_progress).FirstOrDefault <plus_progress>();
             List <plus_progress_version> list = (from m in entities.plus_progress_version
                                                  where ((m.plus_progress.ProgressId == progress.ProgressId) && (m.IsLatest == true)) || (m.ProgressVersionId == progressVersionId)
                                                  select m).ToList <plus_progress_version>();
             plus_progress_version _version = (from m in entities.plus_progress_version
                                               where m.ProgressVersionId == progressVersionId
                                               select m).FirstOrDefault <plus_progress_version>();
             if ((list != null) && (_version != null))
             {
                 foreach (plus_progress_version _version2 in list)
                 {
                     _version2.IsLatest = false;
                 }
                 _version.IsLatest = true;
             }
             AddWarn(progressVersionId, entities);
             entities.SaveChanges();
         }
     }
 }
Esempio n. 3
0
 public static void UpdateLatest(string progressId)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         plus_progress_version _version = (from m in entities.plus_progress
                                           join n in entities.plus_progress_version on m.ProgressId equals n.plus_progress.ProgressId into n
                                           where (m.ProgressId == progressId) && (n.FlowState == null)
                                           select n).FirstOrDefault <plus_progress_version>();
         plus_progress progress = (from m in entities.plus_progress
                                   where m.ProgressId == progressId
                                   select m).FirstOrDefault <plus_progress>();
         if ((progress != null) && progress.IsMain)
         {
             plus_progress _progress = (from m in entities.plus_progress
                                        where ((m.IsMain && (m.PrjId == progress.PrjId)) && (m.FlowState == 1)) && (m.ProgressId != progressId)
                                        select m).FirstOrDefault <plus_progress>();
             if (_progress != null)
             {
                 _progress.IsMain = false;
             }
         }
         if (_version != null)
         {
             _version.IsLatest = true;
             cn.justwin.BLL.ProgressManagement.Version.AddWarn(_version.ProgressVersionId, entities);
             entities.SaveChanges();
         }
     }
 }
Esempio n. 4
0
 public static void Del(List <string> verIds)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         if (verIds != null)
         {
             int num = 0;
             using (List <string> .Enumerator enumerator = verIds.GetEnumerator())
             {
                 string verId;
                 while (enumerator.MoveNext())
                 {
                     verId = enumerator.Current;
                     string progressId = (from m in entities.plus_progress_version
                                          where m.ProgressVersionId == verId
                                          select m.plus_progress.ProgressId).FirstOrDefault <string>();
                     plus_progress entity = (from m in entities.plus_progress
                                             where m.ProgressId == progressId
                                             select m).FirstOrDefault <plus_progress>();
                     if (entity != null)
                     {
                         entities.DeleteObject(entity);
                         num++;
                     }
                 }
             }
             if (num > 0)
             {
                 entities.SaveChanges();
             }
         }
     }
 }
Esempio n. 5
0
 public void Add(Progress entity)
 {
     if (entity != null)
     {
         using (pm2Entities entities = new pm2Entities())
         {
             PT_yhmc _yhmc = (from m in entities.PT_yhmc
                              where m.v_yhdm == entity.InputUser
                              select m).FirstOrDefault <PT_yhmc>();
             plus_progress _progress = new plus_progress {
                 ProgressId   = entity.ProgressId,
                 PrjId        = new Guid?(entity.PrjId),
                 ProgressName = entity.ProgressName,
                 IsMain       = entity.IsMain,
                 FlowState    = new int?(entity.FlowState),
                 Note         = entity.Note,
                 InputDate    = new DateTime?(entity.InputDate),
                 PT_yhmc      = _yhmc
             };
             entities.AddToplus_progress(_progress);
             if (entity.IsMain)
             {
                 List <plus_progress> list = (from m in entities.plus_progress
                                              where (m.PrjId == entity.PrjId) && m.IsMain
                                              select m).ToList <plus_progress>();
                 if (list.Count > 0)
                 {
                     foreach (plus_progress _progress2 in list)
                     {
                         _progress2.IsMain = false;
                     }
                 }
             }
             string str = Guid.NewGuid().ToString();
             plus_progress_version _version = new plus_progress_version {
                 ProgressVersionId = str,
                 ParentVersionId   = null,
                 VersionCode       = entity.VersionCode,
                 VersionName       = entity.ProgressName,
                 FlowState         = null,
                 InputDate         = new DateTime?(entity.InputDate),
                 IsLatest          = false,
                 Note          = entity.Note,
                 plus_progress = _progress
             };
             entities.AddToplus_progress_version(_version);
             List <string> userCodes = new List <string> {
                 entity.InputUser
             };
             if (entity.InputUser != "00000000")
             {
                 userCodes.Add("00000000");
             }
             Privilege.AddPrivilege(userCodes, _progress, entities);
             entities.SaveChanges();
         }
     }
 }
Esempio n. 6
0
 public static void AddPrivilegeNoDelete(string progressId, IList <string> userCodes)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         plus_progress progress = (from m in entities.plus_progress
                                   where m.ProgressId == progressId
                                   select m).FirstOrDefault <plus_progress>();
         AddPrivilege(userCodes, progress, entities);
         entities.SaveChanges();
     }
 }
Esempio n. 7
0
 public static Progress GetById(string id)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         plus_progress _progress = (from m in entities.plus_progress
                                    where m.ProgressId == id
                                    select m).FirstOrDefault <plus_progress>();
         return(new Progress {
             ProgressId = _progress.ProgressId, ProgressName = _progress.ProgressName, PrjId = _progress.PrjId.Value, FlowState = _progress.FlowState.Value, InputDate = _progress.InputDate.Value, InputUser = _progress.PT_yhmc.v_yhdm, Note = _progress.Note
         });
     }
 }
Esempio n. 8
0
 public static void Del(string progressId)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         plus_progress entity = (from m in entities.plus_progress
                                 where m.ProgressId == progressId
                                 select m).FirstOrDefault <plus_progress>();
         if (entity != null)
         {
             entities.DeleteObject(entity);
             entities.SaveChanges();
         }
     }
 }
Esempio n. 9
0
 public static void AddPrivilegenew(string progressId, List <string> userCodes)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         foreach (string str2 in userCodes)
         {
             publicDbOpClass.ExecuteSQL("DELETE FROM plus_progress_privilege WHERE ProgressId='" + progressId + "' and UserCode='" + str2 + "'");
         }
         plus_progress progress = (from m in entities.plus_progress
                                   where m.ProgressId == progressId
                                   select m).FirstOrDefault <plus_progress>();
         AddPrivilege(userCodes, progress, entities);
         entities.SaveChanges();
     }
 }
Esempio n. 10
0
 public static void AddPrivilege(string progressId, IList <string> userCodes)
 {
     using (pm2Entities entities = new pm2Entities())
     {
         List <plus_progress_privilege> list = (from m in entities.plus_progress_privilege
                                                where m.plus_progress.ProgressId == progressId
                                                select m).ToList <plus_progress_privilege>();
         if (list != null)
         {
             foreach (plus_progress_privilege _privilege in list)
             {
                 entities.DeleteObject(_privilege);
             }
         }
         plus_progress progress = (from m in entities.plus_progress
                                   where m.ProgressId == progressId
                                   select m).FirstOrDefault <plus_progress>();
         AddPrivilege(userCodes, progress, entities);
         entities.SaveChanges();
     }
 }
Esempio n. 11
0
 public void Update(Progress entity)
 {
     if (entity != null)
     {
         using (pm2Entities entities = new pm2Entities())
         {
             plus_progress _progress = (from m in entities.plus_progress
                                        where m.ProgressId == entity.ProgressId
                                        select m).FirstOrDefault <plus_progress>();
             if (_progress == null)
             {
                 _progress.ProgressName = entity.ProgressName;
                 _progress.PT_yhmc      = (from m in entities.PT_yhmc
                                           where m.v_yhdm == entity.InputUser
                                           select m).FirstOrDefault <PT_yhmc>();
                 _progress.Note = entity.Note;
                 entities.SaveChanges();
             }
         }
     }
 }