Professional Documents
Culture Documents
Code
Code
Code
Models;
using BrandMaster.Views.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using ImageMagick;
using System.IO;
using System.Windows.Media;
using System.Drawing;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System.Drawing.Imaging;
using System.Text;
using System.ComponentModel;
using System.Diagnostics;
using PdfSharp.Pdf.IO;
using PdfSharp;
using System.Security.Policy;
using System.Web;
using MigraDoc;
using System.Net.Http.Headers;
using Amazon.S3.Transfer;
using Amazon.S3;
using Amazon;
using Amazon.S3.IO;
using System.Web.UI.WebControls;
using System.Threading.Tasks;
using System.Data.Entity.Core.Objects;
using Amazon.S3.Model;
using System.Runtime.Serialization;
using System.Collections;
namespace BrandMaster.Controllers
{
// [System.Web.Http.Authorize]
[System.Web.Http.Httpget]
[System.Web.Http.Route("api/check")]
public class CheckController : ApiController
{
#region Bindingbycheckbox
public HttpResponseMessage GettingcheckboxesImages(string checkbox)
{
PdfDocument doc = new PdfDocument();
using (CheckFranchiseEntities dc = new CheckFranchiseEntities())
{
byte[] image = null;
string allKeyString = checkbox.Substring(checkbox.IndexOf("?") +
1);
string[] allKeyAndValue = allKeyString.Split(',');
List<GetImagesinPdf> listOfClass_mrg = new List<GetImagesinPdf>();
{
for (var i = 0; i < allKeyAndValue.Length; i++)
{
int item = Convert.ToInt32(allKeyAndValue[i]);
GetImagesinPdf obj = new GetImagesinPdf();
{
var u = (from obj1 in dc.tbl_BrandMaster
join obj2 in dc.tbl_GraphicMaster on obj1.VAImageId
equals obj2.id
where obj1.id == item
select new
{
ImageId = obj1.VAImageId,
path_img = obj2.FileName,
Awsimage = ""
}).ToList()
.Select(x => new AwsImageClass()
{
AwsImage =
AwsClass.GetUrlAwsS3("vibcarevisualaids", x.path_img),
// imageId = Convert.ToString(x.ImageId)
}).ToList();
if (u.Count() == 0)
{
List<AwsImageClass> listclass = new
List<AwsImageClass>();
u.Add(new AwsImageClass { path = null, path_img = null,
AwsImage = null, });
}
for(int j=0; j < allKeyAndValue.Length; j++)
{
if(u[i].imageId == u[j].imageId)
{
listOfClass_mrg.Add(obj);
}
}
}
// var c = listOfClass_mrg.Distinct().ToList();
}
}
}
//save to destination file
// br.Close();
}
}
}
}
}
}
}
}
}
}
string DateTimeFormat = "yyyy''MM''dd'T'HH''mm''ss.fffffffK";
var DateValue = DateTime.Now.ToString(DateTimeFormat);
string newname = String.Format("DateValue" + ".pdf");
// string path =
Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory());
string projectDirectory =
Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Pers
onal));
//doc.Save((projectDirectory + "\\Image2.pdf");
doc.Save(projectDirectory + "//" + newname);
doc.Close();
using (TransferUtility transferUtility = new
Amazon.S3.Transfer.TransferUtility("AKIAJWK5MRYUNKDTWCZQ",
"HT5c8npdGtRVXPsbIFGkZ8WGLzDhWUf+kM+SoXA1", RegionEndpoint.APSouth1))
{
TransferUtilityUploadRequest uploadRequest = new
TransferUtilityUploadRequest
{
BucketName = "vibcaretemp",
FilePath = projectDirectory + "//" + newname,
};
transferUtility.Upload(uploadRequest);
}
List<GetImagesinPdf> listOfClass_mrg2 = new List<GetImagesinPdf>();
{
GetImagesinPdf obj = new GetImagesinPdf();
{
obj.BSaveFile = AwsClass.GetUrlAwsS3("vibcaretemp",
newname);
}
listOfClass_mrg2.Add(obj);
}
#endregion
#endregion