Beispiel #1
0
 public static ShippingExportDC[] FindExportContractList(Guid tenantId, string numberToMatch, int?status, Guid?owner)
 {
     using (ExtensibleObjectContext context = new ExtensibleObjectContext(Constants.Database.TenantData))
     {
         List <ShippingExportDC> dcList      = new List <ShippingExportDC>();
         StringBuilder           queryClause = new StringBuilder();
         queryClause.Append(string.Format("TenantId='{0}'", tenantId.ToString()));
         queryClause.Append(string.Format(" AND Number LIKE '{0}%'", numberToMatch == null?string.Empty:numberToMatch.Trim().Replace("'", "''")));
         if (status != null)
         {
             queryClause.Append(string.Format(" AND Status = {0}", (int)status));
         }
         if (owner != null)
         {
             queryClause.Append(string.Format(" AND Creator = '{0}'", ((Guid)owner).ToString()));
         }
         queryClause.Append(" ORDER BY Number");
         EntityQuery <ShippingExportContract> query = context.GetQuery <ShippingExportContract>(queryClause.ToString());
         foreach (ShippingExportContract exportContract in query)
         {
             ShippingExportDC dc = new ShippingExportDC();
             EntityExchanger.WriteEntityToDC(exportContract, dc);
             dcList.Add(dc);
         }
         return(dcList.ToArray());
     }
 }
Beispiel #2
0
        public static Guid CreateExportContract(Guid tenantId, string number, Guid creator)
        {
            ShippingExportDC contractDC = null;

            using (ExtensibleObjectContext context = new ExtensibleObjectContext(Constants.Database.TenantData))
            {
                KeyValuePair <string, object>        keyValueTenantId = new KeyValuePair <string, object>("TenantId", tenantId);
                KeyValuePair <string, object>        keyValueNumber   = new KeyValuePair <string, object>("Number", number);
                EntityQuery <ShippingExportContract> query            = context.GetQuery <ShippingExportContract>(keyValueTenantId, keyValueNumber);
                if (query.GetCount() > 0)
                {
                    throw new ExportContractExcepiton(string.Format("The export contract with number {0} has already existed!"));
                }

                contractDC            = new ShippingExportDC();
                contractDC.Id         = Guid.NewGuid();
                contractDC.TenantId   = tenantId;
                contractDC.Number     = number;
                contractDC.CreateDate = DateTime.Now;
                contractDC.Creator    = creator;
                ShippingExportContract contract = new ShippingExportContract();
                EntityExchanger.WriteDCToEntity(contractDC, contract);
                context.AddObject(contract);
                context.SaveAllChanges();
            }
            ExportProcessLogic.OpenExportProcess(tenantId, contractDC);
            return(contractDC.Id);
        }
Beispiel #3
0
 public static ShippingExportDC GetExportContractById(Guid id)
 {
     using (ExtensibleObjectContext context = new ExtensibleObjectContext(Constants.Database.TenantData))
     {
         KeyValuePair <string, object>[] keyValue = new KeyValuePair <string, object>[] { new KeyValuePair <string, object>("Id", id) };
         EntityKey key = context.CreateKey(typeof(ExtensibleObjectContext), keyValue);
         ShippingExportContract exportContract = context.GetObjectByKey <ShippingExportContract>(key);
         ShippingExportDC       dc             = new ShippingExportDC();
         EntityExchanger.WriteEntityToDC(exportContract, dc);
         return(dc);
     }
 }
Beispiel #4
0
 public static void UpdateExportContract(ShippingExportDC dc)
 {
     using (ExtensibleObjectContext context = new ExtensibleObjectContext(Constants.Database.TenantData))
     {
         string         entityDefName = ExtensibleDC.GetEntityClassName(dc.GetType());
         EntityMetadata metadata      = DataModelWorkspace.Current.GetEntityMetadata(entityDefName);
         KeyValuePair <string, object>[] keyValues = new KeyValuePair <string, object>[] { new KeyValuePair <string, object>("Id", dc.Id) };
         EntityKey key = context.CreateKey(typeof(ShippingExportContract), keyValues);
         ShippingExportContract exportContract = context.GetObjectByKey <ShippingExportContract>(key);
         EntityExchanger.WriteDCToEntity(dc, exportContract);
         context.SaveAllChanges();
     }
 }
Beispiel #5
0
 public static ShippingExportDC GetExportContractByNumber(Guid tenantId, string number)
 {
     using (ExtensibleObjectContext context = new ExtensibleObjectContext(Constants.Database.TenantData))
     {
         KeyValuePair <string, object>        keyValueTenantId = new KeyValuePair <string, object>("TenantId", tenantId);
         KeyValuePair <string, object>        keyValueNumber   = new KeyValuePair <string, object>("Number", number);
         EntityQuery <ShippingExportContract> query            = context.GetQuery <ShippingExportContract>(keyValueTenantId, keyValueNumber);
         foreach (ShippingExportContract exportContract in query)
         {
             ShippingExportDC dc = new ShippingExportDC();
             EntityExchanger.WriteEntityToDC(exportContract, dc);
             return(dc);
         }
         return(null);
     }
 }