예제 #1
0
 public static LabelModel ToModel(this LabelEntity entity) =>
 new LabelModel
 {
     Id          = entity.Id,
     Title       = entity.Title,
     Description = entity.Description
 };
예제 #2
0
        public static ResourceEntity ToResource(this IDictionary <string, string> labels)
        {
            var resource = new ResourceEntity {
                Id = 1
            };

            labels.ForEach((kvp, i) =>
            {
                var language = new LanguageEntity
                {
                    Id          = i,
                    LanguageTag = kvp.Key
                };
                var label = new LabelEntity
                {
                    ResourceId = resource.Id,
                    LanguageId = language.Id,
                    Language   = language,
                    Text       = kvp.Value
                };
                resource.Labels.Add(label);
            });

            return(resource);
        }
예제 #3
0
        private void AddLabelsToMail(String gmLabels, MailEntity mail)
        {
            if (this.AccountLabels == null) //Si no fueron updateados los labels del fetcher (con método setLabels())
            {
                return;                     //no se puede marcar los mails con los labels (se necesita el LabelEntity)
            }
            LabelEntity mailLabel = new LabelEntity();

            gmLabels = gmLabels.Replace("\\", String.Empty);
            gmLabels = gmLabels.Replace("\"", String.Empty);
            //Gmail no pone el label de la carpeta actual donde se encuentra el mail
            gmLabels += " " + this.CurrentOpenedMailbox.Name;

            String[] labelsNames = gmLabels.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (String labelName in labelsNames)
            {
                mailLabel = (from accountLabel in this.AccountLabels
                             where (accountLabel.Name == labelName || accountLabel.SystemName == labelName)
                             select accountLabel).SingleOrDefault <LabelEntity>();

                if (mailLabel != null)
                {
                    mail.Labels.Add(mailLabel);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Adds the label.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <returns></returns>
        public LabelDTO AddLabel(LabelDTO label)
        {
            LabelEntity labelEntity = _mapper.Map <LabelDTO, LabelEntity>(label);

            labelEntity.CreatedDate = DateTime.Now;
            _repo.Add(labelEntity);
            return(label);
        }
예제 #5
0
파일: Mail.cs 프로젝트: marcogatti/glimpse
        public bool HasLabel(Label aLabel)
        {
            LabelEntity entity = (from label
                                  in this.Entity.Labels
                                  where label.MailAccountEntity.Id == aLabel.Entity.MailAccountEntity.Id &&
                                  label.Name == aLabel.Entity.Name
                                  select label).SingleOrDefault <LabelEntity>();

            return(entity != null);
        }
        public void AddLabel_InValidData()
        {
            LabelEntity labelEntity = null;
            LabelDTO    labelDTO    = null;

            _mapper.Setup(p => p.Map <LabelDTO, LabelEntity>(labelDTO)).Returns(labelEntity);
            _repo.Setup(p => p.Add(labelEntity)).Returns(0);
            var returnObj = labelService.AddLabel(labelDTO);

            Assert.IsTrue(returnObj == null);
        }
예제 #7
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, LabelEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #8
0
 /// <summary>
 /// Prints the label
 /// </summary>
 /// <param name="label">The label entity to print</param>
 /// <param name="isPrintDialogRequired">Flag describing when the printer selection and configuration dialog is required</param>
 public void PrintLabel(LabelEntity label, Boolean isPrintDialogRequired)
 {
     using (var work = new PrintingWork(new LabelModel
     {
         UniqueIdentifier = label.UniqueID,
         Customer = label.Customer,
         Date = label.CreateDate
     }, label.ItemCount, 40, 40)) //TODO: replace with values from the configuration
     {
         work.Print(isPrintDialogRequired);
     }
 }
예제 #9
0
        public void UpdateFieNew()
        {
            using (Transaction tr = new Transaction())
            {
                LabelEntity label = new LabelEntity();

                int count = Database.Query <AlbumEntity>().UnsafeUpdate()
                            .Set(a => a.Label, a => label)
                            .Execute();
                //tr.Commit();
            }
        }
예제 #10
0
        public void UpdateFieConditional()
        {
            using (Transaction tr = new Transaction())
            {
                LabelEntity label = Database.Query <LabelEntity>().FirstEx();

                int count = Database.Query <AlbumEntity>().UnsafeUpdate()
                            .Set(a => a.Label, a => (int)a.Id % 2 == 0 ? label : null)
                            .Execute();
                //tr.Commit();
            }
        }
예제 #11
0
    public void UpdateFieSetReadonly()
    {
        using (var tr = new Transaction())
        {
            LabelEntity label = Database.Query <LabelEntity>().FirstEx();

            int count = Database.Query <AlbumEntity>().UnsafeUpdate()
                        .Set(a => a.Label, a => label)
                        .Execute();
            //tr.Commit();
        }
    }
예제 #12
0
        public void UpdateFieToLite()
        {
            using (Transaction tr = new Transaction())
            {
                LabelEntity label = Database.Query <LabelEntity>().FirstEx();

                int count = Database.Query <LabelEntity>().UnsafeUpdate()
                            .Set(a => a.Owner, a => label.ToLite())
                            .Execute();
                //tr.Commit();
            }
        }
예제 #13
0
        public void SaveManyMList()
        {
            using (var tr = new Transaction())
                using (OperationLogic.AllowSave <LabelEntity>())
                    using (OperationLogic.AllowSave <CountryEntity>())
                        using (OperationLogic.AllowSave <AlbumEntity>())
                            using (OperationLogic.AllowSave <ArtistEntity>())
                            {
                                var prev = Database.MListQuery((AlbumEntity a) => a.Songs).Count();

                                var authors =
                                    Database.Query <BandEntity>().Take(6).ToList().Concat <IAuthorEntity>(
                                        Database.Query <ArtistEntity>().Take(8).ToList()).ToList();

                                var label = new LabelEntity {
                                    Name = "Four Music", Country = new CountryEntity {
                                        Name = "Germany"
                                    }, Node = MusicLoader.NextLabelNode()
                                };

                                List <AlbumEntity> albums = 0.To(16).Select(i => new AlbumEntity()
                                {
                                    Name   = "System Greatest hits {0}".FormatWith(i),
                                    Author = i < authors.Count ? authors[i] : new ArtistEntity {
                                        Name = ".Net Framework"
                                    },
                                    Year  = 2001,
                                    Songs = { new SongEmbedded {
                                                  Name = "Compilation {0}".FormatWith(i)
                                              } },
                                    State = AlbumState.Saved,
                                    Label = label,
                                }).ToList();

                                albums.SaveList();

                                Assert.All(GraphExplorer.FromRoots(albums), a => Assert.False(a.IsGraphModified));

                                Assert.Equal(prev + 16, Database.MListQuery((AlbumEntity a) => a.Songs).Count());

                                albums.ForEach(a => a.Name += "Updated");

                                albums.SaveList();

                                albums.ForEach(a => a.Songs.ForEach(s => s.Name = "Updated"));

                                albums.SaveList();

                                //tr.Commit();
                            }
        }
        public void AddLabel_ValidData()
        {
            var labelDto = new LabelDTO {
                Id = 11, Description = "Label_11", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now
            };
            var labelEntity = new LabelEntity {
                Id = 11, Description = "Label_11", CreatedBy = 1, UpdatedBy = 1, CreatedDate = DateTime.Now, UpdatedDate = DateTime.Now
            };

            _mapper.Setup(p => p.Map <LabelDTO, LabelEntity>(labelDto)).Returns(labelEntity);
            _repo.Setup(p => p.Add(labelEntity)).Returns(1);
            var returnObj = labelService.AddLabel(labelDto);

            Assert.AreEqual(11, returnObj.Id);
        }
예제 #15
0
        public void UpdateFieNew()
        {
            var e = Assert.Throws <InvalidOperationException>(() => {
                using (Transaction tr = new Transaction())
                {
                    LabelEntity label = new LabelEntity();

                    int count = Database.Query <AlbumEntity>().UnsafeUpdate()
                                .Set(a => a.Label, a => label)
                                .Execute();
                    //tr.Commit();
                }
            });

            Assert.Contains("is new and has no Id", e.Message);
        }
예제 #16
0
        /// <summary>
        /// Reverts changes related to the new label creating
        /// </summary>
        /// <param name="context">The database context</param>
        /// <param name="entity">The label entity</param>
        /// <returns></returns>
        public Boolean RevertChanges(DbContext context, LabelEntity entity)
        {
            try
            {
                if (entity != null)
                {
                    context.Set <LabelEntity>().Remove(entity);
                    context.SaveChanges();

                    return(true);
                }
            }
            catch (Exception e)
            {
                _logger.FatalException(ErrorCodes.RevertingChanges, e);
            }

            return(false);
        }
예제 #17
0
        private void RegisterLabel(String labelName, ISession session, IList <LabelEntity> databaseLabels, String systemName = null)
        {
            if (labelName == null || databaseLabels.Any(x => x.Name == labelName))
            {
                return;
            }

            LabelEntity labelEntity = new LabelEntity();

            labelEntity.Name = labelName;
            labelEntity.MailAccountEntity = this.Entity;
            labelEntity.SystemName        = systemName;
            labelEntity.Color             = (systemName == null) ? Label.GetNextColor(this.Entity, session) : null;
            labelEntity.Active            = true;

            Label label = new Label(labelEntity);

            label.SaveOrUpdate(session);
        }
예제 #18
0
파일: Label.cs 프로젝트: marcogatti/glimpse
        public static void ColorLabel(LabelEntity labelToColor, MailAccount labelAccount, User currentUser, ISession session)
        {
            if (currentUser != null)
            {
                IList <MailAccount> currentMailAccounts = currentUser.GetAccounts();
                List <LabelEntity>  availableLabels     = new List <LabelEntity>();

                foreach (MailAccount mailAccount in currentMailAccounts)
                {
                    availableLabels.AddRange(Label.FindByAccount(mailAccount.Entity, session));
                }

                //si alguna de las cuentas ya tiene un label con el mismo nombre
                if (availableLabels.Any(x => x.SystemName == null && x.Name == labelToColor.Name))
                {
                    labelToColor.Color = availableLabels.Where(x => x.SystemName == null && x.Name == labelToColor.Name).ToList()[0].Color;
                    return;
                }
            }
            labelToColor.Color = Label.GetNextColor(labelAccount.Entity, session);
        }
예제 #19
0
        public ActionResult RecolorLabel(String labelName, String color)
        {
            ISession     session = NHibernateManager.OpenSession();
            ITransaction tran    = session.BeginTransaction();

            try
            {
                User sessionUser = (User)Session[AccountController.USER_NAME];
                if (sessionUser == null)
                {
                    throw new GlimpseException("No se encontró el usuario.");
                }

                foreach (MailAccount currentMailAccount in sessionUser.GetAccounts())
                {
                    IList <LabelEntity> labels = Label.FindByAccount(currentMailAccount.Entity, session);
                    if (labels.Any(x => x.Name == labelName))
                    {
                        LabelEntity labelToRecolor = labels.Single(x => x.Name == labelName);
                        labelToRecolor.Color = color;
                        session.SaveOrUpdate(labelToRecolor);
                    }
                }
                tran.Commit();

                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception exc)
            {
                tran.Rollback();
                Log.LogException(exc, "Parametros del metodo: labelName(" + labelName + "), color(" + color + ").");
                return(Json(new { success = false, message = "Error al cambiar color." }, JsonRequestBehavior.AllowGet));
            }
            finally
            {
                session.Close();
            }
        }
예제 #20
0
 public ActionResult SaveForm(string keyValue, LabelEntity entity)
 {
     zx_labelbll.SaveForm(keyValue, entity);
     return(Success("操作成功。"));
 }
예제 #21
0
        /// <summary>
        /// Updates a label
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">The label id.</param>
        /// <param name="body">The label configuration details.</param>
        /// <returns>Task of ApiResponse (LabelEntity)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <LabelEntity> > UpdateLabelAsyncWithHttpInfo(string id, LabelEntity body)
        {
            // verify the required parameter 'id' is set
            if (id == null)
            {
                throw new ApiException(400, "Missing required parameter 'id' when calling LabelsApi->UpdateLabel");
            }
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling LabelsApi->UpdateLabel");
            }

            var    localVarPath         = "/labels/{id}";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (id != null)
            {
                localVarPathParams.Add("id", this.Configuration.ApiClient.ParameterToString(id));             // path parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }


            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.PUT, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (this.ExceptionFactory != null)
            {
                Exception exception = this.ExceptionFactory("UpdateLabel", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <LabelEntity>(localVarStatusCode,
                                                 localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                                 (LabelEntity)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(LabelEntity))));
        }
예제 #22
0
        /// <summary>
        /// Updates a label
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">The label id.</param>
        /// <param name="body">The label configuration details.</param>
        /// <returns>Task of LabelEntity</returns>
        public async System.Threading.Tasks.Task <LabelEntity> UpdateLabelAsync(string id, LabelEntity body)
        {
            ApiResponse <LabelEntity> localVarResponse = await this.UpdateLabelAsyncWithHttpInfo(id, body);

            return(localVarResponse.Data);
        }
예제 #23
0
        /// <summary>
        /// Updates a label
        /// </summary>
        /// <exception cref="ApiException">Thrown when fails to make API call</exception>
        /// <param name="id">The label id.</param>
        /// <param name="body">The label configuration details.</param>
        /// <returns>LabelEntity</returns>
        public LabelEntity UpdateLabel(string id, LabelEntity body)
        {
            ApiResponse <LabelEntity> localVarResponse = this.UpdateLabelWithHttpInfo(id, body);

            return(localVarResponse.Data);
        }
예제 #24
0
파일: Label.cs 프로젝트: marcogatti/glimpse
 public Label(LabelEntity labelEntity)
 {
     this.Entity = labelEntity;
 }
예제 #25
0
    public static void Load()
    {
        var ama = new AmericanMusicAwardEntity {
            Category = "Indie Rock", Year = 1991, Result = AwardResult.Nominated
        }
        .Execute(AwardOperation.Save);

        BandEntity smashingPumpkins = new BandEntity
        {
            Name    = "Smashing Pumpkins",
            Members = "Billy Corgan, James Iha, D'arcy Wretzky, Jimmy Chamberlin"
                      .Split(',').Select(s => new ArtistEntity {
                Name = s.Trim(), Sex = s.Contains("Wretzky") ? Sex.Female : Sex.Male, Status = s.Contains("Wretzky") ? Status.Married : (Status?)null
            }).ToMList(),
            LastAward = ama,
        }.Execute(BandOperation.Save);

        CountryEntity usa = new CountryEntity {
            Name = "USA"
        };
        CountryEntity japan = new CountryEntity {
            Name = Japan
        };

        smashingPumpkins.Members.ForEach(m => m.Friends = smashingPumpkins.Members.Where(a => a.Sex != m.Sex).Select(a => a.ToLiteFat()).ToMList());

        smashingPumpkins.Execute(BandOperation.Save);

        new NoteWithDateEntity {
            CreationTime = DateTime.Now.AddHours(+8), CreationDate = DateTime.Now.AddHours(+8).ToDateOnly(), Text = "American alternative rock band", Target = smashingPumpkins
        }
        .Execute(NoteWithDateOperation.Save);

        LabelEntity virgin = new LabelEntity {
            Name = "Virgin", Country = usa, Node = SqlHierarchyId.GetRoot().FirstChild()
        }
        .Execute(LabelOperation.Save);

        new AlbumEntity
        {
            Name   = "Siamese Dream",
            Year   = 1993,
            Author = smashingPumpkins,
            Songs  = { new SongEmbedded {
                           Name = "Disarm"
                       } },
            Label = virgin
        }.Execute(AlbumOperation.Save);

        AlbumEntity mellon = new AlbumEntity
        {
            Name   = "Mellon Collie and the Infinite Sadness",
            Year   = 1995,
            Author = smashingPumpkins,
            Songs  =
            {
                new SongEmbedded {
                    Name = "Zero", Duration = TimeSpan.FromSeconds(123)
                },
                new SongEmbedded {
                    Name = "1976"
                },
                new SongEmbedded {
                    Name = "Tonight, Tonight", Duration = TimeSpan.FromSeconds(376)
                }
            },
            BonusTrack = new SongEmbedded {
                Name = "Jellybelly"
            },
            Label = virgin
        }.Execute(AlbumOperation.Save);

        new NoteWithDateEntity {
            CreationTime = DateTime.Now.AddDays(-100).AddHours(-8), CreationDate = DateTime.Now.AddDays(-100).AddHours(-8).ToDateOnly(), Text = "The blue one with the angel", Target = mellon
        }
        .Execute(NoteWithDateOperation.Save);

        LabelEntity wea = new LabelEntity {
            Name = "WEA International", Country = usa, Owner = virgin.ToLite(), Node = virgin.Node.FirstChild()
        }
        .Execute(LabelOperation.Save);

        new AlbumEntity
        {
            Name   = "Zeitgeist",
            Year   = 2007,
            Author = smashingPumpkins,
            Songs  = { new SongEmbedded {
                           Name = "Tarantula"
                       } },
            BonusTrack = new SongEmbedded {
                Name = "1976"
            },
            Label = wea,
        }.Execute(AlbumOperation.Save);

        new AlbumEntity
        {
            Name   = "American Gothic",
            Year   = 2008,
            Author = smashingPumpkins,
            Songs  = { new SongEmbedded {
                           Name = "The Rose March", Duration = TimeSpan.FromSeconds(276)
                       } },
            Label = wea,
        }.Execute(AlbumOperation.Save);

        var pa = new PersonalAwardEntity {
            Category = "Best Artist", Year = 1983, Result = AwardResult.Won
        }.Execute(AwardOperation.Save);

        ArtistEntity michael  = new ArtistEntity
        {
            Name      = "Michael Jackson",
            Dead      = true,
            LastAward = pa,
            Status    = Status.Single,
            Friends   = { smashingPumpkins.Members.SingleEx(a => a.Name.Contains("Billy Corgan")).ToLite() }
        }.Execute(ArtistOperation.Save);;

        new NoteWithDateEntity {
            CreationTime = new DateTime(2009, 6, 25, 0, 0, 0), CreationDate = new DateOnly(2009, 6, 25), Text = "Death on June, 25th", Target = michael
        }
        .Execute(NoteWithDateOperation.Save);

        new NoteWithDateEntity {
            CreationTime = new DateTime(2000, 1, 1, 0, 0, 0), CreationDate = new DateOnly(2000, 1, 1), Text = null !, Target = michael
        }