public void UpdateJobStatus(Model.JobInfo jobInfo, Model.JobProcessStatus status)
        {
            if (!Active)
                return;
            
            Logger.Log.Instance.Info(string.Format("DefaultJobHistoryUpdater. Update Job status. JobId: {0}, Status: {1}",
                jobInfo.JobId,
                status.ToString()));

            using (var connection = new SqlConnection(RoleSettings.DbConnectionString))
            {
                connection.Open();
                var commandText = "INSERT INTO JobHistory (JobId,Status,UpdateDate,ProcessingRole) VALUES (@JobId,@Status, GETDATE(),@RoleId)";

                using (var command = new SqlCommand(commandText, connection))
                {
                    command.Parameters.Add("@JobId", SqlDbType.NVarChar);
                    command.Parameters["@JobId"].Value = jobInfo.JobId;

                    command.Parameters.Add("@Status", SqlDbType.NVarChar);
                    command.Parameters["@Status"].Value = status.ToString();

                    command.Parameters.Add("@RoleId", SqlDbType.NVarChar);
                    command.Parameters["@RoleId"].Value = RoleSettings.RoleId;

                    command.ExecuteNonQuery();
                }

                connection.Close();
            }
        }
 public Model.PagedList<Model.Employee> GetEmployees(int pageNumber = 1, int pageSize = 20, string orderBy = "Id", Model.SortingOrder sortingOrder = Model.SortingOrder.DESC)
 {
     using (var connection = new SqlConnection(Configurations.EmployeeDbConnectionString))
     {
         var addRemarkCommand = new SqlCommand("spGetEmployees", connection);
         addRemarkCommand.CommandType = System.Data.CommandType.StoredProcedure;
         addRemarkCommand.Parameters.Add(new SqlParameter("@PageNumber", pageNumber));
         addRemarkCommand.Parameters.Add(new SqlParameter("@PageSize", pageSize));
         addRemarkCommand.Parameters.Add(new SqlParameter("@OrderBy", orderBy));
         addRemarkCommand.Parameters.Add(new SqlParameter("@SortingOrder", sortingOrder.ToString()));
         var resultReader = addRemarkCommand.ExecuteReader();
         int totalRecords = 0;
         var pagedList = new Model.PagedList<Model.Employee>();
         if (resultReader.HasRows)
         {
             while (resultReader.Read())
             {
                 pagedList.Add(ParseEmployee(resultReader));
                 totalRecords = (int)resultReader["TotalResults"];
             }
         }
         pagedList.PageSize = pageSize;
         pagedList.PageNumber = pageNumber;
         pagedList.TotalRecords = totalRecords;
         return pagedList;
     }
 }
 public Model.PagedList<Model.Remark> GetRemarks(string employeeId, int pageNumber = 1, int pageSize = 20, string orderBy = "Id", Model.SortingOrder sortingOrder = Model.SortingOrder.DESC)
 {
     using (var connection = new SqlConnection(Configurations.EmployeeDbConnectionString))
     {
         var addRemarkCommand = new SqlCommand("spGetRemarksForEmployee", connection);
         addRemarkCommand.CommandType = System.Data.CommandType.StoredProcedure;
         addRemarkCommand.Parameters.Add(new SqlParameter("@EmployeeId", long.Parse(employeeId)));
         addRemarkCommand.Parameters.Add(new SqlParameter("@PageNumber", pageNumber));
         addRemarkCommand.Parameters.Add(new SqlParameter("@PageSize", pageSize));
         addRemarkCommand.Parameters.Add(new SqlParameter("@OrderBy", orderBy));
         addRemarkCommand.Parameters.Add(new SqlParameter("@SortingOrder", sortingOrder.ToString()));
         var resultReader = addRemarkCommand.ExecuteReader();
         int totalRecords = 0;
         var pagedList = new Model.PagedList<Model.Remark>();
         if (resultReader.HasRows)
         {
             while (resultReader.Read())
             {
                 pagedList.Add(new Model.Remark()
                 {
                     Text = (string)resultReader["RemarkText"],
                     CreateTimeStamp = (DateTime)resultReader["CreateTimestamp"]
                 });
                 totalRecords = (int)resultReader["TotalResults"];
             }
         }
         pagedList.PageSize = pageSize;
         pagedList.PageNumber = pageNumber;
         pagedList.TotalRecords = totalRecords;
         return pagedList;
     }
 }
