public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            if (operation == null)
            {
                throw new ArgumentNullException("operation");
            }

            if (apiDescription == null)
            {
                throw new ArgumentNullException("apiDescription");
            }

            Collection<IFilter> filters = apiDescription.ActionDescriptor.ControllerDescriptor.GetFilters();
            IEnumerable<IFilter> mobileAppFilter = filters.Where(f => typeof(MobileAppControllerAttribute).IsAssignableFrom(f.GetType()));

            if (mobileAppFilter.Any())
            {
                if (operation.parameters == null)
                {
                    operation.parameters = new List<Parameter>();
                }

                operation.parameters.Add(new Parameter
                {
                    name = "ZUMO-API-VERSION",
                    @in = "header",
                    type = "string",
                    required = true,
                    @default = "2.0.0"
                });
            }
        }
        public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            List<SwaggerDefaultValue> listDefine = new List<SwaggerDefaultValue>
            {
                new SwaggerDefaultValue("Compare", "<", "<,<=,>,>=,="),
                //new SwaggerDefaultValue("Model_URI", "@{body(\'besconnector').Results.output2.FullURL}"),
                //new SwaggerDefaultValue("Evaluate_Output_Path", "@{body(\'besconnector\').Results.output1.FullURL}")
            };

            if (operation.parameters == null)
                return;
            foreach (var param in operation.parameters)
            {
                var actionParam = apiDescription.ActionDescriptor.GetParameters().First(p => p.ParameterName == param.name);

                foreach (SwaggerDefaultValue customAttribute in listDefine)
                {
                    if (customAttribute.ParameterName == param.name)
                    {
                        param.@default = customAttribute.DefaultValue;
                        string[] listValue = customAttribute.Values.Split(',');
                        if (listValue != null && listValue.Length > 1)
                            param.@enum = listValue;
                    }
                }
            }
        }
        public static Response LoadRecSource(Operation baseOperation, RecServiceState state)
        {
            Operation<LoadRecSourceRequest> operation = (Operation<LoadRecSourceRequest>)baseOperation;
            if (!operation.PayloadSet || operation.Payload == null)
                return GetArgumentNotSetError("Payload");
            if (operation.Payload.Name == null)
                return GetArgumentNotSetError("Payload.Name");
            if (operation.Payload.Type == null)
                return GetArgumentNotSetError("Payload.Type");

            if (state.JsonRecSourceTypes.ContainsKey(operation.Payload.Type))
            {
                Type jsonRecSourceType = state.JsonRecSourceTypes[operation.Payload.Type];

                // operation.Payload's static type is LoadRecSourceRequest.
                // Its real type will be something like LoadRecSourceRequest<AverageScoreRecSourceParams> thanks to the custom JsonConverter.
                // A json rec source is expected to have one or more constructors taking types derived from LoadRecSourceRequest.
                Func<ITrainableJsonRecSource> recSourceFactory = () => (ITrainableJsonRecSource)(Activator.CreateInstance(jsonRecSourceType, operation.Payload));

                state.LoadRecSource(recSourceFactory, operation.Payload.Name, operation.Payload.ReplaceExisting);
                return new Response();
            }
            else
            {
                return Response.GetErrorResponse(
                    errorCode: ErrorCodes.InvalidArgument,
                    message: string.Format("{0} is not a valid rec source type.", operation.Payload.Type)
                );
            }
        }
        public ActionResult Save(SlsUnit slsUnit)
        {
            int userId = Convert.ToInt32(Session["userId"]);
            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                if (slsUnit.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        slsUnit.CreatedBy = userId;
                        slsUnit.CreatedDate = DateTime.Now.Date;
                        objOperation = _unitOfMeasurementService.Save(slsUnit);
                    }
                    else { objOperation.OperationId = -1; }

                }
                else
                {
                    if ((bool)Session["Edit"])
                    {
                        slsUnit.ModifiedBy = userId;
                        slsUnit.ModifiedDate = DateTime.Now.Date;
                        objOperation = _unitOfMeasurementService.Update(slsUnit);
                    }
                    else { objOperation.OperationId = -2; }
                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
 public void TestCheckStatus2()
 {
     Uri packageUrl = Blob.GetUrl("bzytasksweurosys", "mydeployments", "20111207_015202_Beazley.Tasks.Azure.cspkg");
     IDeployment deployment = new Deployment();
     string createRequestId = deployment.CreateRequest(
         WindowsAzureAccount.SubscriptionId,
         WindowsAzureAccount.CertificateThumbprint,
         "BeazleyTasks-WEuro-Sys",
         DeploymentSlot.Production,
         "DeploymentName",
         packageUrl,
         "DeploymentLabel",
         "ServiceConfiguration.Cloud-SysTest.cscfg",
         true,
         true);
     IOperation operation = new Operation();
     OperationResult operationResult1 = operation.StatusCheck(
         WindowsAzureAccount.SubscriptionId,
         WindowsAzureAccount.CertificateThumbprint,
         createRequestId);
     Assert.IsNotNull(operationResult1);
     System.Threading.Thread.Sleep(5000);
     OperationResult operationResult2 = operation.StatusCheck(
         WindowsAzureAccount.SubscriptionId,
         WindowsAzureAccount.CertificateThumbprint,
         createRequestId);
     Assert.IsNotNull(operationResult2);
 }
 public override void OnReset()
 {
     operation = Operation.Add;
     float1.Value = 0;
     float2.Value = 0;
     storeResult.Value = 0;
 }
Exemple #7
0
 private void GenerateMethodBody(DynamicMethod method, Operation operation)
 {
     ILGenerator generator = method.GetILGenerator();
     generator.DeclareLocal(typeof(double));
     GenerateMethodBody(generator, operation);
     generator.Emit(OpCodes.Ret);
 }
 void ISectionParser.Populate(AreaToken token, Operation operation)
 {
     if (token.Identifier == "Einsatznummer")
     {
         operation.OperationNumber = token.Value;
     }
 }
        public void Add(Type serviceType, Type requestType, Type responseType)
        {
            this.ServiceTypes.Add(serviceType);
            this.RequestTypes.Add(requestType);

            var restrictTo = requestType.GetCustomAttributes(true)
                    .OfType<RestrictAttribute>().FirstOrDefault()
                ?? serviceType.GetCustomAttributes(true)
                    .OfType<RestrictAttribute>().FirstOrDefault();

            var operation = new Operation {
                ServiceType = serviceType,
                RequestType = requestType,
                ResponseType = responseType,
                RestrictTo = restrictTo,
                Actions = GetImplementedActions(serviceType, requestType),
                Routes = new List<RestPath>(),
            };

            this.OperationsMap[requestType] = operation;
            this.OperationNamesMap[requestType.Name.ToLower()] = operation;

            if (responseType != null)
            {
                this.ResponseTypes.Add(responseType);
                this.OperationsResponseMap[responseType] = operation;
            }
        }
        public void Add(Type serviceType, Type requestType, Type responseType)
        {
            this.ServiceTypes.Add(serviceType);
            this.RequestTypes.Add(requestType);

            var restrictTo = requestType.FirstAttribute<RestrictAttribute>()
                          ?? serviceType.FirstAttribute<RestrictAttribute>();

            var operation = new Operation {
                ServiceType = serviceType,
                RequestType = requestType,
                ResponseType = responseType,
                RestrictTo = restrictTo,
                Actions = GetImplementedActions(serviceType, requestType),
                Routes = new List<RestPath>(),
            };

			this.OperationsMap[requestType] = operation;
			this.OperationNamesMap[operation.Name.ToLower()] = operation;
			//this.OperationNamesMap[requestType.Name.ToLower()] = operation;
			if (responseType != null)
			{
				this.ResponseTypes.Add(responseType);
				this.OperationsResponseMap[responseType] = operation;
			}

            //Only count non-core ServiceStack Services, i.e. defined outside of ServiceStack.dll or Swagger
            var nonCoreServicesCount = OperationsMap.Values
                .Count(x => x.ServiceType.Assembly != typeof(Service).Assembly
                && x.ServiceType.FullName != "ServiceStack.Api.Swagger.SwaggerApiService"
                && x.ServiceType.FullName != "ServiceStack.Api.Swagger.SwaggerResourcesService"
                && x.ServiceType.Name != "__AutoQueryServices");

            LicenseUtils.AssertValidUsage(LicenseFeature.ServiceStack, QuotaType.Operations, nonCoreServicesCount);
        }
        public void MakeTransfer(Account creditAccount, Account debitAccount, decimal amount)
        {
            if (creditAccount == null)
            {
                throw new AccountServiceException("creditAccount null");
            }

            if (debitAccount == null)
            {
                throw new AccountServiceException("debitAccount null");
            }

            if (debitAccount.Balance < amount && debitAccount.AutorizeOverdraft == false)
            {
                throw new AccountServiceException("not enough money");
            }

            Operation creditOperation = new Operation() { Amount = amount, Direction = Direction.Credit};
            Operation debitOperation = new Operation() { Amount = amount, Direction = Direction.Debit };

            creditAccount.Operations.Add(creditOperation);
            debitAccount.Operations.Add(debitOperation);

            creditAccount.Balance += amount;
            debitAccount.Balance -= amount;

            _operationRepository.CreateOperation(creditOperation);
            _operationRepository.CreateOperation(debitOperation);

            _accountRepository.UpdateAccount(creditAccount);
            _accountRepository.UpdateAccount(debitAccount);
        }
 /// <summary>
 /// Initializes a new <see cref="OperationWrapper"/> instance.
 /// </summary>
 /// <param name="operationBase">OperationBase instance to be wrapped.</param>
 public OperationWrapper(Operation operationBase)
 {
     Debug.Assert(operationBase != null, "operationBase != null");
     operationBase.EnsureReadOnly();
     this.operation = operationBase;
     this.actionTargetSegmentByResourceType = new Dictionary<ResourceType, string>(EqualityComparer<ResourceType>.Default);
 }
 public SubscriptionDataExtended(Subscription subscription, SubscriptionData subscriptionData,
     string description, Operation operation)
 {
     OperationDescription = description;
     OperationStatus = operation.Status;
     OperationId = operation.OperationTrackingId;
     SubscriptionName = subscriptionData.SubscriptionName;
     SubscriptionId = subscriptionData.SubscriptionId;
     Certificate = subscriptionData.Certificate;
     CurrentStorageAccount = subscriptionData.CurrentStorageAccount;
     ServiceEndpoint = subscriptionData.ServiceEndpoint;
     SqlAzureServiceEndpoint = subscriptionData.SqlAzureServiceEndpoint;
     IsDefault = subscriptionData.IsDefault;
     AccountAdminLiveEmailId = subscription.AccountAdminLiveEmailId;
     CurrentCoreCount = subscription.CurrentCoreCount;
     CurrentHostedServices = subscription.CurrentHostedServices;
     CurrentStorageAccounts = subscription.CurrentStorageAccounts;
     CurrentDnsServers = subscription.CurrentDnsServers;
     CurrentLocalNetworkSites = subscription.CurrentLocalNetworkSites;
     CurrentVirtualNetworkSites = subscription.CurrentVirtualNetworkSites;
     MaxCoreCount = subscription.MaxCoreCount;
     MaxHostedServices = subscription.MaxHostedServices;
     MaxStorageAccounts = subscription.MaxStorageAccounts;
     MaxDnsServers = subscription.MaxDnsServers;
     MaxLocalNetworkSites = subscription.MaxLocalNetworkSites;
     MaxVirtualNetworkSites = subscription.MaxVirtualNetworkSites;
     ServiceAdminLiveEmailId = subscription.ServiceAdminLiveEmailId;
     SubscriptionRealName = subscription.SubscriptionName;
     SubscriptionStatus = subscription.SubscriptionStatus;
 }
        public ActionResult SaveCmnCurrency(CmnCurrency currency)
        {
            Operation objOperation = new Operation { Success = false };

            if (ModelState.IsValid)
            {
                int userId = Convert.ToInt32(Session["userId"].ToString());
                currency.CreatedBy = userId;
                if (currency.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        objOperation = _ccService.SaveCmnCurrency(currency);
                    }
                    else { objOperation.OperationId = -1; }
                }
                else
                {
                    if ((bool)Session["Edit"])
                    {
                        currency.ModifiedBy = userId;
                        objOperation = _ccService.UpdateCmnCurrency(currency);
                    }
                    else { objOperation.OperationId = -2; }
                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
        public void Apply(Operation operation, SchemaRegistry schemaRegistry, System.Web.Http.Description.ApiDescription apiDescription)
        {
            // stripping the name
            string operationName = operation.operationId;

            if (!string.IsNullOrEmpty(operationName))
            {
                // swashbuckle adds controller name, stripping that
                int index = operationName.IndexOf("_", 0);
                if (index >= 0 && (index + 1) < operationName.Length)
                {
                    operation.operationId = operationName.Substring(index + 1);
                }
            }

            // operation response change
            IDictionary<string, Response> responses = operation.responses;
            if (responses != null && !responses.ContainsKey(defaultResponseCode))
            {
                try
                {
                    string successResponseCode = JsonSwaggerGenerator.GetReturnCodeForSuccess(responses.Keys);

                    Response successResponse = responses[successResponseCode];
                    Response defaultResponse = new Response();
                    defaultResponse.description = Resources.DefaultResponseDescription;
                    defaultResponse.schema = null;
                    responses.Add(defaultResponseCode, defaultResponse);
                }
                catch(InvalidOperationException)
                {
                    throw new Exception("No success code found, not adding default response code");
                }
            }
        }
        /// <summary>
        /// Creates the operation with the given name and comment
        /// </summary>
        /// <param name="operationName">Name of the operation.</param>
        /// <param name="comment">Description of the operation.</param>
        /// <returns></returns>
        /* Code duplication [ CreateOperation(string operationName) can call this method with empty comment
         * but was not modified to keep the trunck version clean ] */
        public virtual Operation CreateOperation(string operationName, string comment)
        {
            Guard.Against<ArgumentException>(string.IsNullOrEmpty(operationName), "operationName must have a value");
            Guard.Against<ArgumentException>(string.IsNullOrEmpty(comment), "comment must have a value");
            Guard.Against<ArgumentException>(operationName[0] != '/', "Operation names must start with '/'");

            var op = new Operation { Name = operationName, Comment = comment};

            var parentOperationName = Strings.GetParentOperationName(operationName);
            if (parentOperationName != string.Empty) //we haven't got to the root
            {
                var parentOperation = GetOperationByName(parentOperationName) ??
                                      CreateOperation(parentOperationName);

                parentOperation.Comment = string.IsNullOrEmpty(parentOperation.Comment)
                                              ? parentOperationName.Substring(1) + " operations"
                                              : comment;

                op.Parent = parentOperation;
                parentOperation.Children.Add(op);
            }

            session.Save(op);
            return op;
        }
Exemple #17
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            IPAddress myip= Operation.getMyIP();
               if (myip == null)
               {
               MessageBox.Show("sorry");
               Application.Exit();
               }
               //开始侦听
            frmMain.CheckForIllegalCrossThreadCalls = false;
            Operation ope = new Operation(this);

            Thread th = new Thread(new ThreadStart(ope.listen));
            th.IsBackground = true;
            th.Start();

            Thread.Sleep(100);
               //开始广播
            UdpClient uc = new UdpClient();
            txtName = this.txtNickName.Text;
            string msg = "LOGIN|" + this.txtNickName.Text + "|12|小毛驴";
            byte[] bmsg = Encoding.Default.GetBytes(msg);
            IPEndPoint ipep = new IPEndPoint(IPAddress.Parse("255.255.255.255"), 9527);
            uc.Send(bmsg, bmsg.Length, ipep);
        }
        public Operation AddNotification(string message, string url, int id, int EmployeeId, string ntype)
        {
            string typeOfNotification = ntype;
            Operation objOperation = new Operation { Success = true };
            try
            {
                //START Notification Save
                SlsNotification notification = new SlsNotification()
                {
                    Message = message,
                    URL = url + id,
                    Type = typeOfNotification,
                    Date = DateTime.Now
                };

                int notifId = _NotificationRepository.AddEntity(notification);
                _NotificationRepository.SaveChanges();

                SlsNotificationDetail notificationDetail = new SlsNotificationDetail()
                {
                    SlsNotificationId = notifId,
                    HrmEmployeeId = EmployeeId,
                    IsRead = false,
                    Date = DateTime.Now
                };
                int notifDetailId = _NotificationDetailRepository.AddEntity(notificationDetail);
                _NotificationDetailRepository.SaveChanges();
                //END of Notification Save
            }
            catch (Exception ex)
            {
                objOperation.Success = false;
            }
            return objOperation;
        }
Exemple #19
0
        public void Add(string s, Operation operation)
        {
            ParseTreeItem current = root;

            for (int i = 0; i < s.Length; ++i) {

                char key = s[i];

                if (current.Children.ContainsKey(key)) {
                    current = current.Children[key];

                    if (i == s.Length - 1) {
                        //ADD EXCEPTION HERE FOR IF IT FAILS
                        if (current is ParseTreeOperationItem) {
                            ParseTreeOperationItem opItem = current as ParseTreeOperationItem;
                            if (operation is Binary) {
                                opItem.BinaryOperation = operation as Binary;
                            } else if (operation is Function) {
                                opItem.FunctionOperation = operation as Function;
                            }
                        }
                    }
                } else {
                    ParseTreeItem newItem = null;

                    if (i == s.Length - 1)
                        newItem = new ParseTreeOperationItem(operation);
                    else
                        newItem = new ParseTreeItem();

                    current.Children.Add(key, newItem);
                    current = newItem;
                }
            }
        }
 public int CreateOperation(Operation operation)
 {
    operation.Amount = operation.NumberOfShares * operation.Price + operation.Fees;
    unitOfWork.OperationRepository.Insert(operation);
    unitOfWork.Save();
    return operation.OperationId;
 }
        public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
        {
            if (operation.parameters == null) return;

            HandleFromUriArrayParams(operation);
            HandleFromUriObjectParams(operation, schemaRegistry, apiDescription);
        }
        private static HttpRequestMessage CreateHttpRequestMessage(HttpMethod httpMethod, Operation potentialOperation, SwaggerRoute potentialSwaggerRoute, HttpConfiguration httpConfig)
        {
            Contract.Requires(httpConfig != null);
            Contract.Requires(potentialSwaggerRoute != null);
            Contract.Ensures(Contract.Result<HttpRequestMessage>() != null);

            Contract.Assume(potentialSwaggerRoute.ODataRoute.Constraints != null);

            var oDataAbsoluteUri = potentialOperation.GenerateSampleODataUri(ServiceRoot, potentialSwaggerRoute.PrefixedTemplate);

            var httpRequestMessage = new HttpRequestMessage(httpMethod, oDataAbsoluteUri);

            var odataPath = GenerateSampleODataPath(potentialOperation, potentialSwaggerRoute);

            var requestContext = new HttpRequestContext
            {
                Configuration = httpConfig
            };
            httpRequestMessage.SetConfiguration(httpConfig);
            httpRequestMessage.SetRequestContext(requestContext);
            var oDataRoute = potentialSwaggerRoute.ODataRoute;
            var httpRequestMessageProperties = httpRequestMessage.ODataProperties();
            Contract.Assume(httpRequestMessageProperties != null);
            httpRequestMessageProperties.Model = oDataRoute.GetEdmModel();
            httpRequestMessageProperties.Path = odataPath;
            httpRequestMessageProperties.RouteName = oDataRoute.GetODataPathRouteConstraint().RouteName;
            httpRequestMessageProperties.RoutingConventions = oDataRoute.GetODataPathRouteConstraint().RoutingConventions;
            httpRequestMessageProperties.PathHandler = oDataRoute.GetODataPathRouteConstraint().PathHandler;
            httpRequestMessage.SetRouteData(oDataRoute.GetRouteData("/", httpRequestMessage));
            return httpRequestMessage;
        }
        /// <summary>
        /// Inspects list member to determine if the original list shape in the model has been
        /// substituted and if so, whether a member suffix should be used to extract the value
        /// for use in the query. An example usage would be the replacement of IpRange (in EC2)
        /// within an IpRangeList - we treat as a list of strings, yet need to get to the 
        /// IpRange.CidrIp member in the query marshalling. Note that we also have some EC2 
        /// operations where we don't want this submember extraction too even though the
        /// same substitite is in use.
        /// </summary>
        /// <param name="member"></param>
        /// <returns></returns>
        public static string DetermineAWSQueryListMemberSuffix(Operation operation, Member member)
        {
            if (member.Shape.ModelListShape == null)
                return null;

            string suffixMember = null;
            var substituteShapeData = member.model.Customizations.GetSubstituteShapeData(member.ModelShape.ModelListShape.Name);
            if (substituteShapeData != null && substituteShapeData[CustomizationsModel.EmitFromMemberKey] != null)
            {
                var useSuffix = true;
                if (substituteShapeData[CustomizationsModel.ListMemberSuffixExclusionsKey] != null)
                {
                    var exclusions = substituteShapeData[CustomizationsModel.ListMemberSuffixExclusionsKey];
                    foreach (JsonData excl in exclusions)
                    {
                        if (string.Equals(operation.Name, (string)excl, StringComparison.Ordinal))
                        {
                            useSuffix = false;
                            break;
                        }
                    }
                }

                if (useSuffix)
                    suffixMember = (string)substituteShapeData[CustomizationsModel.EmitFromMemberKey];
            }

            return suffixMember;
        }
 public override void OnReset()
 {
     operation = Operation.AND;
     bool1.Value = false;
     bool2.Value = false;
     storeResult.Value = false;
 }
Exemple #25
0
 public override void OnReset()
 {
     operation = Operation.Add;
     integer1.Value = 0;
     integer2.Value = 0;
     storeResult.Value = 0;
 }
        public ActionResult Save(SlsDefect slsDefect)
        {
            int companyId = Convert.ToInt32(Session["companyId"]);
            int userId = Convert.ToInt32(Session["userId"]);

            Operation objOperation = new Operation { Success = false };
            if (ModelState.IsValid && slsDefect != null)
            {
                if (slsDefect.Id == 0)
                {
                    if ((bool)Session["Add"])
                    {
                        slsDefect.SecCompanyId = companyId;
                        slsDefect.CreatedBy = userId;
                        slsDefect.CreatedDate = DateTime.Now;
                        //invDamage.InvDamageDetails = null;
                        objOperation = _IDefectEntryService.Save(slsDefect);
                    }
                }
                else
                {

                }
            }

            return Json(objOperation, JsonRequestBehavior.DenyGet);
        }
 public AWSQueryValidator(IDictionary<string, string> paramters, object request, ServiceModel serviceModel, Operation operation)
 {
     this.Parameters = paramters;
     this.Request = request;
     this.Model = serviceModel;
     this.Operation = operation;
 }
        public void Add(Type serviceType, Type requestType, Type responseType)
        {
            this.ServiceTypes.Add(serviceType);
            this.RequestTypes.Add(requestType);

            var restrictTo = requestType.FirstAttribute<RestrictAttribute>()
                          ?? serviceType.FirstAttribute<RestrictAttribute>();

            var operation = new Operation {
                ServiceType = serviceType,
                RequestType = requestType,
                ResponseType = responseType,
                RestrictTo = restrictTo,
                Actions = GetImplementedActions(serviceType, requestType),
                Routes = new List<RestPath>(),
            };

			this.OperationsMap[requestType] = operation;
			this.OperationNamesMap[operation.Name.ToLower()] = operation;
			//this.OperationNamesMap[requestType.Name.ToLower()] = operation;
			if (responseType != null)
			{
				this.ResponseTypes.Add(responseType);
				this.OperationsResponseMap[responseType] = operation;
			}


            LicenseUtils.AssertValidUsage(LicenseFeature.ServiceStack, QuotaType.Operations, OperationsMap.Count);
        }
Exemple #29
0
        public PoItemApproved()
        {
            var opJobs=new List<JobDescription>();
              opJobs.Add(JobDescription.PurchasersManager);
              opJobs.Add(JobDescription.Boss);
              opJobs.Add(JobDescription.Admin);

              var operation = new Operation
              {
            jobs=opJobs,
            operationName="Cancel PO",
            operationMethod=this.CancelPo
              };

              var opJobs1 = new List<JobDescription>();
              opJobs1.Add(JobDescription.Purchaser);
              opJobs1.Add(JobDescription.PurchasersManager);
              opJobs1.Add(JobDescription.Boss);
              opJobs1.Add(JobDescription.Admin);

              var operation1 = new Operation
              {
              jobs = opJobs1,
              operationName = "Waiting for Ship",
              operationMethod = this.SetPoStateWatingForShip

              };

              operationList.Add(operation);
              operationList.Add(operation1);
        }
 static void TestOverflow(Operation op, uint a, uint b)
 {
     try
     {
         checked
         {
             switch (op)
             {
                 case Operation.Add:
                     System.Console.WriteLine(a + b);
                     break;
                 case Operation.Sub:
                     System.Console.WriteLine(a - b);
                     break;
                 case Operation.Mul:
                     System.Console.WriteLine(a * b);
                     break;
             }
         }
     }
     catch (System.OverflowException)
     {
         System.Console.WriteLine("Overflow");
     }
 }
Exemple #31
0
 public static Operation Divide(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Division, op2);
Exemple #32
0
 public double Calc(double a, double b, Operation op)
 {
     return((double)Operations.GetInvocationList()[(int)op].DynamicInvoke(a, b));
 }
Exemple #33
0
        public static bool MatchDdxOrDdy(Operation operation)
        {
            // It's assumed that "operation.Inst" is ShuffleXor,
            // that should be checked before calling this method.
            Debug.Assert(operation.Inst == Instruction.ShuffleXor);

            bool modified = false;

            Operand src2 = operation.GetSource(1);
            Operand src3 = operation.GetSource(2);

            if (src2.Type != OperandType.Constant || (src2.Value != 1 && src2.Value != 2))
            {
                return(false);
            }

            if (src3.Type != OperandType.Constant || src3.Value != 0x1c03)
            {
                return(false);
            }

            bool isDdy = src2.Value == 2;
            bool isDdx = !isDdy;

            // We can replace any use by a FSWZADD with DDX/DDY, when
            // the following conditions are true:
            // - The mask should be 0b10100101 for DDY, or 0b10011001 for DDX.
            // - The first source operand must be the shuffle output.
            // - The second source operand must be the shuffle first source operand.
            INode[] uses = operation.Dest.UseOps.ToArray();

            foreach (INode use in uses)
            {
                if (!(use is Operation test))
                {
                    continue;
                }

                if (!(use is Operation useOp) || useOp.Inst != Instruction.SwizzleAdd)
                {
                    continue;
                }

                Operand fswzaddSrc1 = useOp.GetSource(0);
                Operand fswzaddSrc2 = useOp.GetSource(1);
                Operand fswzaddSrc3 = useOp.GetSource(2);

                if (fswzaddSrc1 != operation.Dest)
                {
                    continue;
                }

                if (fswzaddSrc2 != operation.GetSource(0))
                {
                    continue;
                }

                if (fswzaddSrc3.Type != OperandType.Constant)
                {
                    continue;
                }

                int mask = fswzaddSrc3.Value;

                if ((isDdx && mask != 0b10011001) ||
                    (isDdy && mask != 0b10100101))
                {
                    continue;
                }

                useOp.TurnInto(isDdx ? Instruction.Ddx : Instruction.Ddy, fswzaddSrc2);

                modified = true;
            }

            return(modified);
        }
 /// <summary>
 /// Retrieve Item name from a Operation Enum.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <returns>The Operation Name.</returns>
 public virtual string ItemName(Operation operation)
 {
     if ((operation == Operation.AddAsset))
     {
         return("AddAsset");
     }
     if ((operation == Operation.AddAssetCategory))
     {
         return("AddAssetCategory");
     }
     if ((operation == Operation.AddCustodian))
     {
         return("AddCustodian");
     }
     if ((operation == Operation.AddLookupItem))
     {
         return("AddLookupItem");
     }
     if ((operation == Operation.AdjustAsset))
     {
         return("AdjustAsset");
     }
     if ((operation == Operation.AssignNewAsset))
     {
         return("AssignNewAsset");
     }
     if ((operation == Operation.CalculateDepreciation))
     {
         return("CalculateDepreciation");
     }
     if ((operation == Operation.DeleteAsset))
     {
         return("DeleteAsset");
     }
     if ((operation == Operation.DeleteAssetCategory))
     {
         return("DeleteAssetCategory");
     }
     if ((operation == Operation.DeleteCustodian))
     {
         return("DeleteCustodian");
     }
     if ((operation == Operation.DeleteLookupItem))
     {
         return("DeleteLookupItem");
     }
     if ((operation == Operation.DisposeAsset))
     {
         return("DisposeAsset");
     }
     if ((operation == Operation.EditApplicationSetting))
     {
         return("EditApplicationSetting");
     }
     if ((operation == Operation.ReturnAsset))
     {
         return("ReturnAsset");
     }
     if ((operation == Operation.TransferAsset))
     {
         return("TransferAsset");
     }
     if ((operation == Operation.UpdateAsset))
     {
         return("UpdateAsset");
     }
     if ((operation == Operation.UpdateCustodian))
     {
         return("UpdateCustodian");
     }
     if ((operation == Operation.UpdateLookupItem))
     {
         return("UpdateLookupItem");
     }
     if ((operation == Operation.ViewAssetCategory))
     {
         return("ViewAssetCategory");
     }
     if ((operation == Operation.ViewApplicationSetting))
     {
         return("ViewApplicationSetting");
     }
     if ((operation == Operation.ViewAssetList))
     {
         return("ViewAssetList");
     }
     if ((operation == Operation.ViewCautodianList))
     {
         return("ViewCautodianList");
     }
     throw new System.ArgumentException("Unknown Operation name", "operation");
 }
Exemple #35
0
 public void StoreAction(Operation action, OutPoint outpoint, Script script)
 {
     StoreAction(new ActionItem(action, outpoint, script));
 }
Exemple #36
0
 public ActionItem(Operation action, OutPoint outPoint, Script script)
 {
     Action   = action;
     OutPoint = outPoint;
     Script   = script;
 }
        public void ValidateCachingDirectoryEnumerationReadOnlyMountUntrackedScope(bool maskUntrackedAccesses)
        {
            // When true (default), directory enumerations in untracked scopes are ignored
            // When false, directory enumerations in untracked scopes are tracked as normal
            Configuration.Sandbox.MaskUntrackedAccesses = maskUntrackedAccesses;

            AbsolutePath readonlyRootPath;

            AbsolutePath.TryCreate(Context.PathTable, ReadonlyRoot, out readonlyRootPath);
            DirectoryArtifact dir = DirectoryArtifact.CreateWithZeroPartialSealId(CreateUniqueDirectory(ReadonlyRoot));

            // Enumerate untracked scope /dir and its parent directory
            FileArtifact outFile = CreateOutputFileArtifact();
            var          ops     = new Operation[]
            {
                Operation.EnumerateDir(DirectoryArtifact.CreateWithZeroPartialSealId(readonlyRootPath)),
                Operation.EnumerateDir(dir),
                Operation.WriteFile(outFile)
            };
            var builder = CreatePipBuilder(ops);

            builder.AddUntrackedDirectoryScope(dir);
            Process pip = SchedulePipBuilder(builder).Process;

            RunScheduler().AssertCacheMiss(pip.PipId);
            RunScheduler().AssertCacheHit(pip.PipId);

            string checkpoint1 = File.ReadAllText(ArtifactToString(outFile));

            // Create /dir/nestedFile in untracked scope
            FileArtifact nestedFile = CreateSourceFile(ArtifactToString(dir));

            if (!maskUntrackedAccesses)
            {
                RunScheduler().AssertCacheMiss(pip.PipId);
            }
            RunScheduler().AssertCacheHit(pip.PipId);

            // Modify /dir/nestedFile in untracked scope
            File.WriteAllText(ArtifactToString(nestedFile), "nestedFile");
            RunScheduler().AssertCacheHit(pip.PipId);

            // Delete /dir/nestedFile in untracked scope
            File.Delete(ArtifactToString(nestedFile));
            RunScheduler().AssertCacheHit(pip.PipId);

            string checkpoint2 = File.ReadAllText(ArtifactToString(outFile));

            // Filesystem should match state from original run, so cache replays output from that run
            XAssert.AreEqual(checkpoint1, checkpoint2);

            // Create /dir/nestedDir in untracked scope
            DirectoryArtifact nestedDir = DirectoryArtifact.CreateWithZeroPartialSealId(CreateUniqueDirectory(ArtifactToString(dir)));

            if (!maskUntrackedAccesses)
            {
                RunScheduler().AssertCacheMiss(pip.PipId);
            }
            RunScheduler().AssertCacheHit(pip.PipId);

            // Delete /dir/nestedDir in untracked scope
            Directory.Delete(ArtifactToString(nestedDir));
            RunScheduler().AssertCacheHit(pip.PipId);

            string checkpoint3 = File.ReadAllText(ArtifactToString(outFile));

            // Filesystem should match state from original run, so cache replays output from that run
            XAssert.AreEqual(checkpoint1, checkpoint3);

            // Delete untracked scope /dir
            Directory.Delete(ArtifactToString(dir));
            RunScheduler().AssertCacheMiss(pip.PipId);
            RunScheduler().AssertCacheHit(pip.PipId);
        }
Exemple #38
0
 /// <summary>
 /// Writes a new code point to this program
 /// </summary>
 public int Write(Operation op, int arg1 = 0, int arg2 = 0)
 {
     _maxVariableIndex = -1;
     _program.Add(new ByteCodePoint(op, arg1, arg2));
     return(_program.Count - 1);
 }
Exemple #39
0
 public AIMachineTransition(AIMachineNode n, Process r, Process s, Operation <bool> p) : this(n, new AIMachineCondition_Predicate(r, s, p))
 {
 }
Exemple #40
0
 public AIMachineTransition(AIMachineNode n, Operation <bool> p) : this(n, new AIMachineCondition_Predicate(p))
 {
 }
Exemple #41
0
 /// <summary>
 /// Searches the operation did finish with counts.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <param name="counts">The counts.</param>
 public void SearchOperationDidFinishWithCounts(Operation operation, List <int?> counts)
 {
     // Function part of interface implementation, not applicable here, will never be implemented.
     throw new NotImplementedException();
 }
 private JsonPatchError CreateOperationFailedError(object target, string path, Operation operation, string errorMessage)
 {
     return new JsonPatchError(
         target,
         operation,
         errorMessage ?? Resources.FormatCannotPerformOperation(operation.op, path));
 }
Exemple #43
0
 public static Operation Concat(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Concat, op2);
Exemple #44
0
 /// <summary>
 /// Searches the operation did fail with error.
 /// </summary>
 /// <param name="operation">The operation.</param>
 /// <param name="error">The error.</param>
 public virtual void SearchOperationDidFailWithError(Operation operation, Exception error)
 {
     this.repAcceptanceCrmQuery = null;
     this.Finished(error);
 }
Exemple #45
0
 public static Operation Pow(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Exponent, op2);
Exemple #46
0
 public static Operation Set(Expression target, Expression value) =>
 Operation.Create(target, Operator.Set, value);
Exemple #47
0
	void ProcessRequestBodyMembers(string variableName, Operation operation)
	{

        
        #line default
        #line hidden
        
        #line 91 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(@"			var stringWriter = new XMLEncodedStringWriter(CultureInfo.InvariantCulture);
			using (var xmlWriter = XmlWriter.Create(stringWriter, new XmlWriterSettings() { Encoding = System.Text.Encoding.UTF8, OmitXmlDeclaration = true, NewLineHandling = NewLineHandling.Entitize }))
			{   
");

        
        #line default
        #line hidden
        
        #line 95 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

		if(operation.RequestPayloadMember==null)
		{

        
        #line default
        #line hidden
        
        #line 98 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t\t\t\txmlWriter.WriteStartElement(\"");

        
        #line default
        #line hidden
        
        #line 99 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.Input.LocationName));

        
        #line default
        #line hidden
        
        #line 99 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\", \"");

        
        #line default
        #line hidden
        
        #line 99 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.XmlNamespace));

        
        #line default
        #line hidden
        
        #line 99 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\");\t\r\n");

        
        #line default
        #line hidden
        
        #line 100 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

		}
		else
		{

        
        #line default
        #line hidden
        
        #line 104 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t\t\t\tif (");

        
        #line default
        #line hidden
        
        #line 105 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(variableName + ".IsSet" + operation.RequestPayloadMember.PropertyName));

        
        #line default
        #line hidden
        
        #line 105 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("())\r\n\t\t\t\t{\r\n\t\t\t\t\txmlWriter.WriteStartElement(\"");

        
        #line default
        #line hidden
        
        #line 107 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.RequestPayloadMember.MarshallName));

        
        #line default
        #line hidden
        
        #line 107 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\", \"");

        
        #line default
        #line hidden
        
        #line 107 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.XmlNamespace));

        
        #line default
        #line hidden
        
        #line 107 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\");\r\n");

        
        #line default
        #line hidden
        
        #line 108 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

			PushIndent("	");
		}
		var childmembers = operation.RequestPayloadMember == null ? operation.RequestBodyMembers : operation.RequestPayloadMember.Shape.Members;
		variableName = operation.RequestPayloadMember == null ? variableName : variableName + "." + operation.RequestPayloadMember.PropertyName;
		foreach(var member in childmembers)
		{			
			if(member.IsStructure)
			{
				ProcessStructure(variableName, member, operation.XmlNamespace);				
			}
			else if(member.IsList)
			{
				ProcessList(variableName, member, operation.XmlNamespace);
			}
			else if(member.IsMap)
			{				
				ProcessMap(variableName, member, operation.XmlNamespace);
			}
			else
			{

        
        #line default
        #line hidden
        
        #line 129 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t\t\t\tif(");

        
        #line default
        #line hidden
        
        #line 130 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(variableName));

        
        #line default
        #line hidden
        
        #line 130 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(".IsSet");

        
        #line default
        #line hidden
        
        #line 130 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

        
        #line default
        #line hidden
        
        #line 130 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("())\r\n\t\t\t\t\txmlWriter.WriteElementString(\"");

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\", \"");

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.XmlNamespace));

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\", ");

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PrimitiveMarshaller));

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("(");

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(variableName));

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(".");

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture((member.UseNullable ? ".Value" : string.Empty)));

        
        #line default
        #line hidden
        
        #line 131 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("));\t\t\t\t\t\r\n");

        
        #line default
        #line hidden
        
        #line 132 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

				if(member.IsIdempotent)
				{

        
        #line default
        #line hidden
        
        #line 135 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t\t\t\telse\t\t\t\t\r\n\t\t\t\t\txmlWriter.WriteElementString(\"");

        
        #line default
        #line hidden
        
        #line 137 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

        
        #line default
        #line hidden
        
        #line 137 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\", \"");

        
        #line default
        #line hidden
        
        #line 137 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(operation.XmlNamespace));

        
        #line default
        #line hidden
        
        #line 137 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\", Guid.NewGuid().ToString());\t\t\t\t\r\n");

        
        #line default
        #line hidden
        
        #line 138 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
					
				}

        
        #line default
        #line hidden
        
        #line 141 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(""));

        
        #line default
        #line hidden
        
        #line 141 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\r\n");

        
        #line default
        #line hidden
        
        #line 142 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

			}
			
		}  

        
        #line default
        #line hidden
        
        #line 146 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\r\n\t\t\t\txmlWriter.WriteEndElement();\r\n");

        
        #line default
        #line hidden
        
        #line 149 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

		if(operation.RequestPayloadMember!=null)
		{

        
        #line default
        #line hidden
        
        #line 152 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t\t\t}\r\n");

        
        #line default
        #line hidden
        
        #line 154 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

			PopIndent();
		}

        
        #line default
        #line hidden
        
        #line 157 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t\t\t}\r\n\t\t\ttry \r\n\t\t\t{\r\n\t\t\t\tstring content = stringWriter.ToString();\r\n\t\t\t\trequest.C" +
        "ontent = System.Text.Encoding.UTF8.GetBytes(content);\r\n\t\t\t\trequest.Headers[\"Cont" +
        "ent-Type\"] = \"application/xml\";\r\n");

        
        #line default
        #line hidden
        
        #line 164 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"

					CheckContentMd5Header(operation, "content");

        
        #line default
        #line hidden
        
        #line 166 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\t            request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = \"");

        
        #line default
        #line hidden
        
        #line 167 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.APIVersion));

        
        #line default
        #line hidden
        
        #line 167 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
