示例#1
0
        public static void updateDoc(infoGathDocJSON doc)
        {
            InfoGathering newInfoDoc = convertToDBAO(doc);

            using (var curDB = new HelpDesk_DB())
            {
                //Update old document to historic
                InfoGathering oldDoc      = InfoGathList[doc.index];
                var           originalDoc = curDB.InfoGatherings.Find(oldDoc.id);
                originalDoc.Status_id = 4; //historic

                //Transfer persisting information to new document
                newInfoDoc.Original_id = oldDoc.id;

                curDB.SaveChanges();
            }

            using (var curDB = new HelpDesk_DB())
            {
                curDB.InfoGatherings.Add(newInfoDoc);
                curDB.SaveChanges();

                //update info gath list for find and navigate references
                InfoGathList = curDB.InfoGatherings.Where(p => p.Status_id == 2).OrderBy(p => p.searchableAlias).ToList();
            }

            logUsage();
        }
示例#2
0
        /// <summary>
        /// Converts infoGathDocJSON to a DBAO InfoGathering object that is ready to be added to the DB. Does not touch ID, Original_ID
        /// </summary>
        /// <param name="JSON"></param>
        /// <returns></returns>
        public static InfoGathering convertToDBAO(infoGathDocJSON JSON)
        {
            InfoGathering infoGathDoc = new InfoGathering();

            infoGathDoc.searchableAlias = JSON.searchableAlias;
            //Document Links
            if (JSON.infoGathLink != "")
            {
                infoGathDoc.infoGathLink_id = addDocumentLink(JSON.infoGathLink);
            }
            if (JSON.passwordHyperlink != "")
            {
                infoGathDoc.PasswordHyperlink_id = addDocumentLink(JSON.passwordHyperlink);
            }

            infoGathDoc.infoGathTitle      = JSON.infoGathTitle;
            infoGathDoc.assignmentGroup    = JSON.assignmentGroup;
            infoGathDoc.supportInfo        = JSON.supportInfo;
            infoGathDoc.supportHours       = JSON.supportHours;
            infoGathDoc.contactInfo        = JSON.contactInfo;
            infoGathDoc.passwordAttributes = JSON.passwordAttributes;
            infoGathDoc.passwordTitle      = JSON.passwordTitle;
            infoGathDoc.aliases            = JSON.aliases;
            infoGathDoc.Status_id          = 2;

            return(infoGathDoc);
        }
示例#3
0
        public static string convertSerializedJSON(InfoGathering doc)
        {
            infoGathDocJSON docJSON = new infoGathDocJSON();

            docJSON.id              = doc.id;
            docJSON.index           = InfoGathList.IndexOf(doc);
            docJSON.searchableAlias = doc.searchableAlias;

            //Checks for 0 inputed into the databse because this isn't allowed to be null
            if (doc.infoGathLink_id != 0)
            {
                using (var curDB = new HelpDesk_DB())
                {
                    DocumentLink pdfDoc = curDB.DocumentLinks.SingleOrDefault(p => p.Id == doc.infoGathLink_id);
                    if (pdfDoc != null)
                    {
                        docJSON.infoGathLink = pdfDoc.link;
                    }
                    else
                    {
                        docJSON.infoGathLink = "";
                    }
                }
            }

            docJSON.infoGathTitle   = doc.infoGathTitle;
            docJSON.assignmentGroup = doc.assignmentGroup;
            docJSON.supportInfo     = doc.supportInfo;
            docJSON.supportHours    = doc.supportHours;
            docJSON.contactInfo     = doc.contactInfo;
            doc.passwordAttributes  = doc.passwordAttributes;
            doc.passwordTitle       = doc.passwordTitle;

            if (doc.PasswordHyperlink_id != null)
            {
                using (var curDB = new HelpDesk_DB())
                {
                    DocumentLink pwDoc = curDB.DocumentLinks.SingleOrDefault(p => p.Id == doc.PasswordHyperlink_id);
                    if (pwDoc != null)
                    {
                        docJSON.passwordHyperlink = pwDoc.link;
                    }
                    else
                    {
                        docJSON.passwordHyperlink = "";
                    }
                }
            }

            docJSON.aliases = doc.aliases;

            var json = new JavaScriptSerializer().Serialize(docJSON);

            return(json);
        }
示例#4
0
        public static void submit(infoGathDocJSON doc)
        {
            InfoGathering infoGathDoc = convertToDBAO(doc);

            addNewInfoGathering(infoGathDoc);
        }