Exemple #1
0
        /// <summary>
        /// Creates an object that translates the parameters used for external methods to parameters for internal methods.
        /// </summary>
        public DestroyParameterMatrix(TableSchema tableSchema)
        {
            // Initialize the object.
            this.ExternalParameterItems = new SortedList <string, ExternalParameterItem>();

            // Every set of update parameters requires a unique key to identify the record that is to be updated.
            UniqueConstraintParameterItem primaryKeyParameterItem = new UniqueConstraintParameterItem();

            primaryKeyParameterItem.ActualDataType   = typeof(Object[]);
            primaryKeyParameterItem.DeclaredDataType = typeof(Object[]);
            primaryKeyParameterItem.Description      = String.Format("The required key for the {0} table.", tableSchema.Name);
            primaryKeyParameterItem.FieldDirection   = FieldDirection.In;
            primaryKeyParameterItem.Name             = String.Format("{0}Key", CommonConversion.ToCamelCase(tableSchema.Name));
            this.ExternalParameterItems.Add(primaryKeyParameterItem.Name, primaryKeyParameterItem);

            // This will create an interface for the 'Destroy' method.
            foreach (KeyValuePair <string, ColumnSchema> columnPair in tableSchema.Columns)
            {
                // This column is turned into a simple parameter.
                ColumnSchema columnSchema = columnPair.Value;

                // The row version is required for the optimistic concurrency checking that is part of all update operations.
                if (columnSchema.IsRowVersion)
                {
                    SimpleParameterItem simpleParameterItem = new SimpleParameterItem();
                    simpleParameterItem.ActualDataType   = columnSchema.DataType;
                    simpleParameterItem.ColumnSchema     = columnSchema;
                    simpleParameterItem.DeclaredDataType = columnSchema.DataType;
                    simpleParameterItem.Description      = String.Format("The required value for the {0} column.", CommonConversion.ToCamelCase(columnSchema.Name));
                    simpleParameterItem.FieldDirection   = FieldDirection.In;
                    simpleParameterItem.Name             = CommonConversion.ToCamelCase(columnSchema.Name);
                    this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem);
                }
            }
        }
Exemple #2
0
 /// <summary>
 /// A private field used to hold a complex filtering algorithm.
 /// </summary>
 public ComplexFilterField(WhereSchema whereSchema)
 {
     //		private ComplexFilter<Sandbox.WorkingOrder.WorkingOrder> filter;
     this.Attributes = MemberAttributes.Private;
     this.Type       = new CodeTypeReference(string.Format("FluidTrade.Core.ComplexFilter<{0}>", whereSchema.ResultType));
     this.Name       = CommonConversion.ToCamelCase(whereSchema.Predicate);
 }
 /// <summary>
 /// Show an exeption alert
 /// </summary>
 /// <param name="recordNotFoundException"></param>
 public void Show(FaultException <RecordNotFoundFault> recordNotFoundException)
 {
     Display(String.Format(FluidTrade.Core.Properties.Resources.RecordNotFoundError,
                           CommonConversion.FromArray(recordNotFoundException.Detail.Key),
                           recordNotFoundException.Detail.TableName),
             AlertMessageBoxType.RecordNotFoundError);
 }
Exemple #4
0
        public ReductionRecord GetReduction(byte[] reducedCompositionHash)
        {
            var reducedCompositionHashBase16 = CommonConversion.StringBase16FromByteArray(reducedCompositionHash);

            var filePath = Path.Combine(ReductionDirectoryPath, reducedCompositionHashBase16);

            if (!File.Exists(filePath))
            {
                return(null);
            }

            var reductionRecordFromFile =
                JsonConvert.DeserializeObject <ReductionRecordInFile>(
                    File.ReadAllText(filePath, Encoding.UTF8));

            if (reducedCompositionHashBase16 != reductionRecordFromFile.ReducedCompositionHashBase16)
            {
                throw new Exception("Unexpected content in file " + filePath + ", composition hash does not match.");
            }

            return(new ReductionRecord
            {
                ReducedCompositionHash = reducedCompositionHash,
                ReducedValueLiteralString = reductionRecordFromFile.ReducedValue?.LiteralString,
            });
        }
 private SyntaxNode GetRewrittenCollection(
     SyntaxGenerator generator,
     SyntaxNode collection,
     ITypeSymbol iterationVariableType,
     CommonConversion conversion)
 {
     if (conversion.Exists && conversion.IsReference)
     {
         // for a reference cast we can insert `.Cast<DestType>()`
         return(generator.InvocationExpression(
                    generator.MemberAccessExpression(
                        collection,
                        generator.GenericName(
                            nameof(Enumerable.Cast),
                            new[] { iterationVariableType }))));
     }
     else
     {
         // otherwise we need to ensure a language specific conversion by emitting the conversion into the code
         // like so: `.Select(v => (DestType)v)`
         return(generator.InvocationExpression(
                    generator.MemberAccessExpression(
                        collection,
                        generator.IdentifierName(nameof(Enumerable.Select))),
                    generator.ValueReturningLambdaExpression(
                        "v",
                        generator.ConvertExpression(iterationVariableType, generator.IdentifierName("v")))));
     }
 }