Example #4
0
 public static string Render(Model.CSSDocument css)
 {
     StringBuilder txt = new StringBuilder();
     //foreach (Import imp in css.Imports) {
     //    txt.AppendFormat("{0}\r\n", imp.ToString());
     //}
     //foreach (Media mtg in css.Medias) {
     //    txt.AppendFormat("@media{0} {{\r\n", mtg.Media != Media.None ? " " + mtg.Media.ToString() : "");
     //    foreach (Selector sel in mtg.Selectors) {
     //        txt.Append(Render(sel, 1));
     //        txt.Append("\r\n");
     //    }
     //    txt.Append("}\r\n");
     //}
     //foreach (Selector sel in css.Selectors) {
     //    txt.Append(Render(sel));
     //    txt.Append("\r\n");
     //}
     txt.Append(css.ToString());
     return txt.ToString();
 }
        /// <summary>
        /// Sends the async.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="type">The type.</param>
        /// <param name="endOfMessage">if set to <c>true</c> [end of message].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public async Task SendAsync(byte[] bytes, Model.Net.WebSocketMessageType type, bool endOfMessage, CancellationToken cancellationToken = default(CancellationToken))
        {
            await _sendResource.WaitAsync(cancellationToken).ConfigureAwait(false);

            try
            {
                WebSocketMessageType nativeType;

                if (!Enum.TryParse(type.ToString(), true, out nativeType))
                {
                    _logger.Warn("Unrecognized WebSocketMessageType: {0}", type.ToString());
                }

                var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, _cancellationTokenSource.Token);

                await _client.SendAsync(new ArraySegment<byte>(bytes), nativeType, true, linkedTokenSource.Token).ConfigureAwait(false);
            }
            finally
            {
                _sendResource.Release();
            }
        }
 public void AdFailed(Model.AdType AdType)
 {
     _settings.AdFailed(AdType);
     OnLog(string.Format("Ads failed request for: {0}", AdType.ToString()));
     GetAd(null);
 }
Example #7
0
 /// <summary>
 /// 更新状态栏
 /// </summary>
 private void UpdateStatus(Model.DoState doState)
 {
     this.toolStripStatusLabel2.Text = doState.ToString();
     this.toolStripProgressBar1.Value = (int)doState.DoPercent;
     if (doState.CurrentCount == doState.SumCount)
     {
         this.btnSave.Enabled = true;
         this.txtLog.AppendText("文件已全部处理完毕!" + Environment.NewLine);
         this.dgFiles.DataSource = fileBLL.GetAllList();
     }
 }
Example #8
0
        /// <summary>
        /// Update picture in database
        /// </summary>
        /// <param name="item">Picture to update</param>
        /// <returns>Picture info</returns>
        public PictureExecutionResult UpdatePicture(Model.Picture item)
        {
            UpdateSessionCulture();
            using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, RaiseLog))
                try
                {
                    using (var rep = GetNewRepository(logSession))
                    {
                        var itm = rep
                            .Get<Repository.Model.File>(p => p.FileId == item.FileId, asNoTracking: true)
                            .LeftOuterJoin(rep.Get<Repository.Model.Picture>(asNoTracking: true), f=>f.FileId, p=>p.FileId, (File,Picture) => new { File, Picture })
                            .FirstOrDefault();

                        if (itm == null || itm.File == null)
                            throw new Exception(string.Format(Properties.Resources.FILESERVICE_FileNotFound, item.FileId));

                        var dbPicture = AutoMapper.Mapper.Map<Repository.Model.Picture>(item);
                        rep.AddOrUpdate(dbPicture, state: (itm.Picture != null ? System.Data.Entity.EntityState.Modified : System.Data.Entity.EntityState.Added) );
                    }
                    return GetPicture(item.FileId);
                }
                catch (Exception ex)
                {
                    ex.Data.Add(nameof(item), item.ToString());
                    logSession.Enabled = true;
                    logSession.Add(ex);
                    return new PictureExecutionResult(ex);
                }
        }
