Ejemplo n.º 1
0
        private static void GetAC()
        {
            PadSYNC.Model.AssignCourse ac = AssignCourseBLL.GetById(16961);
            string json = JsonConvert.SerializeObject(ac);

            ac.AssignID      = 0;
            ac.AsignCourseID = 0;
            ac.StartTime     = new DateTime(2015, 1, 30, 12, 0, 0);
            ac.EndTime       = new DateTime(2015, 1, 30, 13, 0, 0);


            AssignCourseDataContract acdc = Translate.TranslateAssignCourseEntityToGuest(ac);
            bool   b      = false;
            string result = "";
            AssignCourseServiceClient client = new AssignCourseServiceClient();

            Console.WriteLine("处理消息*---*");
            if (ac.PadOperType == 0)
            {
                b = client.AddNewAssignCourseRetErrowString(out result, acdc);
            }
            else
            {
                List <CancelReasonConditionsDataContract> CancelReasonConditionsList = new List <CancelReasonConditionsDataContract>();
                CancelReasonConditionsDataContract        cancelReasonConditions     = new CancelReasonConditionsDataContract();
                cancelReasonConditions.AssignID = ac.AsignCourseID;
                cancelReasonConditions.Reason   = "";
                CancelReasonConditionsList.Add(cancelReasonConditions);
                CancelReasonConditionsDataContract[] arr = CancelReasonConditionsList.ToArray();
                b      = client.CancleAssignCourse(arr, 0, 0, 1);
                result = "取消失败";
            }
            Console.WriteLine("处理成功 {0}", "*---*" + result);
        }
Ejemplo n.º 2
0
        public ActionResult Upadate(long AssignID)
        {
            PadSYNC.Model.AssignCourse ac = PadSYNC.BLL.AssignCourseBLL.GetById(AssignID);
            try
            {
                ac.Gid = Guid.NewGuid();
                //新增必须为0,不为0会更改原纪录
                ac.AssignID = 0;
                //排课状态为排定
                ac.AsignStatus = 1;
                //5表示来源是Pad
                ac.CourseSourceType = 5;
                //异常类型
                ac.AbnormalReasonType = 0;
                string        json = JsonConvert.SerializeObject(ac);
                SYNCOperation op   = new SYNCOperation();
                op.Id     = ac.AssignID;
                op.Gid    = ac.Gid;
                op.Name   = "AssignCourse";
                op.Status = 0;
                SYNCOperationBLL.Insert(op);
                Send.Push(json);
                string result = "Success";
                return(Content(result, "application/json"));
            }
            catch (Exception ex)
            {
                return(Content(ex.Message, "application/json"));
            }

            //return View();
        }
Ejemplo n.º 3
0
        public ActionResult UpdateCourse(string data)
        {
            Random r = new Random();
            int    x = r.Next(100);

            Send.Push(x.ToString());
            return(Content(x.ToString()));

            //AssignCourse ac = AssignCourseBLL.GetById(19249005);
            PadSYNC.Model.AssignCourse ac = JsonConvert.DeserializeObject <PadSYNC.Model.AssignCourse>(data);
            ac.AssignID = 0;
            //ac.AsignCourseID = 0;
            ac.AsignStatus        = 1;
            ac.CourseSourceType   = 5;
            ac.AbnormalReasonType = 0;
            //ac.StartTime = new DateTime(2014, 12, 11, 8, 0, 0);
            //ac.EndTime = new DateTime(2014, 12, 11, 10, 0, 0);
            //ac.AssignCount = 2;
            AssignCourseDataContract acdc = AssignCourseTranslateEntityAndDataContract.TranslateAssignCourseEntityToGuest(ac);
            bool   b      = false;
            string result = "Failed";

            try
            {
                AssignCourseServiceClient client = new AssignCourseServiceClient();
                //b = client.AddNewAssignCourseRetErrowString(acdc, out result);
                if (b)
                {
                    result = "Success";
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(Content(result, "application/json"));
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //test
            //Test();
            //return;

            //GetAC();
            //return;
            //test over
            string hostName = ConfigurationManager.AppSettings["RabbitMQHostName"];
            string userName = ConfigurationManager.AppSettings["RabbitMQUserName"];
            string password = ConfigurationManager.AppSettings["RabbitMQPassword"];
            var    factory  = new ConnectionFactory()
            {
                HostName = hostName, UserName = userName, Password = password
            };

            factory.AutomaticRecoveryEnabled = true;
            using (var connection = factory.CreateConnection())
            {
                using (var channel = connection.CreateModel())
                {
                    channel.QueueDeclare("AssignCourseSYNC", true, false, false, null);
                    var consumer = new QueueingBasicConsumer(channel);
                    channel.BasicConsume("AssignCourseSYNC", false, consumer);

                    Console.WriteLine(" [*] Waiting for messages." +
                                      "To exit press CTRL+C");
                    while (true)
                    {
                        var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue();
                        Console.WriteLine("获得消息*---*" + ea.DeliveryTag);
                        var body    = ea.Body;
                        var message = Encoding.UTF8.GetString(body);
                        PadSYNC.Model.AssignCourse ac = null;
                        SYNCOperation op = null;
                        //清除消息队列用
                        //channel.BasicAck(ea.DeliveryTag, false);
                        //continue;
                        try
                        {
                            #region 处理消息
                            ac = JsonConvert.DeserializeObject <PadSYNC.Model.AssignCourse>(message);
                            //ac.Gid = new Guid("D67C7F51-29A1-4CA8-ACDF-08512FB3E8DF");
                            op = SYNCOperationBLL.GetById(ac.Gid);
                            //op.Id = ac.AssignID;


                            AssignCourseDataContract acdc = Translate.TranslateAssignCourseEntityToGuest(ac);
                            bool   b      = false;
                            string result = "";
                            AssignCourseServiceClient client = new AssignCourseServiceClient();
                            Console.WriteLine("处理消息*---*" + ea.DeliveryTag);
                            if (ac.PadOperType == 0)
                            {
                                b = client.AddNewAssignCourseRetErrowString(out result, acdc);
                            }
                            else
                            {
                                List <CancelReasonConditionsDataContract> CancelReasonConditionsList = new List <CancelReasonConditionsDataContract>();
                                CancelReasonConditionsDataContract        cancelReasonConditions     = new CancelReasonConditionsDataContract();
                                cancelReasonConditions.AssignID = ac.AssignID;
                                cancelReasonConditions.Reason   = "";
                                CancelReasonConditionsList.Add(cancelReasonConditions);
                                CancelReasonConditionsDataContract[] arr = CancelReasonConditionsList.ToArray();
                                b      = client.CancleAssignCourse(arr, 0, 0, 1);
                                result = "取消失败";
                            }

                            if (b)
                            {
                                result    = "Success";
                                op.Status = 1;
                            }
                            else
                            {
                                op.Status  = 2;
                                op.Content = result;
                            }
                            Console.WriteLine("处理成功 {0}", op.Gid + "*---*" + result);
                            channel.BasicAck(ea.DeliveryTag, false);
                            #endregion
                        }
                        catch (Exception ex)
                        {
                            if (op != null)
                            {
                                op.Status  = 2;
                                op.Content = ex.Message;
                            }
                            Console.WriteLine("处理失败 {0}", "*---*" + ex.Message);
                        }
                        if (op != null)
                        {
                            SYNCOperationBLL.Save(op);
                        }

                        //Thread.Sleep(3000);
                    }
                }
            }
        }