Exemple #6
0
 public CodeColumnExpressionCollection(ColumnSchema[] columns)
 {
     foreach (ColumnSchema columnSchema in columns)
     {
         this.Add(new CodeArgumentReferenceExpression(CommonConversion.ToCamelCase(columnSchema.Name)));
     }
 }
        public List <ExpressBagNumberReport> GetBagNumberReportObj(int bagId, int userId)
        {
            List <ExpressBagNumberReport> list      = new List <ExpressBagNumberReport>();
            ExpressBagNumberReport        reportObj = new ExpressBagNumberReport();

            var bag = dbContext.ExpressBags.Find(bagId);

            if (bag != null)
            {
                if (!string.IsNullOrEmpty(bag.BagNumber))
                {
                    var arr = bag.BagNumber.Split('-');
                    if (arr.Count() > 0 && arr.Count() == 3)
                    {
                        reportObj.Hub      = arr[0];
                        reportObj.Carrier  = arr[1];
                        reportObj.BagCount = arr[1] + "/" + arr[2];
                    }
                    var manifest = dbContext.ExpressManifests.Find(bag.ManifestId);
                    if (manifest != null)
                    {
                        reportObj.TradelaneShipmentId = manifest.TradelaneShipmentId.HasValue ? manifest.TradelaneShipmentId.Value : 0;
                    }
                    reportObj.Ref = CommonConversion.GetNewFrayteNumber();
                    list.Add(reportObj);
                }
            }
            return(list);
        }
        /// <summary>
        /// Generates the method used to handle the Row Changed event.
        /// </summary>
        public FilterRowMethod(TableSchema tableSchema)
        {
            //		/// <summary>
            //		/// Filters a row from the results returned to a client.
            //		/// </summary>
            //		/// <param name="dataModelTransaction">The transaction in which this filter takes place.</param>
            //		/// <param name="filterContext">A general purpose context for the read operation.</param>
            //		/// <param name="containerContext">The Entity which contains this objects and maps to an ACL entry.</param>
            //		/// <returns>True if the given row can be returned to the client, false otherwise.</returns>
            //		private bool FilterRow(object context, object[] transactionLogItem)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Filters a row from the results returned to a client.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"dataModelTransaction\">The transaction in which this filter takes place.</param>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"filterContext\">A general purpose context for the read operation.</param>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"containerContext\">The Entity which contains this objects and maps to an ACL entry.</param>", true));
            this.Attributes = MemberAttributes.Private | MemberAttributes.Final;
            this.ReturnType = new CodeGlobalTypeReference(typeof(Boolean));
            this.Name       = "FilterRow";
            this.Parameters.Add(
                new CodeParameterDeclarationExpression(
                    new CodeGlobalTypeReference(typeof(FluidTrade.Core.IDataModelTransaction)),
                    string.Format("{0}Transaction", CommonConversion.ToCamelCase(tableSchema.DataModel.Name))));
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(Object)), "filterContext"));
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(Object)), "containerContext"));

            //			return true;
            this.Statements.Add(new CodeMethodReturnStatement(new CodePrimitiveExpression(true)));

            //		}
        }
 /// <summary>
 /// A private field used to hold a complex sorting algorithm.
 /// </summary>
 public ComplexComparerField(OrderBySchema orderBySchema)
 {
     //		private ComplexComparer<Sandbox.WorkingOrder.WorkingOrder> comparer;
     this.Attributes = MemberAttributes.Private;
     this.Type       = new CodeTypeReference(string.Format("FluidTrade.Core.ComplexComparer<{0}>", orderBySchema.ResultType));
     this.Name       = CommonConversion.ToCamelCase(orderBySchema.Comparer);
 }