Example #9
0
		public void SmartDelete(List<ThreadUsr.StatusEnum> threadStatusesToChange, Model.Entities.ObjectType? statusChangeObjectType, int? statusChangeObjectK)
		{
			string memcachedKey = new Caching.CacheKey(Caching.CacheKeyPrefix.UpdateThreadUsrJobStatus, "UsrK", this.K.ToString(), "StatusChangeObjectType", statusChangeObjectType.ToString(), "StatusChangeObjectK", statusChangeObjectK.ToString()).ToString();
			SmartDeleteThreadUsrJob sdtuj = new SmartDeleteThreadUsrJob(this.K, threadStatusesToChange, statusChangeObjectType, statusChangeObjectK, memcachedKey);
			sdtuj.ExecuteAsynchronously();
		}
Example #10
0
        /// <summary>
        /// Gets the cache file path based on a set of parameters
        /// </summary>
        private string GetCacheFilePath(string originalPath, ImageSize outputSize, int quality, DateTime dateModified, Model.Drawing.ImageFormat format, bool addPlayedIndicator, double percentPlayed, int? unwatchedCount, string backgroundColor)
        {
            var filename = originalPath;

            filename += "width=" + outputSize.Width;

            filename += "height=" + outputSize.Height;

            filename += "quality=" + quality;

            filename += "datemodified=" + dateModified.Ticks;

            filename += "f=" + format;

            var hasIndicator = false;

            if (addPlayedIndicator)
            {
                filename += "pl=true";
                hasIndicator = true;
            }

            if (percentPlayed > 0)
            {
                filename += "p=" + percentPlayed;
                hasIndicator = true;
            }

            if (unwatchedCount.HasValue)
            {
                filename += "p=" + unwatchedCount.Value;
                hasIndicator = true;
            }

            if (hasIndicator)
            {
                filename += "iv=" + IndicatorVersion;
            }

            if (!string.IsNullOrEmpty(backgroundColor))
            {
                filename += "b=" + backgroundColor;
            }

            return GetCachePath(ResizedImageCachePath, filename, "." + format.ToString().ToLower());
        }
Example #11
0
 /// <summary>
 /// 查询默认命名空间
 /// </summary>
 /// <param name="namespace1"></param>
 /// <returns></returns>
 public Model.ConfigServers GetDefault(Model.DatabaseType dbType = Model.DatabaseType.Empty)
 {
     var list = GetAll();
     if (list.Count == 0)
     {
         return null;
     }
     else
     {
         if (dbType == Model.DatabaseType.Empty)
         {
             return list.Last();
         }
         else
         {
             var li = list.Where(p => p.Type == dbType.ToString());
             var rli = li.Count() > 0 ? li.Last() : null;
             return rli;
         }
     }
 }
 /*!
    \brief Check whether the logical context is satisfiable,
    and compare the result with the expected result.
    If the context is satisfiable, then display the model.
 */
 public void check(Status expected_result, out Model model)
 {
     Status result = solver.Check();
     model = null;
     Console.WriteLine("{0}", result);
     switch (result)
     {
         case Status.UNSATISFIABLE:
             break;
         case Status.UNKNOWN:
             break;
         case Status.SATISFIABLE:
             model = solver.Model;
             Console.WriteLine("{0}", model.ToString());
             break;
     }
     if (result != expected_result)
     {
         Console.WriteLine("BUG: unexpected result");
     }
 }
Example #13
0
        /// <summary>
        /// 90 degree rotation of the cube with rotation axis-z in vertical direction
        /// </summary>
        /// <param name="direction">The direction (left/right) of the cube</param>
        public void rotateVertical90(Model.Direction direction, bool isRecorded = true)
        {
            string directionText = direction.ToString();

            rotateSurface(Model.CubeSurface.Right, direction, false);
            rotateSurface(Model.CubeSurface.MiddleVertical, direction, false);
            rotateSurface(Model.CubeSurface.Left, direction == Model.Direction.Right ? Model.Direction.Left : Model.Direction.Right, false);
            string imgLocation = direction == Model.Direction.Right ? ImageLocation.VerticalRight90 : ImageLocation.VerticalLeft90;

            if (isRecorded)
            {
                // Step +1
                this.numberSteps++;
                this.History.Add(new Model.HistoryItem(this.Clone(), NumberSteps, String.Format("90 degree vertical {0}", directionText), imgLocation));
            }
        }
