Esempio n. 1
0
        public static int CreateNew(Guid OrgID, 
			int DeptID,
			int UserId,
			int TechnicianId,
			int TktUserId,
			DateTime CreationDate,
			int AccountId,
			int AccountLocationId,
			bool LookUpAccount,
			int LocationId,
			int ClassId,
			int LevelId,
			string SubmissionCategoryName,
			bool HandledByCallCenter,
			int CreationCategoryId,
			bool Preventive,
			int PriorityId,
			DateTime RequestComplDate,
			string RequestComplNote,
			string SerialNumber,
			Assets.AssetItem[] assets,
			string IDMethod,
			string CustomFields,
			string Subject,
			string Text,
			System.IO.FileInfo[] files,
			string Status,
			out int initialPostId,
			int ProjectId,
			int folderID,
			int schedTicketID,
			decimal EstimatedTime)
        {
            bool _newUserPost=TechnicianId==UserId ? false : true;
            bool _newTechPost=TktUserId==UserId ? false : true;

            SqlParameter _pRVAL = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
            _pRVAL.Direction = ParameterDirection.ReturnValue;
            SqlParameter _pTechnicianId = new SqlParameter("@techId", SqlDbType.Int);
            if (TechnicianId != 0) _pTechnicianId.Value = TechnicianId;
            else _pTechnicianId.Value = DBNull.Value;
            SqlParameter _pCreationDate = new SqlParameter("@dtCreatedTime", SqlDbType.SmallDateTime);
            if (CreationDate!=null && CreationDate!=DateTime.MinValue) _pCreationDate.Value = CreationDate;
            else _pCreationDate.Value=DBNull.Value;
            SqlParameter _pAccountId = new SqlParameter("@intAcctId", SqlDbType.Int);
            if (AccountId > 0) _pAccountId.Value = AccountId;
            else _pAccountId.Value = DBNull.Value;
            SqlParameter _pbtNoAccount = new SqlParameter("@btNoAccount", SqlDbType.Bit);
            if (AccountId == -2) _pbtNoAccount.Value = true;
            else _pbtNoAccount.Value = false;
            SqlParameter _pAccountLocationId = new SqlParameter("@AccountLocationId", SqlDbType.Int);
            if (AccountLocationId > 0) _pAccountLocationId.Value = AccountLocationId;
            else _pAccountLocationId.Value = DBNull.Value;
            SqlParameter _pLocationId = new SqlParameter("@location", SqlDbType.Int);
            if (LocationId != 0) _pLocationId.Value = LocationId;
            else _pLocationId.Value = DBNull.Value;
            SqlParameter _pClassId = new SqlParameter("@class", SqlDbType.Int);
            if (ClassId != 0) _pClassId.Value = ClassId;
            else _pClassId.Value = DBNull.Value;
            SqlParameter _pLevelId = new SqlParameter("@tintLevel", SqlDbType.TinyInt);
            if (LevelId != 0) _pLevelId.Value = LevelId;
            else _pLevelId.Value = DBNull.Value;
            SqlParameter _pSubmissionCategoryName = new SqlParameter("@vchSubmissionCat", SqlDbType.NVarChar, 50);
            if (!string.IsNullOrEmpty(SubmissionCategoryName)) _pSubmissionCategoryName.Value = SubmissionCategoryName;
            else _pSubmissionCategoryName.Value = DBNull.Value;
            SqlParameter _pCreationCategoryId = new SqlParameter("@intCategoryId", SqlDbType.Int);
            if (CreationCategoryId != 0) _pCreationCategoryId.Value = CreationCategoryId;
            else _pCreationCategoryId.Value = DBNull.Value;
            SqlParameter _pPriorityId = new SqlParameter("@priority", SqlDbType.Int);
            if (PriorityId != 0) _pPriorityId.Value = PriorityId;
            else _pPriorityId.Value = DBNull.Value;
            SqlParameter _pRequestComplDate = new SqlParameter("@dtReqComp", SqlDbType.SmallDateTime);
            if (RequestComplDate!=DateTime.MinValue) _pRequestComplDate.Value = RequestComplDate;
            else _pRequestComplDate.Value = DBNull.Value;
            SqlParameter _pRequestComplNote = new SqlParameter("@vchReqComp", SqlDbType.NVarChar, 50);
            if (!string.IsNullOrEmpty(RequestComplNote)) _pRequestComplNote.Value = RequestComplNote;
            else _pRequestComplNote.Value = DBNull.Value;
            SqlParameter _pIDMethod = new SqlParameter("@vchIdMethod", SqlDbType.NVarChar, 255);
            if (!string.IsNullOrEmpty(IDMethod)) _pIDMethod.Value = IDMethod.Length > 255 ? IDMethod.Substring(0, 255) : IDMethod;
            else _pIDMethod.Value = DBNull.Value;
            SqlParameter _pCustomFields = new SqlParameter("@CustomXML", SqlDbType.NText);
            if (!string.IsNullOrEmpty(CustomFields)) _pCustomFields.Value = CustomFields;
            else _pCustomFields.Value = DBNull.Value;
            SqlParameter _pSubject = new SqlParameter("@subject", SqlDbType.NVarChar, 100);
            if (Subject.Length > 0) _pSubject.Value = Subject;
            else _pSubject.Value = DBNull.Value;
            SqlParameter _pText = new SqlParameter("@vchInitPost", SqlDbType.NVarChar, -1);
            if (!string.IsNullOrEmpty(Text))
            {
                if (Text.Length > 4899) Text = "--Text truncated at 5000 characters--<br><br>" + Text.Substring(0, 4800) + "<br><br>--Text truncated at 5000 characters--";
                _pText.Value = Text;
            }
            else _pText.Value = "(Initial post was blank.)";

            //Depreciated Parameter
            SqlParameter _pSerialNumber=new SqlParameter("@serialnumber", SqlDbType.NVarChar, 50);
            if (!string.IsNullOrEmpty(SerialNumber)) _pSerialNumber.Value = SerialNumber;
            else _pSerialNumber.Value=DBNull.Value;
            //----
            SqlParameter _pViaEmailParser=new SqlParameter("@btViaEmailParser", SqlDbType.Bit);
            _pViaEmailParser.Value=DBNull.Value;

            SqlParameter _pTktId = new SqlParameter("@TId", SqlDbType.Int);
            _pTktId.Direction = ParameterDirection.Output;
            SqlParameter _pTktNumber = new SqlParameter("@intTktNumber", SqlDbType.Int);
            _pTktNumber.Direction = ParameterDirection.Output;

            SqlParameter pInitialPostId = new SqlParameter("@InitialPostId", SqlDbType.Int);
            pInitialPostId.Direction = ParameterDirection.Output;

            SqlParameter _pProjectId = new SqlParameter("@ProjectID", SqlDbType.Int);
            if (ProjectId != 0) _pProjectId.Value = ProjectId;
            else _pProjectId.Value = DBNull.Value;

            SqlParameter _pFolderID = new SqlParameter("@FolderID", SqlDbType.Int);
            if (folderID != 0) _pFolderID.Value = folderID;
            else _pFolderID.Value = DBNull.Value;

            SqlParameter _pSchedTicketID = new SqlParameter("@SchedTicketID", SqlDbType.Int);
            if (schedTicketID != 0) _pSchedTicketID.Value = schedTicketID;
            else _pSchedTicketID.Value = DBNull.Value;

            SqlParameter _pEstTime = new SqlParameter("@EstimatedTime", SqlDbType.Decimal);
            if (EstimatedTime >= 0) _pEstTime.Value = EstimatedTime;
            else _pEstTime.Value = DBNull.Value;

            UpdateData("sp_InsertNewTicket", new SqlParameter[]{_pRVAL,
                new SqlParameter("@DId", DeptID),
                new SqlParameter("@PseudoId", Micajah.Common.Bll.Support.GeneratePseudoUnique()),
                _pPriorityId,
                new SqlParameter("@user_id", TktUserId),
                new SqlParameter("@status", Status),
                _pSubject,
                _pText,
                new SqlParameter("@newuserpost", _newUserPost),
                new SqlParameter("@newtechpost", _newTechPost),
                new SqlParameter("@createdId", UserId),
                _pTechnicianId,
                _pLocationId,
                _pClassId,
                _pSerialNumber,
                _pCustomFields,
                _pTktId,
                _pRequestComplDate,
                _pRequestComplNote,
                _pViaEmailParser,
                new SqlParameter("@btPreventive", Preventive),
                _pTktNumber,
                _pCreationCategoryId,
                _pAccountId,
                _pAccountLocationId,
                new SqlParameter("@btLookUpAcct", LookUpAccount),
                _pCreationDate,
                _pIDMethod,
                new SqlParameter("@btHandledByCallCentre", HandledByCallCenter),
                _pSubmissionCategoryName,
                _pLevelId,
                pInitialPostId,
                _pProjectId,
                _pFolderID,
                _pSchedTicketID,
                _pEstTime,
                _pbtNoAccount}, OrgID);

            initialPostId = pInitialPostId.Value != DBNull.Value ? (int) pInitialPostId.Value : 0;
            int _TktId = (int)_pRVAL.Value;
            if (_TktId < 0) return _TktId;
            if (assets != null)
                foreach (Assets.AssetItem _asset in assets) InsertAsset(OrgID, DeptID, _TktId, _asset.ID, _asset.SerialTagNumber, _asset.Description);
            if (files != null)
            foreach (System.IO.FileInfo _file in files)
            {
                System.IO.FileStream _fstream = _file.OpenRead();
                byte[] _data = new byte[Convert.ToInt32(_fstream.Length)];
                _fstream.Read(_data, 0, _data.Length);
                InsertFile(OrgID, DeptID, _TktId, _file.Name, Convert.ToInt32(_file.Length), _data);
                _fstream.Close();
            }
            return _TktId;
        }
