Beispiel #1
0
 public List <DefectAttach> getattachsbytask(string ttid)
 {
     if (string.IsNullOrEmpty(ttid))
     {
         return(null);
     }
     return(DefectAttach.GetAttachsByTask(Convert.ToInt32(ttid)));
 }
Beispiel #2
0
    public static void AddAttachByTask(int ttid, string filename, string data)
    {
        int taksid = Defect.GetIDbyTT(ttid);
        int repid  = Defect.GetRepRecByTTID(taksid);

        byte[] filedata      = Convert.FromBase64String(data);
        byte[] filedata4Disk = filedata;
        int    filesize      = filedata.Length;

        if (filedata.Length > 1024 * 1024 * 5)
        {
            filedata = new byte[0];
        }
        int key = DefectAttach.AddObject(
            _FileTabl,
            new string[] { "idRecord", "ProjectID", "ArchvFile", "FileData" },
            new object[] {
            new Expression(string.Format("(SELECT MAX(IDRECORD) + 1 FROM {0} where IDRECORD < 3000000)", _FileTabl)),
            1,
            new Expression(string.Format("(SELECT CONVERT(VARCHAR(10), MAX(IDRECORD) + 1) + '.DAT' FROM {0}  where IDRECORD < 3000000)", _FileTabl)),
            filedata
        },
            "IDRECORD"
            );
        int attkey = DefectAttach.AddObject(
            _Tabl,
            new string[] { _ID, _Proj, _Entit, _AttType, _Rid, _Name, _Mac, _MacCr, _DateC, _Size, _File, _Compr, _InDB },
            new object[] {
            new Expression(string.Format("(SELECT MAX(IDRECORD) + 1 FROM {0} where IDRECORD < 3000000)", _Tabl)),
            1,
            1684431732,
            1,
            repid,
            filename,
            1061109567,
            1061109567,
            new Expression("GETUTCDATE()"),
            filesize,
            string.Format("{0}.DAT", key),
            0,
            1
        },
            "IDRECORD"
            );

        if (filedata.Length < 1)
        {
            if (!Directory.Exists(Settings.CurrentSettings.DEFECTATTACHDIR))
            {
                Directory.CreateDirectory(Settings.CurrentSettings.DEFECTATTACHDIR);
            }
            DefectAttach da = new DefectAttach(attkey);
            File.WriteAllBytes(da.FileOnDisk, filedata4Disk);
        }
        DefectHistory.AddHisotoryByTask(taksid, string.Format("Added attachment: {0}", filename));
    }
Beispiel #3
0
    public void delfileupload(string ttid, string id)
    {
        int iid = Convert.ToInt32(id);

        if (iid < 1)
        {
            return;
        }
        DefectAttach.DeleteAttach(ttid, iid);
    }
Beispiel #4
0
 public void newfileupload(string ttid, string filename, string data)
 {
     try
     {
         DefectAttach.AddAttachByTask(Convert.ToInt32(ttid), filename, data.Remove(0, data.IndexOf("base64,") + 7));
     }
     catch (Exception e)
     {
         Logger.Log(e);
     }
 }
Beispiel #5
0
    public static void DeleteAttach(string ttid, int id)
    {
        DefectAttach a      = new DefectAttach(id);
        int          taksid = Defect.GetIDbyTT(Convert.ToInt32(ttid));

        DefectHistory.AddHisotoryByTask(taksid, string.Format("Deleted attachment: {0}", a.FILENAME));
        string fname = a.FileOnDisk;

        if (File.Exists(fname))
        {
            File.Delete(fname);
        }
        DeleteObject(_Tabl, id.ToString(), _ID);
    }