Example #14
0
        /// <summary>
        /// Create the order specified
        /// </summary>
        /// <param name="businessId">business for order</param>
        /// <param name="order">order to create</param>
        public void CreateOrder(long businessId, Model.Order.Order order)
        {
            // do the sql
            const string SQL_INSERT = @"DECLARE @CustomerCultureCode        nvarchar(11),
                                          @CustomerTimezoneId        int,
                                          @OrderRef                 nvarchar(11),
                                          @BusinessReference        nvarchar(10)

                                  SELECT  @CustomerCultureCode = B.DefaultCultureCode,
                                          @CustomerTimezoneId = B.TimezoneId,
                                          @BusinessReference = B.ReferenceCode
                                  FROM      Business.Business as B
                                  INNER JOIN Business.BusinessStatus as S ON B.BusinessStatusCode = S.Code
                                  WHERE      Id = @BusinessId

                                  exec booking.GetOrderReference
                                    @Reference = @OrderRef out

                                  INSERT INTO Booking.Orders (OrderSourceCode, ChannelId, ChannelReference, IntegrationTypeCode, AgentId, OfflineSourceCode,
                                                            CustomerCultureCode, CustomerCurrencyCode, CustomerTimezoneId, LeadGuestId, UpdatedByUserId, GroupReference, 
                                                            OrderReference, Notes, IsIssue, ReasonForIssue, BusinessReference)
                                  VALUES (@OrderSourceCode, @ChannelId, @ChannelReference, @IntegrationTypeCode, @AgentId, @OfflineSourceCode,
                                        @CustomerCultureCode, @CustomerCurrencyCode, @CustomerTimezoneId, @LeadGuestId, @UpdatedByUserId, @GroupReference, 
                                        @OrderRef, @Notes, @IsIssue, @ReasonForIssue, @BusinessReference)

                                  SELECT @Id = SCOPE_IDENTITY()";

            SqlParameter orderIdParam = DbHelper.CreateParameterOut<int>(OrderMapper.Parameters.Id, System.Data.SqlDbType.Int);

            var parameters = new List<SqlParameter>
                {
                    DbHelper.CreateParameter(OrderMapper.Parameters.OrderSourceCode, order.OrderSourceCode),
                    DbHelper.CreateParameter(OrderMapper.Parameters.ChannelId, order.ChannelId),
                    DbHelper.CreateParameter(OrderMapper.Parameters.ChannelReference, order.ChannelReference),
                    DbHelper.CreateParameter(OrderMapper.Parameters.IntegrationTypeCode, order.IntegrationType != null && order.IntegrationType != IntegrationTypeEnum.Unknown ? order.IntegrationType.GetCode() : null),
                    DbHelper.CreateParameter(OrderMapper.Parameters.AgentId, order.AgentId),
                    DbHelper.CreateParameter(OrderMapper.Parameters.OfflineSourceCode, order.OfflineSourceEnum.HasValue ? order.OfflineSourceEnum.GetCode() : null),
                    DbHelper.CreateParameter(OrderMapper.Parameters.CustomerCurrencyCode, order.CustomerCurrencyCode),
                    DbHelper.CreateParameter(BookingMapper.Parameters.BusinessId, businessId),
                    DbHelper.CreateParameter(OrderMapper.Parameters.LeadGuestId, order.LeadGuestId),
                    DbHelper.CreateParameter(OrderMapper.Parameters.GroupReference, order.GroupReference),
                    DbHelper.CreateParameter(OrderMapper.Parameters.Notes, order.Notes),
                    DbHelper.CreateParameter(OrderMapper.Parameters.IsIssue, order.IsIssue),
                    DbHelper.CreateParameter(OrderMapper.Parameters.ReasonForIssue, order.ReasonForIssue),
                    orderIdParam
                };

            AuditFieldsHelper.PopulateAuditFields(parameters);

            // execute
            DbHelper.ExecuteNonQueryCommand(SQL_INSERT, System.Data.CommandType.Text, parameters);
            
            // Make sure the record was created
            if (orderIdParam.Value == DBNull.Value)
            {
                throw new PrimaryKeyNotSetException(ErrorFactory.CreateAndLogError(Errors.SRVEX30112, "OrderDao.Create", additionalDescriptionParameters: (new object[] { "order", order.ToString() }), descriptionParameters: (new object[] { "order" })));
            }

            // set the id
            order.Id = DbHelper.ParameterValue<int>(orderIdParam);
        }
