public ActionResult TelechargerDocument(int idDocument)
        {
            string   nomFichier = "";
            string   urlAbsolue = "";
            Document doc        = new Document();

            try
            {
                using (DocumentDAL db = new DocumentDAL())
                {
                    // Récupération des informations du document à télécharger
                    doc = db.getDocumentById(idDocument);
                    string urlFichier = doc.CheminDocument;
                    nomFichier = Path.GetFileName(urlFichier);
                    string urlRelative = urlFichier.Replace(nomFichier, "");
                    urlAbsolue = Commons.Utils.getStorageRoot(urlRelative) + nomFichier;
                }
            }
            catch (Exception e)
            {
                string strIdDocument = idDocument.ToString();
                Commons.Logger.genererErreur(typeof(DocumentController), "strstrIdDocument =" + strIdDocument + " /n " + e.ToString());
                return(null);
            }

            return(File(urlAbsolue, "multipart/form-data", doc.NomFichierUpload));
        }
        public ActionResult SearchDocument(int idCategoriedocument, bool isSmartPhone, int offSet, int limit)
        {
            ObjDocument model = new ObjDocument();
            string      view  = "~/Views/Document/ListeDocuments.cshtml";

            try
            {
                // S'il s'agit d'un téléphone portable, on charge une vue spéciale
                if (isSmartPhone)
                {
                    view = "~/Views/Document/ListeDocumentsMobile.cshtml";
                    model.NombreDocumentsParLigne = 1;
                    model.NombreLignes            = 6;
                }
                else
                {
                    model.NombreDocumentsParLigne = 4;
                    model.NombreLignes            = 2;
                }

                using (DocumentDAL db = new DocumentDAL())
                {
                    model.ListeDocuments = db.getListeDocuments(idCategoriedocument, offSet, limit);
                }
            }
            catch (Exception e)
            {
                Commons.Logger.genererErreur(typeof(DocumentController), e.ToString());
                return(RedirectToAction("AfficherErreur", "Error", new { message = e.Message }));
            }

            return(PartialView(view, model));
        }
예제 #3
0
        public int ReviewedFilledUpForm(int approverUserId, string uploadedFormName)
        {
            DocumentDAL documentDal = new DocumentDAL();



            return(documentDal.ReviewedFilledUpForm(approverUserId, uploadedFormName));
        }
예제 #4
0
        public List <Forms> GetFormsListCategoryWise(int categoryId)
        {
            DocumentDAL  uploadDal    = new DocumentDAL();
            List <Forms> categoryList = new List <Forms>();

            categoryList = uploadDal.GetFormsListCategoryWise(categoryId);
            return(categoryList);
        }
예제 #5
0
        public List <FormsCategory> GetCategoryList()
        {
            DocumentDAL          uploadDal    = new DocumentDAL();
            List <FormsCategory> categoryList = new List <FormsCategory>();

            categoryList = uploadDal.GetCategoryList();
            return(categoryList);
        }