this.Write("\";            \r\n\t\t\t} \r\n\t\t\tcatch (EncoderFallbackException e) \r\n\t\t\t{\r\n\t\t\t\tthrow ne" +
        "w AmazonServiceException(\"Unable to marshall request to XML\", e);\r\n\t\t\t}\r\n");

        
        #line default
        #line hidden
        
        #line 173 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\RestXmlRequestMarshaller.tt"
				       
	}
Exemple #48
0
 public static Operation Remainder(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Modulo, op2);
Exemple #49
0
 public BoardDa(Operation operation)
 {
     _operation = operation;
 }
Exemple #50
0
 public static Operation Subtract(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Subtraction, op2);
Exemple #51
0
 public Literal(Operation operation)
 {
     this.type      = Type.OPERATION;
     this.operation = operation;
 }
Exemple #52
0
 public static Operation Multiply(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Multiplication, op2);
        /// <summary>
        /// Создание заявки.
        /// </summary>
        /// <param name="classCode">Код класса инструмента</param>
        /// <param name="securityCode">Код инструмента</param>
        /// <param name="accountID">Счет клиента</param>
        /// <param name="operation">Операция заявки (покупка/продажа)</param>
        /// <param name="price">Цена заявки</param>
        /// <param name="qty">Количество (в лотах)</param>
        /// <param name="orderType">Тип заявки (L - лимитная, M - рыночная)</param>
        async Task <Order> SendOrder(string classCode, string securityCode, string accountID, Operation operation, decimal price, int qty, TransactionType orderType)
        {
            long        res                 = 0;
            bool        set                 = false;
            Order       order_result        = new Order();
            Transaction newOrderTransaction = new Transaction
            {
                ACTION    = TransactionAction.NEW_ORDER,
                ACCOUNT   = accountID,
                CLASSCODE = classCode,
                SECCODE   = securityCode,
                QUANTITY  = qty,
                OPERATION = operation == Operation.Buy ? TransactionOperation.B : TransactionOperation.S,
                PRICE     = price,
                TYPE      = orderType
            };

            try
            {
                res = await Quik.Trading.SendTransaction(newOrderTransaction).ConfigureAwait(false);

                Thread.Sleep(500);
                Console.WriteLine("res: " + res);
            }
            catch
            {
                //ignore
            }

            while (!set)
            {
                if (res > 0)
                {
                    try { order_result = await Quik.Orders.GetOrder_by_transID(classCode, securityCode, res).ConfigureAwait(false); }
                    catch { order_result = new Order {
                                RejectReason = "Неудачная попытка получения заявки по ID-транзакции №" + res
                            }; }
                }
                else
                {
                    if (order_result != null)
                    {
                        order_result.RejectReason = newOrderTransaction.ErrorMessage;
                    }
                    else
                    {
                        order_result = new Order {
                            RejectReason = newOrderTransaction.ErrorMessage
                        }
                    };
                }
                if (order_result != null && (order_result.RejectReason != "" || order_result.OrderNum > 0))
                {
                    set = true;
                }
            }
            return(order_result);
        }