Exemple #10
0
        static PersistentProcessWithHistoryOnFileFromElm019Code BuildPersistentProcess(IServiceProvider services)
        {
            var logger      = services.GetService <ILogger <Startup> >();
            var elmAppFiles = services.GetService <WebAppConfiguration>()?.ElmAppFiles;

            if (!(0 < elmAppFiles?.Count))
            {
                logger.LogInformation("Found no ElmAppFile in configuration.");
                return(null);
            }

            var elmAppComposition =
                Composition.FromTree(
                    Composition.TreeFromSetOfBlobsWithStringPath(elmAppFiles, System.Text.Encoding.UTF8));

            logger.LogInformation("Begin to build the persistent process for Elm app " +
                                  CommonConversion.StringBase16FromByteArray(Composition.GetHash(elmAppComposition)));

            var persistentProcess =
                new PersistentProcessWithHistoryOnFileFromElm019Code(
                    services.GetService <ProcessStore.IProcessStoreReader>(),
                    elmAppFiles,
                    logger: logEntry => logger.LogInformation(logEntry));

            logger.LogInformation("Completed building the persistent process.");

            return(persistentProcess);
        }
Exemple #11
0
 /// <summary>
 /// A private field used to hold a complex sorting algorithm.
 /// </summary>
 public SelectField(SelectSchema selectSchema)
 {
     //		private ComplexComparer<Sandbox.WorkingOrder.WorkingOrder> comparer;
     this.Attributes = MemberAttributes.Private;
     this.Type       = new CodeTypeReference(string.Format("System.Func<{0}, {1}>", selectSchema.SourceType, selectSchema.ResultType));
     this.Name       = CommonConversion.ToCamelCase(selectSchema.Selector);
 }
    BuildConfigurationZipArchiveFromPath(string sourcePath)
    {
        var loadCompositionResult =
            LoadComposition.LoadFromPathResolvingNetworkDependencies(sourcePath)
            .LogToActions(Console.WriteLine);

        if (loadCompositionResult?.Ok == null)
        {
            throw new Exception("Failed to load from path '" + sourcePath + "': " + loadCompositionResult?.Err);
        }

        var sourceTree = loadCompositionResult.Ok.tree;

        /*
         * TODO: Provide a better way to avoid unnecessary files ending up in the config: Get the source files from git.
         */
        var filteredSourceTree =
            loadCompositionResult.Ok.origin?.FromLocalFileSystem != null
            ?
            RemoveNoiseFromTreeComingFromLocalFileSystem(sourceTree)
            :
            sourceTree;

        var filteredSourceComposition = Composition.FromTreeWithStringPath(filteredSourceTree);

        var filteredSourceCompositionId = CommonConversion.StringBase16FromByteArray(Composition.GetHash(filteredSourceComposition));

        Console.WriteLine("Loaded source composition " + filteredSourceCompositionId + " from '" + sourcePath + "'.");

        var configZipArchive =
            BuildConfigurationZipArchive(sourceComposition: filteredSourceComposition);

        return(sourceTree, filteredSourceCompositionId, configZipArchive);
    }
 /// <summary>
 /// An internal vector field.
 /// </summary>
 public SchemaVectorField(PropertySchema propertySchema)
 {
     //		internal System.Collections.Generic.IEnumerable<Sandbox.WorkingOrder.WorkingOrder> workingOrderList;
     this.Attributes = MemberAttributes.Assembly;
     this.Type       = new CodeTypeReference(string.Format("{0}[]", propertySchema.Type));
     this.Name       = CommonConversion.ToCamelCase(propertySchema.Name);
 }
        ProcessEvents(IReadOnlyList <string> serializedEvents)
        {
            lock (process)
            {
                var responses =
                    serializedEvents.Select(serializedEvent => process.ProcessEvent(serializedEvent))
                    .ToImmutableList();

                var compositionRecord = new CompositionRecordInFile
                {
                    ParentHashBase16 = CommonConversion.StringBase16FromByteArray(lastStateHash),
                    AppendedEvents   = serializedEvents.Select(@event => new ValueInFile {
                        LiteralString = @event
                    }).ToImmutableList(),
                };

                var serializedCompositionRecord =
                    Encoding.UTF8.GetBytes(Serialize(compositionRecord));

                var compositionHash = CompositionRecordInFile.HashFromSerialRepresentation(serializedCompositionRecord);

                lastStateHash = compositionHash;

                return(responses, (serializedCompositionRecord, compositionHash));
            }
        }
 /// <summary>
 /// Creates a property that gets the collection of relationship between tables in the data model.
 /// </summary>
 /// <param name="dataModelSchema">The data model schema.</param>
 public RelationsProperty(DataModelSchema dataModelSchema)
 {
     //        /// <summary>
     //        /// Gets the collection of relations that link tables and allow navigation between parent tables and child tables.
     //        /// </summary>
     //        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     //        [global::System.ComponentModel.BrowsableAttribute(false)]
     //        public static global::System.Data.DataRelationCollection Relations {
     //            get {
     //                return FluidTrade.UnitTest.Server.DataModel.dataSet.Relations;
     //            }
     //        }
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement("Gets the collection of relations that link tables and allow navigation between parent tables and child tables.", true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     // HACK - Put this line back in for official releases
     //this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(System.Diagnostics.DebuggerNonUserCodeAttribute))));
     this.CustomAttributes.Add(new CodeAttributeDeclaration(new CodeGlobalTypeReference(typeof(System.ComponentModel.BrowsableAttribute)), new CodeAttributeArgument(new CodePrimitiveExpression(false))));
     this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
     this.Type       = new CodeGlobalTypeReference(typeof(System.Data.DataRelationCollection));
     this.Name       = "Relations";
     this.GetStatements.Add(
         new CodeMethodReturnStatement(
             new CodePropertyReferenceExpression(
                 new CodePropertyReferenceExpression(
                     new CodeTypeReferenceExpression(dataModelSchema.Name),
                     String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                 "Relations")));
 }
Exemple #16
0
        /// <summary>
        /// Creates a method to handle moving the deleted records from the active data model to the deleted data model.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public AddTransactionMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Adds a transaction item to the log.
            //		/// </summary>
            //		/// <param name="iRow">The record to be added to the transaction log.</param>
            //		/// <param name="data">An array of updated fields.</param>
            //		[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
            //		[global::System.ComponentModel.BrowsableAttribute(false)]
            //		internal static void AddTransaction(IRow iRow, object[] data)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Adds a transaction item to the log.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"iRow\">The record to be added to the transaction log.</param>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"data\">An array of updated fields.</param>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Name       = "AddTransaction";
            this.Attributes = MemberAttributes.Assembly | MemberAttributes.Static;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(FluidTrade.Core.IRow)), "iRow"));
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(Object[])), "data"));

            //			DataModel.dataModelDataSet.AddTransaction(iRow, data);
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodeFieldReferenceExpression(
                        new CodeTypeReferenceExpression(dataModelSchema.Name),
                        String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                    "AddTransaction",
                    new CodeArgumentReferenceExpression("iRow"),
                    new CodeArgumentReferenceExpression("data")));

            //		}
        }
        /// <summary>
        /// Creates a method to read an XML file.
        /// </summary>
        /// <param name="schema">The data model schema.</param>
        public ReadXmlMethod(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Reads an XML file into the data model.
            //		/// </summary>
            //		/// <param name="fileName">The name of the file to read.</param>
            //		public static void ReadXml(string fileName)
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Reads an XML file into the data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.Comments.Add(new CodeCommentStatement("<param name=\"fileName\">The name of the file to read.</param>", true));
            this.Name       = "ReadXml";
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Parameters.Add(new CodeParameterDeclarationExpression(new CodeGlobalTypeReference(typeof(String)), "fileName"));

            //			DataModel.dataSet.ReadXml(fileName);
            this.Statements.Add(
                new CodeMethodInvokeExpression(
                    new CodePropertyReferenceExpression(
                        new CodeTypeReferenceExpression(dataModelSchema.Name),
                        String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                    "ReadXml",
                    new CodeArgumentReferenceExpression("fileName")));

            //		}
        }
Exemple #18
0
 /// <summary>
 /// An internal scalar field.
 /// </summary>
 public SchemaScalarField(PropertySchema propertySchema)
 {
     //		internal FluidTrade.Sandbox.WorkingOrder.AskPrice askPrice;
     this.Attributes = MemberAttributes.Assembly;
     this.Type       = new CodeTypeReference(propertySchema.Type);
     this.Name       = CommonConversion.ToCamelCase(propertySchema.Name);
 }
Exemple #19
0
        /// <summary>
        /// Generates a property that gets the lock for the data model.
        /// </summary>
        public DataLockProperty(DataModelSchema dataModelSchema)
        {
            //		/// <summary>
            //		/// Gets the lock for the data model.
            //		/// </summary>
            //		public global::System.Threading.ReaderWriterLockSlim DataLock
            //		{
            this.Comments.Add(new CodeCommentStatement("<summary>", true));
            this.Comments.Add(new CodeCommentStatement("Gets the lock for the data model.", true));
            this.Comments.Add(new CodeCommentStatement("</summary>", true));
            this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
            this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
            this.Type       = new CodeGlobalTypeReference(typeof(ReaderWriterLockSlim));
            this.Name       = "DataLock";

            //			get
            //			{
            //				return this.dataLock;
            //			}
            this.GetStatements.Add(
                new CodeMethodReturnStatement(
                    new CodeFieldReferenceExpression(
                        new CodeFieldReferenceExpression(
                            new CodeTypeReferenceExpression(dataModelSchema.Name),
                            String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                        "DataLock")));

            //		}
        }
 /// <summary>
 /// Creates a property to return a collection of the tables in the data model.
 /// </summary>
 /// <param name="dataModelSchema">The data model schema.</param>
 public TablesProperty(DataModelSchema dataModelSchema)
 {
     //        /// <summary>
     //        /// Gets the collection of tables contained in the DataModel.
     //        /// </summary>
     //        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
     //        [global::System.ComponentModel.BrowsableAttribute(false)]
     //        [global::System.ComponentModel.DesignerSerializationVisibility(global::System.ComponentModel.DesignerSerializationVisibility.Content)]
     //        public static global::System.Data.DataTableCollection Tables {
     //            get {
     //                return FluidTrade.UnitTest.Server.DataModel.dataSet.Tables;
     //            }
     //        }
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement(string.Format("Gets the collection of tables contained in the {0}.", dataModelSchema.Name), true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     this.CustomAttributes.AddRange(new CodeCustomAttributesForProperties());
     this.Attributes = MemberAttributes.Public | MemberAttributes.Static;
     this.Type       = new CodeGlobalTypeReference(typeof(System.Data.DataTableCollection));
     this.Name       = "Tables";
     this.GetStatements.Add(
         new CodeMethodReturnStatement(
             new CodePropertyReferenceExpression(
                 new CodePropertyReferenceExpression(
                     new CodeTypeReferenceExpression(dataModelSchema.Name),
                     String.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name))),
                 "Tables")));
 }
Exemple #21
0
 /// <summary>
 /// Represents an expression that creates an object array using an array of ColumnSchemas.
 /// </summary>
 /// <param name="columns">The columns used to create the array expression.</param>
 public CodeKeyCreateExpression(ColumnSchema[] columns)
 {
     this.CreateType = new CodeGlobalTypeReference(typeof(Object));
     foreach (ColumnSchema columnSchema in columns)
     {
         this.Initializers.Add(new CodeArgumentReferenceExpression(CommonConversion.ToCamelCase(columnSchema.Name)));
     }
 }
Exemple #22
0
 /// <summary>
 /// Creates a private field to hold the generic DataSet.
 /// </summary>
 public DataSetField(DataModelSchema dataModelSchema)
 {
     //        // The generic data behind the strongly typed data model.
     //        private static global::System.Data.DataSet dataSet;
     this.Attributes = MemberAttributes.Assembly | MemberAttributes.Static;
     this.Type       = new CodeTypeReference(string.Format("{0}DataSet", dataModelSchema.Name));
     this.Name       = string.Format("{0}DataSet", CommonConversion.ToCamelCase(dataModelSchema.Name));
 }
        public FrayteResult CreateWarehouseLocation(string LocationName, string countryCode)
        {
            FrayteResult result = new FrayteResult();

            Location location = new Location();

            location.WarehouseId  = 1;
            location.LocationName = LocationName;
            location.CountryId    = 228;
            dbContext.Locations.Add(location);
            dbContext.SaveChanges();

            location.Barcode = CommonConversion.GetNewFrayteNumber() + "|" + countryCode + "|" + location.LocationId;
            dbContext.SaveChanges();

            BarcodeSettings settings = new BarcodeSettings();
            string          data     = location.Barcode;
            string          type     = "Code128";
            short           fontSize = 8;
            string          font     = "SimSun";

            settings.Data2D = data;
            settings.Data   = data;
            settings.Type   = (BarCodeType)Enum.Parse(typeof(BarCodeType), type);

            if (fontSize != 0 && fontSize.ToString().Length > 0 && Int16.TryParse(fontSize.ToString(), out fontSize))
            {
                if (font != null && font.Length > 0)
                {
                    settings.TextFont = new System.Drawing.Font(font, fontSize, FontStyle.Bold);
                }
            }
            short barHeight = 15;

            if (barHeight != 0 && barHeight.ToString().Length > 0 && Int16.TryParse(barHeight.ToString(), out barHeight))
            {
                settings.BarHeight = barHeight;
            }

            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image            barcode   = generator.GenerateImage();

            // Path where we will have barcode
            string filePathToSave = AppSettings.LabelFolder + "Waerehouse/";

            filePathToSave = HttpContext.Current.Server.MapPath(filePathToSave + location.LocationId);

            if (!System.IO.Directory.Exists(filePathToSave))
            {
                System.IO.Directory.CreateDirectory(filePathToSave);
            }
            barcode.Save(filePathToSave + "/" + location.LocationName + ".Png");
            result.Status = true;


            return(result);
        }
        /// <summary>
        /// Creates an object that translates the parameters used for external methods to parameters for internal methods.
        /// </summary>
        public UpdateParameterMatrix(TableSchema tableSchema)
        {
            // Initialize the object.
            this.ExternalParameterItems = new SortedList <string, ExternalParameterItem>();

            // Every set of update parameters requires a unique key to identify the record that is to be updated.
            UniqueConstraintParameterItem primaryKeyParameterItem = new UniqueConstraintParameterItem();

            primaryKeyParameterItem.ActualDataType   = typeof(Object[]);
            primaryKeyParameterItem.DeclaredDataType = typeof(Object[]);
            primaryKeyParameterItem.Description      = String.Format("The required key for the {0} table.", tableSchema.Name);
            primaryKeyParameterItem.FieldDirection   = FieldDirection.In;
            primaryKeyParameterItem.Name             = String.Format("{0}Key", CommonConversion.ToCamelCase(tableSchema.Name));
            this.ExternalParameterItems.Add(primaryKeyParameterItem.Name, primaryKeyParameterItem);

            // This will create an interface for the 'Update' method.
            foreach (KeyValuePair <string, ColumnSchema> columnPair in tableSchema.Columns)
            {
                // This column is turned into a simple parameter.
                ColumnSchema columnSchema = columnPair.Value;

                // If a column requires special processing, it is not handled with the rest of the parameters.
                bool isOrdinaryColumn = true;

                // The row version is required for the optimistic concurrency checking that is part of all update operations.
                if (columnSchema.IsRowVersion)
                {
                    isOrdinaryColumn = false;
                    SimpleParameterItem simpleParameterItem = new SimpleParameterItem();
                    simpleParameterItem.ActualDataType   = columnSchema.DataType;
                    simpleParameterItem.ColumnSchema     = columnSchema;
                    simpleParameterItem.DeclaredDataType = columnSchema.DataType;
                    simpleParameterItem.Description      = String.Format("The required value for the {0} column.", CommonConversion.ToCamelCase(columnSchema.Name));
                    simpleParameterItem.FieldDirection   = FieldDirection.In;
                    simpleParameterItem.Name             = CommonConversion.ToCamelCase(columnSchema.Name);
                    this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem);
                }

                // Ordinary parameters are passed from the external caller to the internal methods without modification or
                // interpretation.
                if (isOrdinaryColumn)
                {
                    SimpleParameterItem simpleParameterItem = new SimpleParameterItem();
                    simpleParameterItem.ActualDataType   = columnSchema.DataType;
                    simpleParameterItem.ColumnSchema     = columnSchema;
                    simpleParameterItem.DeclaredDataType = typeof(Object);
                    simpleParameterItem.Description      = String.Format("The optional value for the {0} column.", CommonConversion.ToCamelCase(columnSchema.Name));
                    simpleParameterItem.FieldDirection   = FieldDirection.In;
                    simpleParameterItem.Name             = CommonConversion.ToCamelCase(columnSchema.Name);
                    this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem);
                }
            }
        }
