Ejemplo n.º 1
0
        public static string AddAppealDocument(HttpRequestBase Request, List <Tbl_Document_List> Doclist,
                                               string fileSavePath, string Appno, int Custid, string messageappeal)
        {
            string results = "";

            if (Request.Files.AllKeys.Length > 0)
            {
                BirthProcessAction obj = new BirthProcessAction();

                for (int k = 0; k < Doclist.Count; k++)
                {
                    try
                    {
                        var DocumentTmp = Doclist[k];
                        var files       = Request.Files;

                        var file = files[k];
                        if (file != null)
                        {
                            var fileName = file.FileName;
                            if (fileName != null && fileName.Trim().Length > 0)
                            {
                                if (fileName.Contains(@"\"))
                                {
                                    fileName = fileName.Substring(fileName.LastIndexOf(@"\"));
                                }
                                string Docname = DocumentTmp.Docname;

                                if (Docname.Equals("Identity Document"))
                                {
                                    Docname = Docname.Replace(" ", "_");
                                }
                                else
                                {
                                    string[] temp = Appno.Split('_');
                                    Docname = "AP";
                                }

                                int    idx          = fileName.LastIndexOf(".");
                                string fileNameTemp = fileName.Substring(0, idx);
                                string extemp       = fileName.Substring(idx);
                                fileNameTemp = fileNameTemp + "_" + Appno;
                                fileName     = fileNameTemp + extemp;

                                fileSavePath = fileSavePath + Docname;
                                if (!Directory.Exists(fileSavePath))
                                {
                                    Directory.CreateDirectory(fileSavePath);
                                }

                                fileSavePath = fileSavePath + "\\" + fileName;


                                //populate DocumentTmp
                                DocumentTmp.DocFilePath = fileSavePath;
                                DocumentTmp.IsActive    = true;
                                DocumentTmp.BR_ID       = Appno;
                                string Appealmessage =
                                    results = results + obj.InsertAppealDocAtt
                                                  (DocumentTmp.BR_ID, fileName, DocumentTmp.DocFilePath, DocumentTmp.IsActive, messageappeal);
                                file.SaveAs(fileSavePath);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.Message.ToString();
                    }
                }
            }
            return(results);
        }