예제 #6
0
        public int ApproveFilledUpForm(int filledUpFormId, int approverUserId, string uploadedFormName)
        {
            DocumentDAL documentDal = new DocumentDAL();



            return(documentDal.ApproveFilledUpForm(filledUpFormId, approverUserId, uploadedFormName));
        }
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                base.OnActionExecuting(filterContext);

                // Gestion du user connecté dans le context
                if (System.Web.HttpContext.Current.Session[Commons.Const.sessionName_UserConnecte] != null)
                {
                    Utilisateur UtilisateurConnecte = (Utilisateur)System.Web.HttpContext.Current.Session[Commons.Const.sessionName_UserConnecte];
                    if (UtilisateurConnecte.Login != null)
                    {
                        CustomPrincipal UserConnecte = new CustomPrincipal(UtilisateurConnecte.Login);
                        System.Web.HttpContext.Current.User = UserConnecte;
                        GenericPrincipal gp = new GenericPrincipal(System.Web.HttpContext.Current.User.Identity, UtilisateurConnecte.Profils.ToArray());
                        System.Web.HttpContext.Current.User = gp;
                    }
                    else
                    {
                        System.Web.HttpContext.Current.User = null;
                    }
                }
                else
                {
                    System.Web.HttpContext.Current.User = null;
                }

                // On va regarder en base de données la liste des catégories de documents à afficher
                if (System.Web.HttpContext.Current.Session[Commons.Const.sessionName_MenusDocuments] == null)
                {
                    using (DocumentDAL db = new DocumentDAL())
                    {
                        List <CategorieDocument> listeMenus = db.getListeCategoriesDocument();
                        Session[Commons.Const.sessionName_MenusDocuments] = listeMenus;
                    }
                }

                // On va regarder en base de données la liste des catégories d'équipe à afficher
                if (System.Web.HttpContext.Current.Session[Commons.Const.sessionName_MenusEquipes] == null)
                {
                    using (EquipeDAL db = new EquipeDAL())
                    {
                        List <Equipe> listeEquipes = db.getListeEquipes();
                        Session[Commons.Const.sessionName_MenusEquipes] = listeEquipes;
                    }
                }
            }
            catch (Exception e)
            {
                Commons.Logger.genererErreur(typeof(BaseController), e.ToString());
            }
        }
        public static Task fetchById(decimal id)
        {
            try {
                Task task   = null;
                var  result = TaskDAL.fetchById(id);

                if (result != null)
                {
                    task      = new Task();
                    task.id   = long.Parse(result.id + "");
                    task.name = result.name;
                    if (result.assing_id != null)
                    {
                        task.assingId = long.Parse(result.assing_id + "");
                    }
                    else
                    {
                        task.assingId = -1;
                    }
                    task.description = result.description;
                    task.dateStart   = result.date_start;
                    if (task.dateStart != null)
                    {
                        task.sDateStart = ((DateTime)task.dateStart).ToString("dd/MM/yyyy").Replace("-", "/");
                    }
                    task.dateEnd = result.date_end;
                    if (task.dateEnd != null)
                    {
                        task.sDateEnd = ((DateTime)task.dateEnd).ToString("dd/MM/yyyy").Replace("-", "/");
                    }
                    task.creatorUserId = long.Parse(result.creator_user_id + "");
                    task.name          = result.name;
                    task.taskStatusId  = result.task_status;
                    task.documents     = DocumentDAL.fetchAllByTaskId(long.Parse(result.id + "")).Select(x => new Document()
                    {
                        id      = long.Parse(x.id + ""),
                        name    = x.name,
                        path    = x.path,
                        url     = x.url,
                        task_id = long.Parse(x.task_id + "")
                    }).ToList();
                }

                return(task);
            } catch (Exception e) {
                throw e;
            }
        }
        public static void createTask(Task task)
        {
            try {
                if (TaskDAL.exists(task.name))
                {
                    throw new ExistsException();
                }
                else
                {
                    tasks tasks = new tasks();
                    tasks.name        = task.name;
                    tasks.description = task.description;

                    if (task.processId != -1 && task.processId != 0)
                    {
                        tasks.process_id = int.Parse(task.processId + "");
                    }
                    if (task.assingId != -1 && task.processId != 0)
                    {
                        tasks.assing_id = int.Parse(task.assingId + "");
                    }
                    if (task.fatherTaksId != -1 && task.processId != 0)
                    {
                        tasks.father_taks_id = int.Parse(task.fatherTaksId + "");
                    }
                    tasks.task_status     = task.taskStatusId;
                    tasks.creator_user_id = task.creatorUserId;
                    tasks.created_at      = DateTime.Now;
                    tasks.date_end        = task.dateEnd;


                    var id = TaskDAL.createTask(tasks);

                    if (task.document != null)
                    {
                        files file = new files();
                        file.name    = task.document.name;
                        file.url     = task.document.url;
                        file.path    = task.document.path;
                        file.task_id = id;

                        DocumentDAL.createDocument(file);
                    }
                }
            } catch (Exception e) {
                throw e;
            }
        }
        public static List <Task> getTasksByProcessId(decimal id)
        {
            try {
                List <Task> list   = new List <Task>();
                var         dTasks = TaskDAL.getTasksByProcessId(id).ToList();

                foreach (tasks item in dTasks)
                {
                    Task task = new Task();
                    task.id          = long.Parse(item.id + "");
                    task.name        = item.name;
                    task.description = item.description;
                    task.dateEnd     = item.date_end;
                    task.sDateEnd    = ((DateTime)item.date_end).ToString("dd/MM/yyyy").Replace("-", "/");

                    if (item.process_id != null)
                    {
                        var     process  = ProcessDAL.getById(Decimal.Parse(item.process_id + ""));
                        Process dProcess = new Process();
                        dProcess.name        = process.name;
                        dProcess.description = process.description;
                        dProcess.id          = long.Parse(process.id + "");
                        task.process         = dProcess;
                    }

                    var listFiles = DocumentDAL.fetchAllByTaskId(long.Parse(item.id + "")).Select(x => new Document()
                    {
                        id      = long.Parse(x.id + ""),
                        name    = x.name,
                        url     = x.url,
                        path    = x.path,
                        task_id = x.task_id
                    }).ToList();

                    task.documents = listFiles;

                    task.alert = 0;

                    list.Add(task);
                }


                return(list);
            } catch (Exception e) {
                throw e;
            }
        }
