Ejemplo n.º 1
0
        public async Task <ActionResult> CreateFolderinContainer(string valNameFolder)
        {
            bool vResult = false;

            if (!string.IsNullOrEmpty(valNameFolder))
            {
                try {
                    UserViewModel vUserSession = HttpContext.Session.Get <UserViewModel>("UserSesion");
                    IFolderData   vFolderData  = new FolderData();
                    string        vFullUrl     = await UploadAzureHelper.CreateFolderContainerBlobStorage(valNameFolder);

                    string[]        vInfoUrl = vFullUrl.Split("/");
                    string          vUrl     = string.Join("/", vInfoUrl.Take(vInfoUrl.Count() - 1));
                    FolderViewModel vFolder  = new FolderViewModel();
                    vFolder.Id         = Guid.NewGuid();
                    vFolder.Name       = vInfoUrl.ElementAt(vInfoUrl.Count() - 2);
                    vFolder.VisualName = valNameFolder;
                    vFolder.Thumnail   = string.Empty;
                    vFolder.Url        = vUrl;
                    vFolder.Icon       = string.Empty;
                    vFolder.State      = 1;
                    vFolder.UserCreate = vUserSession.Id.ToString();

                    vResult = vFolderData.SaveFolder(vFolder);
                } catch (Exception vEx) {
                    vResult = false;
                    return(Json(new { content = vResult.ToString(), message = vEx.Message }));
                }
            }

            return(Json(new { content = vResult.ToString(), message = valNameFolder }));
        }
