コード例 #1
0
 public static ClientDataSet.RuleRow GetRuleRow(Guid ruleId, Guid organizationId)
 {
     using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
     {
         ClientDataSet.RuleDataTable table = adapter.GetRule(ruleId);
         return((table.Count > 0) ? table[0] : null);
     }
 }
コード例 #2
0
        public static void UpdateRule(Guid ruleId, Guid ruleEngineId, Guid organizationId, Guid?instanceId, string name, string displayName, int orderNumber, bool active)
        {
            if (ruleId.Equals(Guid.Empty) || ruleEngineId.Equals(Guid.Empty) || string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException("ruleId", Properties.Resources.ExceptionMessage_ArgumentsIsEmpty);
            }

            ClientDataSet.RuleDataTable table = new ClientDataSet.RuleDataTable();

            using (RuleTableAdapter adapter = new RuleTableAdapter(OrganizationProvider.GetConnectionString(organizationId)))
            {
                table = adapter.GetRule(ruleId);

                ClientDataSet.RuleRow row = ((table.Count > 0) ? table[0] : null);

                if (row == null)
                {
                    row                = table.NewRuleRow();
                    row.RuleId         = ruleId;
                    row.RuleEngineId   = ruleEngineId;
                    row.OrganizationId = organizationId;
                    if (instanceId.HasValue)
                    {
                        row.InstanceId = instanceId.Value;
                    }
                    else
                    {
                        row.SetInstanceIdNull();
                    }
                    row.UsedQty = 0;
                    row.SetLastUsedUserNull();
                    row.SetLastUsedDateNull();
                    row.CreatedBy   = UserContext.Current != null ? UserContext.Current.UserId : Guid.Empty;
                    row.CreatedDate = DateTime.UtcNow;
                }

                row.Name        = name;
                row.DisplayName = displayName;
                row.Active      = active;
                row.OrderNumber = orderNumber;

                if (row.RowState == DataRowState.Detached)
                {
                    table.AddRuleRow(row);
                }

                adapter.Update(row);
            }
        }