Ejemplo n.º 1
0
        public SelectProjectViewModel(
            ITogglDataSource dataSource,
            IRxActionFactory rxActionFactory,
            IInteractorFactory interactorFactory,
            INavigationService navigationService,
            IDialogService dialogService,
            ISchedulerProvider schedulerProvider,
            IStopwatchProvider stopwatchProvider)
        {
            Ensure.Argument.IsNotNull(dataSource, nameof(dataSource));
            Ensure.Argument.IsNotNull(dialogService, nameof(dialogService));
            Ensure.Argument.IsNotNull(rxActionFactory, nameof(rxActionFactory));
            Ensure.Argument.IsNotNull(interactorFactory, nameof(interactorFactory));
            Ensure.Argument.IsNotNull(navigationService, nameof(navigationService));
            Ensure.Argument.IsNotNull(schedulerProvider, nameof(schedulerProvider));
            Ensure.Argument.IsNotNull(stopwatchProvider, nameof(stopwatchProvider));

            this.dataSource        = dataSource;
            this.dialogService     = dialogService;
            this.interactorFactory = interactorFactory;
            this.navigationService = navigationService;
            this.schedulerProvider = schedulerProvider;
            this.stopwatchProvider = stopwatchProvider;

            Close = rxActionFactory.FromAsync(close);
            ToggleTaskSuggestions = rxActionFactory.FromAction <ProjectSuggestion>(toggleTaskSuggestions);
            SelectProject         = rxActionFactory.FromAsync <AutocompleteSuggestion>(selectProject);

            IsEmpty         = dataSource.Projects.GetAll().Select(projects => projects.None());
            PlaceholderText = IsEmpty.Select(isEmpty => isEmpty ? Resources.EnterProject : Resources.AddFilterProjects);
        }
Ejemplo n.º 2
0
        void Remove(ToastAdorner toast)
        {
            var index = _adorners.IndexOf(toast) - 1;

            if (!_adorners.Remove(toast))
            {
                return;
            }

            RemoveDelegate del = _adornerLayer.Remove;

            Application.Current?.Dispatcher?.Invoke(del, toast);

            if (!_adorners.Any())
            {
                IsEmpty?.Invoke(this, new EventArgs());
                return;
            }

            if (index < 0)
            {
                return;
            }

            MoveBackwards(index);
        }
Ejemplo n.º 3
0
        //Generic Function to take inputs, validate and return.
        private static T ReadAndValidateInput <T>(T OldValue,
                                                  String promptString, IsEmpty <T> isEmpty,
                                                  ValidationFunction <T> validationFunction, String invalidPrompt)
        {
            T    readValue;
            bool isReadDone;

            do
            {
                Console.Write(promptString);
                if (!isEmpty(OldValue))
                {
                    Console.Write($" ({OldValue}) ");
                }

                readValue  = (T)Convert.ChangeType(Console.ReadLine(), typeof(T));
                readValue  = isEmpty(readValue) ? OldValue : readValue;
                isReadDone = validationFunction(readValue);
                if (!isReadDone)
                {
                    Console.WriteLine("\n" + invalidPrompt + "\n");
                }
            } while (!isReadDone);
            return(readValue);
        }