Exemple #25
0
        static public void BuildConfiguration(string[] args)
        {
            string argumentValueFromParameterName(string parameterName) =>
            args
            .Select(arg => Regex.Match(arg, parameterName + "=(.*)", RegexOptions.IgnoreCase))
            .FirstOrDefault(match => match.Success)
            ?.Groups[1].Value;

            var outputArgument = argumentValueFromParameterName("--output");

            var loweredElmOutputArgument = argumentValueFromParameterName("--lowered-elm-output");

            var frontendWebElmMakeCommandAppendix = argumentValueFromParameterName("--frontend-web-elm-make-appendix");

            var(configZipArchive, loweredElmAppFiles) = BuildConfigurationZipArchive(frontendWebElmMakeCommandAppendix);

            if (0 < loweredElmOutputArgument?.Length)
            {
                Console.WriteLine("I write the lowered Elm app to '" + loweredElmOutputArgument + "'.");

                foreach (var file in loweredElmAppFiles)
                {
                    var outputPath = Path.Combine(new[] { loweredElmOutputArgument }.Concat(file.Key).ToArray());
                    Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
                    File.WriteAllBytes(outputPath, file.Value.ToArray());
                }
            }

            var configZipArchiveFileId =
                CommonConversion.StringBase16FromByteArray(CommonConversion.HashSHA256(configZipArchive));

            var webAppConfigFileId =
                Composition.GetHash(Composition.FromTree(Composition.TreeFromSetOfBlobsWithCommonOSPath(
                                                             ZipArchive.EntriesFromZipArchive(configZipArchive), System.Text.Encoding.UTF8)));

            Console.WriteLine(
                "I built zip archive " + configZipArchiveFileId + " containing web app config " + webAppConfigFileId + ".");

            if (outputArgument == null)
            {
                Console.WriteLine("I did not see a path for output, so I don't attempt to save the configuration to a file.");
            }
            else
            {
                Directory.CreateDirectory(Path.GetDirectoryName(outputArgument));
                File.WriteAllBytes(outputArgument, configZipArchive);

                Console.WriteLine("I saved zip arcchive " + configZipArchiveFileId + " to '" + outputArgument + "'");
            }
        }
