Beispiel #1
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 #2
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);
    }
Beispiel #3
0
 protected override void PostStore()
 {
     if (REQUESTRESET)
     {
         DefectHistory.DelHisotoryByTask(IDREC);
         DefectEvent.DelHisotoryByTask(IDREC);
         _HistoryChanges = "Task was reset.";
     }
     if (!string.IsNullOrEmpty(_HistoryChanges))
     {
         DefectHistory.AddHisotoryByTask(IDREC, _HistoryChanges, GetUpdater().TTUSERID.ToString());
         _HistoryChanges = "";
     }
     base.PostStore();
 }