Example #1
0
        /// <summary>
        /// 邮件处理逻辑
        /// </summary>
        /// <param name="ope"></param>
        /// <param name="manual"></param>
        private void OperationHandler(OperationAction ope, ManualOperation manual)
        {
            if (this.textBoxID.Text.Trim() == string.Empty)
            {
                return;
            }

            this.timerNext.Stop();

            needUpdate = true;

            //发送处理结果给PLC
            wrapper.ClientSend(this.textBoxID.Text, ope);

            //实时将处理数据更新到数据库中
            ExecNonQuery(ope, manual);

            //图像清除
            this.pictureBoxPic.Image = null;
            //旋转按钮隐藏
            this.buttonRotateLeft.Visible  = false;
            this.buttonRotateRight.Visible = false;

            //UI 邮件信息清空
            this.textBoxID.Text     = string.Empty;
            this.textBoxVolume.Text = string.Empty;
            this.textBoxWeight.Text = string.Empty;
            this.textBoxBar.Text    = string.Empty;
        }
Example #2
0
 public NavigationPropertyInfo(PropertyInfo propertyInfo, OperationAction referencedEntityDeleteBehavior,
                               bool referencedEntityIsDependent)
 {
     PropertyInfo = propertyInfo;
     ReferencedEntityDeleteBehavior = referencedEntityDeleteBehavior;
     ReferencedEntityIsDependent    = referencedEntityIsDependent;
 }
Example #3
0
        // GET: OperationActions/Create
        public IActionResult Create(string id)
        {
            var operationAction = new OperationAction();

            operationAction.OperationId = id;
            return(View(operationAction));
        }
 public OperationActionRelationWindow(OperationActionInfoModel entity, OperationAction operationAction,IUserOperationDAL userOperationDAL)
    : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
Example #5
0
        public bool VerifyAccess(DocumentTypeKey documentType, OperationAction action,
                                 out List <UserRoleFunction> permissionOfThisView)
        {
            var principal     = _oxProjectContext.User as IQuickspatchPrincipal;
            var hasPermission = false;

            permissionOfThisView = null;

            if (principal != null && principal.User != null)
            {
                var userRoleId = principal.User.UserRoleId.GetValueOrDefault();

                var userGroupRights = MenuExtractData.Instance.LoadUserSecurityRoleFunction(userRoleId,
                                                                                            (int)documentType);
                if (userGroupRights == null || userGroupRights.Count == 0)
                {
                    userGroupRights = _userRoleFunctionRepostory.LoadUserSecurityRoleFunction(userRoleId, (int)documentType);
                }

                if (userGroupRights != null)
                {
                    hasPermission        = userGroupRights.Any(r => r.SecurityOperationId == (int)action);
                    permissionOfThisView = userGroupRights.ToList();
                }
            }

            return(hasPermission);
        }
Example #6
0
        private static void SetElementPolicy(DependencyObject element, string code, OperationAction action)
        {
            if (SystemInfo.OperationCodes == null || SystemInfo.OperationCodes.Count == 0)
                return;

            var containCode = SystemInfo.OperationCodes.Contains(code);
            if (containCode)
                return;

            switch (action)
            {
                case OperationAction.Disable:
                    {
                        element.SetValue(Control.IsEnabledProperty, false);
                        element.SetValue(Control.VisibilityProperty, Visibility.Visible);
                        break;
                    }
                case OperationAction.Hide:
                    {
                        element.SetValue(Control.VisibilityProperty, Visibility.Collapsed);
                        element.SetValue(Control.IsEnabledProperty, true);
                        break;
                    }
                default:
                    break;
            }

        }