예제 #11
0
파일: MenuDAL.cs 프로젝트: hoatv/ims2019
        // Check version exists
        public int ExistsOrInsertVersion(DocumentModel document, string actionUser)
        {
            DocumentDAL         documentDAL  = new DocumentDAL();
            MenuDAL             menuDAL      = new MenuDAL();
            int                 count        = 0;
            int                 countVersion = 0;
            List <VersionModel> listDocument = new List <VersionModel>();

            using (MySqlConnection con = new MySqlConnection(connectionString))
            {
                MySqlCommand cmd = new MySqlCommand("sp_GetVersionByName", con);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                cmd.Parameters.Add("@version_name", MySqlDbType.VarChar).Value = document.VersionName;
                countVersion = int.Parse(cmd.ExecuteScalar().ToString());
                con.Close();
            }
            if (countVersion <= 0)
            {
                // Insert to new version
                VersionModel versionModel = new VersionModel();
                versionModel.VersionName        = document.VersionName;
                versionModel.VersionDescription = "Auto insert version";
                versionModel.CreatedBy          = actionUser;
                versionModel.UpdatedBy          = actionUser;

                int versionID = this.InsertVersion(versionModel);

                if (versionID >= 0)
                {
                    // insert document here
                    document.VersionID = versionID;
                    return(documentDAL.InsertDocument(document, actionUser));
                }
                else
                {
                    return(count);
                }
            }
            else
            {
                return(documentDAL.InsertDocument(document, actionUser));
            }
        }
        public void BindEmployee()
        {
            DocumentDAL obj = new DocumentDAL();
            var         lst = obj.EmployeeList();

            if (lst != null && lst.Count > 0)
            {
                ddlEmployee.DataSource     = lst;
                ddlEmployee.DataTextField  = "Emp_Name";
                ddlEmployee.DataValueField = "User_Idno";
                ddlEmployee.DataBind();
                ddlEmployee.Items.Insert(0, new ListItem("< Choose Employee Name >", "0"));
            }
            else
            {
                ddlEmployee.Items.Clear();
                ddlEmployee.Items.Insert(0, new ListItem("< Choose Employee Name >", "0"));
            }
        }
        /// <summary>
        ///  Lecture de la video
        /// </summary>
        /// <returns>The video.</returns>
        /// <param name="idDocument">Identifier document.</param>
        public ActionResult ReadVideo(int idDocument)
        {
            string CheminDocument = "";

            try
            {
                using (DocumentDAL db = new DocumentDAL())
                {
                    // Récupération des informations du document à télécharger
                    CheminDocument = db.getDocumentById(idDocument).CheminDocument;
                }
            }
            catch (Exception e)
            {
                string strIdDocument = idDocument.ToString();
                Commons.Logger.genererErreur(typeof(DocumentController), "strstrIdDocument =" + strIdDocument + " : " + e.ToString());
            }

            return(new VideoResult(CheminDocument));
        }
        public void BindGrid()
        {
            string      DateFrom = string.IsNullOrEmpty(txtDateFrom.Text.Trim()) ? "" : txtDateFrom.Text.Trim();
            string      DateTo   = string.IsNullOrEmpty(txtDateTo.Text.Trim()) ? "" : txtDateTo.Text.Trim();
            Int32       DocType  = Convert.ToInt32(ddlDoucmentType.SelectedValue);
            Int32       EmpID    = Convert.ToInt32(ddlEmployee.SelectedValue);
            Int64       DocNo    = string.IsNullOrEmpty(txtDocumentNo.Text.Trim()) ? 0 : Convert.ToInt64(txtDocumentNo.Text.Trim());
            DocumentDAL obj      = new DocumentDAL();
            DataSet     ds       = obj.SelectDocumentRecord(DateFrom, DateTo, DocType, EmpID, DocNo, ApplicationFunction.ConnectionString());

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                grdMain.DataSource = ds;
                grdMain.DataBind();
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
            }
        }
        /// <summary>
        /// Affichers the documents.
        /// </summary>
        /// <returns>The documents.</returns>
        /// <param name="idCategorieDocument">Identifier categorie document.</param>
        public ActionResult AfficherDocuments(int idCategorieDocument, bool?isMobilePhone)
        {
            ObjDocument model = new ObjDocument();

            model.idCategorieDocument = idCategorieDocument;
            string view = "~/Views/Document/Documents.cshtml";

            try
            {
                Business.StatBLL.ajouterStat("PageDocument");

                if (isMobilePhone == null || !isMobilePhone.Value)
                {
                    model.NombreDocumentsParLigne = 4;
                    model.NombreLignes            = 2;
                }
                else
                {
                    model.NombreDocumentsParLigne = 1;
                    model.NombreLignes            = 6;
                }

                using (DocumentDAL db = new DocumentDAL())
                {
                    // récupération de tous les documents
                    CategorieDocument Categorie = db.getCategorieDocumentById(idCategorieDocument);
                    model.LibelleCategorieDocument = Categorie.Libelle;
                    model.ElementCount             = db.getNombreDocumentsParCategorie(idCategorieDocument);
                }
            }
            catch (Exception e)
            {
                string strCategorieDocument = idCategorieDocument.ToString();
                Commons.Logger.genererErreur(typeof(DocumentController), "strCategorieDocument =" + strCategorieDocument + " : " + e.ToString());
                return(RedirectToAction("AfficherErreur", "Error", new { message = e.Message }));
            }
            return(View(view, model));
        }