Ejemplo n.º 2
0
        public async Task <string> Insert(ListCityLanguage valCity)
        {
            string vResult = "4";

            try {
                City vUserExist = SelectUserPortalByName(valCity.ListCity.FirstOrDefault().Name);
                if (vUserExist != null)
                {
                    vResult = "5";
                }
                else if (vUserExist == null)
                {
                    string vUrl = await UploadAzureHelper.UploadFilesToBlobStorageContainer(valCity.ListCity.FirstOrDefault().Photo?.NameFile, valCity.ListCity.FirstOrDefault().Photo?.FileData);

                    if (vUrl != null)
                    {
                        SQLToolsLibrary     vSqlTools      = new SQLToolsLibrary();
                        Guid                IdCity         = Guid.NewGuid();
                        List <SqlParameter> vParameterList = new List <SqlParameter> {
                            new SqlParameter("@Id", IdCity != Guid.Empty?IdCity:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@Name", !string.IsNullOrEmpty(valCity.ListCity.FirstOrDefault().Name)?valCity.ListCity.FirstOrDefault().Name:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@Icon", !string.IsNullOrEmpty(valCity.ListCity.FirstOrDefault().Icon)?valCity.ListCity.FirstOrDefault().Icon:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@Temperature", valCity.ListCity.FirstOrDefault().Temperature != int.MinValue?valCity.ListCity.FirstOrDefault().Temperature:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@Altitude", valCity.ListCity.FirstOrDefault().Altitude != int.MinValue?valCity.ListCity.FirstOrDefault().Altitude:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@Population", valCity.ListCity.FirstOrDefault().Population != int.MinValue?valCity.ListCity.FirstOrDefault().Population:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@UrlPhoto", !string.IsNullOrEmpty(vUrl) ? vUrl : throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@Position", valCity.ListCity.FirstOrDefault().Position != int.MinValue?valCity.ListCity.FirstOrDefault().Position:0),
                            new SqlParameter("@State", valCity.ListCity.FirstOrDefault().State),
                            new SqlParameter("@UserCreate", !string.IsNullOrEmpty(valCity.ListCity.FirstOrDefault().UserCreate) ? valCity.ListCity.FirstOrDefault().UserCreate : throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                            new SqlParameter("@DateCreate", valCity.ListCity.FirstOrDefault().DateCreate != DateTime.MinValue ? valCity.ListCity.FirstOrDefault().DateCreate:DateTime.Now)
                        };
                        bool vResponseCityLanguage = InsertarListaCityLanguage(valCity.ListCity, IdCity);
                        bool vResponseCity         = vSqlTools.ExecuteIUWithStoreProcedure(vParameterList, "sp_Insert_City", vConnection);

                        if (vResponseCity)
                        {
                            if (vResponseCityLanguage)
                            {
                                return(vResult = "1");
                            }
                            return(vResult = "2");
                        }
                    }
                }
            } catch (Exception vEx) {
                string vMessage = vEx.Message;
                return(vResult = "3");
            }
            return(vResult);
        }
Ejemplo n.º 3
0
        public async Task <string> InsertUserPortal(UserPortalAdmin valUser)
        {
            string vResult = "4";

            try {
                UserPortalAdmin vUserExist = SelectUserPortalByEmail(valUser.UserName);
                if (vUserExist != null)
                {
                    vResult = "2";
                }
                else if (vUserExist == null)
                {
                    string vUrl = await UploadAzureHelper.UploadFilesToBlobStorageContainer(valUser.Photo?.NameFile, valUser.Photo?.FileData);


                    SQLToolsLibrary vSqlTools = new SQLToolsLibrary();

                    List <SqlParameter> vListofParameters = new List <SqlParameter> {
                        new SqlParameter("@Id", valUser.Id != Guid.Empty ? valUser.Id : Guid.NewGuid()),
                        new SqlParameter("@UserName", !string.IsNullOrEmpty(valUser.UserName)?valUser.UserName:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                        new SqlParameter("@Password", !string.IsNullOrEmpty(valUser.Password)?valUser.Password:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                        new SqlParameter("@FirstName", !string.IsNullOrEmpty(valUser.FirstName)?valUser.FirstName:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                        new SqlParameter("@SecondName", valUser.SecondName),
                        new SqlParameter("@FirstLastname", !string.IsNullOrEmpty(valUser.FirstLastName)?valUser.FirstLastName:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                        new SqlParameter("@SecondLastName", valUser.SecondLastName),
                        new SqlParameter("@Email", !string.IsNullOrEmpty(valUser.UserName)?valUser.UserName:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                        new SqlParameter("@UrlPhoto", !string.IsNullOrEmpty(vUrl) ? vUrl : string.Empty),
                        new SqlParameter("@BirthDate", valUser.BirthDate != DateTime.MinValue ? valUser.BirthDate : new DateTime(1900, 1, 1)),
                        new SqlParameter("@Phone", valUser.Phone),
                        new SqlParameter("@backmail", !string.IsNullOrEmpty(valUser.Backmail)?valUser.Backmail:string.Empty),
                        new SqlParameter("@IdCompany", valUser.IdCompany != Guid.Empty?valUser.IdCompany:throw new Exception(GlobalValues.vTextExceptionParameterNull)),
                        new SqlParameter("@State", valUser.State),
                        new SqlParameter("@UserCreate", valUser.UserCreate /*!string.IsNullOrEmpty(valUser.UserCreate)?valUser.UserCreate:throw new Exception(GlobalValues.vTextExceptionParameterNull)*/),
                        new SqlParameter("@DateCreate", valUser.DateCreate != DateTime.MinValue ? valUser.DateCreate : DateTime.Now)
                    };
                    bool vSuccessInsert = vSqlTools.ExecuteIUWithStoreProcedure(vListofParameters, "sp_Insert_UserPortal", vConnection);
                    if (vSuccessInsert)
                    {
                        vResult = "1";
                    }
                }
            } catch (Exception e) {
                string vMsg = e.Message;
                vResult = "3";
            }
            return(vResult);
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> DownloadFile(string valFile)
        {
            CloudBlockBlob vBlobClient = UploadAzureHelper.GetBlobStorageContainer(valFile);

            //using (Stream vMemoryStream = new FileStream(vHandle, FileAccess.ReadWrite)) {
            AccessCondition vAccesCondition = new AccessCondition();

            BlobRequestOptions vBlobRequestOptions = new BlobRequestOptions();

            vBlobRequestOptions.MaximumExecutionTime = TimeSpan.FromHours(24);
            vBlobRequestOptions.ServerTimeout        = TimeSpan.FromHours(24);
            OperationContext vOperationContext = new OperationContext();
            var ms = new MemoryStream();
            await vBlobClient.DownloadToStreamAsync(ms, vAccesCondition, vBlobRequestOptions, vOperationContext);

            ActionResult va = File(ms, vBlobClient.Properties.ContentType);

            return(va);
            //}
        }