Ejemplo n.º 1
0
        private static void SyncFiles(int commit_PK, List <FileToUpload> files, string upLoadedBy)
        {
            var oldDDocs = GetDocuments(commit_PK);

            var toDelete = oldDDocs.Where(oldElem => files.Where(newElem => newElem.DocumentPK == oldElem.Document_PK).Count() == 0);
            var toAdd    = files.Where(p => p.DocumentPK == null);

            foreach (var file in toDelete)
            {
                OVPRDat.usp_24a_Document_DelSpecificDocument(file.Document_PK);
            }

            foreach (var file in toAdd)
            {
/*                In the Angular code you’re going to write, you’re going to be reading the file from the file system usingthe FileReader class.
 *                This class is only available on newer browsers.The FileReader class reads the file from disk as a Base64-encoded string.
 *                At the beginning of this Base64-encoded string is the type of file read from the disk followed by a comma.
 *                The rest of the file contents are after the comma.Next is a sample of what the contents of the file uploaded look like.
 *              "data:image/jpeg;base64,/9j/4AAQSkZJRgABAg..."
 *
 */
                if (file.FileAsBase64.Contains(","))
                {
                    file.FileAsBase64 = file.FileAsBase64.Substring(file.FileAsBase64.IndexOf(",") + 1);
                }

                OVPRDat.usp_23_Document_InsertDocFile(commit_PK, file.FileName, file.FileSize, file.FileType, Convert.FromBase64String(file.FileAsBase64), upLoadedBy);
            }
        }
Ejemplo n.º 2
0
        public static int CreateCommitment(string LoginEmail, CommitmentChangeEnt commitment, List <FileToUpload> files, out string sql)
        {
            // var uploadArgs = new UploadArgs();
            var Commit_PK = OVPRDat.usp_25_Commitment_CreateCommitmentRequest(LoginEmail, commitment, out sql);

            //uploadArgs.Files = files;
            //Upload(uploadArgs, LoginEmail);

            SyncFiles(Commit_PK, files, LoginEmail);

            return(Commit_PK);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var x = OVPRDat.usp_22_Document_GetDocFileByCommitmentPkFileName(32, "Kalichman_Rent.pdf");



            MemoryStream memoryStream = new MemoryStream();

            memoryStream.Write(x, 0, x.Length);



            return(File(memoryStream, "application/octet-stream")); // returns a FileStream
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            var bytes = OVPRDat.usp_22_Document_GetDocFileByCommitmentPkFileName(32, "Kalichman_Rent.pdf");

            //MemoryStream memoryStream = new MemoryStream();
            // /memoryStream.Write(bytes, 0, bytes.Length);

            // FileStream fileStream = new FileStream("test.txt", FileMode.Open, FileAccess.Read);
            //memoryStream.CopyTo(fileStream);


            FileStream fs = new FileStream(@"C:\Kalichman_Rent.pdf", FileMode.Create);

            fs.Write(bytes, 0, bytes.Length);
            fs.Close();
        }
Ejemplo n.º 5
0
        public static CommitmentsSearchReturnEnt Search(CommitmentsSearchArg arg)
        {
            var toReturn = new CommitmentsSearchReturnEnt();

            var allData = OVPRDat.usp_13_Commitment_GetCommitmentData(arg);

            allData = allData.AsQueryable().OrderByFieldName(arg.sortBy_Property, arg.sortBy_IsAsc).ToList();

            var startIndex = arg.pageIndex * arg.pageSize;
            var length     = arg.pageSize;

            if ((startIndex + arg.pageSize) > allData.Count)
            {
                length = allData.Count - startIndex;
            }

            toReturn.totalRows  = allData.Count;
            toReturn.totalPages = (int)Math.Ceiling((double)toReturn.totalRows / arg.pageSize);
            toReturn.result     = allData.GetRange(startIndex, length);


            return(toReturn);
        }
Ejemplo n.º 6
0
 public static List <demo_GetAllCommitmentsEnt> _demo_GetAllCommitments()
 {
     return(OVPRDat._demo_GetAllCommitments());
 }
Ejemplo n.º 7
0
 public static List <DocumentEnt> GetDocuments(int Commitment_PK)
 {
     return(OVPRDat.usp_21_Document_GetDocFileNamesByCommitment_PK(Commitment_PK));
 }
Ejemplo n.º 8
0
 public static string GetCommitmentStatusByCommitPK(int Commitment_PK)
 {
     return(OVPRDat.usp_27b_GetCommitmentStatusByCommitPK(Commitment_PK));
 }
Ejemplo n.º 9
0
 public static CommitmentEnt GetCommitment(int Commitment_PK)
 {
     return(OVPRDat.usp_27_GetCommitmentDetailByCommitPK(Commitment_PK)[0]);
 }
Ejemplo n.º 10
0
 public static void UpdateCommitment(string LoginEmail, CommitmentChangeEnt commitment, List <FileToUpload> files, out string sql)
 {
     SyncFiles(commitment.CommitmentPK.Value, files, LoginEmail);
     OVPRDat.usp_26_Commitment_UpdateBaseCommitmentRequest(LoginEmail, commitment, out sql);
 }
Ejemplo n.º 11
0
 public static usp_16a_GetProposalDetailByPropNo_Ent GetProposalDetailByPropNo(string proposalNum)
 {
     return(OVPRDat.usp_16a_GetProposalDetailByPropNo(proposalNum));
 }
Ejemplo n.º 12
0
 public static byte[] GetFile(int DOC_PK_ID)
 {
     return(OVPRDat.usp_22a_Document_GetDocFileByDocPK(DOC_PK_ID));
 }