示例#1
0
        public JsonResult AddUserRole(UserRoleAddDto dto)
        {
            try
            {
                foreach (var u in dto.users)
                {
                    int cnt = db.UserRoles.Where(ur => ur.username == u).Count();
                    if (cnt < 1)
                    {
                        db.UserRoles.Add(new UserRole {
                            roletype = dto.role, username = u, COMP_CODE = dto.company
                        });

                        //RoleLogs code added by Nagaraju Madishetti as part of IND29615692i-5/Nov/2018
                        string myIP        = Server.HtmlEncode(Request.UserHostAddress);
                        string currentuser = !string.IsNullOrEmpty(User?.Identity?.Name) ? User.Identity.Name.ToUpper() : "Anonymous";
                        currentuser = currentuser.Substring(currentuser.IndexOf('\\') + 1).Replace("\\", "").ToUpper();
                        string Activity = "Assigned to " + dto.role.GetDisplayName() + " role";
                        db.Rolelogs.Add(new Rolelog {
                            UserID = currentuser, IP = myIP, Target_User_ID = u, Activity = Activity, COMP_CODE = dto.company
                        });
                    }
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                log.Error(e);
                return(Json(new { result = false }));
            }
            return(Json(new { result = true }));
        }
示例#2
0
        public static string Generater()
        {
            PCMSDBContext dbContext = new PCMSDBContext();
            PcmsId        id        = new PcmsId();

            using (System.Data.Entity.DbContextTransaction dbTran = dbContext.Database.BeginTransaction())
            {
                try
                {
                    dbContext.PcmsIds.Add(id);
                    dbContext.SaveChanges();

                    id.KEY = String.Format("P{0:D6}", id.ID);
                    dbContext.SaveChanges();
                    dbTran.Commit();
                }
                catch (Exception e)
                {
                    log.Error(e);
                    dbTran.Rollback();
                }
                dbTran.Dispose();
            }
            return(id.KEY);
        }
        public ActionResult Create([Bind(Include = "ID,type,name,value")] Setting setting)
        {
            if (ModelState.IsValid)
            {
                db.Settings.Add(setting);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(setting));
        }
示例#4
0
        public ActionResult Create([Bind(Include = "ID,title,contents,createdate,creater,modifieddate,modifier")] Agreement agreement)
        {
            if (ModelState.IsValid)
            {
                db.Agreements.Add(agreement);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agreement));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "ID,name,ftpname,status,createdate,modifieddate")] Collection collection)
        {
            if (ModelState.IsValid)
            {
                db.Collections.Add(collection);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(collection));
        }
        public ActionResult Create([Bind(Include = "ID,name,type,athour,usage,modifieddate,host,account,pwd,path")] Channel channel)
        {
            if (ModelState.IsValid)
            {
                db.Channels.Add(channel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(channel));
        }
示例#7
0
        public static void Call(XferActionEnum action, string scriptfile)
        {
            StringBuilder sb = new StringBuilder();
            PCMSDBContext db = new PCMSDBContext();

            string basefolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xfer\");
            string exepath    = basefolder + @"xfer.exe";

            try
            {
                string id  = ConfigurationManager.AppSettings["user"];
                string pwd = ConfigurationManager.AppSettings["password"];

                //string xferargs = @" -z https://secure-transfer.cegedim.com -user:"******" -password:"******" -s:" + scriptfile;
                string xferargs = @" -z https://SECURE-TRANSFER.SOLUTIONS.IQVIA.COM -user:"******" -password:"******" -s:" + scriptfile;

                Process p           = new Process();
                var     processInfo = p.StartInfo;
                p.StartInfo.RedirectStandardError  = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.CreateNoWindow         = false;
                p.StartInfo.WorkingDirectory       = basefolder;
                p.StartInfo.FileName  = exepath;
                p.StartInfo.Arguments = xferargs;

                p.OutputDataReceived += new DataReceivedEventHandler((s, e) => { sb.Append(e.Data); sb.Append("\r\n"); });
                p.ErrorDataReceived  += new DataReceivedEventHandler((s, e) => { sb.Append(e.Data); sb.Append("\r\n"); });

                p.Start();
                p.BeginOutputReadLine();
                p.WaitForExit();
                p.Close();

                Batch batch = new Batch {
                    name = @"XPER_" + action.ToString(), message = sb.ToString(), status = BatchStatus.Running
                };
                db.Batches.Add(batch);
                db.SaveChanges();
            }
            catch (Exception e)
            {
                sb.Append(e.Message);
                Batch batch = new Batch {
                    name = @"XPER_" + action.ToString(), message = sb.ToString(), status = BatchStatus.Error
                };
                db.Batches.Add(batch);
                db.SaveChanges();
            }
        }
示例#8
0
        public static void SendAlertInterface(string inf)
        {
            PCMSDBContext db      = new PCMSDBContext();
            SmtpClient    client  = initClient();
            MailMessage   message = initMail(inf);

            message.Subject = "[PCMS] 인터페이스 오류 알림";
            string template = File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/Template/InterfaceAlert.html"));

            try
            {
                message.Body = Engine.Razor.RunCompile(template, Guid.NewGuid().ToString(), typeof(string), inf);
                db.Userlogs.Add(new Userlog {
                    useremail = message.To.ToString(), reqtype = @"Email", url = message.Subject, parameters = message.Body
                });
                client.Send(message);
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            message.Dispose();
            db.SaveChanges();
        }
示例#9
0
        public static void SendAlertPfizerLink()
        {
            PCMSDBContext db      = new PCMSDBContext();
            SmtpClient    client  = initClient();
            MailMessage   message = initMail(Status.SettingType.PfizerLinkAlert);

            message.Subject = "[PCMS] 화이자링크 신청이 등록되었습니다.";
            string template = File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/Template/PfizerLinkEmail.html"));
            IEnumerable <Privacy> pLinks = db.Privacies.Where(p => !string.IsNullOrEmpty(p.LINK_RESERVATION) && !p.LINK_ALERTED);

            foreach (Privacy p in pLinks)
            {
                try
                {
                    message.Body = Engine.Razor.RunCompile(template, Guid.NewGuid().ToString(), typeof(Privacy), p);
                    db.Userlogs.Add(new Userlog {
                        useremail = message.To.ToString(), reqtype = @"Email", url = message.Subject, parameters = message.Body
                    });
                    client.Send(message);
                    p.LINK_ALERTED    = true;
                    db.Entry(p).State = System.Data.Entity.EntityState.Modified;
                }
                catch (Exception e)
                {
                    log.Error(e);
                }
            }
            message.Dispose();
            db.SaveChanges();
        }
示例#10
0
        public static void ImportN360()
        {
            PCMSDBContext db = new PCMSDBContext();
            //using (ImpersonateUser u = new ImpersonateUser())
            {
                try
                {
                    string n360importpath = HttpContext.Current.Server.MapPath("~/Content/xfer/xfer.exe");
                    string xferargs       = @"-z https://secure-transfer.cegedim.com -user:okc_pfizer_kr -password:4azr39 -s:" + HttpContext.Current.Server.MapPath("~/Content/xfer/xfer_n360_import.txt");
                    var    processInfo    = new ProcessStartInfo(n360importpath, xferargs);
                    processInfo.CreateNoWindow   = true;
                    processInfo.UseShellExecute  = true;
                    processInfo.WorkingDirectory = HttpContext.Current.Server.MapPath("~/Content/xfer/");

                    var process = Process.Start(processInfo);
                    process.WaitForExit();
                    process.Close();
                    // System.Diagnostics.Process.Start(n360importpath, xferargs);
                }
                catch (Exception e)
                {
                    Batch batch = new Batch {
                        name = @"XferHelper.ImportN360", message = e.Message, status = BatchStatus.Error
                    };
                    db.Batchs.Add(batch);
                    db.SaveChanges();
                }
            }
        }
示例#11
0
        public static void SendApprovalRequest()
        {
            PCMSDBContext db      = new PCMSDBContext();
            SmtpClient    client  = initClient();
            MailMessage   message = initMail(Status.SettingType.NotificationEmail);

            message.Subject = "[PCMS:알림] 승인요청이 등록되었습니다.";
            string template = File.ReadAllText(System.Web.Hosting.HostingEnvironment.MapPath("~/Template/AprovalRequestEmail.html"));

            try
            {
                message.Body = Engine.Razor.RunCompile(template, Guid.NewGuid().ToString());
                db.Userlogs.Add(new Userlog {
                    useremail = message.To.ToString(), reqtype = @"Email", url = message.Subject, parameters = message.Body
                });
                client.Send(message);
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            message.Dispose();
            db.SaveChanges();
        }
示例#12
0
        public ActionResult Create([Bind(Include = "name")] AccessRoles accessRoles)
        {
            if (accessRoles != null && accessRoles.name != null)
            {
                string currentuser = !string.IsNullOrEmpty(User?.Identity?.Name) ? User.Identity.Name.ToUpper() : "Anonymous";
                currentuser = currentuser.Substring(currentuser.IndexOf('\\') + 1).Replace("\\", "").ToUpper();

                accessRoles.creator    = currentuser;
                accessRoles.createdate = DateTime.UtcNow;
                db.AccessRoles.Add(accessRoles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(accessRoles));
        }
示例#13
0
        private void initFirstLogin(string username)
        {
            IEnumerable <UserRole> roles = db.UserRoles.Where(r => r.username == username).ToList();

            if (roles.Count() < 1)
            {
                db.UserRoles.Add(new UserRole {
                    username = username, roletype = MyRoleManager.RoleType.SALES
                });
                db.SaveChanges();
            }
        }
示例#14
0
 public void JobLog(Channel c, BatchStatus batchStatus)
 {
     using (System.Data.Entity.DbContextTransaction dbTran = upsertContext.Database.BeginTransaction())
     {
         try
         {
             Batch batch = new Batch {
                 name = c.name, bound = c.bound, status = batchStatus
             };
             upsertContext.Batches.Add(batch);
             upsertContext.SaveChanges();
             dbTran.Commit();
         }
         catch (Exception e)
         {
             log.Error(e);
             dbTran.Rollback();
         }
         dbTran.Dispose();
     }
 }
示例#15
0
        public ActionResult Create([Bind(Include = "ApprovalId,approvalstatus,createdate,creater,modifieddate,Companies")] Approval approval)
        {
            if (ModelState.IsValid)
            {
                db.Approvals.Add(approval);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(approval));
        }
示例#16
0
 private void publishlog(string user, string ip, string path, string rtype, string param)
 {
     using (System.Data.Entity.DbContextTransaction dbTran = dbContext.Database.BeginTransaction())
     {
         try
         {
             Userlog batch = new Userlog {
                 username = user, ip = ip, url = path, reqtype = rtype, parameters = param
             };
             dbContext.Userlogs.Add(batch);
             dbContext.SaveChanges();
             dbTran.Commit();
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             dbTran.Rollback();
         }
         dbTran.Dispose();
     }
 }
示例#17
0
        public static void SendAlertInterface(string inf, string msg = null)
        {
            PCMSDBContext db      = new PCMSDBContext();
            SmtpClient    client  = initClient();
            MailMessage   message = initMail(Status.SettingType.InterfaceAlertMail);

            message.Subject = "[PCMS] 인터페이스 오류 알림";
            try
            {
                message.Body = "Interface error occured from " + inf + "\n" + msg;
                db.Userlogs.Add(new Userlog {
                    useremail = message.To.ToString(), reqtype = @"Email", url = message.Subject, parameters = message.Body
                });
                client.Send(message);
            }
            catch (Exception e)
            {
                log.Error(e);
            }

            message.Dispose();
            db.SaveChanges();
        }
示例#18
0
        public static void Call(XferActionEnum action, string localpath, string remotepath)
        {
            StringBuilder sb = new StringBuilder();
            PCMSDBContext db = new PCMSDBContext();

            string basefolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"xfer\");
            string exepath    = basefolder + @"xfer.exe";
            string scriptfile = basefolder + @"xfer_n360_" + action.ToString() + "_" + DateTime.UtcNow.ToString("yyyyMMddTHHmmss") + @".txt";

            try
            {
                StreamWriter fileStream = new StreamWriter(scriptfile);
                fileStream.WriteLine(@"lcd " + localpath);
                fileStream.WriteLine(@"cd " + remotepath);
                if (action == XferActionEnum.Import)
                {
                    fileStream.WriteLine(@"mget *.txt");
                }
                else if (action == XferActionEnum.Export)
                {
                    fileStream.WriteLine(@"mput *.txt");
                }
                fileStream.WriteLine(@"quit");
                fileStream.Close();
                fileStream.Dispose();

                string id  = ConfigurationManager.AppSettings["user"];
                string pwd = ConfigurationManager.AppSettings["password"];

                //string xferargs = @" -z https://secure-transfer.cegedim.com -user:"******" -password:"******" -s:" + scriptfile;
                string xferargs = @" -z https://SECURE-TRANSFER.SOLUTIONS.IQVIA.COM -user:"******" -password:"******" -s:" + scriptfile;

                Process p           = new Process();
                var     processInfo = p.StartInfo;
                p.StartInfo.RedirectStandardError  = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.UseShellExecute        = false;
                p.StartInfo.CreateNoWindow         = false;
                p.StartInfo.WorkingDirectory       = basefolder;
                p.StartInfo.FileName  = exepath;
                p.StartInfo.Arguments = xferargs;

                p.OutputDataReceived += new DataReceivedEventHandler((s, e) => { sb.Append(e.Data); sb.Append("\r\n"); });
                p.ErrorDataReceived  += new DataReceivedEventHandler((s, e) => { sb.Append(e.Data); sb.Append("\r\n"); });

                p.Start();
                p.BeginOutputReadLine();
                p.WaitForExit();
                p.Close();

                Batch batch = new Batch {
                    name = @"XPER_" + action.ToString(), message = sb.ToString(), status = BatchStatus.Running
                };
                db.Batches.Add(batch);
                db.SaveChanges();
                File.Delete(scriptfile);
            }
            catch (Exception e)
            {
                sb.Append(e.Message);
                Batch batch = new Batch {
                    name = @"XPER_" + action.ToString(), message = sb.ToString(), status = BatchStatus.Error
                };
                db.Batches.Add(batch);
                db.SaveChanges();
            }
        }
示例#19
0
        public void TaskApi()
        {
            // 네트워크드라이브 연결
            NetworkDriveHelper.Connect();

            //CommonUtil.LogWrite("Start PcmsTask");
            //CommonUtil.LogWrite("connection string" + System.Configuration.ConfigurationManager.ConnectionStrings["PUBLISH"].ConnectionString);
            // 디비 연결
            PCMSDBContext db = new PCMSDBContext();

            string curHour = DateTime.UtcNow.ToString("HH");
            //CommonUtil.LogWrite("현재시간:" + curHour);
            List <Channel> channels = new List <Channel>();

            try
            {
                channels = db.Channels.ToList();
            }
#pragma warning disable CS0168 // The variable 'e' is declared but never used
            catch (Exception e) {
#pragma warning restore CS0168 // The variable 'e' is declared but never used
                //CommonUtil.LogWrite(e.Message);
            }

            //CommonUtil.LogWrite("Channel Count:" + channels.Count());

            foreach (Channel c in channels)
            {
                //CommonUtil.LogWrite("Channel:"+c.name + "=" + c.type);
                // 사용여부
                if (c.usage == false && !c.Instantrun)
                {
                    continue;
                }
                // 입력 시간 -> UTC 화
                int athour = c.athour - 9 < 0 ? c.athour - 9 + 24: c.athour - 9;
                if (string.Format("{0:D2}", athour) != curHour && !c.Instantrun)
                {
                    continue;
                }
                if (!c.Instantrun)
                {
                    //CommonUtil.LogWrite("Time Trigger");
                    // 최근실행 내역 비교
                    var bs = db.Batches.Where(b => b.name == c.name && b.bound == c.bound);
                    if (bs.Count() > 0)
                    {
                        Batch  lastrun = bs.OrderByDescending(b => b.ID).First();
                        string cur     = DateTime.UtcNow.ToString("yyyyMMddHH");
                        string old     = lastrun.createdate.ToString("yyyyMMddHH");
                        if (cur == old)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    //CommonUtil.LogWrite("Instant Run");
                    c.Instantrun      = false;
                    db.Entry(c).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
                // 실행
                if (c.name == @"ODSM" && c.bound == BoundType.Inbound)
                {
                    ODSMInbound bound = new ODSMInbound(c);
                    bound.Execute();
                }
                else if (c.name == @"N360" && c.bound == BoundType.Outbound)
                {
                    N360Outbound bound = new N360Outbound(c);
                    bound.Execute();
                }
                else if (c.name == @"PforceRX" && c.bound == BoundType.Inbound)
                {
                    PforceRXInbound bound = new PforceRXInbound(c);
                    bound.Execute();
                }
                else if (c.name == @"PforceRX" && c.bound == BoundType.Outbound)
                {
                    PforceRXOutbound bound = new PforceRXOutbound(c);
                    bound.Execute();
                }
                else if (c.name == @"MMS" && c.bound == BoundType.Inbound)
                {
                    MMSInbound bound = new MMSInbound(c);
                    bound.Execute();
                }
            } // for channel

            // 삭제/만료 설정 추가
            try
            {
                if (db.Settings.Where(s => s.type == SettingType.ExpiredBatch).Count() < 1)
                {
                    Setting s = new Setting();
                    s.name  = @"만료배치";
                    s.type  = SettingType.ExpiredBatch;
                    s.value = @"N";
                    db.Settings.Add(s);
                    db.SaveChanges();
                }
                if (db.Settings.Where(s => s.type == SettingType.RemoveBatch).Count() < 1)
                {
                    Setting s = new Setting();
                    s.name  = @"삭제배치";
                    s.type  = SettingType.RemoveBatch;
                    s.value = @"N";
                    db.Settings.Add(s);
                    db.SaveChanges();
                }
#pragma warning disable CS0168 // The variable 'e' is declared but never used
            } catch (Exception e) {
#pragma warning restore CS0168 // The variable 'e' is declared but never used
            }
            // 삭제처리
            if (curHour == "00")
            {
                Setting ss = db.Settings.Where(s => s.type == SettingType.RemoveBatch).First();
                if (ss.value != @"N")
                {
                    DeleteTask dt = new DeleteTask();
                    dt.Execute();
                }
            }

            // 기간 만료 하기
            if (curHour == "00")
            {
                Setting ss = db.Settings.Where(s => s.type == SettingType.ExpiredBatch).First();
                if (ss.value != @"N")
                {
                    ExpirationTask et = new ExpirationTask();
                    et.Execute();
                }
            }

            NetworkDriveHelper.Disconnect();
            //CommonUtil.LogWrite("PcmsTask End.");
        }