Exemple #26
0
 /// <summary>
 /// Creates a field for the strongly typed row.
 /// </summary>
 public RowField(TableSchema tableSchema)
 {
     //
     //            /// <summary>
     //            /// The Department row that has been changed.
     //            /// </summary>
     //            private DepartmentRow departmentRow;
     this.Comments.Add(new CodeCommentStatement("<summary>", true));
     this.Comments.Add(new CodeCommentStatement(String.Format("The {0} row that has been changed.", tableSchema.Name), true));
     this.Comments.Add(new CodeCommentStatement("</summary>", true));
     this.Attributes = MemberAttributes.Private;
     this.Type       = new CodeTypeReference(String.Format("{0}Row", tableSchema.Name));
     this.Name       = String.Format("{0}Row", CommonConversion.ToCamelCase(tableSchema.Name));
 }
Exemple #27
0
        /// <summary>
        /// Creates an object that translates the parameters used for external methods to parameters for internal methods.
        /// </summary>
        public CreateParameterMatrix(TableSchema tableSchema)
        {
            // Initialize the object.
            this.ExternalParameterItems = new SortedList <string, ExternalParameterItem>();

            // This will create an interface for the 'Create' method.
            foreach (KeyValuePair <string, ColumnSchema> columnPair in tableSchema.Columns)
            {
                // This column is turned into a simple parameter.
                ColumnSchema columnSchema = columnPair.Value;

                // If a column requires special processing, it is not handled with the rest of the parameters.
                bool isOrdinaryColumn = true;

                // The row version is not used in the set of Create parameters.
                if (columnSchema.IsRowVersion)
                {
                    isOrdinaryColumn = false;
                }

                // AutoIncremented columns can only be specified as output parameters.
                if (columnSchema.IsAutoIncrement)
                {
                    isOrdinaryColumn = false;
                    SimpleParameterItem simpleParameterItem = new SimpleParameterItem();
                    simpleParameterItem.ActualDataType   = columnSchema.DataType;
                    simpleParameterItem.ColumnSchema     = columnSchema;
                    simpleParameterItem.DeclaredDataType = columnSchema.DataType;
                    simpleParameterItem.Description      = String.Format("The generated value for the {0} column.", columnSchema.Name);
                    simpleParameterItem.FieldDirection   = FieldDirection.Out;
                    simpleParameterItem.Name             = CommonConversion.ToCamelCase(columnSchema.Name);
                    this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem);
                }

                // The only complication for ordinary parameters is whether the data type can accept a default or not.
                if (isOrdinaryColumn)
                {
                    SimpleParameterItem simpleParameterItem = new SimpleParameterItem();
                    bool isOptional = columnSchema.IsNullable || columnSchema.DefaultValue != DBNull.Value;
                    simpleParameterItem.ActualDataType   = columnSchema.DataType;
                    simpleParameterItem.ColumnSchema     = columnSchema;
                    simpleParameterItem.DeclaredDataType = isOptional ? typeof(Object) : columnSchema.DataType;
                    simpleParameterItem.Description      = String.Format("The {0} value for the {1} column.", isOptional ? "optional" : "required", columnSchema.Name);
                    simpleParameterItem.FieldDirection   = FieldDirection.In;
                    simpleParameterItem.Name             = CommonConversion.ToCamelCase(columnSchema.Name);
                    this.ExternalParameterItems.Add(simpleParameterItem.Name, simpleParameterItem);
                }
            }
        }
