protected void Page_Load(object sender, EventArgs e)
    {
        //get the library record path
        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMConnection2;
        ds.TableName = "Library";
        //NOTE: This page lacks any security check as to whether the document belongs to a person/company
        //When deployed to a live server further development is required to secure this page.
        //CRM Together take no responsibility for this as this site is for sample purposes. 
        ds.WhereClause = "libr_libraryid="+Request.QueryString["libr_libraryid"];

        IDataReader idr = ds.SelectData();  //get our IDataReader class

        string filepath="";
        string filename="";
        //loop through our class
        while (idr.Read())
        {
            filepath=idr["libr_filepath"].ToString();
            filename = idr["libr_filename"].ToString();
        }
        string fullpath = getDocStore() + filepath + filename;
        System.IO.FileInfo file = new System.IO.FileInfo(fullpath);
        //stream the file out
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" +filename);
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = getMimeType(fullpath);
        Response.WriteFile(file.FullName);
        Response.End();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!this.FileUpload1.HasFile)
        {
            return;
        }

        //this.FileUpload1.SaveAs(@"C:\\Program Files\\Sage\\CRM\\CRM62sp1\\Library\\" + FileUpload1.FileName.ToString());
        string path = getPath(FileUpload1.FileName.ToString());

        this.FileUpload1.SaveAs(@path);

        //create library record
        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMDataSource2.SageCRMConnection;
        ds.TableName         = "Library";
        ds.Parameters.Add("libr_caseid", this.caseid);
        ds.Parameters.Add("libr_personid", SageCRMPortalEntryBlock.GetVisitorInfo("pers_personid"));
        ds.Parameters.Add("libr_companyid", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));
        string folderpath = getLibrFolder("company", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));

        ds.Parameters.Add("libr_filepath", folderpath);
        ds.Parameters.Add("libr_filename", this.FileUpload1.FileName.ToString());
        ds.Parameters.Add("libr_note", this.libr_note.Text.ToString());
        //Label1.Text= ds.InsertRecord();
        ds.InsertRecord();
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //get the library record path
        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMConnection2;
        ds.TableName         = "Library";
        //NOTE: This page lacks any security check as to whether the document belongs to a person/company
        //When deployed to a live server further development is required to secure this page.
        //CRM Together take no responsibility for this as this site is for sample purposes.
        ds.WhereClause = "libr_libraryid=" + Request.QueryString["libr_libraryid"];

        IDataReader idr = ds.SelectData();  //get our IDataReader class

        string filepath = "";
        string filename = "";

        //loop through our class
        while (idr.Read())
        {
            filepath = idr["libr_filepath"].ToString();
            filename = idr["libr_filename"].ToString();
        }
        string fullpath = getDocStore() + filepath + filename;

        System.IO.FileInfo file = new System.IO.FileInfo(fullpath);
        //stream the file out
        Response.Clear();
        Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);
        Response.AddHeader("Content-Length", file.Length.ToString());
        Response.ContentType = getMimeType(fullpath);
        Response.WriteFile(file.FullName);
        Response.End();
    }
 public DataSet getCases()
 {
     getSageObject();
     SageCRMDataSource ds = new SageCRMDataSource();
     ds.SageCRMConnection = this.SageCon;
     ds.TableName = "Cases";
     string id = SageObject.GetVisitorInfo("pers_personid");
     ds.WhereClause = "case_primarypersonid=" + id;
     return ds.getDataSet();
 }
 public string getDocStore()
 {
     /*
      * select * from custom_sysparams
             where parm_name='DocStore'
      * */
     SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
     ds.SageCRMConnection = this.SageCRMConnection2;
     ds.SelectSQL = "select * from custom_sysparams where parm_name='DocStore'";
     IDataReader idr = ds.SelectData();  //get our IDataReader class
     //loop through our class
     idr.Read();
     return idr["parm_value"].ToString();
 }
    public string getDocStore()
    {
        /*
         * select * from custom_sysparams
         *      where parm_name='DocStore'
         * */
        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMConnection2;
        ds.SelectSQL         = "select * from custom_sysparams where parm_name='DocStore'";
        IDataReader idr = ds.SelectData();  //get our IDataReader class

        //loop through our class
        idr.Read();
        return(idr["parm_value"].ToString());
    }
 public string getCompanyId()
 {
     string result = "-1";
     SageCRMDataSource ds = new SageCRMDataSource();
     ds.SageCRMConnection = this.SageCRMConnection;
     ds.TableName = "CrmProject";
     ds.WhereClause = "proj_projectid=" + Session["proj_projectid"];
     IDataReader idr = ds.SelectData();
     while (idr.Read())
     {
         result =idr["proj_companyid"].ToString();
         if (result == "")
             result = "-1";
     }
     return result;
 }
 public bool setUpData()
 {
     string extraSQL ="";
     if (this.SageCRMConnectionObject == null)
         return false;
     cbds = new SageCRMDataSource(); //create our datasource
     cbds.SageCRMConnection = this.SageCRMConnectionObject; //assign a connection 
     cbds.SelectSQL = "select * from custom_screenobjects "+
         " where cobj_type='List' " + 
         extraSQL +
         " order by cobj_name";
     listBox1.DataSource = cbds;
     listBox1.DisplayMember = "bord_caption";
     listBox1.ValueMember = "bord_name";
     return true;
 }
    public string getLibrFolder(string EntityName, string EntityID)
    {
        string res = "";

        EntityName = EntityName.ToLower();

        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMConnection2;
        ds.TableName         = EntityName;
        string librfield = "comp_librarydir";

        if (EntityName == "person")
        {
            ds.WhereClause = "pers_personid=" + EntityID;
            librfield      = "pers_librarydir";
            IDataReader idr = ds.SelectData();      //get our IDataReader class
            //loop through our class
            idr.Read();
            res = idr[librfield].ToString() + "\\";
        }
        else
        if (EntityName == "company")
        {
            ds.WhereClause = "comp_companyid=" + EntityID;
            IDataReader idr = ds.SelectData();          //get our IDataReader class
            //loop through our class
            idr.Read();
            res = idr[librfield].ToString() + "\\";
        }
        else
        if (EntityName == "user")
        {
            ds.TableName   = "users";
            ds.WhereClause = "user_userid=" + EntityID;
            IDataReader idr = ds.SelectData();              //get our IDataReader class
            //loop through our class
            idr.Read();
            res = idr["user_firstname"].ToString() + " " + idr["user_lastname"].ToString() + "\\";
        }
        return(res);
    }
 private void setConnection()
 {
     this.ds = new SageCRMDataSource(); //create our datasource
     this.ds.SageCRMConnection = this.connectionObject; //assign a connection 
 }
 public DataSourcePropEditor(SageCRMDataSource _block)
 {
     this.Block = _block;
     this.connectionObject = this.Block.SageCRMConnection;
     InitializeComponent();
 }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (!this.FileUpload1.HasFile)
            return;

        //this.FileUpload1.SaveAs(@"C:\\Program Files\\Sage\\CRM\\CRM62sp1\\Library\\" + FileUpload1.FileName.ToString());
        string path = getPath(FileUpload1.FileName.ToString());
        this.FileUpload1.SaveAs(@path );

        //create library record
        SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
        ds.SageCRMConnection = this.SageCRMDataSource2.SageCRMConnection;
        ds.TableName = "Library";
        ds.Parameters.Add("libr_caseid", this.caseid);
        ds.Parameters.Add("libr_personid", SageCRMPortalEntryBlock.GetVisitorInfo("pers_personid"));
        ds.Parameters.Add("libr_companyid", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));
        string folderpath = getLibrFolder("company", SageCRMPortalEntryBlock.GetVisitorInfo("comp_companyid"));
        ds.Parameters.Add("libr_filepath", folderpath);
        ds.Parameters.Add("libr_filename", this.FileUpload1.FileName.ToString());
        ds.Parameters.Add("libr_note", this.libr_note.Text.ToString());
        //Label1.Text= ds.InsertRecord();
        ds.InsertRecord();

    }
       public string getLibrFolder(string EntityName, string EntityID)
        {
            string res = "";
            EntityName = EntityName.ToLower();

            SageCRM.AspNet.SageCRMDataSource ds = new SageCRM.AspNet.SageCRMDataSource();
            ds.SageCRMConnection = this.SageCRMConnection2;
            ds.TableName = EntityName;
            string librfield = "comp_librarydir";
            if (EntityName == "person")
            {
                ds.WhereClause = "pers_personid=" + EntityID;
                librfield = "pers_librarydir";
                IDataReader idr = ds.SelectData();  //get our IDataReader class
                //loop through our class
                idr.Read();
                res = idr[librfield].ToString() + "\\";
            }
            else
                if (EntityName == "company")
                {
                    ds.WhereClause = "comp_companyid=" + EntityID;
                    IDataReader idr = ds.SelectData();  //get our IDataReader class
                    //loop through our class
                    idr.Read();
                    res = idr[librfield].ToString() + "\\";
                }
                else
                    if (EntityName == "user")
                    {
                        ds.TableName = "users";
                        ds.WhereClause = "user_userid=" + EntityID;
                        IDataReader idr = ds.SelectData();  //get our IDataReader class
                        //loop through our class
                        idr.Read();
                        res = idr["user_firstname"].ToString() + " " + idr["user_lastname"].ToString() + "\\";
                    }
            return res;
        }