Exemplo n.º 1
0
        public virtual void Init()
        {
            _store = new AzureStore(AzureTestsHelper.GetDevelopentService(), true);

            _blob     = AzureTestsHelper.GetBlockBlob("kalix-leo-tests", "AzureStoreTests.testdata", true);
            _location = new StoreLocation("kalix-leo-tests", "AzureStoreTests.testdata");
        }
        public ValueTask <string> GetSharedAccessSignature(ISharedAccessPolicy policy)
        {
            var adHocPolicy = new SharedAccessBlobPolicy()
            {
                SharedAccessStartTime  = policy.StartTime,
                SharedAccessExpiryTime = policy.ExpiryTime,
                Permissions            = AzureStore.FromGenericToAzure(policy.Permissions),
            };

            return(new ValueTask <string>(this.CloudBlob.GetSharedAccessSignature(adHocPolicy)));
        }
Exemplo n.º 3
0
        public virtual async Task Init()
        {
            _store = new AzureStore(CloudStorageAccount.DevelopmentStorageAccount.CreateCloudBlobClient(), true);

            try
            {
                _blob = await AzureTestsHelper.GetBlockBlob("kalix-leo-tests", "AzureStoreTests.testdata", true).ConfigureAwait(false);

                _location = new StoreLocation("kalix-leo-tests", "AzureStoreTests.testdata");
            }
            catch (Exception e)
            {
                var ex = e;
            }
        }
        public async Task <Responce <ComplaintsDTO> > SaveComplaint(HttpRequest complaintRequest, string UserName)
        {
            Responce <ComplaintsDTO> Responce = new Responce <ComplaintsDTO>();

            Responce.Success = true;
            try
            {
                using (SSCEntities = new SSCEntities())
                {
                    Complaints complaints = new Complaints();
                    int        Id         = Convert.ToInt32(complaintRequest.Form["Id"]);
                    var        Cityid     = Convert.ToInt32(complaintRequest.Form["Cityid"]);
                    var        SpeciesId  = Convert.ToInt32(complaintRequest.Form["SpeciesId"]);
                    complaints.City = Cityid;

                    complaints.Id = Id;
                    if (complaints.Id != 0)
                    {
                        complaints = SSCEntities.Complaints.Find(Id);
                        var ComplaintLows   = complaints.ComplaintsLows;
                        var ComplaintImages = complaints.ComplaintImages;
                        SSCEntities.ComplaintsLows.RemoveRange(ComplaintLows);
                        SSCEntities.ComplaintImages.RemoveRange(ComplaintImages);
                        await SSCEntities.SaveChangesAsync();
                    }

                    complaints.SpeciesId        = SpeciesId;
                    complaints.ShopName         = Convert.ToString(complaintRequest.Form["ShopName"]);
                    complaints.ShopAddress      = Convert.ToString(complaintRequest.Form["ShopAddress"]);
                    complaints.DateOfInspection = Convert.ToDateTime(complaintRequest.Form["DateOfInspection"]);
                    complaints.Comments         = Convert.ToString(complaintRequest.Form["Comments"]);
                    complaints.Violations       = Convert.ToString(complaintRequest.Form["Violations"]);
                    complaints.GpsLocations     = Convert.ToString(complaintRequest.Form["GpsLocations"]);
                    complaints.UserId           = Convert.ToString(complaintRequest.Form["UserId"]);
                    complaints.ComplainStatus   = Convert.ToInt32(complaintRequest.Form["ComplainStatus"]);
                    complaints.GroupName        = Convert.ToString(complaintRequest.Form["GroupName"]);
                    complaints.IsDelete         = Convert.ToBoolean(complaintRequest.Form["IsDelete"]);
                    complaints.IsActive         = Convert.ToBoolean(complaintRequest.Form["IsActive"]);


                    complaints.ModifiedBy = UserName ?? Convert.ToString(complaintRequest.Form["UserId"]);

                    complaints.ModifiedDate        = DateTime.UtcNow;
                    complaints.IsRejecet           = Convert.ToBoolean(complaintRequest.Form["IsRejecet"]);
                    complaints.CommentForRejection = Convert.ToString(complaintRequest.Form["CommentForRejection"]);
                    complaints.RegistrationDate    = Convert.ToDateTime(complaintRequest.Form["RegistrationDate"]);
                    complaints.IsRegister          = Convert.ToBoolean(complaintRequest.Form["IsRegister"]);
                    complaints.IsEmailSend         = Convert.ToBoolean(complaintRequest.Form["IsEmailSend"]);
                    if (complaints.Id != 0)
                    {
                        SSCEntities.Entry(complaints).State = EntityState.Modified;
                    }
                    else
                    {
                        complaints.CreatedBy   = UserName ?? Convert.ToString(complaintRequest.Form["UserId"]);
                        complaints.CreatedDate = DateTime.UtcNow;
                        SSCEntities.Complaints.Add(complaints);
                    }
                    await SSCEntities.SaveChangesAsync();

                    var LowsIds = Convert.ToString(complaintRequest.Form["LowIds"]).Split(',');

                    if (LowsIds.Count() > 0)
                    {
                        foreach (var item in LowsIds)
                        {
                            ComplaintsLows complaintsLows = new ComplaintsLows();
                            complaintsLows.LowId       = Convert.ToInt32(item);
                            complaintsLows.ComplaintId = complaints.Id;
                            SSCEntities.ComplaintsLows.Add(complaintsLows);
                            await SSCEntities.SaveChangesAsync();
                        }
                    }

                    if (complaintRequest.Files != null)
                    {
                        if (complaintRequest.Files.Count > 0)
                        {
                            for (int i = 0; i < complaintRequest.Files.Count; i++)
                            {
                                if (complaintRequest.Files[i].ContentLength > 0)
                                {
                                    ComplaintImages complaintsImages = new ComplaintImages();
                                    string          extension        = Path.GetExtension(complaintRequest.Files[i].FileName);
                                    bool            isImage          = Functions.IsImage(complaintRequest.Files[i].FileName);
                                    string          ContentType      = complaintRequest.Files[i].ContentType;
                                    string[]        bloburi          = AzureStore.UploadFile(complaintRequest.Files[i].InputStream, complaintRequest.Files[i].FileName, ContentType, isImage, extension);
                                    complaintsImages.ComplaintId  = complaints.Id;
                                    complaintsImages.Imagetype    = extension;
                                    complaintsImages.ImageUrl     = bloburi[0];
                                    complaintsImages.CreatedDate  = DateTime.UtcNow;
                                    complaintsImages.ModifiedDate = DateTime.UtcNow;
                                    complaintsImages.CreatedBy    = UserName;
                                    complaintsImages.ModifiedBy   = UserName;
                                    SSCEntities.ComplaintImages.Add(complaintsImages);
                                    await SSCEntities.SaveChangesAsync();
                                }
                            }



                            //foreach (string item in complaintRequest.Files)
                            //{
                            //    var postedFile = complaintRequest.Files[item];
                            //    if (!string.IsNullOrEmpty(postedFile.FileName))
                            //    {
                            //        ComplaintImages complaintsImages = new ComplaintImages();

                            //        string extension = Path.GetExtension(postedFile.FileName);

                            //    }
                            //    i = i + 1;
                            //}
                        }
                    }
                    ComplaintsDTO complaintsdto    = new ComplaintsDTO();
                    SSCEntities   db               = new SSCEntities();
                    var           saveComplaintobj = db.Complaints.Find(complaints.Id);
                    complaintsdto           = saveComplaintobj.MapComplaintsToDTO();
                    Responce.ResponeContent = complaintsdto;
                }
            }
            catch (Exception ex)
            {
                Responce.Success = false;
                Responce.Message = $"ERROR SaveComplaint :{ex.ToString()}";
            }
            return(Responce);
        }