예제 #16
0
        /// <summary>
        /// Affichers the documents.
        /// </summary>
        /// <returns>The documents.</returns>
        /// <param name="idCategorieDocument">Identifier categorie document.</param>
        public ActionResult AfficherDocuments(int idCategorieDocument)
        {
            ObjDocument model = new ObjDocument();

            model.NombreDocumentsParLigne = 4;
            try
            {
                Business.StatBLL.ajouterStat("PageDocument");
                using (DocumentDAL db = new DocumentDAL())
                {
                    // récupération de tous les documents
                    model.ListeDocuments = db.getListeDocuments(idCategorieDocument);
                    CategorieDocument Categorie = db.getCategorieDocumentById(idCategorieDocument);
                    model.LibelleCategorieDocument = Categorie.Libelle;
                }
            }
            catch (Exception e)
            {
                string strCategorieDocument = idCategorieDocument.ToString();
                Commons.Logger.genererErreur(typeof(DocumentController), "strCategorieDocument =" + strCategorieDocument + " : " + e.ToString());
                return(RedirectToAction("AfficherErreur", "Error", new { message = e.Message }));
            }
            return(View("~/Views/Document/Documents.cshtml", model));
        }
예제 #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="approverUserId"></param>
        /// <param name="shipNo">Added on 30th Nov 2021</param>
        /// <returns></returns>
        public List <Forms> GetFilledupFormRequiredApprovalList(int approverUserId, int shipNo)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.GetFilledupFormRequiredApprovalList(approverUserId, shipNo));
        }
