Exemple #1
0
        public void UpdateDetailStatus(WorkZoneDetail workZoneDetail)// int WorkZoneId, int WorkZoneDetailId, int Status, string CreateAccount) //
        {
            logger.DebugFormat("updateDetailStatus Begin, workZoneId= {0}, workZoneDetailId = {1}, updateStatus ={2}, userName = {3}", workZoneDetail.WorkZoneId, workZoneDetail.WorkZoneDetailId, workZoneDetail.Status, workZoneDetail.CreateAccount);
            WorkZoneDetail.UpdateDetailStatus(workZoneDetail.WorkZoneId, workZoneDetail.WorkZoneDetailId, workZoneDetail.Status, workZoneDetail.CreateAccount);

            if (workZoneDetail.Status == 2)
            {
                logger.Debug("Case Finish workZone - remove detail problem");
                try
                {
                    WorkZone wk = WorkZone.GetWorkZone(workZoneDetail.WorkZoneId);

                    string pathFolderProblem = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, Common.GetFolderWorkZoneProblem(wk.CompanyId, wk.CompanyName, wk.FactoryId, wk.FactoryName, wk.WorkZoneId, wk.Name));

                    List <DetailProblem> listProblem = DetailProblem.GetAllDetailProblem(workZoneDetail.WorkZoneId, workZoneDetail.WorkZoneDetailId);
                    foreach (DetailProblem i in listProblem)
                    {
                        i.Delete();

                        string pathFile = Path.Combine(pathFolderProblem, i.ImageFile);
                        if (File.Exists(pathFile))
                        {
                            File.Delete(pathFile);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Warn("Ignore case delete problem", ex);
                }
            }
        }
Exemple #2
0
        public string UploadFileTest()
        {
            DetailProblem problem = new DetailProblem();

            problem.WorkZoneId       = 50;
            problem.WorkZoneDetailId = 1;
            problem.ImageFile        = "a.jpg";
            problem.Base64Data       = "afdsfdfs";
            problem.FileId           = 1;
            problem.CreateAccount    = "ddv1";
            UploadFile(problem);
            return("");
        }
Exemple #3
0
        public List <DetailProblem> GetAllFileProblem(int workZoneId, int workZoneDetailId)
        {
            //string workZoneName = WorkZone.GetWorkZoneName(workZoneId);
            List <DetailProblem> listFile = DetailProblem.GetAllDetailProblem(workZoneId, workZoneDetailId);

            WorkZone wz = WorkZone.GetWorkZone(workZoneId);

            foreach (DetailProblem i in listFile)
            {
                string pathProblem = Common.GetFolderWorkZoneProblem(wz.CompanyId, wz.CompanyName, wz.FactoryId, wz.FactoryName, wz.WorkZoneId, wz.Name);
                pathProblem = pathProblem.Replace("Portal", "");
                i.ImageFile = string.Format(@"{0}{1}/{2}", Common.AppSettingKey(Constant.PORTAL_CONFIG), pathProblem, i.ImageFile).Replace(" ", "%20");
            }
            return(listFile);
        }
        public void TestUpload(string newPath)
        {
            WorkNCController control = new WorkNCController();
            DetailProblem p = new DetailProblem();
            p.Comment = "sdf";
            p.WorkZoneId = 62;
            p.WorkZoneDetailId = 1;
            p.FileId = 1;

            p.ImageFile = @"";
            if(newPath=="")
                newPath = @"D:\t1.jpg";
            byte[] data = File.ReadAllBytes(newPath);
            p.Base64Data = Convert.ToBase64String(data);
            p.CreateAccount = "WS";
            control.UploadFile(p);
        }
Exemple #5
0
        public void TestUpload(string newPath)
        {
            WorkNCController control = new WorkNCController();
            DetailProblem    p       = new DetailProblem();

            p.Comment          = "sdf";
            p.WorkZoneId       = 62;
            p.WorkZoneDetailId = 1;
            p.FileId           = 1;

            p.ImageFile = @"";
            if (newPath == "")
            {
                newPath = @"D:\t1.jpg";
            }
            byte[] data = File.ReadAllBytes(newPath);
            p.Base64Data    = Convert.ToBase64String(data);
            p.CreateAccount = "WS";
            control.UploadFile(p);
        }
Exemple #6
0
 public string UploadFileTest()
 {
     DetailProblem problem = new DetailProblem();
     problem.WorkZoneId = 50;
     problem.WorkZoneDetailId = 1;
     problem.ImageFile = "a.jpg";
     problem.Base64Data = "afdsfdfs";
     problem.FileId = 1;
     problem.CreateAccount = "ddv1";
     UploadFile(problem);
     return "";
 }
Exemple #7
0
        public void UploadFile(DetailProblem problem)
        {
            logger.DebugFormat("Begin UploadFile , WorkZoneId = {0},  workZOneDetailId id = {1}", problem.WorkZoneId, problem.WorkZoneDetailId);
            WorkZone wk = WorkZone.GetWorkZone(problem.WorkZoneId);
            string pathFolderProblem = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, Common.GetFolderWorkZoneProblem(wk.CompanyId, wk.CompanyName, wk.FactoryId, wk.FactoryName, wk.WorkZoneId, wk.Name));
            logger.Debug("PhysicalPath pathFolder =" + pathFolderProblem);

            string uploadFilePath = "";
            try
            {
                using (DBContext db = new DBContext())
                {
                    using (System.Data.Common.DbTransaction tran = db.UseTransaction())
                    {
                        try
                        {
                            if (problem.FileId == 0) // case insert New
                            {
                                logger.Debug(" Case Insert new problem");

                                WorkZoneDetail d = WorkZoneDetail.GetWorkZoneDetail(problem.WorkZoneId, problem.WorkZoneDetailId);
                                d.Status = 1; // Has Problem
                                d.ModifiedAccount = problem.CreateAccount;
                                d.Update();

                                problem.FileId = DetailProblem.GetNextFileID(d.WorkZoneId, d.WorkZoneDetailId);
                                if(problem.Base64Data!= null)
                                {
                                    problem.ImageFile = string.Format("{0}_{1}.png", d.WorkZoneDetailId, problem.FileId);
                                }
                                problem.ModifiedAccount = problem.CreateAccount;
                                problem.Insert();

                                logger.Debug(" Update problem and WorkZone Detail");

                                if (!Directory.Exists(pathFolderProblem))
                                    Directory.CreateDirectory(pathFolderProblem);

                                if (!string.IsNullOrEmpty(problem.Base64Data))
                                {
                                    uploadFilePath = Path.Combine(pathFolderProblem, problem.ImageFile);
                                    logger.Debug("Case Create file problem = " + uploadFilePath);
                                    Byte[] data = Convert.FromBase64String(problem.Base64Data);
                                    File.WriteAllBytes(uploadFilePath, data);
                                    problem.Base64Data = null;
                                }
                            }
                            else if (problem.FileId != 0) // Update or Delete
                            {
                                DetailProblem p = DetailProblem.GetDetailProblem(problem.WorkZoneId, problem.WorkZoneDetailId, problem.FileId);
                                if(string.IsNullOrEmpty(problem.ImageFile))
                                {
                                    //delete
                                    logger.Debug("Case Delete detail Problem");
                                    p.Delete();

                                    uploadFilePath = Path.Combine(pathFolderProblem, p.ImageFile);
                                    logger.Debug("Case Delete file uploadFilePath = " + uploadFilePath);
                                    if (File.Exists(uploadFilePath))
                                        File.Delete(uploadFilePath);
                                }
                                else
                                {
                                    logger.Debug("Case update detail Problem");
                                    p.Comment = problem.Comment;
                                    p.ModifiedAccount = problem.CreateAccount;
                                    p.Update();
                                }
                            }
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                            logger.Error("Error UploadFile", ex);
                            throw ex;
                        }
                    }
                }
                logger.Debug("End UploadFile");
            }
            catch (Exception ex)
            {
                logger.Error("Error UploadFile ", ex);
                throw ex;
            }
        }
