Esempio n. 1
0
 public PhotoInfo GetPhoto(string accessToken, int photoID)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             POPhoto poPhoto = getPOPhotoByID(photoID, db);
             if (poPhoto == null)
             {
                 return(null);
             }
             else
             {
                 return(ConversionUtils.ToPhotoInfo(poPhoto, db));
             }
         }
     }
     catch (Exception ex)
     {
         logException(ex);
         return(null);
     }
 }
Esempio n. 2
0
 public string GetPhotos(string accessToken, int orderID)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             POPhoto[] poPhotos = getPOPhotosByOrderID(orderID, db);
             if (poPhotos == null)
             {
                 return(null);
             }
             else
             {
                 PhotoInfo[] photos = ConversionUtils.ToPhotoInfoArray(poPhotos, db);
                 return(PhotoInfo.BuildPhotosXml(photos));
             }
         }
     }
     catch (Exception ex)
     {
         logException(ex);
         return(null);
     }
 }
Esempio n. 3
0
        public bool AddPhoto(string accessToken, int orderID, PhotoInfo photo, string fileExtension, string uploadedFileClaimToken)
        {
            logMethodInvocation();
            checkAccessToken(accessToken);
            try
            {
                using (CFIEntities db = new CFIEntities())
                {
                    Order order = getOrderByID(orderID, db);

                    // the file name will depend on the po number and how many other photos may have already been added
                    string fileName = getPhotoFileName(order.OrderID, fileExtension);
                    photo.FilePath = fileName;

                    // claim the uploaded file and name it and store it in the proper location
                    byte[] photoBytes = Globals.FileTransferManager.Uploader.ClaimFile(uploadedFileClaimToken);
                    savePhoto(order.OrderID, fileName, photoBytes);

                    POPhoto poPhoto = ConversionUtils.ToPOPhoto(photo, orderID);
                    order.POPhotos.Add(poPhoto);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                logException(ex);
                return(false);
            }
        }
Esempio n. 4
0
 public string GetNotes(string accessToken, int orderID)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             PONote[] poNotes = getPONotesByOrderID(orderID, db);
             if (poNotes == null)
             {
                 return(null);
             }
             else
             {
                 NoteInfo[] notes = ConversionUtils.ToNoteInfoArray(poNotes, db);
                 return(NoteInfo.BuildNotesXml(notes));
             }
         }
     }
     catch (Exception ex)
     {
         logException(ex);
         return(null);
     }
 }
Esempio n. 5
0
 public NoteInfo GetNote(string accessToken, int noteID)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             PONote poNote = getPONoteByID(noteID, db);
             if (poNote == null)
             {
                 return(null);
             }
             else
             {
                 return(ConversionUtils.ToNoteInfo(poNote, db));
             }
         }
     }
     catch (Exception ex)
     {
         logException(ex);
         return(null);
     }
 }
Esempio n. 6
0
 public OrderInfo GetOrderByID(string accessToken, int ID)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             Order order = getOrderByID(ID, db);
             if (order == null)
             {
                 return(null);
             }
             else
             {
                 return(ConversionUtils.ToOrderInfo(order, db));
             }
         }
     }
     catch (Exception ex)
     {
         logException(ex);
         return(null);
     }
 }
Esempio n. 7
0
        private static UserInfo[] getAllUsersInternal()
        {
            using (CFIEntities db = new CFIEntities())
            {
                var query =
                    from employee in db.Employees
                    where employee.Active == true
                    select employee;

                UserInfo[] users = ConversionUtils.ToUserInfoArray(query.ToList <Employee>());
                return(users);
            }
        }
Esempio n. 8
0
 public bool AddNote(string accessToken, int orderID, NoteInfo note)
 {
     logMethodInvocation();
     checkAccessToken(accessToken);
     try
     {
         using (CFIEntities db = new CFIEntities())
         {
             Order  order  = getOrderByID(orderID, db);
             PONote poNote = ConversionUtils.ToPONote(note, orderID);
             order.PONotes.Add(poNote);
             db.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         logException(ex);
         return(false);
     }
 }
Esempio n. 9
0
        public string GetAllNoteTypes(string accessToken)
        {
            logMethodInvocation();
            checkAccessToken(accessToken);
            try
            {
                using (CFIEntities db = new CFIEntities())
                {
                    var query =
                        from noteType in db.NoteTypes
                        select noteType;

                    NoteTypeInfo[] noteTypes = ConversionUtils.ToNoteTypeInfoArray(query.ToList <NoteType>());
                    return(NoteTypeInfo.BuildNoteTypesXml(noteTypes));
                }
            }
            catch (Exception ex)
            {
                logException(ex);
                return(null);
            }
        }
Esempio n. 10
0
        public static OrderInfo ToOrderInfo(Order entityOrder, CFIEntities db)
        {
            OrderInfo order = new OrderInfo();

            order.ID       = entityOrder.OrderID;
            order.Customer = ConversionUtils.ToCustomerInfo(entityOrder.Customer);
            order.Market   = entityOrder.Store.Market.MarketName;
            if (order.Market != null)
            {
                order.Market = order.Market.Trim();
            }
            order.PONumber    = entityOrder.PurchaseOrderNumber.Trim();
            order.StoreNumber = entityOrder.Store.StoreNumber.Trim();

            // division assignment requires another lookup
            order.Division = getDivision(entityOrder.MaterialTypeID, db);

            // Diagrams
            if (entityOrder.OrderDiagrams.Count > 0)
            {
                try
                {
                    string installOrderNumber = entityOrder.CustomerOrderNumber.Trim();
                    string calcDateTimeStamp  = entityOrder.OrderDiagrams.ElementAt <OrderDiagram>(0).DiagramDateTime.Value.ToString("MMddyyyyHHmm");
                    string diagramNumber      = entityOrder.OrderDiagrams.ElementAt <OrderDiagram>(0).DiagramNumber;
                    string fileName           = string.Format("{0}-{1}-{2}-{3}-{4}-1-0.pdf", order.StoreNumber, order.PONumber, installOrderNumber, diagramNumber, calcDateTimeStamp);
                    order.DiagramNumber = fileName;
                }
                catch (Exception ex)
                {
                    LogAPI.WebServiceLog.DebugFormat("failed to generate order diagram file name.  exception: {0}\r\n{1}", ex.Message, ex.StackTrace);
                    order.DiagramNumber = "";
                }
            }

            // if order is not scheduled then assign largest date value
            order.ScheduledDate = DateTime.MaxValue;
            if ((entityOrder.Scheduled == true) && (entityOrder.ScheduleStartDate != null))
            {
                order.ScheduledDate = entityOrder.ScheduleStartDate.Value;
            }

            // assign notes
            List <NoteInfo> notes = new List <NoteInfo>();

            foreach (PONote poNote in entityOrder.PONotes)
            {
                if (poNote.Deleted == false)
                {
                    NoteInfo note = ConversionUtils.ToNoteInfo(poNote, db);
                    notes.Add(note);
                }
            }
            order.Notes = notes.ToArray();

            // assign photos
            List <PhotoInfo> photos = new List <PhotoInfo>();

            foreach (POPhoto poPhoto in entityOrder.POPhotos)
            {
                if (poPhoto.Deleted == false)
                {
                    PhotoInfo photo = ConversionUtils.ToPhotoInfo(poPhoto, db);
                    photos.Add(photo);
                }
            }
            order.Photos = photos.ToArray();

            return(order);
        }