Example #15
0
 public string GenerateFullFile(Model.FullFile file)
 {
     return file.ToString();
 }
Example #16
0
 public static Intermediate.Operand Operand(Model.Register r)
 {
     return Operand(r.ToString());
 }
Example #17
0
		public void UpdateThreadUsrs(ThreadUsr.StatusEnum changeStatus, List<ThreadUsr.StatusEnum> threadStatusesToChange, Model.Entities.ObjectType? statusChangeObjectType, int? statusChangeObjectK)
		{
			string memcachedKey = new Caching.CacheKey(Caching.CacheKeyPrefix.UpdateThreadUsrJobStatus, "UsrK", this.K.ToString(), "StatusChangeObjectType", statusChangeObjectType.ToString(), "StatusChangeObjectK", statusChangeObjectK.ToString()).ToString();
			UpdateThreadUsrJob utuj = new UpdateThreadUsrJob(this.K, changeStatus, threadStatusesToChange, statusChangeObjectType, statusChangeObjectK, memcachedKey);
			utuj.ExecuteAsynchronously();

			//Update uThreadUsr = new Update();
			//uThreadUsr.Table = TablesEnum.ThreadUsr;
			//uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.Status, changeStatus));
			//uThreadUsr.Changes.Add(new Assign(ThreadUsr.Columns.StatusChangeDateTime, Time.Now));
			//uThreadUsr.Where = new Q(ThreadUsr.Columns.UsrK, this.K);

			//if (threadStatusesToChange != null && threadStatusesToChange.Count > 0)
			//{
			//    Or statusOr = new Or();
			//    foreach (ThreadUsr.StatusEnum statusEnum in threadStatusesToChange)
			//    {
			//        statusOr = new Or(statusOr,
			//                        new Q(ThreadUsr.Columns.Status, statusEnum));
			//    }
			//    uThreadUsr.Where = new And(uThreadUsr.Where,
			//                               statusOr);
			//}
			//else
			//    throw new Exception("Usr.UpdateThreadUsrs(): Invalid list of ThreadUsr.StatusEnum to change.");


			//if (statusChangeObjectType != null)
			//{
			//    if (statusChangeObjectType.Value == Model.Entities.ObjectType.Usr)
			//    {
			//        // do nothing here
			//    }
			//    else
			//    {
			//        uThreadUsr.Where = new And(uThreadUsr.Where,
			//                                   new Q(ThreadUsr.Columns.StatusChangeObjectType, statusChangeObjectType.Value));
			//    }

			//    if (statusChangeObjectK != null)
			//    {
			//        if (statusChangeObjectType.Value == Model.Entities.ObjectType.Usr)
			//        {
			//            uThreadUsr.Where = new And(uThreadUsr.Where,
			//                                       new Q(ThreadUsr.Columns.InvitingUsrK, statusChangeObjectK.Value));
			//        }
			//        else
			//        {
			//            uThreadUsr.Where = new And(uThreadUsr.Where,
			//                                       new Q(ThreadUsr.Columns.StatusChangeObjectK, statusChangeObjectK.Value));
			//        }
			//    }
			//}
			//uThreadUsr.CommandTimeout = 90;
			//uThreadUsr.Run();
		}
        /// <summary>
        /// Sends the async.
        /// </summary>
        /// <param name="bytes">The bytes.</param>
        /// <param name="type">The type.</param>
        /// <param name="endOfMessage">if set to <c>true</c> [end of message].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task.</returns>
        public Task SendAsync(byte[] bytes, Model.Net.WebSocketMessageType type, bool endOfMessage, CancellationToken cancellationToken)
        {
            WebSocketMessageType nativeType;

            if (!Enum.TryParse(type.ToString(), true, out nativeType))
            {
                _logger.Warn("Unrecognized WebSocketMessageType: {0}", type.ToString());
            }

            return _client.SendAsync(new ArraySegment<byte>(bytes), nativeType, true, cancellationToken);
        }
 public PostBulkDocuments(IDatabase db, Model.BulkDocuments documents)
     : base(UriBuilder.Build(db, documents), new Http.Methods.Post())
 {
     _stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(documents.ToString()));
 }
 /// <summary>
 /// Creates a statement verb from the 0.90 set of verbs.
 /// </summary>
 /// <param name="verb"></param>
 /// <remarks>You really shouldn't be using this method.  It's simply used as an easy way to promote the
 /// verb enum to the verb class.</remarks>
 public StatementVerb(Model.TinCan090.StatementVerb verb)
     : this((PredefinedVerbs)Enum.Parse(typeof(PredefinedVerbs), verb.ToString(), true))
 {
 }