Exemple #54
0
 public static Operation Add(Expression op1, Expression op2) =>
 Operation.Create(op1, Operator.Addition, op2);
 /// <summary>
 /// Создание "лимитрированной"заявки.
 /// </summary>
 /// <param name="classCode">Код класса инструмента</param>
 /// <param name="securityCode">Код инструмента</param>
 /// <param name="accountID">Счет клиента</param>
 /// <param name="operation">Операция заявки (покупка/продажа)</param>
 /// <param name="price">Цена заявки</param>
 /// <param name="qty">Количество (в лотах)</param>
 public async Task <Order> SendLimitOrder(string classCode, string securityCode, string accountID, Operation operation, decimal price, int qty)
 {
     return(await SendOrder(classCode, securityCode, accountID, operation, price, qty, TransactionType.L).ConfigureAwait(false));
 }
 public void CreateOperation(
     Operation o)
 {
     return;
 }
Exemple #57
0
 public ConsoleLog(Operation operation)
 {
     operation.EventLogHandler += print;
 }
 /// <summary>
 /// Создание "рыночной"заявки.
 /// </summary>
 /// <param name="classCode">Код класса инструмента</param>
 /// <param name="securityCode">Код инструмента</param>
 /// <param name="accountID">Счет клиента</param>
 /// <param name="operation">Операция заявки (покупка/продажа)</param>
 /// <param name="qty">Количество (в лотах)</param>
 public async Task <Order> SendMarketOrder(string classCode, string securityCode, string accountID, Operation operation, int qty)
 {
     return(await SendOrder(classCode, securityCode, accountID, operation, 0, qty, TransactionType.M).ConfigureAwait(false));
 }
