예제 #1
0
        public JsonResult SaveDoc(Document postData)
        {
            long docid = default(long);

            string[] formats = { "dd.MM.yyyy", "dd/MM/yyyy", "dd/MM/yy" };
            DateTime docdate = DateTime.Now;

            try
            {
                long.TryParse(Encryption64.DecryptQueryString(postData.DocInfo10), out docid);
                postData.DocID = docid;
                DateTime.TryParseExact(postData.DocInfo9, formats, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out docdate);
                postData.DocDate    = docdate;
                postData.Opmode     = 3;
                postData.ModifiedBy = GlobalSettings.oUserData.ID;
                postData.ApprovedBy = GlobalSettings.oUserData.ID;
                postData.CheckedBy  = GlobalSettings.oUserData.ID;
                var result = DBOperations <Document> .DMLOperation(postData, Constant.usp_DocumentManager, DMLOperationFlag.Update);

                if (result > default(int))
                {
                    return(Json(new { Success = 1, Message = "Data saved successfully" }));
                }
                else
                {
                    throw new Exception("Unable to update data");
                }
            }
            catch (Exception ex)
            {
                Utility.Logger(ex);
                return(Json(new { Success = default(int), Message = ex.Message }));
            }
        }
예제 #2
0
        public ActionResult New(string id = "")
        {
            long permissionid = default(long);
            var  obj          = new UserPermissionMaster();

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    long.TryParse(Encryption64.DecryptQueryString(id), out permissionid);
                }

                if (permissionid > default(long))
                {
                    obj = DBOperations <UserPermissionMaster> .GetSpecific(new UserPermissionMaster()
                    {
                        AccessID = permissionid, Opmode = 4
                    }, Constant.usp_UserPermissionMaster);
                }
            }
            catch (Exception)
            {
            }
            return(View("New", obj));
        }