예제 #18
0
        public int DeleteForm(string formName)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.DeleteForm(formName));
        }
예제 #19
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="form"></param>
        /// <param name="catchMessage"></param>
        /// <returns></returns>
        public int SaveFilledUpForm(Forms form, ref string catchMessage)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.SaveFilledUpForm(form, ref catchMessage));
        }
예제 #20
0
        /// <summary>
        /// Old
        /// </summary>
        /// <param name="form"></param>
        /// <param name="approvers"></param>
        /// <param name="catchMessage"></param>
        /// <returns></returns>
        public int SaveFilledUpForm(Forms form, List <ApproverMaster> approvers, ref string catchMessage)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.SaveFilledUpForm(form, approvers, ref catchMessage));
        }
예제 #21
0
        public int SaveUploadedForms(List <Forms> formsList)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.SaveUploadedForms(formsList));
        }
예제 #22
0
 public DocumentBAL()
 {
     documentDAL = new DocumentDAL();
 }
예제 #23
0
        public List <Forms> GetFormsByCategoryForDropdown(int categoryId)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.GetFormsByCategoryForDropdown(categoryId));
        }
예제 #24
0
        public List <Forms> GetFillupFormsListForNotification(int aApproverUserId)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.GetFillupFormsListForNotification(aApproverUserId));
        }
예제 #25
0
파일: DocumentBL.cs 프로젝트: leahr0040/C-
        public static bool AddUserDocuments(DocumentDTO doc)
        {
            Document d = DocumentDTO.ToDAL(doc);

            return(DocumentDAL.AddUserDocuments(d));
        }
        public static List <Task> getTasksByUserId(decimal id)
        {
            try {
                List <Task> list   = new List <Task>();
                var         dTasks = TaskDAL.getTasksByUser(id);

                foreach (tasks item in dTasks)
                {
                    Task task = new Task();
                    task.id          = long.Parse(item.id + "");
                    task.name        = item.name;
                    task.description = item.description;
                    task.dateEnd     = item.date_end;
                    task.sDateEnd    = ((DateTime)item.date_end).ToString("dd/MM/yyyy").Replace("-", "/");

                    if (item.process_id != null)
                    {
                        var     process  = ProcessDAL.getById(Decimal.Parse(item.process_id + ""));
                        Process dProcess = new Process();
                        dProcess.name        = process.name;
                        dProcess.description = process.description;
                        dProcess.id          = long.Parse(process.id + "");
                        task.process         = dProcess;
                    }

                    var listFiles = DocumentDAL.fetchAllByTaskId(long.Parse(item.id + "")).Select(x => new Document()
                    {
                        id      = long.Parse(x.id + ""),
                        name    = x.name,
                        url     = x.url,
                        path    = x.path,
                        task_id = x.task_id
                    }).ToList();

                    task.documents = listFiles;

                    var alert = ConfigTrafficLightDAL.fetch();

                    var end  = (DateTime)item.date_end;
                    var now  = DateTime.Now;
                    var date = -(Math.Round((now - end).TotalDays));

                    if (date <= double.Parse(alert.red + ""))
                    {
                        task.alert = 1;
                    }
                    else if (date <= double.Parse(alert.yellow + ""))
                    {
                        task.alert = 2;
                    }
                    else if (date > double.Parse(alert.green + ""))
                    {
                        task.alert = 3;
                    }

                    list.Add(task);
                }


                return(list);
            } catch (Exception e) {
                throw e;
            }
        }
예제 #27
0
파일: DocumentBL.cs 프로젝트: leahr0040/C-
        public static bool DeleteUserDocument(DocumentDTO doc)
        {
            Document d = DocumentDTO.ToDAL(doc);

            return(DocumentDAL.DeleteUserDocuments(d));
        }
예제 #28
0
        public ApprovedFilledupFormAndApproverViewModel GetApprovedFilledUpForms(int userId, int currentPage = 1)
        {
            DocumentDAL documentDal = new DocumentDAL();

            return(documentDal.GetApprovedFilledUpForms(userId, currentPage));
        }