示例#1
0
        public DataProvider()
        {
            client = new WebMechServiceClient();

            surfaceList = new ObservableCollection<SurfaceData>();
            sampleList = new ObservableCollection<SampleData>();
            parameterNameList = new ObservableCollection<ParameterData>();

            surfaceFilter = GetFilter();
            sampleFilter = GetFilter();
            sampleFilter.Count = 1000;

            surfacePageInfo = GetPageInfo();
            samplePageInfo = GetPageInfo();

            visualization = new Visualization();

            newSurface = new NewSurface();

            uploadData = new UploadData { Surfaces = surfaceList };

            ResetSurfaceList();
            ResetSampleList();

            RegisterCallbacks();
        }
示例#2
0
        //public bool UpdateData(int id, ref object dtoItem, out Library.DTO.Notification notification)
        //{
        //    BackCushionDTO dtoPBackCushion = ((Newtonsoft.Json.Linq.JObject)dtoItem).ToObject<BackCushionDTO>();
        //    notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success };
        //    try
        //    {
        //        using (BackCushionMngEntities context = CreateContext())
        //        {
        //            BackCushion dbItem = null;
        //            if (id == 0)
        //            {
        //                dbItem = new BackCushion();
        //                context.BackCushion.Add(dbItem);
        //            }
        //            else
        //            {
        //                var item = context.BackCushionMng_BackCushionCheck_View.Where(o => o.BackCushionID == id).FirstOrDefault();
        //                //CheckPermission
        //                if (item.isUsed.Value == true)
        //                {
        //                    throw new Exception("You can't update because it used in item other!");
        //                }
        //                dbItem = context.BackCushion.FirstOrDefault(o => o.BackCushionID == id);
        //            }

        //            if (dbItem == null)
        //            {
        //                notification.Message = "Back cushion not found!";
        //                return false;
        //            }
        //            else
        //            {
        //                // check concurrency
        //                if (dbItem.ConcurrencyFlag != null && !dbItem.ConcurrencyFlag.SequenceEqual(Convert.FromBase64String(dtoPBackCushion.ConcurrencyFlag_String)))
        //                {
        //                    throw new Exception(DALBase.Helper.TEXT_CONCURRENCY_CONFLICT);
        //                }
        //                converter.DTO2BD(dtoPBackCushion, ref dbItem);
        //                // processing image
        //                if (dtoPBackCushion.ImageFile_HasChange)
        //                {
        //                    dbItem.ImageFile = fwFactory.CreateFilePointer(this._TempFolder, dtoPBackCushion.ImageFile_NewFile, dtoPBackCushion.ImageFile);
        //                }

        //                if (id <= 0)
        //                {
        //                    // generate code
        //                    using (DbContextTransaction scope = context.Database.BeginTransaction())
        //                    {
        //                        context.Database.ExecuteSqlCommand("SELECT * FROM BackCushion WITH (TABLOCKX, HOLDLOCK)");
        //                        try
        //                        {
        //                            var newCode = context.BackCushionMng_function_GenerateCode().FirstOrDefault();
        //                            if (newCode != "*")
        //                            {
        //                                dbItem.BackCushionUD = newCode;
        //                            }
        //                            else
        //                            {
        //                                throw new Exception("Auto generated code exceed maximum option: [Z]");
        //                            }
        //                            context.SaveChanges();
        //                        }
        //                        catch (Exception ex)
        //                        {
        //                            throw ex;
        //                        }
        //                        finally
        //                        {
        //                            scope.Commit();
        //                        }
        //                    }
        //                }
        //                else
        //                {
        //                    context.SaveChanges();
        //                }

        //                // Handle notification missing information.
        //                string emailSubject = (id == 0) ? "TASK REQUEST [CREATE BACK CUSHION]" : "TASK REQUEST [UPDATE BACK CUSHION]";
        //                string emailBody = string.Empty;

        //                if (!IsNullPropertiesBackCushion(dbItem, ref emailBody))
        //                {
        //                    SendToEmailNotification(context, emailSubject, emailBody);
        //                }

        //                dtoItem = GetData(dbItem.BackCushionID, out notification).Data;

        //                return true;
        //            }
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        notification.Type = Library.DTO.NotificationType.Error;
        //        notification.Message = ex.Message;

        //        return false;
        //    }
        //}


        public SearchFilterData GetFilterData(out Library.DTO.Notification notification)
        {
            notification = new Library.DTO.Notification()
            {
                Type = Library.DTO.NotificationType.Success
            };
            SearchFilterData data = new SearchFilterData();

            data.Seasons       = new List <Support.DTO.Season>();
            data.YesNoValues   = new List <Support.DTO.YesNo>();
            data.ProductGroups = new List <Support.DTO.ProductGroup>();

            //try to get data
            try
            {
                data.Seasons       = supportFactory.GetSeason();
                data.YesNoValues   = supportFactory.GetYesNo();
                data.ProductGroups = supportFactory.GetProductGroup();
            }
            catch (Exception ex)
            {
                notification.Type    = Library.DTO.NotificationType.Error;
                notification.Message = ex.Message;
            }

            return(data);
        }
示例#3
0
 /// <summary>
 /// Sets dafault values of filter object.
 /// </summary>
 /// <param name="filter">WebMech.Web.SearchFilterData which specifies
 /// filter for selection of surfaces.</param>
 private void ResetFilter(SearchFilterData filter)
 {
     filter.Start = 1;
     filter.Count = 10;
     filter.SearchType = SearchType.All;
     filter.LastMonths = 3;
     filter.From = DateTime.Now.Date.AddMonths(-1);
     filter.To = DateTime.Now.Date;
     filter.SortType = SortType.Date;
     filter.SortDirection = SortDirection.Descending;
 }
示例#4
0
 /// <summary>
 /// Gets new instance of filter object.
 /// </summary>
 /// <returns>WebMech.Web.SearchFilterData which specifies
 /// filter for selection of surfaces.</returns>
 private SearchFilterData GetFilter()
 {
     SearchFilterData filter = new SearchFilterData();
     ResetFilter(filter);
     return filter;
 }