Exemple #28
0
        /// <summary>
        /// Creates an array of values from a unique constraint that can be used for finding records.
        /// </summary>
        /// <param name="uniqueConstraintSchema">A description of a unique constraint.</param>
        /// <returns>An array of expressions that can be used as a key for finding records in a table.</returns>
        public CodeExpression[] CreateKey(UniqueConstraintSchema uniqueConstraintSchema)
        {
            // This will cycle through all the foreign and simple parameters looking for any columns that match up to the child
            // columns of the constraint.  When found, they are placed in the array in the proper order to match up against the
            // given unique constraint.
            List <CodeExpression> keys = new List <CodeExpression>();

            foreach (ColumnSchema uniqueColumn in uniqueConstraintSchema.Columns)
            {
                foreach (KeyValuePair <string, ExternalParameterItem> parameterPair in this.ExternalParameterItems)
                {
                    // This correlates the unique constraint columns with the variables that have been created in the method to
                    // hold the key values from the foreign tables.  These variables exist outside of the conditional logic that
                    // finds the parent row, so if the parent key is null, these values will also be null.  However, since they're
                    // still declared, they can be used to construct keys, which is useful when they're optional values.
                    if (parameterPair.Value is ForeignKeyConstraintParameterItem)
                    {
                        ForeignKeyConstraintParameterItem foreignKeyConstraintParameterItem = parameterPair.Value as ForeignKeyConstraintParameterItem;
                        ForeignKeyConstraintSchema        foreignKeyConstraintSchema        = foreignKeyConstraintParameterItem.ForeignKeyConstraintSchema;
                        for (int columnIndex = 0; columnIndex < foreignKeyConstraintSchema.Columns.Length; columnIndex++)
                        {
                            if (uniqueColumn == foreignKeyConstraintSchema.Columns[columnIndex])
                            {
                                foreach (ForeignKeyVariableItem foreignKeyVariableItem in foreignKeyConstraintParameterItem.ForeignKeyVariables)
                                {
                                    if (foreignKeyConstraintSchema.Columns[columnIndex] == foreignKeyVariableItem.ColumnSchema)
                                    {
                                        keys.Add(foreignKeyVariableItem.Expression);
                                    }
                                }
                            }
                        }
                    }

                    // This will match the columns described in the simple parameters to the columns in the unique constraint.
                    if (parameterPair.Value is SimpleParameterItem)
                    {
                        SimpleParameterItem simpleParameterItem = parameterPair.Value as SimpleParameterItem;
                        if (uniqueColumn == simpleParameterItem.ColumnSchema)
                        {
                            keys.Add(new CodeVariableReferenceExpression(CommonConversion.ToCamelCase(simpleParameterItem.ColumnSchema.Name)));
                        }
                    }
                }
            }

            // This array can be used as a key to find the record in a table.
            return(keys.ToArray());
        }
        public JsonResult GetProjec()
        {
            var eList = new List <ProjectMaster>();

            try
            {
                eList = _commonService.GetProjectNameList().ToList();
            }
            catch (Exception ex)
            {
            }
            var objstate = eList.Select(x => new { value = x.ProjectName + "-" + CommonConversion.AddOrdinal(x.OrderNuber) + " Order", Id = x.ProjectMasterId, display = x.DisplaySize, ram = x.Ram, rom = x.Rom }).ToList();

            return(Json(objstate.ToArray(), JsonRequestBehavior.AllowGet));
        }
        //for project Name Auto Complete

        public JsonResult GetProjectNameList(string term)
        {
            List <ProjectMaster> eList;

            try
            {
                eList = _commonService.GetProjectNameList().Where(x => x.ProjectName.ToLower().Contains(term.ToLower())).OrderBy(x => x.ProjectName).ThenByDescending(x => x.OrderNuber).ToList();
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
            var objstate = eList.Select(x => new { value = x.ProjectName + "-" + CommonConversion.AddOrdinal(x.OrderNuber) + " Order", Id = x.ProjectMasterId, display = x.DisplaySize, ram = x.Ram, rom = x.Rom }).ToList();

            return(Json(objstate.ToArray(), JsonRequestBehavior.AllowGet));
        }