Exemple #8
0
 public int GetCountFileProblem(int workZoneId, int workZoneDetailId)
 {
     return(DetailProblem.GetCountListAddPicture(workZoneId, workZoneDetailId));
 }
Exemple #9
0
        public void UploadFile(DetailProblem problem)
        {
            logger.DebugFormat("Begin UploadFile , WorkZoneId = {0},  workZOneDetailId id = {1}", problem.WorkZoneId, problem.WorkZoneDetailId);
            WorkZone wk = WorkZone.GetWorkZone(problem.WorkZoneId);
            string   pathFolderProblem = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, Common.GetFolderWorkZoneProblem(wk.CompanyId, wk.CompanyName, wk.FactoryId, wk.FactoryName, wk.WorkZoneId, wk.Name));

            logger.Debug("PhysicalPath pathFolder =" + pathFolderProblem);

            string uploadFilePath = "";

            try
            {
                using (DBContext db = new DBContext())
                {
                    using (System.Data.Common.DbTransaction tran = db.UseTransaction())
                    {
                        try
                        {
                            if (problem.FileId == 0) // case insert New
                            {
                                logger.Debug(" Case Insert new problem");

                                WorkZoneDetail d = WorkZoneDetail.GetWorkZoneDetail(problem.WorkZoneId, problem.WorkZoneDetailId);
                                d.Status          = 1; // Has Problem
                                d.ModifiedAccount = problem.CreateAccount;
                                d.Update();


                                problem.FileId = DetailProblem.GetNextFileID(d.WorkZoneId, d.WorkZoneDetailId);
                                if (problem.Base64Data != null)
                                {
                                    problem.ImageFile = string.Format("{0}_{1}.png", d.WorkZoneDetailId, problem.FileId);
                                }
                                problem.ModifiedAccount = problem.CreateAccount;
                                problem.Insert();

                                logger.Debug(" Update problem and WorkZone Detail");

                                if (!Directory.Exists(pathFolderProblem))
                                {
                                    Directory.CreateDirectory(pathFolderProblem);
                                }

                                if (!string.IsNullOrEmpty(problem.Base64Data))
                                {
                                    uploadFilePath = Path.Combine(pathFolderProblem, problem.ImageFile);
                                    logger.Debug("Case Create file problem = " + uploadFilePath);
                                    Byte[] data = Convert.FromBase64String(problem.Base64Data);
                                    File.WriteAllBytes(uploadFilePath, data);
                                    problem.Base64Data = null;
                                }
                            }
                            else if (problem.FileId != 0) // Update or Delete
                            {
                                DetailProblem p = DetailProblem.GetDetailProblem(problem.WorkZoneId, problem.WorkZoneDetailId, problem.FileId);
                                if (string.IsNullOrEmpty(problem.ImageFile))
                                {
                                    //delete
                                    logger.Debug("Case Delete detail Problem");
                                    p.Delete();

                                    uploadFilePath = Path.Combine(pathFolderProblem, p.ImageFile);
                                    logger.Debug("Case Delete file uploadFilePath = " + uploadFilePath);
                                    if (File.Exists(uploadFilePath))
                                    {
                                        File.Delete(uploadFilePath);
                                    }
                                }
                                else
                                {
                                    logger.Debug("Case update detail Problem");
                                    p.Comment         = problem.Comment;
                                    p.ModifiedAccount = problem.CreateAccount;
                                    p.Update();
                                }
                            }
                            tran.Commit();
                        }
                        catch (Exception ex)
                        {
                            tran.Rollback();
                            logger.Error("Error UploadFile", ex);
                            throw ex;
                        }
                    }
                }
                logger.Debug("End UploadFile");
            }
            catch (Exception ex)
            {
                logger.Error("Error UploadFile ", ex);
                throw ex;
            }
        }