Example #21
0
 private void assignSpecific(int id, Model model)
 {
     GameObject target;
     GameObject targetLabel;
     switch (id)
     {
         case 0:
             target = d_original;
             targetLabel = d_originalLabel;
             break;
         case 1:
             target = d_copy;
             targetLabel = d_copyLabel;
             break;
         case 2:
             target = t_original;
             targetLabel = t_originalLabel;
             break;
         case 3:
             target = t_copyA;
             targetLabel = t_copyALabel;
             break;
         case 4:
             target = t_copyB;
             targetLabel = t_copyBLabel;
             break;
         default:
             MonoBehaviour.print("Illegal specific model assign("+id+")");
             return;
             //break;
     }
     setupModel(target, model);
     if (!sceneParameters.hide_labels)
     {
         if (model != null)
         {
             targetLabel.GetComponent<TextMesh>().text = model.ToString();
         }
         else
         {
             targetLabel.GetComponent<TextMesh>().text = "NULL";
         }
     }
 }
Example #22
0
        /// <summary>
        /// Update file in database
        /// </summary>
        /// <param name="file">File to update</param>
        /// <returns>File info</returns>
        public FileExecutionResult Update(Model.File item)
        {
            UpdateSessionCulture();
            using (var logSession = Helpers.Log.Session($"{GetType()}.{System.Reflection.MethodBase.GetCurrentMethod().Name}()", VerboseLog, RaiseLog))
                try
                {
                    using (var rep = GetNewRepository(logSession))
                    {
                        SRVCCheckCredentials(logSession, rep, Repository.Model.RightType.Login, Repository.Model.RightType.UploadFile);

                        logSession.Add($"Try to get file with id = '{item.Id}' from database...");

                        var dbFile = rep.GetFile(item.Id);
                        if (dbFile == null)
                            throw new Exception(string.Format(Properties.Resources.FILESERVICE_FileNotFound, item.Id));

                        if (item.EncodingName != null)
                            dbFile.Encoding = item.Encoding;

                        dbFile.MimeType = (string.IsNullOrEmpty(item.Mime))
                            ? FileStorage.MimeStorage.GetMimeTypeByExtension(dbFile.UniqueFileName)
                            : item.Mime;

                        if (!string.IsNullOrEmpty(item.Name))
                        {
                            dbFile.FileName = System.IO.Path.GetFileName(item.Name);

                            logSession.Add($"Try to rename file in file storage...");
                            var fi = MainFileStorage.FileRename(item.Id, dbFile.FileName);
                            dbFile.UniqueFileName = fi.Name;
                        }

                        logSession.Add($"Try to update file in database...");
                        rep.SaveChanges();

                        return new FileExecutionResult(AutoMapper.Mapper.Map<Model.File>(dbFile));
                    }
                }
                catch (Exception ex)
                {
                    ex.Data.Add(nameof(item), item.ToString());
                    logSession.Enabled = true;
                    logSession.Add(ex);
                    return new FileExecutionResult(ex);
                }
        }