Exemple #59
0
        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            while (true)
            {
                bool success = false;

                try
                {
                    using (var db = ApplicationDbContext.Create())
                    {
                        Operation next = null;

                        next = db.Operations.Where(x => x.Status == OperationStatus.Queued).OrderBy(x => x.Id).FirstOrDefault();
                        if (next == null)
                        {
                            break;
                        }

                        logger.Info("Beginning operation: " + next.OperationName);

                        next.Status    = OperationStatus.Working;
                        next.StartedOn = DateTime.UtcNow;
                        db.SaveChanges();

                        IOperation operation = GetOperation(next);
                        MefConfig.Container.SatisfyImportsOnce(operation);


                        // Perform the operation, with error handling.
                        try
                        {
                            success = operation.Execute();
                        }
                        catch (EmptyCommitException emptyCommitException)
                        {
                            logger.Debug("No changes to commit, files were identical. " + emptyCommitException.Message);
                            success = true;
                        }
                        catch (Exception operationException)
                        {
                            logger.Error("Error in operation execution.", operationException);
                            success = false;
                        }


                        // Mark the operation as completed or in error.
                        if (success)
                        {
                            next.Status = OperationStatus.Completed;
                        }
                        else
                        {
                            next.Status = OperationStatus.Error;
                        }
                        next.CompletedOn = DateTime.UtcNow;


                        // Update the catalog record status.
                        CatalogRecord record = db.CatalogRecords.Where(x => x.Id == next.CatalogRecordContext).FirstOrDefault();
                        if (record != null)
                        {
                            record.OperationLockId = null;
                            record.OperationStatus = string.Empty;
                        }

                        int changes = db.SaveChanges();
                    } //end using
                }     //end try
                catch (Exception ex)
                {
                    logger.Error("Error while processing operations.", ex);
                    success = false;
                }
            } //end while there are operations to process

            timer.Interval = 1000 * 10;
            timer.Enabled  = true;
        }
        public ResourceDetails GetResouceDetails(string groupPath)
        {
            var swaggerSpec = new ResourceDetails
            {
                swaggerVersion = "1.2",
                apiVersion     = Assembly.GetCallingAssembly().GetName().Version.ToString(),
                apis           = new List <ApiDetails>(),
                resourcePath   = "/",
                basePath       = "/"
            };

            var groupOperations =
                Operations().Where(x => x.Group.Path.Equals(groupPath, StringComparison.InvariantCultureIgnoreCase));

            var typeMapper = new TypeMapper();

            foreach (var operationMetadata in groupOperations)
            {
                var mappedReturnType = typeMapper.Register(operationMetadata.ReturnType);

                var op = new Operation
                {
                    method           = operationMetadata.HttpVerb,
                    nickname         = operationMetadata.Nickname ?? "",
                    notes            = operationMetadata.Notes ?? "",
                    type             = mappedReturnType.Type,
                    items            = mappedReturnType.Items,
                    summary          = operationMetadata.Summary ?? "",
                    parameters       = new List <Parameter>(),
                    responseMessages = new List <Responsemessage>()
                };

                foreach (var header in SwaggerGenerator.Configuration.Headers)
                {
                    op.parameters.Add(new Parameter
                    {
                        paramType   = "header",
                        name        = header.Name,
                        required    = true,
                        description = header.SuggestedValue,
                        type        = "string",
                        minimum     = 1,
                        maximum     = 1
                    });
                }

                foreach (var param in operationMetadata.InputParameters)
                {
                    var swagParam = typeMapper.Map(param);
                    swagParam.paramType = param.LocationType.ToString().ToLower();
                    op.parameters.Add(swagParam);
                }

                foreach (var code in operationMetadata.ResponseCodes)
                {
                    op.responseMessages.Add(new Responsemessage {
                        code = code.StatusCode, message = code.Description
                    });
                }

                swaggerSpec.apis.Add(new ApiDetails
                {
                    description = operationMetadata.Summary,
                    path        = operationMetadata.UriParser.Path,
                    operations  = new List <Operation> {
                        op
                    }
                });
            }

            foreach (var item in typeMapper.Models)
            {
                swaggerSpec.models.Add(item.id, item);
            }

            return(swaggerSpec);
        }