Ejemplo n.º 4
0
            public void RateBy()
            {
                if (IsEmpty.Invoke())
                {
                    string userId = m_UserId;
                    try
                    {
                        foreach (T1 item in m_Items)
                        {
                            FacebookObjectCollection <T2> items = MethodOne(item);

                            if (items.Count != 0)
                            {
                                MethodTwo.Invoke(items, userId, m_ScoreValue);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (Exception == null)
                        {
                            Exception = e;
                        }
                    }
                }
            }
Ejemplo n.º 5
0
      public void Request (IList<string> collection, bool useSeparator, bool full)
      {
        if (collection.NotNull ()) {
          if (IsEmpty.IsFalse ()) {
            var separator = useSeparator ? " - " : string.Empty;

            collection.Clear ();

            if (HasContentTest) {
              var testList = TestCollection
                .OrderBy (p => p.GadgetName)
                .ToList ()
              ;

              foreach (var gadgetTest in testList) {
                collection.Add (separator + gadgetTest.GadgetName);

                if (gadgetTest.HasContentTarget) {
                  var namesCollection = new Collection<string> ();

                  if (full) {
                    gadgetTest.RequestContentNamesFull (namesCollection);
                  }

                  else {
                    gadgetTest.RequestContentNames (namesCollection);
                  }

                  foreach (var itemName in namesCollection) {
                    collection.Add (separator + itemName);
                  }
                }
              }
            }

            if (HasContentTarget) {
              var list = TargetCollection
                .OrderBy (p => p.GadgetName)
                .ToList ()
              ;

              foreach (var item in list) {
                if (full) {
                  var str = $"{separator}{item.GadgetName}     :{item.Reference}" +
                            $"{Environment.NewLine}" +
                            $"    resultado: [ {item.Value} ]" +
                            $"{Environment.NewLine}";

                  collection.Add (str);
                }

                else {
                  collection.Add (separator + item.GadgetName);
                }
              }
            }
          }
        }
      }
Ejemplo n.º 6
0
        /// <summary>
        /// Deserializes the specified configuration in an <see cref="IsEmpty"/> object
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        public override SqlTag Deserialize(IConfiguration configuration)
        {
            IsEmpty isEmpty = new IsEmpty(accessorFactory);

            isEmpty.Prepend  = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "prepend");
            isEmpty.Property = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "property");

            return(isEmpty);
        }
        public SqlTag Deserialize(XmlNode node)
        {
            IsEmpty             empty      = new IsEmpty(this._configScope.DataExchangeFactory.AccessorFactory);
            NameValueCollection attributes = NodeUtils.ParseAttributes(node, this._configScope.Properties);

            empty.Prepend  = NodeUtils.GetStringAttribute(attributes, "prepend");
            empty.Property = NodeUtils.GetStringAttribute(attributes, "property");
            return(empty);
        }
Ejemplo n.º 8
0
 public override bool Equals(object obj)
 {
     if (obj is Vector2D)
     {
         Vector2D other = (Vector2D)obj;
         return(X.Equals(other.X) && Y.Equals(other.Y) && IsEmpty.Equals(other.IsEmpty));
     }
     return(base.Equals(obj));
 }
Ejemplo n.º 9
0
        public bool IsEmpty_Expression_IsValid(PopulateListAction populateListAction)
        {
            //Create Validator
            var validator = new IsEmpty <Contact, IEnumerable>();
            RuleValidatorContext <Contact, IEnumerable> context = BuildContextForAliases(populateListAction);

            var notification = new ValidationNotification();

            //Validate the validator only, return true of no error returned
            return(validator.Validate(context, null, notification));
        }
Ejemplo n.º 10
0
 public void Get(double val)
 {
     if (val < CurrentVolume && CurrentVolume != 0)
     {
         CurrentVolume -= val;
     }
     else
     {
         CurrentVolume = 0;
         IsEmpty?.Invoke(this);
     }
 }
Ejemplo n.º 11
0
      public void Request (IList<Guid> collection)
      {
        if (collection.NotNull ()) {
          collection.Clear ();

          if (IsEmpty.IsFalse ()) {
            foreach (var id in IdCollection) {
              collection.Add (id);
            }
          }
        }
      }
Ejemplo n.º 12
0
        public override int GetHashCode()
        {
            var hashCode = -1563939470;

            hashCode = hashCode * -1521134295 + EqualityComparer <byte[]> .Default.GetHashCode(keyBytes);

            hashCode = hashCode * -1521134295 + off.GetHashCode();
            hashCode = hashCode * -1521134295 + IsTerminal.GetHashCode();
            hashCode = hashCode * -1521134295 + Length.GetHashCode();
            hashCode = hashCode * -1521134295 + IsEmpty.GetHashCode();
            return(hashCode);
        }
Ejemplo n.º 13
0
        public override int GetHashCode()
        {
            var hashCode = -596621668;

            hashCode = hashCode * -1521134295 + base.GetHashCode();
            hashCode = hashCode * -1521134295 + IsEmpty.GetHashCode();
            hashCode = hashCode * -1521134295 + BlockId.GetHashCode();
            hashCode = hashCode * -1521134295 + ItemCount.GetHashCode();
            hashCode = hashCode * -1521134295 + ItemDamage.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <NbtFile> .Default.GetHashCode(NBT);

            return(hashCode);
        }