Esempio n. 2
0
 public static void UpdateAssets(int DeptID, int TicketId, Assets.AssetItem[] assets)
 {
     Assets.AssetItem[] _assArr = SelectAssetsToArray(DeptID, TicketId);
     bool _toDelete = true;
     foreach (Assets.AssetItem _ass1 in _assArr)
     {
         _toDelete = true;
         foreach (Assets.AssetItem _ass2 in assets)
         {
             if (_ass2.ID!=0 && _ass1.ID == _ass2.ID)
             {
                 _toDelete = false;
                 break;
             }
             else if (_ass2.ID == 0 && _ass1.SerialTagNumber == _ass2.SerialTagNumber)
             {
                 _toDelete = false;
                 break;
             }
         }
         if (!_toDelete) continue;
         DeleteAsset(DeptID, TicketId, _ass1.ID, _ass1.SerialTagNumber);
     }
     foreach (Assets.AssetItem _asset in assets) InsertAsset(DeptID, TicketId, _asset.ID, _asset.SerialTagNumber, _asset.Description);
 }
Esempio n. 3
0
        public static int CreateNew(Guid OrgID,
			int DeptID,
			int UserId,
			int TechnicianId,
			int TktUserId,
			DateTime CreationDate,
			int AccountId,
			int AccountLocationId,
			bool LookUpAccount,
			int LocationId,
			int ClassId,
			int LevelId,
			string SubmissionCategoryName,
			bool HandledByCallCenter,
			int CreationCategoryId,
			bool Preventive,
			int PriorityId,
			DateTime RequestComplDate,
			string RequestComplNote,
			string SerialNumber,
			Assets.AssetItem[] assets,
			string IDMethod,
			string CustomFields,
			string Subject,
			string Text,
			System.IO.FileInfo[] files,
			string Status,
			out int initialPostId)
        {
            return CreateNew(OrgID,
            DeptID,
            UserId,
            TechnicianId,
            TktUserId,
            CreationDate,
            AccountId,
            AccountLocationId,
            LookUpAccount,
            LocationId,
            ClassId,
            LevelId,
            SubmissionCategoryName,
            HandledByCallCenter,
            CreationCategoryId,
            Preventive,
             PriorityId,
            RequestComplDate,
            RequestComplNote,
             SerialNumber,
            assets,
            IDMethod,
            CustomFields,
            Subject,
            Text,
            files,
            Status,
            out initialPostId,
            0,
            0,
            0,
            -1);
        }
