Ejemplo n.º 1
0
        protected void SaveAttachment(string filName, string extension, string docKind, string callRefNo, string attachedBlob)
        {
            var usNo     = nav.grantees_Register.ToList().Where(usr => usr.Organization_Username == Session["username"].ToString()).Select(nu => nu.No).SingleOrDefault();
            var usaname  = Session["username"].ToString();
            var taskNum  = Session["tasknumber"].ToString();
            int userType = Convert.ToInt32(Session["usertype"]);
            var prjct    = ddlAccountType.SelectedItem.Text;

            // string fullFPath = Request.PhysicalApplicationPath + "All Uploads\\" + Grantees.No + @"\" + filName;

            string navfilePath = @"D:\All_Portal_Uploaded\" + filName;

            // string uriPath = new Uri(navfilePath).LocalPath;
            // string urI =;

            var       credentials = new NetworkCredential(ConfigurationManager.AppSettings["W_USER"], ConfigurationManager.AppSettings["W_PWD"], ConfigurationManager.AppSettings["DOMAIN"]);
            const int granttype   = 1;
            string    docType     = "";

            if ((extension == ".jpg") || (extension == ".jpeg") || (extension == ".png"))
            {
                docType = "Picture";
            }
            else
            if ((extension == ".pdf"))
            {
                docType = "PDF";
            }
            if ((extension == ".doc") || (extension == ".docx"))
            {
                docType = "Word Document";
            }
            if (extension == ".xlsx")
            {
                docType = "Excel Document";
            }
            //try
            //{

            int slVal = ddlAccountType.SelectedIndex;

            switch (slVal)
            {
            case 0:
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "alert('Select valid project from dropdownlist!');", true);
                txtPrefNo.Text = "";
                break;

            default:
                Portals sup = new Portals();
                sup.Credentials     = credentials;
                sup.PreAuthenticate = true;
                if (sup.FnAttachMatrixx(usNo, docType, navfilePath, filName, granttype, docKind, usaname, prjct, callRefNo, attachedBlob) == true)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "anything", "alert('Document: " + filName + " uploaded and Saved successfully!');", true);
                    sup.FnFullfillTask(taskNum, userType);
                }
                break;
            }

            //}
            //catch (Exception r)
            //{
            //    KCDFAlert.ShowAlert(r.Message);
            //}
        }