Ejemplo n.º 14
0
        public override int GetHashCode()
        {
            var hashCode = -545639716;

            hashCode = hashCode * -1521134295 + X.GetHashCode();
            hashCode = hashCode * -1521134295 + Y.GetHashCode();
            hashCode = hashCode * -1521134295 + Width.GetHashCode();
            hashCode = hashCode * -1521134295 + Height.GetHashCode();
            hashCode = hashCode * -1521134295 + Location.GetHashCode();
            hashCode = hashCode * -1521134295 + Size.GetHashCode();
            hashCode = hashCode * -1521134295 + IsEmpty.GetHashCode();
            return(hashCode);
        }
Ejemplo n.º 15
0
        public string GetErrorsString()
        {
            string returnedError = new IsEmpty().IsValid(Error) ? "" : Error + "\n";

            foreach (string error in Errors)
            {
                if (new IsRequired().IsValid(error))
                {
                    returnedError += error + "\n";
                }
            }
            return(returnedError);
        }
Ejemplo n.º 16
0
 /// <summary>
 ///     Generates a hash code for this <see cref="LSLSourceCodeRange" /> using all of its properties.
 /// </summary>
 /// <returns>The generated hash code.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = IsEmpty.GetHashCode();
         hashCode = (hashCode * 397) ^ LineStart;
         hashCode = (hashCode * 397) ^ LineEnd;
         hashCode = (hashCode * 397) ^ ColumnStart;
         hashCode = (hashCode * 397) ^ ColumnEnd;
         hashCode = (hashCode * 397) ^ StartIndex;
         hashCode = (hashCode * 397) ^ StopIndex;
         return(hashCode);
     }
 }
Ejemplo n.º 17
0
 public void Update (Collection<GadgetTest> list)
 {
   if (list.NotNull ()) {
     if (IsEmpty.IsFalse ()) {
       if (HasContentTest) {
         foreach (var gadgetTest in list) {
           if (Contains (gadgetTest.Id)) {
             if (ContainsTest (gadgetTest.Id).IsFalse ()) {
               TestCollection.Add (gadgetTest);
             }
           }
         }
       }
     }
   }
 }
Ejemplo n.º 18
0
      internal void Request (IList<GadgetTest> collection)
      {
        if (collection.NotNull ()) {
          if (IsEmpty.IsFalse ()) {
            collection.Clear ();

            var list = TestCollection
              .OrderBy (p => p.GadgetName)
              .ToList ()
            ;

            foreach (var item in list) {
              collection.Add (item);
            }
          }
        }
      }
