Exemple #1
0
        private void Upd_Disable_ByCode_ByLang(HttpContext context)
        {
            int    ret        = -1;
            String jSonString = "";

            try
            {
                Files   aFiles   = new Files();
                FilesBO aFilesBO = new FilesBO();
                string  Code     = context.Request.Form["Code"];
                int     IDLang   = int.Parse(context.Request.QueryString["IDLang"]);
                //int Status = Convert.ToInt32(context.Request.Form["cbbStatus"]);
                // int Type = Convert.ToInt32(context.Request.Form["cbbType"]);
                bool Disable = Convert.ToBoolean(context.Request.Form["cbbDisable"]);
                ret = aFilesBO.Upd_Disable_ByCode_ByLang(Code, Disable, IDLang);
                if (ret != 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }
Exemple #2
0
        private void Upd_ByID_ByType(HttpContext context)
        {
            int    ret        = -1;
            String jSonString = "";

            try
            {
                Files   aFiles   = new Files();
                FilesBO aFilesBO = new FilesBO();
                int     ID       = int.Parse(context.Request.Form["ID"]);
                //int Status = Convert.ToInt32(context.Request.Form["cbbStatus"]);
                int Type = Convert.ToInt32(context.Request.Form["cbbType"]);
                //Disable =  Convert.ToBoolean(context.Request.Form["cbbDisable"]) ;
                ret = aFilesBO.Upd_Type_ByID(ID, Type);
                if (ret != 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }
Exemple #3
0
        private void Upd_Disable(HttpContext context)
        {
            int    ret        = -1;
            String jSonString = "";

            try
            {
                FilesBO aFilesBO = new FilesBO();
                Files   aFiles   = new Files();
                int     IDFiles  = Convert.ToInt32(context.Request.QueryString["IDFiles"]);
                aFiles = aFilesBO.Sel_ByID(IDFiles);

                aFiles.Disable = true;

                ret = aFilesBO.Upd(aFiles);
                if (ret != 0)
                {
                    jSonString = "{\"status\":\"error|" + ret.ToString() + "\"}";
                }

                if (ret == 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }
Exemple #4
0
        private void Sel_Files_ByCodeAlbums_ByType(HttpContext context, int IDLang)
        {
            String jSonString = "";

            string CodeAlbums = context.Request.QueryString["CodeAlbums"];
            int    Type       = Convert.ToInt32(context.Request.QueryString["Type"]);

            FilesBO      aFilesBO = new FilesBO();
            List <Files> obj      = aFilesBO.Sel_ByIDLang(IDLang).Where(p => p.CodeAlbums == CodeAlbums).Where(p => p.Type == Type).ToList();

            if (obj.Count > 0)
            {
                if (obj != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";

                    jSonString = JsonConvert.SerializeObject(obj, _converter);
                }
                jSonString = "{\"total\":" + obj.Count + ",\"file\":" + jSonString + "}";
            }
            else
            {
                jSonString = "{\"total\":0,\"file\":" + jSonString + "}";
            }


            context.Response.Write(jSonString);
        }
Exemple #5
0
        private void Sel_ByCode(HttpContext context)
        {
            FilesBO      aFilesBO = new FilesBO();
            List <Files> obj      = new List <Files>();

            string Code       = context.Request.QueryString["Code"];
            String jSonString = "";


            if (string.IsNullOrEmpty(context.Request.QueryString["Disable"]))
            {
                obj = aFilesBO.Sel_ByCode(Code);
            }
            else
            {
                obj = aFilesBO.Sel_ByCode(Code, bool.Parse(context.Request.QueryString["Disable"]));
            }


            int count = obj.Count;

            for (int i = 0; i < obj.Count; i++)
            {
                obj[i].Intro = HttpUtility.HtmlDecode(obj[i].Intro);
                // obj[i].Contents_Intro = HttpUtility.HtmlDecode(obj[i].Intro);
            }
            if (obj != null)
            {
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(obj, _converter);
            }

            jSonString = "{\"data\":" + jSonString + "}";
            context.Response.Write(jSonString);
        }
Exemple #6
0
        private void Sel_ByCodeAlbum_ByIDLang(HttpContext context)
        {
            try
            {
                int     IDLang   = int.Parse(context.Request.QueryString["IDLang"]);
                FilesBO aFilesBO = new FilesBO();
                List <vw_FilesViewAll> aListvw_FilesViewAll = new List <vw_FilesViewAll>();


                String jSonString = "";
                string CodeAlbum  = context.Request.QueryString["CodeAlbum"];
                IDLang = int.Parse(context.Request.QueryString["IDLang"]);
                if (string.IsNullOrEmpty(context.Request.QueryString["Disable"]))
                {
                    aListvw_FilesViewAll = aFilesBO.Sel_Ext_ByCodeAlbums(CodeAlbum, IDLang);
                }
                else
                {
                    aListvw_FilesViewAll = aFilesBO.Sel_Ext_ByCodeAlbums(CodeAlbum, IDLang, bool.Parse(context.Request.QueryString["Disable"]));
                }
                aListvw_FilesViewAll      = aFilesBO.Sel_Ext_ByCodeAlbums(CodeAlbum, IDLang);
                _converter.DateTimeFormat = "dd/MM/yyyy";
                jSonString = JsonConvert.SerializeObject(aListvw_FilesViewAll, _converter);
                jSonString = "{\"Files\":" + jSonString + "}";
                context.Response.Write(jSonString);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("FilesAction.Sel_ByCodeAlbum: {0}", ex.Message));
            }
        }
Exemple #7
0
        private void Sel_ByID(HttpContext context)
        {
            try
            {
                bool Disable = !String.IsNullOrEmpty(Convert.ToString(context.Request.QueryString["Disable"]))
                    ? Convert.ToBoolean(context.Request.QueryString["Disable"])
                    : false;
                int ID = Convert.ToInt32(context.Request.QueryString["ID"]);

                FilesBO aFilesBO = new FilesBO();
                Files   obj      = new Files();
                obj = String.IsNullOrEmpty(Convert.ToString(context.Request.QueryString["Disable"]))?aFilesBO.Sel_ByID(ID):aFilesBO.Sel_ByID(ID, Disable);


                String jSonString = "";

                //int IDLang = string.IsNullOrEmpty(context.Request.QueryString["IDLang"]) ? CORE_Language.sys_CUR_LANG : int.Parse(context.Request.QueryString["IDLang"]);


                if (obj != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(obj, _converter);
                }

                jSonString = "{\"data\":" + jSonString + "}";
                context.Response.Write(jSonString);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("FilesAction.Sel_ByCodeAlbum: {0}", ex.Message));
            }
        }
        public IActionResult GetAllFilesInformation(string username, string password, string folderPath)
        {
            Authentication     user   = new Authentication(username, username, username, username);
            FilesBO            oFiles = new FilesBO();
            List <FileMessage> result = new List <FileMessage>();

            return(new ObjectResult(result));
        }
        public IActionResult CheckoutFile(string username, string password, string filepath)
        {
            Authentication user = new Authentication(username, username, username, username);

            if (user.IsAuthenticated)
            {
                FilesBO oFiles = new FilesBO();
                bool    result = oFiles.CheckoutFile(username, filepath);
                return(new ObjectResult(result));
            }
            else
            {
                return(new ObjectResult(null));
            }
        }
Exemple #10
0
        private void Sel_ByIDLang(HttpContext context, int IDLang)
        {
            try
            {
                FilesBO aFilesBO           = new FilesBO();
                List <vw_FilesViewAll> obj = new List <vw_FilesViewAll>();


                String jSonString = "";


                if (string.IsNullOrEmpty(context.Request.QueryString["Disable"]))
                {
                    obj = aFilesBO.Sel_Ext_ByIDLang(IDLang);
                }
                else
                {
                    obj = aFilesBO.Sel_Ext_ByIDLang(IDLang, bool.Parse(context.Request.QueryString["Disable"]));
                }


                int count = obj.Count;

                for (int i = 0; i < obj.Count; i++)
                {
                    obj[i].Files_Intro = HttpUtility.HtmlDecode(obj[i].Files_Intro);
                    // obj[i].Contents_Intro = HttpUtility.HtmlDecode(obj[i].Intro);
                }
                if (obj != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(obj, _converter);
                }

                jSonString = "{\"data\":" + jSonString + "}";
                context.Response.Write(jSonString);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("FilesAction.Sel_ByCodeAlbum: {0}", ex.Message));
            }
        }
Exemple #11
0
        private void Del_ByCode(HttpContext context)
        {
            FilesBO aFilesBO   = new FilesBO();
            String  jSonString = "";
            String  Code       = context.Request.QueryString["Code"].ToString();
            int     ret        = aFilesBO.Del_ByCode(Code);


            if (ret > 0)
            {
                jSonString = "{\"status\": \"success\"}";
            }

            if (ret == 0)
            {
                jSonString = "{\"status\":\"error|" + ret.ToString() + "\"}";
            }


            context.Response.Write(jSonString);
        }
Exemple #12
0
        public IActionResult DownloadFileByFilePath(string username, string password, string filepath)
        {
            Authentication user = new Authentication(username, username, username, username);

            filepath = HttpUtility.UrlDecode(filepath);
            FileDownload result = new FileDownload();

            if (user.IsAuthenticated)
            {
                result.FileName = System.IO.Path.GetFileName(filepath);
                result.FilePath = filepath.Substring(0, filepath.Length - result.FileName.Length);
                FilesBO oFiles = new FilesBO();

                // work with apples to build your file in memory
                result.FileContent = oFiles.GetFileContent(filepath);
                return(new ObjectResult(result));
            }
            else
            {
                return(null);
            }
        }
Exemple #13
0
        private void Sel_ByType_ByStatus_ByIDLang(HttpContext context)
        {
            try
            {
                int          IDLang     = int.Parse(context.Request.QueryString["IDLang"]);
                FilesBO      aFilesBO   = new FilesBO();
                List <Files> obj        = new List <Files>();
                int          Type       = int.Parse(context.Request.QueryString["Type"]);
                int          Status     = int.Parse(context.Request.QueryString["Status"]);
                String       jSonString = "";
                if (string.IsNullOrEmpty(context.Request.QueryString["Disable"]))
                {
                    obj = aFilesBO.Sel_ByType_ByStatus_ByIDLang(Type, Status, IDLang);
                }
                else
                {
                    obj = aFilesBO.Sel_ByType_ByStatus_ByIDLang(Type, Status, IDLang, bool.Parse(context.Request.QueryString["Disable"]));
                }


                int count = obj.Count;


                if (obj != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(obj, _converter);
                }

                jSonString = "{\"data\":" + jSonString + "}";
                context.Response.Write(jSonString);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("FilesAction.Sel_ByCodeAlbum: {0}", ex.Message));
            }
        }
Exemple #14
0
        private void Sel_Ext_ByKeyCodeFiles(HttpContext context)
        {
            try
            {
                string  Key                = context.Request.QueryString["CodeFiles"];
                FilesBO aFilesBO           = new FilesBO();
                List <vw_FilesViewAll> obj = new List <vw_FilesViewAll>();

                String jSonString = "";
                if (string.IsNullOrEmpty(context.Request.QueryString["Disable"]))
                {
                    obj = aFilesBO.Sel_Ext_ByKeyCodeFiles(Key);
                }
                else
                {
                    obj = aFilesBO.Sel_Ext_ByKeyCodeFiles(Key, bool.Parse(context.Request.QueryString["Disable"]));
                }


                int count = obj.Count;


                if (obj != null)
                {
                    _converter.DateTimeFormat = "dd/MM/yyyy";
                    jSonString = JsonConvert.SerializeObject(obj, _converter);
                }

                jSonString = "{\"data\":" + jSonString + "}";
                context.Response.Write(jSonString);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("FilesAction.Sel_ByCodeAlbum: {0}", ex.Message));
            }
        }
Exemple #15
0
        private void Upd_ByCode(HttpContext context, int NUM_LANG)
        {
            int    ret        = -1;
            String jSonString = "";

            try
            {
                if (NUM_LANG < 1)
                {
                    NUM_LANG = 1;
                }
                List <Files> aFiles   = new List <Files>();
                FilesBO      aFilesBO = new FilesBO();
                String       Code     = context.Request.Form["txtCode"];

                aFiles = aFilesBO.Sel_ByCode(Code);

                int LoopUpdate = 0;

                if (aFiles.Count <= NUM_LANG)
                {
                    LoopUpdate = aFiles.Count;
                    for (int i = 0; i < LoopUpdate; i++)
                    {
                        aFiles[i].ID = aFiles[i].ID;

                        aFiles[i].Code   = aFiles[i].Code;
                        aFiles[i].IDLang = aFiles[i].IDLang;

                        aFiles[i].CodeAlbums = !String.IsNullOrEmpty(context.Request.Form["txt_CodeAlbums"]) ? Convert.ToString(context.Request.Form["txt_CodeAlbums"]) : aFiles[i].CodeAlbums;

                        aFiles[i].Image  = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : aFiles[i].Image;
                        aFiles[i].Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"]) ? Convert.ToString(context.Request.Form["txtImage_2"]) : aFiles[i].Image;
                        aFiles[i].Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"]) ? Convert.ToString(context.Request.Form["txtImage_3"]) : aFiles[i].Image;
                        aFiles[i].Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"]) ? Convert.ToString(context.Request.Form["txtImage_4"]) : aFiles[i].Image;

                        aFiles[i].Info = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtInfo_Lang" + (i + 1)]) : aFiles[i].Info;

                        aFiles[i].Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtIntro_Lang" + (i + 1)]) : aFiles[i].Intro;

                        aFiles[i].Title = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + (i + 1)]) ? Convert.ToString(context.Request.Form["txtTitle_Lang" + (i + 1)]) : aFiles[i].Title;


                        aFiles[i].UploadDate = !String.IsNullOrEmpty(context.Request.Form["dtpPublishDate"]) ? DateTime.ParseExact(context.Request.Form["dtpPublishDate"], "dd/MM/yyyy", culture) : aFiles[i].UploadDate;


                        aFiles[i].Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : aFiles[i].Status;

                        aFiles[i].Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : aFiles[i].Type;

                        aFiles[i].Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : aFiles[i].Disable;

                        aFiles[i].Width = !String.IsNullOrEmpty(context.Request.Form["txtWidth"]) ? Convert.ToInt32(context.Request.Form["txtWidth"]) : aFiles[i].Width;

                        aFiles[i].Height = !String.IsNullOrEmpty(context.Request.Form["txtHeight"]) ? Convert.ToInt32(context.Request.Form["txtHeight"]) : aFiles[i].Height;

                        // aFiles[i].Code = !String.IsNullOrEmpty(context.Request.Form["Code"]) ? Convert.ToString(context.Request.Form["txt_Code"]) : aFiles[i].Code;

                        //aFiles[i].IDLang = !String.IsNullOrEmpty(context.Request.Form["txt_IDLang"]) ? Convert.ToInt32(context.Request.Form["txt_IDLang"]) : aFiles[i].IDLang;



                        ret = aFilesBO.Upd(aFiles[i]);
                        if (ret == 0)
                        {
                            jSonString = "{\"status\":\"error|" + ret.ToString() + "\"}";
                            break;
                        }
                    }
                }
                if (ret != 0)
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }
Exemple #16
0
        private void Ins(HttpContext context, int NUM_LANG)
        {
            List <Files> aListFiles = new List <Files>();
            int          ret        = -1;
            String       jSonString = "";
            TimeSpan     Codespan   = new TimeSpan(DateTime.Now.Ticks);
            string       Code       = Math.Floor(Codespan.TotalSeconds).ToString();

            try
            {
                for (int i = 1; i <= NUM_LANG; i++)
                {
                    Files aFiles = new Files();
                    aFiles.CodeAlbums = !String.IsNullOrEmpty(context.Request.Form["txt_CodeAlbums"]) ? Convert.ToString(context.Request.Form["txt_CodeAlbums"]) : "";
                    aFiles.Image      = !String.IsNullOrEmpty(context.Request.Form["txtImage_1"]) ? Convert.ToString(context.Request.Form["txtImage_1"]) : "";

                    aFiles.UploadDate = DateTime.Now;
                    //aFiles.CreateByIDUser = !String.IsNullOrEmpty(context.Request.Form["txt_CreateByIDUser"]) ? Convert.ToInt64(context.Request.Form["txt_CreateByIDUser"]) : aFiles.CreateByIDUser;

                    aFiles.Status = !String.IsNullOrEmpty(context.Request.Form["cbbStatus"]) ? Convert.ToInt32(context.Request.Form["cbbStatus"]) : 0;

                    aFiles.Type = !String.IsNullOrEmpty(context.Request.Form["cbbType"]) ? Convert.ToInt32(context.Request.Form["cbbType"]) : 0;

                    aFiles.Disable = !String.IsNullOrEmpty(context.Request.Form["cbbDisable"]) ? Convert.ToBoolean(context.Request.Form["cbbDisable"]) : false;

                    aFiles.Width = !String.IsNullOrEmpty(context.Request.Form["txtWidth"]) ? Convert.ToInt32(context.Request.Form["txt_Width"]) : 0;

                    aFiles.Height = !String.IsNullOrEmpty(context.Request.Form["txtHeight"]) ? Convert.ToInt32(context.Request.Form["txt_Height"]) : 0;
                    aFiles.Code   = Code;
                    aFiles.Image1 = !String.IsNullOrEmpty(context.Request.Form["txtImage_2"]) ? Convert.ToString(context.Request.Form["txtImage_2"]) : "";
                    aFiles.Image2 = !String.IsNullOrEmpty(context.Request.Form["txtImage_3"]) ? Convert.ToString(context.Request.Form["txtImage_3"]) : "";
                    aFiles.Image3 = !String.IsNullOrEmpty(context.Request.Form["txtImage_4"]) ? Convert.ToString(context.Request.Form["txtImage_4"]) : "";
                    aFiles.IDLang = !String.IsNullOrEmpty(context.Request.Form["IDLang_" + i]) ? Convert.ToInt32(context.Request.Form["IDLang_" + i]) : 0;
                    aFiles.Title  = !String.IsNullOrEmpty(context.Request.Form["txtTitle_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlEncode(context.Request.Form["txtTitle_Lang" + i])) : "";

                    aFiles.Intro = !String.IsNullOrEmpty(context.Request.Form["txtIntro_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlEncode(context.Request.Form["txtIntro_Lang" + i])) : "";
                    aFiles.Info  = !String.IsNullOrEmpty(context.Request.Form["txtInfo_Lang" + i]) ? Convert.ToString(HttpUtility.HtmlEncode(context.Request.Form["txtInfo_Lang" + i])) : "";

                    aListFiles.Add(aFiles);
                }

                FilesBO aFilesBO = new FilesBO();


                ret = aFilesBO.Ins(ref aListFiles);
                if (ret < aListFiles.Count)
                {
                    jSonString = "{\"status\":\"error\" ,\"message\":\"" + ret.ToString() + "\"}";
                    aFilesBO.Del(aListFiles);
                    return;
                }
                else
                {
                    jSonString = "{\"status\": \"success\"}";
                }
            }
            catch (Exception ex)
            {
                jSonString = "{\"status\":\"error\" ,\"message\":\"" + ex.Message.ToString() + "\"}";
            }
            finally
            {
                context.Response.Write(jSonString);
            }
        }