示例#1
0
        /// <summary>
        /// its use to download the file
        /// </summary>
        /// <param name="filename"></param>
        /// <returns></returns>
        public static async Task <FileDownloadBase64String> Download(string filename)
        {
            FileDownloadBase64String fileDownload = new FileDownloadBase64String();

            if (string.IsNullOrEmpty(filename))
            {
                fileDownload.Status   = StatusFlag.Failure;
                fileDownload.Message  = "File Path is Empty";
                fileDownload.FileName = Path.GetFileName(filename);
            }
            else
            {
                //
                //Pending for default path location conformations.
                //
                var path = Path.Combine(
                    Directory.GetCurrentDirectory(),
                    "Resources\\Images", filename);
                byte[] bytes;
                var    memory = new MemoryStream();
                using (var stream = new FileStream(path, FileMode.Open))
                {
                    await stream.CopyToAsync(memory);

                    bytes = memory.ToArray();
                    fileDownload.Status               = StatusFlag.Success;
                    fileDownload.Message              = "File Downloaded";
                    fileDownload.FileName             = filename;
                    fileDownload.FileContentsAsBase64 = Convert.ToBase64String(bytes);
                }
            }

            return(fileDownload);
        }
示例#2
0
        public async Task <string> Get()
        {
            var DbContent = DB_config.db_conection();

            TblOrganization tblOrganizations = new TblOrganization();

            tblOrganizations.City = "Erunakulam";
            DbContent.TblOrganizations.Add(tblOrganizations);

            //upload Multiple files
            List <string> s = new List <string>();

            s.Add("E:\\a.txt");
            s.Add("E:\\b.txt");
            s.Add("E:\\ac.txt");

            FileOperations.upload(s);

            //How to call Download method.
            FileDownloadBase64String fileinfo = await FileOperations.Download("b.txt");

            // Call Log implementation method.
            //
            LogModel logModel = new LogModel();

            logModel.LogType = LogTypes.Error;
            logModel.Message = "Success";

            Log log = new Log();

            log.LogWrite(logModel);

            // Maill function

            GMailServices gMailServices = new GMailServices();

            gMailServices.SendMail("*****@*****.**", "Test", "Hello Ramabose");


            // insert and update samples


            //var org = new TblOrganization
            //{
            //    OrganizationName = "",
            //    OrganizationCode = "",
            //    OrganizationEmail = "",
            //    OrganizationAddress1 = "",
            //    OrganizationContact = "",
            //    OrganizationType = "",
            //    OrganizationAddress2 = "",
            //    City = "",
            //    State = "",
            //    PinCode = "",
            //    OrganizationLogo = "",
            //    DelFlag = true,
            //    CreatedDate = DateTime.Now,
            //    UpdatedDate = DateTime.Now,

            //};

            //DbContent.TblOrganizations.Add(org);
            //DbContent.SaveChanges();

            return("Good");
        }