Example #7
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Message")] OperationAction operationAction)
        {
            if (id != operationAction.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(operationAction);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OperationActionExists(operationAction.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(operationAction));
        }
 public UserGroupRelationWindow(string groupId, OperationAction operationAction,IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     var entity = UserOperationDAL.DataOperationInstance.QueryByID<UserGroupModel>(groupId);
     InitData(entity);
 }
Example #9
0
 public OperationActionRelationWindow(OperationActionInfoModel entity, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
 public UserGroupRelationWindow(UserGroupModel entity, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
Example #11
0
        public void PerformAction(OperationAction action)
        {
            LastPerformedAction = action;
            switch (action)
            {
            case OperationAction.Start:
                ActionRequestCreator.Start();
                ActionRequestProcessor.Start();
                InformAboutCurrentStatus(OperandSelectorMessageType.OperandAvailable);
                break;

            case OperationAction.Pause:
                InformAboutCurrentStatus(OperandSelectorMessageType.OperandUnavailable);
                ActionRequestCreator.Pause();
                ActionRequestProcessor.Pause();
                break;

            case OperationAction.Resume:
                InformAboutCurrentStatus(OperandSelectorMessageType.OperandAvailable);
                ActionRequestCreator.Resume();
                ActionRequestProcessor.Resume();
                break;

            case OperationAction.Stop:
                InformAboutCurrentStatus(OperandSelectorMessageType.OperandUnavailable);
                ActionRequestCreator.Stop();
                ActionRequestProcessor.Stop();
                break;

            default:
                break;
            }
        }
Example #12
0
 public UserGroupRelationWindow(UserGroupModel entity, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     InitData(entity);
     InitControl();
 }
Example #13
0
 public UserGroupRelationWindow(string groupId, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     var entity = UserOperationDAL.DataOperationInstance.QueryByID <UserGroupModel>(groupId);
     InitData(entity);
 }
Example #14
0
 public Definition(int code, string name, int paramCount, bool write, OperationAction action)
 {
     this.Code       = code;
     this.Name       = name;
     this.ParamCount = paramCount;
     this.Write      = write;
     this.Action     = action;
 }
Example #15
0
 public UserRelationWindow(string userId, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     var userInfoEntity = UserOperationDAL.DataOperationInstance.QueryByID <UserInfoModel>(userId);
     InitData(userInfoEntity);
     InitControl();
 }
Example #16
0
 public AssociationSetEndDetails(
     AssociationSetEnd associationSetEnd, RelationshipMultiplicity multiplicity,
     OperationAction deleteBehavior)
 {
     AssociationSetEnd = associationSetEnd;
     Multiplicity      = multiplicity;
     DeleteBehavior    = deleteBehavior;
 }
        public ActionResult DeleteConfirmed(long id)
        {
            OperationAction operationAction = db.OperationActions.Find(id);

            db.OperationActions.Remove(operationAction);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public UserRelationWindow(string userId, OperationAction operationAction, IUserOperationDAL userOperationDAL)
     : this(userOperationDAL)
 {
     UserAction = operationAction;
     var userInfoEntity = UserOperationDAL.DataOperationInstance.QueryByID<UserInfoModel>(userId);
     InitData(userInfoEntity);
     InitControl();
 }
 public AssociationSetEndDetails(
     AssociationSetEnd associationSetEnd, RelationshipMultiplicity multiplicity,
     OperationAction deleteBehavior)
 {
     AssociationSetEnd = associationSetEnd;
     Multiplicity = multiplicity;
     DeleteBehavior = deleteBehavior;
 }
        internal void WriteOperationActionElement(string elementName, OperationAction operationAction)
        {
            DebugCheck.NotEmpty(elementName);

            _xmlWriter.WriteStartElement(elementName);
            _xmlWriter.WriteAttributeString(XmlConstants.Action, operationAction.ToString());
            _xmlWriter.WriteEndElement();
        }
Example #21
0
            public override MetaObject Operation(OperationAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.Operation))
                {
                    return(CallMethodNAry(action, args, "Operation"));
                }

                return(base.Operation(action, args));
            }
Example #22
0
 public virtual ConventionNavigationPropertyConfiguration HasDeleteAction(
     OperationAction deleteAction)
 {
     if (this._configuration != null && !this._configuration.DeleteAction.HasValue)
     {
         this._configuration.DeleteAction = new OperationAction?(deleteAction);
     }
     return(this);
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            OperationAction operationAction = await db.OperationActions.FindAsync(id);

            db.OperationActions.Remove(operationAction);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Example #24
0
 public override void Reset()
 {
     base.Reset();
     action     = OperationAction.None;
     mode       = OperationMode.None;
     size       = 0ul;
     totalSize  = 0ul;
     count      = 0ul;
     totalCount = 0ul;
 }
Example #25
0
        // <summary>
        // Sets the action to take when a delete operation is attempted.
        // </summary>
        public virtual ConventionNavigationPropertyConfiguration HasDeleteAction(OperationAction deleteAction)
        {
            if (_configuration != null &&
                _configuration.DeleteAction == null)
            {
                _configuration.DeleteAction = deleteAction;
            }

            return(this);
        }
            private void GetFromAssociationSetEnd(AssociationSet definingSet, AssociationSet multiplicitySet, out AssociationSetEnd associationSetEnd, out RelationshipMultiplicity multiplicity, out OperationAction deleteBehavior)
            {
                // for a situation like this (CD is CascadeDelete)
                //
                // --------  CD   --------  CD   --------
                // | A    |1 <-  1| AtoB |* <-  1|  B   |
                // |      |-------|      |-------|      |
                // |      |       |      |       |      |
                // --------       --------       --------
                //
                // You get
                // --------  CD   --------
                // |  A   |* <-  1|  B   |
                // |      |-------|      |
                // |      |       |      |
                // --------       --------
                //
                // Notice that the of the new "link table association" muliplicities are opposite of what comming into the original link table
                // this seems counter intuitive at first, but makes sense when you think all the way through it
                //
                // CascadeDelete Behavior (we can assume the runtime will always delete cascade
                //                         to the link table from the outside tables (it actually doesn't, but that is a bug))
                //  Store               Effective
                //  A -> AToB <- B      None
                //  A <- AToB <- B      <-
                //  A -> AToB -> B      ->
                //  A <- AToB -> B      None
                //  A <- AToB    B      <-
                //  A    AToB -> B      ->
                //  A -> AToB    B      None
                //  A    AToB <- B      None
                //
                //  Other CascadeDelete rules
                //  1. Can't have a delete from a Many multiplicity end
                //  2. Can't have a delete on both ends
                //

                associationSetEnd = GetAssociationSetEnd(definingSet, true);
                AssociationSetEnd multiplicityAssociationSetEnd = GetAssociationSetEnd(multiplicitySet, false);

                multiplicity   = multiplicityAssociationSetEnd.CorrespondingAssociationEndMember.RelationshipMultiplicity;
                deleteBehavior = OperationAction.None;
                if (multiplicity != RelationshipMultiplicity.Many)
                {
                    OperationAction otherEndBehavior = GetAssociationSetEnd(definingSet, false).CorrespondingAssociationEndMember.DeleteBehavior;
                    if (otherEndBehavior == OperationAction.None)
                    {
                        // Since the other end does not have an operation
                        // that means that only one end could possibly have an operation, that is good
                        // so set it the operation
                        deleteBehavior = multiplicityAssociationSetEnd.CorrespondingAssociationEndMember.DeleteBehavior;
                    }
                }
            }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name")] OperationAction operationAction)
        {
            if (ModelState.IsValid)
            {
                db.Entry(operationAction).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(operationAction));
        }
Example #28
0
        /// <summary>
        ///     Решает простую операцию двух чисел
        /// </summary>
        /// <param name="tokens">Символы в разборе</param>
        private double SolveSimpleExpression(List <string> tokens)
        {
            switch (tokens.Count)
            {
            case 1:
                return(double.Parse(tokens[0], this.CultureInfo));

            case 2:
                var op = tokens[0];

                if (op == "-" || op == "+")
                {
                    return(double.Parse((op == "+" ? ""
                                                       : (tokens[1].Substring(0, 1) == "-" ? "" : "-")) + tokens[1],
                                        this.CultureInfo));
                }

                return(OperationAction[op](0, double.Parse(tokens[1], this.CultureInfo)));

            case 0:
                return(0);
            }

            foreach (var op in OperatorList)
            {
                while (tokens.IndexOf(op) != -1)
                {
                    var opPlace = tokens.IndexOf(op);

                    var numberA = double.Parse(tokens[opPlace - 1], this.CultureInfo);
                    var numberB = double.Parse(tokens[opPlace + 1], this.CultureInfo);

                    var result = OperationAction[op](numberA, numberB);

                    tokens[opPlace - 1] = result.ToString(this.CultureInfo);
                    tokens.RemoveRange(opPlace, 2);
                }
            }

            return(double.Parse(tokens[0], this.CultureInfo));
        }
 public ActionResult Edit([Bind(Include = "OperationActionId,OperationTypeId,AccountId,Direction,ActionType,IsFinalNode,IsVisible,HasVehicle,HasContainer")] OperationAction operationAction)
 {
     if (ModelState.IsValid)
     {
         db.Entry(operationAction).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccountId       = new SelectList(db.Accounts, "AccountId", "AccountNo", operationAction.AccountId);
     ViewBag.OperationTypeId = new SelectList(db.OperationTypes, "OperationTypeId", "Name", operationAction.OperationTypeId);
     return(View(operationAction));
 }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name")] OperationAction operationAction)
        {
            if (ModelState.IsValid)
            {
                db.OperationActions.Add(operationAction);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(operationAction));
        }
Example #31
0
        private string GetAssociationCreateScript(AssociationType a)
        {
            StringBuilder sql    = new StringBuilder();
            StringBuilder keySql = new StringBuilder();

            if (a.IsForeignKey)
            {
                EntityType childType  = (EntityType)a.ReferentialConstraints[0].ToProperties[0].DeclaringType;
                EntityType parentType = (EntityType)a.ReferentialConstraints[0].FromProperties[0].DeclaringType;
                string     fkName     = a.Name;
                if (fkName.Length > 64)
                {
                    fkName = "FK_" + Guid.NewGuid().ToString().Replace("-", "");
                }
                sql.AppendLine(String.Format(
                                   "ALTER TABLE `{0}` ADD CONSTRAINT {1}", _pluralizedNames[childType.Name], fkName));
                sql.Append("\t FOREIGN KEY (");
                string delimiter = "";
                foreach (EdmProperty p in a.ReferentialConstraints[0].ToProperties)
                {
                    EdmMember member;
                    if (!childType.KeyMembers.TryGetValue(p.Name, false, out member))
                    {
                        keySql.AppendLine(String.Format(
                                              "ALTER TABLE `{0}` ADD KEY (`{1}`);", _pluralizedNames[childType.Name], p.Name));
                    }
                    sql.AppendFormat("{0}{1}", delimiter, p.Name);
                    delimiter = ", ";
                }
                sql.AppendLine(")");
                delimiter = "";
                sql.Append(String.Format("\tREFERENCES `{0}` (", _pluralizedNames[parentType.Name]));
                foreach (EdmProperty p in a.ReferentialConstraints[0].FromProperties)
                {
                    EdmMember member;
                    if (!parentType.KeyMembers.TryGetValue(p.Name, false, out member))
                    {
                        keySql.AppendLine(String.Format(
                                              "ALTER TABLE `{0}` ADD KEY (`{1}`);", _pluralizedNames[parentType.Name], p.Name));
                    }
                    sql.AppendFormat("{0}{1}", delimiter, p.Name);
                    delimiter = ", ";
                }
                sql.AppendLine(")");
                OperationAction oa = a.AssociationEndMembers[0].DeleteBehavior;
                sql.AppendLine(String.Format(" ON DELETE {0} ON UPDATE {1};",
                                             oa == OperationAction.None ? "NO ACTION" : oa.ToString(), "NO ACTION"));
                sql.AppendLine();
            }

            keySql.Append(sql.ToString());
            return(keySql.ToString());
        }
Example #32
0
 private void ExecNonQuery(OperationAction ope, ManualOperation manual)
 {
     sqlHandler.ExecNonQuery(string.Format(SqlHelper.InsertStr,
                                           ValueHelper.LeftMailID(this.textBoxID.Text == string.Empty ? "0" : this.textBoxID.Text),
                                           this.textBoxBar.Text == string.Empty ? "000000000000" : this.textBoxBar.Text,
                                           (Byte)ope,
                                           DateTime.Now.ToString(),
                                           this.textBoxVolume.Text == string.Empty ? "0" : this.textBoxVolume.Text,
                                           this.textBoxWeight.Text == string.Empty ? "0" : this.textBoxWeight.Text,
                                           (Byte)manual)
                             );
 }
            private void GetFromAssociationSetEnd(AssociationSet definingSet, AssociationSet multiplicitySet, out AssociationSetEnd associationSetEnd, out RelationshipMultiplicity multiplicity, out OperationAction deleteBehavior)
            {
                // for a situation like this (CD is CascadeDelete)
                // 
                // --------  CD   --------  CD   --------
                // | A    |1 <-  1| AtoB |* <-  1|  B   |  
                // |      |-------|      |-------|      | 
                // |      |       |      |       |      |
                // --------       --------       --------
                // 
                // You get
                // --------  CD   --------
                // |  A   |* <-  1|  B   |
                // |      |-------|      |
                // |      |       |      |
                // --------       --------
                // 
                // Notice that the of the new "link table association" muliplicities are opposite of what comming into the original link table
                // this seems counter intuitive at first, but makes sense when you think all the way through it
                //
                // CascadeDelete Behavior (we can assume the runtime will always delete cascade 
                //                         to the link table from the outside tables (it actually doesn't, but that is a 















                associationSetEnd = GetAssociationSetEnd(definingSet, true);
                AssociationSetEnd multiplicityAssociationSetEnd = GetAssociationSetEnd(multiplicitySet, false);
                multiplicity = multiplicityAssociationSetEnd.CorrespondingAssociationEndMember.RelationshipMultiplicity;
                deleteBehavior = OperationAction.None;
                if (multiplicity != RelationshipMultiplicity.Many)
                {
                    OperationAction otherEndBehavior = GetAssociationSetEnd(definingSet, false).CorrespondingAssociationEndMember.DeleteBehavior;
                    if(otherEndBehavior == OperationAction.None)
                    {
                        // Since the other end does not have an operation
                        // that means that only one end could possibly have an operation, that is good
                        // so set it the operation
                        deleteBehavior = multiplicityAssociationSetEnd.CorrespondingAssociationEndMember.DeleteBehavior;
                    }
                }
            }
 internal RelationshipEndMember(
     string name,
     RefType endRefType,
     RelationshipMultiplicity multiplicity)
     : base(name, TypeUsage.Create((EdmType)endRefType, new FacetValues()
 {
     Nullable = (FacetValueContainer <bool?>) new bool?(false)
 }))
 {
     this._relationshipMultiplicity = multiplicity;
     this._deleteBehavior           = OperationAction.None;
 }
Example #35
0
        /// <summary>
        /// 保存采集到的明细数据。
        /// </summary>
        /// <param name="db">数据库对象。</param>
        /// <param name="dbtran">数据库事务对象。</param>
        /// <param name="dataset">包含到采集到的明细数据的数据集。</param>
        internal static void SaveEDCCollectionData(Database db, DbTransaction dbtran, DataSet dsParams)
        {
            string editor = Convert.ToString(dsParams.ExtendedProperties[EDC_MAIN_INS_FIELDS.FIELD_EDITOR]);
            EDC_COLLECTION_DATA_FIELDS edcCollectionData = new EDC_COLLECTION_DATA_FIELDS();
            string sql = "";

            if (dsParams.Tables.Contains(EDC_COLLECTION_DATA_FIELDS.DATABASE_TABLE_NAME))
            {
                DataTable dtParams = dsParams.Tables[EDC_COLLECTION_DATA_FIELDS.DATABASE_TABLE_NAME];
                for (int i = 0; i < dtParams.Rows.Count; i++)
                {
                    OperationAction action = (OperationAction)Convert.ToInt32(dtParams.Rows[i][COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION]);
                    switch (action)
                    {
                    case OperationAction.New:
                        //生成INSERT SQL
                        string colkey = UtilHelper.GenerateNewKey(0);
                        dtParams.Rows[i][EDC_COLLECTION_DATA_FIELDS.FIELD_COL_KEY] = colkey;
                        sql = DatabaseTable.BuildInsertSqlStatement(edcCollectionData, dtParams, i,
                                                                    new Dictionary <string, string>()
                        {
                            { COMMON_FIELDS.FIELD_COMMON_EDITOR, editor },
                            { COMMON_FIELDS.FIELD_COMMON_EDIT_TIME, string.Empty },
                            { COMMON_FIELDS.FIELD_COMMON_EDIT_TIMEZONE, "CN-ZH" },
                        },
                                                                    new List <string>()
                        {
                            COMMON_FIELDS.FIELD_COMMON_OPERATION_ACTION
                        });

                        db.ExecuteNonQuery(dbtran, CommandType.Text, sql);
                        break;

                    case OperationAction.Update:
                        //生成UPDATE SQL
                        string paramValue = Convert.ToString(dtParams.Rows[i][EDC_COLLECTION_DATA_FIELDS.FIELD_PARAM_VALUE]);
                        string colKey     = Convert.ToString(dtParams.Rows[i][EDC_COLLECTION_DATA_FIELDS.FIELD_COL_KEY]);
                        sql = string.Format(@"UPDATE EDC_COLLECTION_DATA 
                                                  SET PARAM_VALUE='{1}',EDIT_TIME= GETDATE(),EDITOR='{2}'
                                                  WHERE COL_KEY='{0}'",
                                            colKey.PreventSQLInjection(),
                                            paramValue.PreventSQLInjection(),
                                            editor.PreventSQLInjection());
                        db.ExecuteNonQuery(dbtran, CommandType.Text, sql);
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Example #36
0
        internal void ProcessAck(OperationAction action, Guid objectId)
        {
            CollectionOperation firstOp = this.LocalOperations[0];

            if (firstOp.Action == action && firstOp.ObjectId == objectId)
            {
                this.LocalOperations.RemoveAt(0);
            }
            else
            {
                Debug.Assert(false, "Received ack for unknown or out of order operation");
            }
        }
Example #37
0
        private AssociationEnd ParseAssociationEnd(XElement associationEndElement)
        {
            var roleName = associationEndElement.GetRequiredAttributeValue("Role");

            string entityTypeNamespace = this.ParseEdmTypeName(associationEndElement.GetRequiredAttributeValue("Type"))[0];
            string entityTypeName      = this.ParseEdmTypeName(associationEndElement.GetRequiredAttributeValue("Type"))[1];

            EndMultiplicity multiplicity   = this.ParseEndMultiplicity(associationEndElement.GetRequiredAttributeValue("Multiplicity"));
            OperationAction onDeleteAction = associationEndElement.Descendants().Any(e => e.Name.LocalName.Equals("OnDelete") && e.Attribute("Action").Value.Equals("Cascade")) ? OperationAction.Cascade : OperationAction.None;
            AssociationEnd  end            = new AssociationEnd(roleName, new EntityTypeReference(entityTypeNamespace, entityTypeName), multiplicity, onDeleteAction);

            this.ParseAnnotations(end, associationEndElement);
            return(end);
        }
        /// <summary>
        ///     Creates a read-only AssociationEndMember instance.
        /// </summary>
        /// <param name="name">The name of the association end member.</param>
        /// <param name="endRefType">The reference type for the end.</param>
        /// <param name="multiplicity">The multiplicity of the end.</param>
        /// <param name="deleteAction">Flag that indicates the delete behavior of the end.</param>
        /// <param name="metadataProperties">Metadata properties to be associated with the instance.</param>
        /// <returns>The newly created AssociationEndMember instance.</returns>
        /// <exception cref="ArgumentException">The specified name is null or empty.</exception>
        /// <exception cref="ArgumentNullException">The specified reference type is null.</exception>
        public static AssociationEndMember Create(
            string name,
            RefType endRefType,
            RelationshipMultiplicity multiplicity,
            OperationAction deleteAction,
            IEnumerable<MetadataProperty> metadataProperties)
        {
            Check.NotEmpty(name, "name");
            Check.NotNull(endRefType, "endRefType");

            var instance = new AssociationEndMember(name, endRefType, multiplicity);
            instance.DeleteBehavior = deleteAction;

            if (metadataProperties != null)
            {
                instance.AddMetadataProperties(metadataProperties.ToList());
            }

            instance.SetReadOnly();

            return instance;
        }
        /// <summary>
        /// 作为客户端给PLC发送数据
        /// </summary>
        /// <param name="data"></param>
        public void ClientSend(string mailId, OperationAction ope)
        {
            if (Flag.PLCConnected)
            {
                ModBusRequest tempModBusReqData = new ModBusRequest();
                tempModBusReqData.ModBusReqHeader.TransId = 1;  // 暂时不需要设置
                tempModBusReqData.ModBusReqHeader.StartAddr = UInt16.Parse(ConfigurationManager.AppSettings["StartingAddress"]); //60H
                tempModBusReqData.ModBusReqHeader.RegisNum = UInt16.Parse(ConfigurationManager.AppSettings["RegisterNumber"]);  //3
                tempModBusReqData.ModBusReqHeader.Length = (UInt16)(Byte.Parse(ConfigurationManager.AppSettings["DataLength"]) + 7); // 6+7
                tempModBusReqData.ModBusReqHeader.DataLength = Byte.Parse(ConfigurationManager.AppSettings["DataLength"]); //6

                tempModBusReqData.ModBusReqBody.MailId = UInt16.Parse(mailId == string.Empty ? "0" : mailId);
                tempModBusReqData.ModBusReqBody.Mark = MarkupBit.Normal;
                tempModBusReqData.ModBusReqBody.Ope = ope;

                int arrLen = tempModBusReqData.ModBusReqHeader.Length + ModBusRequestBody.TotalLength;  //6 = Transaction ID(2) + Protocol ID(2) + Length(2)
                byte[] data = new byte[arrLen];
                tempModBusReqData.ToBytes(data, 0);

                try
                {
                    this.socketClientWrapper.Write(data);

                    //读取PLC反馈信息,主要用于调试查看
                    byte[] responseHeader = this.socketClientWrapper.Read(20);
                }
                catch (Exception e)
                {
                    Log.Write("Client: 向PLC发送数据时异常: " + e.Message);
                }

            }
            else
            {
                Log.Write("Client: 与PLC连接断开,无法发送");

                MessageBox.Show("Client: 与PLC连接断开,无法发送");
            }
        }
Example #40
0
 /// <summary>
 /// Initializes a new instance of the AssociationEnd class with a given RoleName, EntityType, multiplicity and OnDeleteAction
 /// </summary>
 /// <param name="roleName">The RoleName for the association end</param>
 /// <param name="type">The EntityType this association end refers to</param>
 /// <param name="multiplicity">Mulitipliciy of this association end</param>
 /// <param name="onDeleteAction">OnDelete value</param>
 public AssociationEnd(string roleName, EntityType type, EndMultiplicity multiplicity, OperationAction onDeleteAction)
     : this(roleName, type, multiplicity)
 {
     this.DeleteBehavior = onDeleteAction;
 }
Example #41
0
 public Operation(OperationAction action)
 {
     this.Action = action;
 }
        private AssociationEndMember CreateAssociationEndMember(LoadMethodSessionState session, AssociationEndMember storeEndMember, UniqueIdentifierService usedEndMemberNames, RelationshipMultiplicity multiplicityOverride, OperationAction deleteBehaviorOverride)
        {
            Debug.Assert(storeEndMember.TypeUsage.EdmType.BuiltInTypeKind == BuiltInTypeKind.RefType, "The type is not a ref type");
            Debug.Assert(((RefType)storeEndMember.TypeUsage.EdmType).ElementType.BuiltInTypeKind == BuiltInTypeKind.EntityType, "the ref is not holding on to an EntityType");
            
            EntityType storeEntityType = ((EntityType)((RefType)storeEndMember.TypeUsage.EdmType).ElementType);
            EntityType modelEntityType = session.MappingLookups.StoreEntityTypeToModelEntityType[storeEntityType];

            string name = CreateModelName(storeEndMember.Name, usedEndMemberNames);
            AssociationEndMember end = new AssociationEndMember(name, modelEntityType.GetReferenceType(), multiplicityOverride);
            end.DeleteBehavior = deleteBehaviorOverride;
            return end;            
        }
Example #43
0
            public override MetaObject Operation(OperationAction action, MetaObject[] args)
            {
                if (ImplementsActions(StandardActionKinds.Operation)) {
                    return CallMethodNAry(action, args, "Operation");
                }

                return base.Operation(action, args);
            }
Example #44
0
 /// <summary>
 /// When overridden in a derived class provides the non-Meta implementation of performing
 /// the operation.
 /// 
 /// When not overridden the call site requesting the action determines the behavior.
 /// </summary>
 protected virtual object Operation(OperationAction action, params object[] args)
 {
     throw new NotSupportedException();
 }
        /// <summary>
        /// 邮件处理逻辑
        /// </summary>
        /// <param name="ope"></param>
        /// <param name="manual"></param>
        private void OperationHandler(OperationAction ope, ManualOperation manual)
        {
            if (this.textBoxID.Text.Trim() == string.Empty)
            {
                return;
            }

            this.timerNext.Stop();

            needUpdate = true;

            //发送处理结果给PLC
            wrapper.ClientSend(this.textBoxID.Text, ope);

            //实时将处理数据更新到数据库中
            ExecNonQuery(ope, manual);

            //图像清除
            this.pictureBoxPic.Image = null;
            //旋转按钮隐藏
            this.buttonRotateLeft.Visible = false;
            this.buttonRotateRight.Visible = false;

            //UI 邮件信息清空
            this.textBoxID.Text = string.Empty;
            this.textBoxVolume.Text = string.Empty;
            this.textBoxWeight.Text = string.Empty;
            this.textBoxBar.Text = string.Empty;
        }
            private static void Check_cascade_delete_flag_is_reflected_by_delete_behavior(
                bool isCascadeDelete, OperationAction expectedDeleteBehavior)
            {
                var tableDetails = new[]
                    {
                        CreateRow("catalog", "schema", "source", "Id", 0, false, "int", isIdentiy: true, isPrimaryKey: true),
                        CreateRow("catalog", "schema", "target", "Id", 0, false, "int", isIdentiy: true)
                    };

                var relationshipDetails = new List<RelationshipDetailsRow>
                    {
                        CreateRelationshipDetailsRow(
                            "RelationshipId", "name", 0, isCascadeDelete, "catalog", "schema", "source", "Id", "catalog", "schema", "target",
                            "Id")
                    };

                var storeModelBuilder = CreateStoreModelBuilder();

                var entityRegister = new StoreModelBuilder.EntityRegister();
                storeModelBuilder.CreateEntitySets(tableDetails, new TableDetailsRow[0], entityRegister);

                var associationTypes = new List<AssociationType>();
                var associationSet = storeModelBuilder.TryCreateAssociationSet(relationshipDetails, entityRegister, associationTypes);

                Assert.Equal(1, associationTypes.Count);
                Assert.NotNull(associationSet);

                var associationType = associationTypes[0];

                Assert.False(MetadataItemHelper.IsInvalid(associationType));
                Assert.Null(associationType.MetadataProperties.SingleOrDefault(p => p.Name == "EdmSchemaErrors"));

                var sourceEnd = associationType.AssociationEndMembers.FirstOrDefault();
                var targetEnd = associationType.AssociationEndMembers.ElementAtOrDefault(1);

                Assert.Equal(expectedDeleteBehavior, sourceEnd.DeleteBehavior);
                Assert.Equal(OperationAction.None, targetEnd.DeleteBehavior);
            }
Example #47
0
 public static void SetAction(DependencyObject obj, OperationAction value)
 {
     obj.SetValue(ActionProperty, value);
 }
        internal void WriteOperationActionElement(string elementName, OperationAction operationAction)
        {
            DebugCheck.NotEmpty(elementName);

            _xmlWriter.WriteStartElement(elementName);
            _xmlWriter.WriteAttributeString(XmlConstants.Action, operationAction.ToString());
            _xmlWriter.WriteEndElement();
        }
 public void GetStoreAssociationSetEnd(int index, out AssociationSetEnd storeAssociationSetEnd, out RelationshipMultiplicity multiplicity, out OperationAction deleteBehavior)
 {
     Debug.Assert(index >= 0 && index < AssociationSets.Count, "out of bounds dude!!");
     Debug.Assert(AssociationSets.Count == 2, "This code depends on only having exactly two AssociationSets");
     GetFromAssociationSetEnd(AssociationSets[index], AssociationSets[(index+1)%2], out storeAssociationSetEnd, out multiplicity, out deleteBehavior);
 }
Example #50
0
 public override void Reset()
 {
     base.Reset();
     action = OperationAction.None;
     mode = OperationMode.None;
     size = 0ul;
     totalSize = 0ul;
     count = 0ul;
     totalCount = 0ul;
 }
 private AssociationEndMember CreateAssociationEnd(LoadMethodSessionState session, 
     EntityType type, 
     RelationshipMultiplicity multiplicity,
     UniqueIdentifierService usedEndNames,
     OperationAction deleteAction
     )
 {
     string role = usedEndNames.AdjustIdentifier(type.Name);
     RefType refType = type.GetReferenceType();
     AssociationEndMember end = new AssociationEndMember(role, refType, multiplicity);
     end.DeleteBehavior = deleteAction;
     session.RelationshipEndTypeLookup.Add(end, type);
     return end;
 }
        private static AssociationEndMember GenerateAssociationEndMember(
            SimpleMappingContext mappingContext,
            AssociationEndMember storeEndMember,
            UniqueIdentifierService uniqueEndMemberNames,
            RelationshipMultiplicity multiplicity,
            OperationAction deleteBehavior)
        {
            var storeEntityType = ((EntityType)((RefType)storeEndMember.TypeUsage.EdmType).ElementType);
            var conceptualEntityType = mappingContext[storeEntityType];

            var conceptualEndMember = AssociationEndMember.Create(
                CreateModelName(storeEndMember.Name, uniqueEndMemberNames),
                conceptualEntityType.GetReferenceType(),
                multiplicity,
                deleteBehavior,
                null);

            mappingContext.AddMapping(storeEndMember, conceptualEndMember);

            return conceptualEndMember;
        }
 private void ExecNonQuery(OperationAction ope, ManualOperation manual)
 {
     sqlHandler.ExecNonQuery(string.Format(SqlHelper.InsertStr,
         ValueHelper.LeftMailID(this.textBoxID.Text == string.Empty ? "0" : this.textBoxID.Text),
         this.textBoxBar.Text == string.Empty ? "000000000000" : this.textBoxBar.Text,
         (Byte)ope,
         DateTime.Now.ToString(),
         this.textBoxVolume.Text == string.Empty ? "0" : this.textBoxVolume.Text,
         this.textBoxWeight.Text == string.Empty ? "0" : this.textBoxWeight.Text,
         (Byte)manual)
         );
 }