Ejemplo n.º 19
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (R != 0)
            {
                hash ^= R.GetHashCode();
            }
            if (G != 0)
            {
                hash ^= G.GetHashCode();
            }
            if (B != 0)
            {
                hash ^= B.GetHashCode();
            }
            if (A != 0)
            {
                hash ^= A.GetHashCode();
            }
            if (IsKnownColor != false)
            {
                hash ^= IsKnownColor.GetHashCode();
            }
            if (IsEmpty != false)
            {
                hash ^= IsEmpty.GetHashCode();
            }
            if (IsNamedColor != false)
            {
                hash ^= IsNamedColor.GetHashCode();
            }
            if (IsSystemColor != false)
            {
                hash ^= IsSystemColor.GetHashCode();
            }
            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 20
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (IsEmpty != false)
            {
                hash ^= IsEmpty.GetHashCode();
            }
            if (Sensors.Length != 0)
            {
                hash ^= Sensors.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 21
0
    public void AllowsAllEmptyCells_WithNoPlacedTiles()
    {
        var initial = new InitialHiveBuilder();

        initial += " ⬡ ⬡ ";
        initial += "⬡ ★ ⬡";
        initial += " ⬡ ⬡ ";

        var expected = new ExpectedMovementBuilder();

        expected += " ✔ ✔ ";
        expected += "✔ ★ ✔";
        expected += " ✔ ✔ ";

        var move = new IsEmpty();

        move.Should().HaveMoves(initial, expected);
    }
Ejemplo n.º 22
0
      internal void Request (IList<string> collection, bool useSeparator)
      {
        if (collection.NotNull ()) {
          if (IsEmpty.IsFalse ()) {
            var separator = useSeparator ? " - " : string.Empty;

            collection.Clear ();

            var list = TestCollection
              .OrderBy (p => p.GadgetName)
              .ToList ()
            ;

            foreach (var item in list) {
              collection.Add (separator + item.GadgetName);
            }
          }
        }
      }
Ejemplo n.º 23
0
 public void Clear()
 {
     lock (this)
     {
         IsEmpty.Set();
         DataReady.Reset();
         WriteReady.Set();
         readclosevent.Reset();
         writecloseevent.Reset();
         foreach (byte[] block in m_Blocks)
         {
             FreeBlock(block);
         }
         m_Blocks.Clear();
         m_RPos = 0;
         m_WPos = 0;
         m_Size = 0;
         EOS.Reset();
     }
 }
Ejemplo n.º 24
0
    public void AllowsAllEmptyCells_WithPlacedTiles()
    {
        var initial = new InitialHiveBuilder();

        initial += "⬡ ⬡ ⬢ ⬡ ⬡";
        initial += " ⬡ ⬢ ⬢ ⬢ ";
        initial += "⬡ ⬡ ★ ⬢ ⬢";
        initial += " ⬡ ⬢ ⬢ ⬡ ";
        initial += "⬢ ⬡ ⬢ ⬡ ⬡";

        var expected = new ExpectedMovementBuilder();

        expected += "✔ ✔ ⬢ ✔ ✔";
        expected += " ✔ ⬢ ⬢ ⬢ ";
        expected += "✔ ✔ ★ ⬢ ⬢";
        expected += " ✔ ⬢ ⬢ ✔ ";
        expected += "⬢ ✔ ⬢ ✔ ✔";

        var move = new IsEmpty();

        move.Should().HaveMoves(initial, expected);
    }
Ejemplo n.º 25
0
        private void btnDraft_Click(object sender, EventArgs e)
        {
            Mail _mail = new Mail();

            _mail.EmailID     = txtEmail.Text;
            _mail.Subject     = txtSubject.Text;
            _mail.Message     = richTextBox1.Text;
            _mail.FromEmailId = LoginCredentials.LoggedEmailId;
            _mail.FileName    = AttachmentName;
            string IsEmptyUSer = IsEmpty.CheckIfEmpty_Mail(_mail);

            if (IsEmptyUSer != null)
            {
                MessageBox.Show(IsEmptyUSer, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                int User_id = UserBusinessModel.GetUser(_mail.EmailID);
                if (User_id != 0)
                {
                    _mail.UserId = User_id;
                    MailServer _composeMail = new MailServer();
                    if (_composeMail.SaveMail(_mail))
                    {
                        MessageBox.Show("Mail saved to draft sucessfully", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    }

                    else
                    {
                        MessageBox.Show("Unable save this mail", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("EmailID is not registered with our domain", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            this.Close();
        }
Ejemplo n.º 26
0
        private ITag LoadTag(XmlNode xmlNode, Statement statement)
        {
            ITag tag          = null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var innerText = xmlNode.InnerText;
                var bodyText  = innerText;
                //bodyText += innerText.Trim().Replace("\r", " ").Replace("\n", " ");
                //bodyText += " ";
                return(new SqlText
                    {
                        Statement = statement,
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId = xmlNode.Attributes?["RefId"]?.Value;
                if (refId.IndexOf('.') < 0)
                {
                    refId = $"{statement.SmartSqlMap.Scope}.{refId}";
                }
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = xmlNode.Attributes?["Prepend"]?.Value
                };
                statement.IncludeDependencies.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Placeholder":
            {
                tag = new Placeholder
                {
                    Prepend   = xmlNode.Attributes?["Prepend"]?.Value,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property  = property,
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { return(null); }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            tag.Statement = statement;
            #endregion
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode, statement);
                if (childTag != null && tag != null)
                {
                    childTag.Parent = tag;
                    (tag as Tag).ChildTags.Add(childTag);
                }
            }
            return(tag);
        }
        bool EnviarPreAdvice()
        {
            TransDepotProxy  proxy   = new TransDepotProxy();
            RequestPreAdvice request = new RequestPreAdvice();

            request.YardCode   = ConfigurationManager.AppSettings["DepSanAgustin"].ToString();
            request.ActionType = "P";
            request.OperationTypeMovementCode = "";
            request.VoyageStopExternalCode    = txtOrdenServicio.Text.Trim();
            request.VesselIMO    = "";
            request.VoyageNumber = "";
            request.OceanCarrier = OceanCarrier;

            if (OperationType != null)
            {
                if (OperationType.Equals("E"))
                {
                    request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBK"].ToString();
                }
                else
                {
                    request.ReferenceType = ConfigurationManager.AppSettings["ReferenceTypeBL"].ToString();
                }
            }

            request.OperationType   = OperationType;
            request.ReferenceNumber = ReferenceNumber;
            request.PlaceOfReceipt  = PlaceOfReceipt;
            request.PortOfLoading   = PortOfLoading;
            request.PortOfDischarge = PortOfDischarge;
            request.PlaceOfDelivery = PlaceOfDelivery;
            request.CustomerERPCode = CustomerERPCode;
            request.ShipmentType    = "";

            request.Equipments.Add(new PreAdviceEquipment()
            {
                EquipmentNumber          = EquipmentNumber,
                EquipmentTypeSizeISOCode = EquipmentTypeSizeISOCode,
                IsEmpty               = (IsEmpty.Equals("S")) ? true : false,
                IsHazardous           = (IsHazardous.Equals("S")) ? true : false,
                RequiresReview        = false,
                SetPoint              = (SetPoint.Trim() != "") ? Convert.ToDouble(SetPoint) : 0.0,
                SetPointUnitOfMeasure = SetPointUnitOfMeasure,
                Ventilation           = 0.0,
                RelativeHumidityLevel = 0.0,
                O2Level               = 0.0,
                CO2Level              = 0.0,
                RequiresPlug          = (RequiresPlug.Equals("S")) ? true : false,
                Technology            = ""
            });

            ResponsePreAdvice resp = new ResponsePreAdvice();

            resp = proxy.PreAdvice(request);

            if (!resp.isValid)
            {
                List <string> listaDestinatarios = new List <string>();
                List <string> listaCopia         = new List <string>();
                List <string> listaCopiaOculta   = new List <string>();

                string destinatarios = ConfigurationManager.AppSettings["Destinatarios"].ToString();
                if (destinatarios != "" && destinatarios.Contains(";"))
                {
                    var correosDestino = destinatarios.Split(';');
                    foreach (string item in correosDestino)
                    {
                        listaDestinatarios.Add(item);
                    }
                }
                else
                {
                    listaDestinatarios.Add(destinatarios);
                }

                string copia = ConfigurationManager.AppSettings["ConCopia"].ToString();
                if (copia != "" && copia.Contains(";"))
                {
                    var correosCopia = copia.Split(';');
                    foreach (string item in correosCopia)
                    {
                        listaCopia.Add(item);
                    }
                }
                else
                {
                    listaCopia.Add(copia);
                }

                string copiaOculta = ConfigurationManager.AppSettings["CopiaOculta"].ToString();
                if (copiaOculta != "" && copiaOculta.Contains(";"))
                {
                    var correosCopiaOculta = copiaOculta.Split(';');
                    foreach (string item in correosCopiaOculta)
                    {
                        listaCopiaOculta.Add(item);
                    }
                }
                else
                {
                    listaCopiaOculta.Add(copiaOculta);
                }

                new ManejadorCorreos().EnviarCorreo(ConfigurationManager.AppSettings["AsuntoCorreoError"].ToString(), resp.messages[0].message, listaDestinatarios, listaCopia, listaCopiaOculta);
            }

            return(true);
        }
Ejemplo n.º 28
0
        public static ITag LoadTag(XmlNode xmlNode, IList <Include> includes)
        {
            ITag tag          = null;
            bool isIn         = xmlNode.Attributes?["In"] != null;
            var  prepend      = xmlNode.Attributes?["Prepend"]?.Value.Trim();
            var  property     = xmlNode.Attributes?["Property"]?.Value.Trim();
            var  compareValue = xmlNode.Attributes?["CompareValue"]?.Value.Trim();

            #region Init Tag
            switch (xmlNode.Name)
            {
            case "#text":
            case "#cdata-section":
            {
                var bodyText = " " + xmlNode.InnerText.Replace("\n", "").Trim();
                return(new SqlText
                    {
                        BodyText = bodyText
                    });
            }

            case "Include":
            {
                var refId       = xmlNode.Attributes?["RefId"]?.Value;
                var include_tag = new Include
                {
                    RefId   = refId,
                    Prepend = prepend
                };
                includes.Add(include_tag);
                tag = include_tag;
                break;
            }

            case "IsEmpty":
            {
                tag = new IsEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsEqual":
            {
                tag = new IsEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterEqual":
            {
                tag = new IsGreaterEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsGreaterThan":
            {
                tag = new IsGreaterThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessEqual":
            {
                tag = new IsLessEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsLessThan":
            {
                tag = new IsLessThan
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotEmpty":
            {
                tag = new IsNotEmpty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNotEqual":
            {
                tag = new IsNotEqual
                {
                    In           = isIn,
                    Prepend      = prepend,
                    Property     = property,
                    CompareValue = compareValue,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "IsNotNull":
            {
                tag = new IsNotNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsNull":
            {
                tag = new IsNull
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsTrue":
            {
                tag = new IsTrue
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsFalse":
            {
                tag = new IsFalse
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "IsProperty":
            {
                tag = new IsProperty
                {
                    In        = isIn,
                    Prepend   = prepend,
                    Property  = property,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Switch":
            {
                tag = new Switch
                {
                    Property = property,
                    //Prepend = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Case":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Case
                {
                    CompareValue = compareValue,
                    Property     = switchProperty,
                    Prepend      = switchPrepend,
                    ChildTags    = new List <ITag>()
                };
                break;
            }

            case "Default":
            {
                var switchNode     = xmlNode.ParentNode;
                var switchProperty = switchNode.Attributes?["Property"]?.Value.Trim();
                var switchPrepend  = switchNode.Attributes?["Prepend"]?.Value.Trim();
                tag = new Switch.Defalut
                {
                    Property  = switchProperty,
                    Prepend   = switchPrepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Dynamic":
            {
                tag = new Dynamic
                {
                    Prepend   = prepend,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Where":
            {
                tag = new Where
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Set":
            {
                tag = new Set
                {
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "For":
            {
                var open      = xmlNode.Attributes?["Open"]?.Value.Trim();
                var separator = xmlNode.Attributes?["Separator"]?.Value.Trim();
                var close     = xmlNode.Attributes?["Close"]?.Value.Trim();
                var key       = xmlNode.Attributes?["Key"]?.Value.Trim();
                tag = new For
                {
                    Prepend   = prepend,
                    Property  = property,
                    Open      = open,
                    Close     = close,
                    Separator = separator,
                    Key       = key,
                    ChildTags = new List <ITag>()
                };
                break;
            }

            case "Env":
            {
                var dbProvider = xmlNode.Attributes?["DbProvider"]?.Value.Trim();
                tag = new Env
                {
                    Prepend    = prepend,
                    DbProvider = dbProvider,
                    ChildTags  = new List <ITag>()
                };
                break;
            }

            case "#comment": { break; }

            default:
            {
                throw new SmartSqlException($"Statement.LoadTag unkonw tagName:{xmlNode.Name}.");
            };
            }
            #endregion
            foreach (XmlNode childNode in xmlNode)
            {
                ITag childTag = LoadTag(childNode, includes);
                if (childTag != null && tag != null)
                {
                    (tag as Tag).ChildTags.Add(childTag);
                }
            }
            return(tag);
        }
Ejemplo n.º 29
0
        public Expression Process(ParameterExpression ctxExpression, Type parameterType)
        {
            var leftExpression = ctxExpression.EvaluateExpression(Left, false);

            leftExpression = leftExpression.AddToStringWithEnumType();
            if (Operator != Operator.IsNull && Operator != Operator.NotIsNull)
            {
                leftExpression = leftExpression.AddValueWithNullableNumberType();
            }
            var        leftSideType = leftExpression.Type;
            Expression rightExpression;

            if (RightSideIsExpression)
            {
                rightExpression = ctxExpression.EvaluateExpression(Right);
                rightExpression = rightExpression.AddToStringWithEnumType().AddValueWithNullableNumberType();
            }
            else
            {
                rightExpression = GetRightConstantExpression(leftSideType);
            }

            Expression generatedExpression;

            switch (Operator)
            {
            case Operator.Equals:
                generatedExpression = Expression.Equal(leftExpression, rightExpression);
                break;

            case Operator.NotEquals:
                generatedExpression = Expression.Not(Expression.Equal(leftExpression, rightExpression));
                break;

            case Operator.GreaterThan:
                generatedExpression = leftExpression.Type == typeof(DateTime)
                        ? Expression.MakeBinary(ExpressionType.GreaterThan, leftExpression, rightExpression)
                        : Expression.GreaterThan(leftExpression, rightExpression);
                break;

            case Operator.GreaterOrEqual:
                generatedExpression = leftExpression.Type == typeof(DateTime)
                        ? Expression.MakeBinary(ExpressionType.GreaterThanOrEqual, leftExpression, rightExpression)
                        : Expression.GreaterThanOrEqual(leftExpression, rightExpression);
                break;

            case Operator.LessThan:
                generatedExpression = leftExpression.Type == typeof(DateTime)
                        ? Expression.MakeBinary(ExpressionType.LessThan, leftExpression, rightExpression)
                        : Expression.LessThan(leftExpression, rightExpression);
                break;

            case Operator.LessOrEqual:
                generatedExpression = leftExpression.Type == typeof(DateTime)
                        ? Expression.MakeBinary(ExpressionType.LessThanOrEqual, leftExpression, rightExpression)
                        : Expression.LessThanOrEqual(leftExpression, rightExpression);
                break;

            case Operator.Contains:
                generatedExpression = new Contains(leftExpression, rightExpression).Create();
                break;

            case Operator.NotContains:
                generatedExpression = Expression.Not(new Contains(leftExpression, rightExpression).Create());
                break;

            case Operator.ContainsAll:
                generatedExpression = new ContainsAll(leftExpression, rightExpression).Create();
                break;

            case Operator.NotContainsAll:
                generatedExpression = Expression.Not(new ContainsAll(leftExpression, rightExpression).Create());
                break;

            case Operator.StartsWith:
                generatedExpression = new StartsWith(leftExpression, rightExpression).Create();
                break;

            case Operator.NotStartsWith:
                generatedExpression = Expression.Not(new StartsWith(leftExpression, rightExpression).Create());
                break;

            case Operator.In:
                generatedExpression = new In(leftExpression, rightExpression).Create();
                break;

            case Operator.NotIn:
                generatedExpression = Expression.Not(new In(leftExpression, rightExpression).Create());
                break;

            case Operator.AllIn:
                generatedExpression = new AllIn(leftExpression, rightExpression).Create();
                break;

            case Operator.NotAllIn:
                generatedExpression = Expression.Not(new AllIn(leftExpression, rightExpression).Create());
                break;

            case Operator.AnyIn:
                generatedExpression = new AnyIn(leftExpression, rightExpression).Create();
                break;

            case Operator.NotAnyIn:
                generatedExpression = Expression.Not(new AnyIn(leftExpression, rightExpression).Create());
                break;

            case Operator.IsNull:
                if (leftSideType.IsPrimitiveType() && Nullable.GetUnderlyingType(leftSideType) != null)
                {
                    rightExpression = Expression.Constant(null, leftSideType);
                }
                generatedExpression = Expression.Equal(leftExpression, rightExpression);
                break;

            case Operator.NotIsNull:
                if (leftSideType.IsPrimitiveType() && Nullable.GetUnderlyingType(leftSideType) != null)
                {
                    rightExpression = Expression.Constant(null, leftSideType);
                }
                generatedExpression = Expression.Not(Expression.Equal(leftExpression, rightExpression));
                break;

            case Operator.IsEmpty:
                generatedExpression = new IsEmpty(leftExpression, rightExpression).Create();
                break;

            case Operator.NotIsEmpty:
                generatedExpression = Expression.Not(new IsEmpty(leftExpression, rightExpression).Create());
                break;

            case Operator.DiffWithinPct:
                generatedExpression = new DiffWithinPct(leftExpression, rightExpression, OperatorArgs).Create();
                break;

            case Operator.AllInRangePct:
                generatedExpression = new AllInRange(leftExpression, rightExpression, OperatorArgs).Create();
                break;

            default:
                throw new NotSupportedException($"operation {Operator} is not supported");
            }

            if (Operator == Operator.IsNull || Operator == Operator.NotIsNull)
            {
                return(generatedExpression);
            }

            return(leftExpression.AddNotNullCheck(out var nullCheckExpression)
                ? Expression.AndAlso(nullCheckExpression, generatedExpression)
                : generatedExpression);
        }
Ejemplo n.º 30
0
 public override int GetHashCode()
 {
     return(IsEmpty.GetHashCode() ^ Message.GetHashCode());
 }