Esempio n. 4
0
 public static int Update(int DeptID,
     int SchedTktID,
     int UserId,
     int OwnerId,
     int TechId,
     int LocationId,
     int PriorityId,
     int ClassId,
     int CategoryId,
     int LevelId,
     string TktSubject,
     string TktText,
     DateTime DateNext,
     string ReccuringOn,
     string MethodEnd,
     int EndCount,
     DateTime DateStop,
     int ReccuringFeq,
     bool Enabled,
     string UserEmail,
     int AccountId,
     int AccountLocationId,
     string CustomFields,
     string IdMethod,
     int projectID,
     int folderID,
     bool repeatFromCompletion,
     Assets.AssetItem[] assets)
 {
     SqlParameter _pRVAL = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
     _pRVAL.Direction = ParameterDirection.ReturnValue;
     SqlParameter _pSchedTktId = new SqlParameter("@Id", SqlDbType.Int);
     if (SchedTktID != 0) _pSchedTktId.Value = SchedTktID;
     else _pSchedTktId.Value = DBNull.Value;
     SqlParameter _pUserId = new SqlParameter("@intUserId", SqlDbType.Int);
     if (UserId != 0) _pUserId.Value = UserId;
     else _pUserId.Value = DBNull.Value;
     SqlParameter _pTechId = new SqlParameter("@intTechId", SqlDbType.Int);
     if (TechId != 0) _pTechId.Value = TechId;
     else _pTechId.Value = DBNull.Value;
     SqlParameter _pLocationId = new SqlParameter("@LocationId", SqlDbType.Int);
     if (LocationId != 0) _pLocationId.Value = LocationId;
     else _pLocationId.Value = DBNull.Value;
     SqlParameter _pPriorityId = new SqlParameter("@intPriorityId", SqlDbType.Int);
     if (PriorityId != 0) _pPriorityId.Value = PriorityId;
     else _pPriorityId.Value = DBNull.Value;
     SqlParameter _pClassId = new SqlParameter("@intClassId", SqlDbType.Int);
     if (ClassId != 0) _pClassId.Value = ClassId;
     else _pClassId.Value = DBNull.Value;
     SqlParameter _pCategoryId = new SqlParameter("@intCategoryId", SqlDbType.Int);
     if (CategoryId != 0) _pCategoryId.Value = CategoryId;
     else _pCategoryId.Value = DBNull.Value;
     SqlParameter _pLevelId = new SqlParameter("@tintLevel", SqlDbType.Int);
     if (LevelId != 0) _pLevelId.Value = LevelId;
     else _pLevelId.Value = DBNull.Value;
     //Depreciated Parameter
     SqlParameter _pSerialNumber = new SqlParameter("@vchAssetSerial", SqlDbType.NVarChar, 50);
     _pSerialNumber.Value = DBNull.Value;
     //----
     SqlParameter _pSubject = new SqlParameter("@vchSubject", SqlDbType.NVarChar, 100);
     if (TktSubject.Length > 0) _pSubject.Value = TktSubject;
     else _pSubject.Value = DBNull.Value;
     SqlParameter _pText = new SqlParameter("@vchText", SqlDbType.NVarChar);
     if (TktText.Length > 0)
     {
         if (TktText.Length > 4999) TktText = "--Text truncated at 5000 characters--<br><br>" + TktText.Substring(0, 4905) + "<br><br>--Text truncated at 5000 characters--";
         _pText.Value = TktText;
     }
     else _pText.Value = "(Initial post was blank.)";
     SqlParameter _pDateNext = new SqlParameter("@dtNext", SqlDbType.SmallDateTime);
     if (DateNext != null && DateNext != DateTime.MinValue) _pDateNext.Value = DateNext;
     else _pDateNext.Value = DBNull.Value;
     SqlParameter _pMethodEnd = new SqlParameter("@vchEndMethod", SqlDbType.VarChar, 5);
     if (MethodEnd.Length > 0) _pMethodEnd.Value = MethodEnd;
     else _pMethodEnd.Value = DBNull.Value;
     SqlParameter _pDateStop = new SqlParameter("@dtStop", SqlDbType.SmallDateTime);
     if (DateStop != null && DateStop != DateTime.MinValue) _pDateStop.Value = DateStop;
     else _pDateStop.Value = DBNull.Value;
     SqlParameter _pUserEmail = new SqlParameter("@vchUserEmail", SqlDbType.NVarChar, 50);
     if (UserEmail.Length > 0) _pUserEmail.Value = UserEmail;
     else _pUserEmail.Value = DBNull.Value;
     SqlParameter _pAccountId = new SqlParameter("@intAcctId", SqlDbType.Int);
     if (AccountId > 0) _pAccountId.Value = AccountId;
     else _pAccountId.Value = DBNull.Value;
     SqlParameter _pAccountLocationId = new SqlParameter("@AccountLocationId", SqlDbType.Int);
     if (AccountLocationId != 0) _pAccountLocationId.Value = AccountLocationId;
     else _pAccountLocationId.Value = DBNull.Value;
     SqlParameter _pCustomXML = new SqlParameter("@CustomXML", SqlDbType.NText);
     if (CustomFields.Length > 0) _pCustomXML.Value = CustomFields;
     else _pCustomXML.Value = DBNull.Value;
     SqlParameter _pIdMethod = new SqlParameter("@vchIdMethod", SqlDbType.NVarChar);
     if (IdMethod.Length > 0) _pIdMethod.Value = IdMethod.Length > 255 ? IdMethod.Substring(0, 255) : IdMethod;
     else _pIdMethod.Value = DBNull.Value;
     SqlParameter _pProjectID = new SqlParameter("@ProjectID", SqlDbType.Int);
     if (projectID > 0) _pProjectID.Value = projectID;
     else _pProjectID.Value = DBNull.Value;
     SqlParameter _pFolderID = new SqlParameter("@FolderID", SqlDbType.Int);
     if (folderID > 0) _pFolderID.Value = folderID;
     else _pFolderID.Value = DBNull.Value;
     UpdateData("sp_UpdateSchedTkt", new SqlParameter[]{_pRVAL,
         new SqlParameter("@DId", DeptID),
         _pSchedTktId,
         _pUserId,
         new SqlParameter("@intOwnerId", OwnerId),
         _pTechId,
         _pLocationId,
         _pPriorityId,
         _pClassId,
         _pCategoryId,
         _pLevelId,
         _pSerialNumber,
         _pSubject,
         _pText,
         _pDateNext,
         new SqlParameter("@vchRecurringOn", ReccuringOn),
         _pMethodEnd,
         new SqlParameter("@tintEndCount", EndCount),
         _pDateStop,
         new SqlParameter("@tintRecurringFeq", ReccuringFeq),
         new SqlParameter("@btEnabled", Enabled),
         _pUserEmail,
         _pAccountId,
         _pAccountLocationId,
         _pIdMethod,
         _pCustomXML,
         _pProjectID,
         _pFolderID,
         new SqlParameter("@RepeatFromCompletion", repeatFromCompletion)});
     int _SchedTktId = (int)_pRVAL.Value;
     if (_SchedTktId < 0) return _SchedTktId;
     if (SchedTktID != 0)
     {
         Assets.AssetItem[] _assArr = SelectTicketAssets(DeptID, SchedTktID);
         bool _toDelete = true;
         foreach (Assets.AssetItem _ass1 in _assArr)
         {
             _toDelete = true;
             foreach (Assets.AssetItem _ass2 in assets)
             {
                 if (_ass1.ID == _ass2.ID)
                 {
                     _toDelete = false;
                     break;
                 }
             }
             if (!_toDelete) continue;
             DeleteAsset(DeptID, SchedTktID, _ass1.ID);
         }
     }
     foreach (Assets.AssetItem _asset in assets) InsertAsset(DeptID, _SchedTktId, _asset.ID, _asset.Description);
     return _SchedTktId;
 }