예제 #3
0
        public JsonResult SetApproval(string key, int key1)
        {
            long docid = default(long);

            try
            {
                var userid = GlobalSettings.oUserData.ID;

                long.TryParse(Encryption64.DecryptQueryString(key), out docid);
                var result = DBOperations <Document> .DMLOperation(new Document()
                {
                    Opmode = 6, IsUploadApproved = key1, DocID = docid, ApprovedBy = userid
                }, Constant.usp_DocumentManager);

                if (result > default(int))
                {
                    return(Json(new { Success = 1, Message = "Approval status has been updated for the document" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    throw new Exception("Unable to update approval status");
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Success = default(int), Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #4
0
        public JsonResult SaveData(Organization postData)
        {
            long orgid = default(long);

            try
            {
                if (postData == null)
                {
                    throw new Exception("No data found for insert");
                }

                long.TryParse(Encryption64.DecryptQueryString(postData.EncryptedOrgID), out orgid);
                postData.OrgID     = orgid;
                postData.Opmode    = orgid > default(int) ? 3 : 2;
                postData.CreatedBy = postData.ModifiedBy = GlobalSettings.oUserData.ID;
                var result = DBOperations <Organization> .DMLOperation(postData, Constant.usp_Organization);

                if (result > default(int))
                {
                    return(Json(new { Success = 1, Message = string.Format("Data have been {0} successfully", orgid > default(long) ? "updated" : "saved") }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    throw new Exception("Operation has been failed to execute");
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Success = default(int), Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
        public ActionResult New(string id = "")
        {
            long orgid = default(long);
            var  obj   = new Organization();

            try
            {
                if (!string.IsNullOrEmpty(id))
                {
                    long.TryParse(Encryption64.DecryptQueryString(id), out orgid);
                }

                if (orgid > default(long))
                {
                    obj = DBOperations <Organization> .GetSpecific(new Organization()
                    {
                        OrgID = orgid, Opmode = 1
                    }, Constant.usp_Organization);
                }
            }
            catch (Exception)
            {
            }
            return(View("New", obj));
        }
예제 #6
0
        public ActionResult LoadAttachmentList(string docid)
        {
            long documentId           = default(long);
            List <AttachmentFile> lst = new List <AttachmentFile>();

            try
            {
                long.TryParse(Encryption64.DecryptQueryString(docid), out documentId);
                lst = DBOperations <AttachmentFile> .GetAllOrByRange(new AttachmentFile()
                {
                    DocID = documentId, Opmode = default(int)
                }, Constant.usp_Attachment);
            }
            catch (Exception) { }
            return(PartialView("_AttachmentList", lst));
        }
예제 #7
0
        public ActionResult AttachmentDelete(string id, string did)
        {
            long attachid  = default(long);
            long docid     = default(long);
            int  delresult = default(int);

            try
            {
                long.TryParse(Encryption64.DecryptQueryString(id), out attachid);
                long.TryParse(Encryption64.DecryptQueryString(did), out docid);
                var obj = DBOperations <AttachmentFile> .GetSpecific(new AttachmentFile()
                {
                    AttachmentID = attachid, Opmode = 1
                }, Constant.usp_Attachment);

                if (System.IO.File.Exists(string.Format(@"{0}\{1}\{2}{3}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docid, obj.FileName, obj.FileExtenssion)))
                {
                    System.IO.File.Delete(string.Format(@"{0}\{1}\{2}{3}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docid, obj.FileName, obj.FileExtenssion));
                }
                delresult = DBOperations <AttachmentFile> .DMLOperation(new AttachmentFile()
                {
                    DocID = docid, AttachmentID = attachid, Opmode = 5
                }, Constant.usp_Attachment, DMLOperationFlag.Delete);

                if (delresult > default(int))
                {
                    return(Json(new { Success = 1, Message = string.Format("Attachement file ({0}{1}) has been deleted successfully", obj.FileName, obj.FileExtenssion) }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    throw new Exception(string.Format("Unable to delete file ({0}{1})", obj.FileName, obj.FileExtenssion));
                }
            }
            catch (Exception ex)
            {
                Utility.Logger(ex);
                return(Json(new { Success = default(int), Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #8
0
        public ActionResult New(string id = "")
        {
            long     docid          = default(long);
            Document obj            = new Document();
            var      lstDepartments = new List <SelectLists>();

            try
            {
                IEnumerable <long> deptLst = GlobalSettings.oUserPermission.Select(d => d.DeptID);

                if (!string.IsNullOrEmpty(id))
                {
                    long.TryParse(Encryption64.DecryptQueryString(id), out docid);
                }

                if (docid > default(long))
                {
                    obj = DBOperations <Document> .GetSpecific(new Document()
                    {
                        DocID = docid, Opmode = 1
                    }, Constant.usp_DocumentManager);
                }

                //ViewBag.Projects = new DropdownClient().Getdropdown(Dropdown.Project);
                //ViewBag.Departments = new DropdownClient().Getdropdown(Dropdown.Department);
                //ViewBag.SubTypes = new DropdownClient().Getdropdown(Dropdown.SubType);
                //ViewBag.FinYears = new DropdownClient().Getdropdown(Dropdown.FinYear);

                //lstDepartments.Add(new SelectLists() { Value = 0, Text = "Select Department" });
                lstDepartments.AddRange(new DropdownClient().Getdropdown(Dropdown.Department));
                ViewBag.Departments = (GlobalSettings.oUserData.RoleID != (long)Role.BuiltinAdmin ? lstDepartments.Where(w => deptLst.Contains(w.Value) || w.Value == 0).ToList() : lstDepartments);

                ViewBag.FinYears = new DropdownClient().Getdropdown(Dropdown.FinYear);
            }
            catch (Exception) { }
            return(View("New", obj));
        }
예제 #9
0
        public FileResult DowloadUnsupportedFile(string id)
        {
            long attachid = default(long);
            var  obj      = new AttachmentFile();

            try
            {
                long.TryParse(Encryption64.DecryptQueryString(id), out attachid);
                obj = DBOperations <AttachmentFile> .GetSpecific(new AttachmentFile()
                {
                    AttachmentID = attachid, Opmode = 1
                }, Constant.usp_Attachment);

                //var stream = new FileStream(Server.MapPath(obj.FilePath), FileMode.Open);
                var stream = new FileStream(obj.FilePath, FileMode.Open);
                //Utility.Logger(attachid.ToString());
                return(File(stream, MediaTypeNames.Application.Octet, string.Format("{0}{1}", obj.FileName, obj.FileExtenssion)));
            }
            catch (Exception ex)
            {
                Utility.Logger(ex);
                return(null);
            }
        }
예제 #10
0
        public ActionResult AttachmentPreview(string id, string iseditargument)
        {
            long           attachid      = default(long);
            int            iseditrequest = default(int);
            AttachmentFile obj           = new AttachmentFile();

            try
            {
                long.TryParse(Encryption64.DecryptQueryString(id), out attachid);
                obj = DBOperations <AttachmentFile> .GetSpecific(new AttachmentFile()
                {
                    AttachmentID = attachid, Opmode = 1
                }, Constant.usp_Attachment);

                int.TryParse(Encryption64.DecryptQueryString(iseditargument), out iseditrequest);
                Tuple <AttachmentFile, int> tpl = new Tuple <AttachmentFile, int>(obj, iseditrequest);
                return(View("AttachmentViewer", tpl));
            }
            catch (Exception ex)
            {
                Utility.Logger(ex);
                return(null);
            }
        }
예제 #11
0
        public JsonResult SaveData(UserPermissionMaster postData)
        {
            long accessid = default(long);

            try
            {
                if (postData == null)
                {
                    throw new Exception("No data found for insert");
                }

                long.TryParse(Encryption64.DecryptQueryString(postData.EncryptedAccessID), out accessid);
                postData.AccessID = accessid;
                postData.Opmode   = accessid > default(int) ? 5 : 0;

                UserPermissionMaster obj = new UserPermissionMaster();
                obj.UserID        = postData.UserID;
                obj.OrgID         = postData.OrgID;
                obj.LocationID    = postData.LocationID;
                obj.SublocationID = postData.SublocationID;
                obj.DeptID        = postData.DeptID;
                obj.ProjectID     = postData.ProjectID;
                obj.SubTypeID     = postData.SubTypeID;
                obj.AccessID      = accessid;

                if (postData.Opmode == 0) //add
                {
                    obj.Opmode = 1;
                }
                else
                {
                    obj.Opmode = 6; // edit
                }

                //  var countid = default(long);
                if (postData.Opmode == 0) // add
                {
                    var objcount = new UserPermissionMaster();

                    objcount = DBOperations <UserPermissionMaster> .GetSpecific(obj, Constant.usp_UserPermissionMaster);

                    if (objcount.AccessID > default(long))
                    {
                        throw new Exception("Permission already exist");
                    }
                    else
                    {
                        var result = DBOperations <UserPermissionMaster> .DMLOperation(postData, Constant.usp_UserPermissionMaster);

                        if (result > default(int))
                        {
                            return(Json(new { Success = 1, Message = string.Format("Data have been {0} successfully", accessid > default(long) ? "updated" : "saved") }, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            throw new Exception("Operation has been failed to execute");
                        }
                    }
                }
                else // edit
                {
                    var objcount = new UserPermissionMaster();

                    objcount = DBOperations <UserPermissionMaster> .GetSpecific(obj, Constant.usp_UserPermissionMaster);

                    if (objcount.AccessID > default(long))
                    {
                        throw new Exception("Permission already exist");
                    }
                    else
                    {
                        var result = DBOperations <UserPermissionMaster> .DMLOperation(postData, Constant.usp_UserPermissionMaster);

                        if (result > default(int))
                        {
                            return(Json(new { Success = 1, Message = string.Format("Data have been {0} successfully", accessid > default(long) ? "updated" : "saved") }, JsonRequestBehavior.AllowGet));
                        }
                        else
                        {
                            throw new Exception("Operation has been failed to execute");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Success = default(int), Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
예제 #12
0
        public ActionResult SaveUploadedFile(long deptid, long prjid, long subtype, long finyr, string docno, string id)
        {
            long     docIdentity = default(long);
            DateTime dt          = DateTime.Now;
            var      doc         = new Document();

            string[] viewerSupportedFiles = ConfigurationManager.AppSettings["ViewerJSSupportedExtenssions"].Split(',');
            try
            {
                if (GlobalSettings.oUserData != null && GlobalSettings.oUserData.ID > default(long))
                {
                    long.TryParse(Encryption64.DecryptQueryString(id), out docIdentity);

                    if (docIdentity <= default(long))
                    {
                        doc.DeptID      = deptid;
                        doc.ProjectID   = prjid;
                        doc.SubTypeID   = subtype;
                        doc.FinYearID   = finyr;
                        doc.DocNumber   = !string.IsNullOrWhiteSpace(docno.Trim()) ? docno.Trim().ToUpper() : "DOC-" + dt.ToString("yyyyMMdd") + "_" + dt.ToString("hhmmss");
                        doc.CreatedBy   = GlobalSettings.oUserData.ID;
                        doc.TaggingType = (int)TaggingType.ScanOnly;
                        doc.DocDate     = dt;
                        doc.Opmode      = 2;
                        var docidstr = DBOperations <Document> .InsertWithOutputVariable(doc, Constant.usp_DocumentManager);

                        long.TryParse(docidstr, out docIdentity);
                    }

                    foreach (string fileName in Request.Files)
                    {
                        try
                        {
                            HttpPostedFileBase file = Request.Files[fileName];
                            var contentLength       = file.ContentLength;
                            if (file != null && contentLength > 0)
                            {
                                byte[] imgAsBytes = new byte[contentLength];
                                using (BinaryReader theReader = new BinaryReader(file.InputStream))
                                {
                                    imgAsBytes = theReader.ReadBytes(contentLength);
                                }
                                //if (!Directory.Exists(Server.MapPath(string.Format("~/Uploads/{0}/", docIdentity))))
                                //{
                                //    Directory.CreateDirectory(Server.MapPath(string.Format("~/Uploads/{0}/", docIdentity)));
                                //}
                                //if (System.IO.File.Exists(Server.MapPath(string.Format("~/Uploads/{0}/{1}", docIdentity, file.FileName))))
                                //{
                                //    System.IO.File.Delete(Server.MapPath(string.Format("~/Uploads/{0}/{1}", docIdentity, file.FileName)));
                                //}
                                //System.IO.File.WriteAllBytes(Server.MapPath(string.Format("~/Uploads/{0}/{1}", docIdentity, file.FileName)), imgAsBytes);
                                if (!Directory.Exists(string.Format(@"{0}\{1}\", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docIdentity)))
                                {
                                    Directory.CreateDirectory(string.Format(@"{0}\{1}\", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docIdentity));
                                }
                                if (System.IO.File.Exists(string.Format(@"{0}\{1}\{2}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docIdentity, file.FileName)))
                                {
                                    System.IO.File.Delete(string.Format(@"{0}\{1}\{2}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docIdentity, file.FileName));
                                }
                                System.IO.File.WriteAllBytes(string.Format(@"{0}\{1}\{2}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docIdentity, file.FileName), imgAsBytes);

                                AttachmentFile a = new AttachmentFile();
                                a.DocID          = docIdentity;
                                a.FileSizeBytes  = contentLength.ToString();
                                a.FileName       = System.IO.Path.GetFileNameWithoutExtension(file.FileName);
                                a.FileExtenssion = System.IO.Path.GetExtension(file.FileName);
                                //a.FilePath = string.Format("~/Uploads/{0}/{1}", docIdentity, file.FileName); // Set Virtual Path in DB
                                a.FilePath          = string.Format(@"{0}\{1}\{2}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docIdentity, file.FileName); // Set Virtual Path in DB
                                a.IsViewerSupported = viewerSupportedFiles.Contains(System.IO.Path.GetExtension(file.FileName)) ? 1 : default(int);
                                a.CreatedOn         = dt;
                                a.CreatedBy         = GlobalSettings.oUserData.ID;
                                a.Opmode            = 2;
                                var result = DBOperations <AttachmentFile> .DMLOperation(a, Constant.usp_Attachment);
                            }
                        }
                        catch (Exception ex)
                        {
                            //continue;
                            throw ex;
                        }
                    }
                    return(Json(new { success = true, docid = Encryption64.EncryptQueryString(docIdentity.ToString()) }));
                }
                else
                {
                    throw new Exception("Session timed-out. Unable to upload. Please login again");
                }
            }
            catch (Exception)
            {
                return(Json(new { success = false, docid = Encryption64.EncryptQueryString(default(long).ToString()) }));
            }
        }
예제 #13
0
        public ActionResult DocumentDelete(string did)
        {
            long docid                = default(long);
            int  docdelresult         = default(int);
            int  delresult            = default(int);
            List <AttachmentFile> lst = new List <AttachmentFile>();
            StringBuilder         sb  = new StringBuilder();

            try
            {
                long.TryParse(Encryption64.DecryptQueryString(did), out docid);
                lst = DBOperations <AttachmentFile> .GetAllOrByRange(new AttachmentFile()
                {
                    DocID = docid, Opmode = default(int)
                }, Constant.usp_Attachment);

                if (lst != null && lst.Count() > default(int))
                {
                    foreach (var attachmentobj in lst)
                    {
                        try
                        {
                            if (System.IO.File.Exists(string.Format(@"{0}\{1}\{2}{3}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docid, attachmentobj.FileName, attachmentobj.FileExtenssion)))
                            {
                                System.IO.File.Delete(string.Format(@"{0}\{1}\{2}{3}", ConfigurationManager.AppSettings["DocumentDomainRootDirectory"], docid, attachmentobj.FileName, attachmentobj.FileExtenssion));
                                delresult = DBOperations <AttachmentFile> .DMLOperation(new AttachmentFile()
                                {
                                    DocID = docid, AttachmentID = attachmentobj.AttachmentID, Opmode = 5
                                }, Constant.usp_Attachment, DMLOperationFlag.Delete);
                            }
                        }
                        catch (Exception ex)
                        {
                            Utility.Logger(ex);
                            sb.AppendLine(ex.Message);
                            continue;
                        }
                    }
                }
                if (string.IsNullOrWhiteSpace(sb.ToString()))
                {
                    docdelresult = DBOperations <Document> .DMLOperation(new Document()
                    {
                        DocID = docid, Opmode = 5
                    }, Constant.usp_DocumentManager, DMLOperationFlag.Delete);

                    if (docdelresult > default(int))
                    {
                        return(Json(new { Success = 1, Message = "Document has been deleted successfully" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        throw new Exception("Unable to delete document right now. Please try again after some time");
                    }
                }
                else
                {
                    throw new Exception(sb.ToString());
                }
            }
            catch (Exception ex)
            {
                Utility.Logger(ex);
                return(Json(new { Success = default(int), Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }