Exemple #1
0
 private static void Host_RefreshOperation(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     //刷新操作
     CardManager.CardInfos.Clear();
     byte[] bys;
     try
     {
         bys = PortAgreement.ReadAllCard();
         bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, bys);
         if (ret)
         {
             ReceivedManager.SetReceivedFunction <CardRefresh>();
         }
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
     finally
     {
         bys = null;
     }
 }
Exemple #2
0
        private static void Host_PostPersonnelIssue(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                int index = e.Arguments[0].IntValue;
                Chromium.Remote.CfrTime cTime = e.Arguments[1].DateValue;
                DateTime time       = new DateTime(cTime.Year, cTime.Month, cTime.DayOfMonth);
                int      partition  = e.Arguments[2].IntValue;
                int      dataType   = e.Arguments[3].IntValue;
                string   customData = e.Arguments[4].StringValue;

                CardInfo info = CardManager.CardInfos[index];
                info.CardTime      = time;
                info.CardPartition = partition;

                byte[] by = PersonnelIssue.Issue(info, dataType, customData);

                bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <CardIssuePersonnel>();
                    ReceivedManager.GetReceivedFun <CardIssuePersonnel>().IssueInfo = info;
                }
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Exemple #3
0
        private static void Host_PostBatch(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            UpdateBatchParam(e);

            Task.Factory.StartNew(() =>
            {
                try
                {
                    int index = -1;
                    CardBatch batchReceived = null;
                    foreach (CardInfo item in CardManager.CardInfos)
                    {
                        if (item.Id == 0 && item.CardType < 3)
                        {
                            index += 1;

                            item.CardTime            = CardManager.BatchParam.CardTime;
                            item.CardDistance        = CardManager.BatchParam.CardDistance;
                            item.ParkingRestrictions = CardManager.BatchParam.ParkingRestrictions;
                            item.CardPartition       = CardManager.BatchParam.CardPartition;

                            byte[] by = DistanceIssue.Issue(item);
                            bool ret  = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
                            if (ret)
                            {
                                ReceivedManager.SetReceivedFunction <CardBatch>();
                                if (batchReceived == null)
                                {
                                    batchReceived = ReceivedManager.GetReceivedFun <CardBatch>();
                                }
                                batchReceived.IssueInfo = item;

                                for (int i = 0; i < 250; i++)
                                {
                                    Thread.Sleep(10);
                                    if (batchReceived.IssueInfo == null)
                                    {
                                        if (item.Id > 0)
                                        {
                                            ViewCallFunction.ViewDisplayBatchContent(item, index);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log4Helper.ErrorInfo(ex.Message, ex);
                    ViewCallFunction.ViewAlert(ex.Message);
                }
                finally
                {
                    int count = CardManager.CardInfos.Where(w => w.Id == 0 && w.CardType < 3).Count();
                    ViewCallFunction.ViewBatchOver(count);
                }
            });
        }
Exemple #4
0
        private void SetNoteToFormCSFunc_Execute(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            var    noteTitle = e.Arguments.FirstOrDefault(p => p.IsString);
            string noteID    = noteUtils.CreateTitle(noteTitle.ToString());

            e.SetReturnValue(noteID);
        }
Exemple #5
0
        private void UpdateNoteTitleFormCSFunc_Execute(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            var array     = e.Arguments.ToArray();
            var noteID    = array.GetValue(0).ToString();
            var noteTitle = array.GetValue(1).ToString();

            noteUtils.UpdateNoteTitle(Convert.ToInt32(noteID), noteTitle);
        }
Exemple #6
0
        private void SetNoteContentFormCSFunc_Execute(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            //var content = e.Arguments.FirstOrDefault(p => p.IsString);
            var array         = e.Arguments.ToArray();
            var noteID        = array.GetValue(0).ToString();
            var htmlContent   = array.GetValue(1).ToString();
            var contentLength = htmlContent.Length;

            noteUtils.SetNoteContent(Convert.ToInt32(noteID), htmlContent, Convert.ToInt32(contentLength));
        }
Exemple #7
0
        private static void UpdateBatchParam(Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            Chromium.Remote.CfrTime cTime = e.Arguments[0].DateValue;
            DateTime time      = new DateTime(cTime.Year, cTime.Month, cTime.DayOfMonth);
            int      distance  = e.Arguments[1].IntValue;
            int      partition = e.Arguments[2].IntValue;

            CardManager.BatchParam.CardTime      = time;
            CardManager.BatchParam.CardDistance  = distance;
            CardManager.BatchParam.CardPartition = partition;
        }
Exemple #8
0
 private static void Host_PostDelAllData(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         bool ret = CardManager.Delete();
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #9
0
 private static void Host_PostDelNumberInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int index = e.Arguments[0].IntValue;
         LimitManager.Del(index);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #10
0
 private static void Host_PostClientInfoCount(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string strWhere = e.Arguments[0].StringValue;
         int    count    = UserManager.GetCount(strWhere);
         e.SetReturnValue(count);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #11
0
 private static void Host_PostHostType(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int      index = e.Arguments[0].IntValue;
         CardInfo info  = CardManager.CardInfos[index];
         e.SetReturnValue(info.CardType);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #12
0
 private static void Host_PostLimitNumberInfos(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         List <NumberLimit> infos = LimitManager.GetInfos();
         string             json  = Utility.JsonSerializerByArrayData(infos.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #13
0
 private static void Host_PostAddUserInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string json = e.Arguments[0].StringValue;
         UserManager.Add(json);
         json = Utility.JsonSerializerByArrayData(UserManager.UserInfos.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #14
0
 private static void Host_PostAddNumberInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string strNumber = e.Arguments[0].StringValue;
         int    number    = Utility.StrToInt(strNumber);
         bool   ret       = LimitManager.Add(number);
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #15
0
 private static void Host_PostViceCardList(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int             index     = e.Arguments[0].IntValue;
         List <CardInfo> viceCards = CardManager.GetViceCards(index);
         string          json      = Utility.JsonSerializerByArrayData(viceCards.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #16
0
        private void GetNoteContentFormCSFunc_Execute(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            var noteID           = e.Arguments.FirstOrDefault(p => p.IsString).ToString();
            var noteContent      = noteUtils.GetNoteContent(Convert.ToInt32(noteID));
            var jsObjectAccessor = new CfrV8Accessor();
            var jsObject         = CfrV8Value.CreateObject(jsObjectAccessor);

            if (noteContent == null)
            {
                return;
            }
            jsObject.SetValue("id", noteContent.id, CfxV8PropertyAttribute.DontDelete);
            jsObject.SetValue("n_content", noteContent.n_content, CfxV8PropertyAttribute.DontDelete);
            e.SetReturnValue(jsObject);
        }
Exemple #17
0
 private static void Host_PostLimitNumberInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int         index = e.Arguments[0].IntValue;
         NumberLimit info  = LimitManager.NumberInfos[index];
         string      json  = Utility.JsonSerializerBySingleData(info);
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #18
0
 private static void Host_PostUpdateUserInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string   json  = e.Arguments[0].StringValue;
         int      index = e.Arguments[1].IntValue;
         UserInfo info  = UserManager.Update(json, index);
         json = Utility.JsonSerializerBySingleData(info);
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #19
0
 private static void Host_PostUserInfos(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string          whereContent = e.Arguments[0].StringValue;
         int             page         = e.Arguments[1].IntValue;
         List <UserInfo> infos        = UserManager.GetInfos(whereContent, page - 1, DefaultParams.PAGE_ROW_COUNT);
         string          json         = Utility.JsonSerializerBySingleData(infos.ToArray());
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #20
0
 private static void Host_PostDownloadTime(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         byte[] bys = PortAgreement.SetPersonnelHostTime();
         bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, bys);
         if (ret)
         {
             ReceivedManager.SetReceivedFunction <TimeDownload>();
         }
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #21
0
        private static void Host_PostUpdateBatchParam(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                Chromium.Remote.CfrTime cTime = e.Arguments[0].DateValue;
                DateTime time      = new DateTime(cTime.Year, cTime.Month, cTime.DayOfMonth);
                int      distance  = e.Arguments[1].IntValue;
                int      partition = e.Arguments[2].IntValue;

                CardManager.BatchParam.CardTime      = time;
                CardManager.BatchParam.CardDistance  = distance;
                CardManager.BatchParam.CardPartition = partition;
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
            }
        }
Exemple #22
0
        private static string GetLoseNumber(Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            Chromium.Remote.CfrV8Value cfrV8Value = e.Arguments[0];
            StringBuilder loseCardNumber          = new StringBuilder();

            if (cfrV8Value.IsArray)
            {
                for (int i = 0; i < cfrV8Value.ArrayLength; i++)
                {
                    loseCardNumber.Append($"'{cfrV8Value.GetValue(i).StringValue}'");
                    if (i < cfrV8Value.ArrayLength - 1)
                    {
                        loseCardNumber.Append(',');
                    }
                }
            }
            return(loseCardNumber.ToString());
        }
Exemple #23
0
 private static void Host_PostViceCardCount(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int index = e.Arguments[0].IntValue;
         int count = 0;
         if (CardManager.CardInfos[index].ViceCardInfos != null)
         {
             count = CardManager.CardInfos[index].ViceCardInfos.Count;
         }
         e.SetReturnValue(count);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #24
0
 private static void Host_PostCreateNumberFile(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         int index = e.Arguments[0].IntValue;
         FolderBrowserDialog folder = new FolderBrowserDialog();
         if (folder.ShowDialog() == DialogResult.OK)
         {
             UserManager.CreateNumberFile(index, folder.SelectedPath);
         }
         //string folder = e.Arguments[1].StringValue;
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #25
0
        private static void Host_PostDelViceCardInfo(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                int hostIndex = e.Arguments[0].IntValue;
                int viceIndex = e.Arguments[1].IntValue;

                CardInfo hostInfo = CardManager.CardInfos[hostIndex];
                CardInfo viceInfo = hostInfo.ViceCardInfos[viceIndex];

                BundledInfoManager.Delete(hostInfo.CardNumber, viceInfo.CardNumber);
                hostInfo.ViceCardInfos.RemoveAt(viceIndex);
                viceInfo = null;
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Exemple #26
0
 private static void Host_PortBatchParameter(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         if (CardManager.BatchParam == null)
         {
             CardManager.BatchParam = new CardInfo()
             {
                 CardTime = DateTime.Now
             };
         }
         string json = Utility.JsonSerializerBySingleData(CardManager.BatchParam);
         e.SetReturnValue(json);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #27
0
        private static void Host_PostDownloadNumber(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                int      index = e.Arguments[0].IntValue;
                UserInfo info  = UserManager.UserInfos[index];

                byte[] bys = PortAgreement.SetPersonnelHostNumber(info.UserNumber);
                bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, bys);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <NumberDownload>();
                }
                e.SetReturnValue(ret);
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Exemple #28
0
        private static void Host_PostDownloadPassword(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            try
            {
                string oldpwd = e.Arguments[0].StringValue;
                string newpwd = e.Arguments[1].StringValue;

                byte[] by  = PortAgreement.SetPersonnelHostPassword(oldpwd, newpwd);
                bool   ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device2, by);
                if (ret)
                {
                    ReceivedManager.SetReceivedFunction <PasswordDownload>();
                }
                e.SetReturnValue(ret);
            }
            catch (Exception ex)
            {
                Log4Helper.ErrorInfo(ex.Message, ex);
                ViewCallFunction.ViewAlert(ex.Message);
            }
        }
Exemple #29
0
 private static void Host_PostPersonnelLose(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
 {
     try
     {
         string          loseCardNumber = GetLoseNumber(e);
         List <CardInfo> list           = CardManager.GetCardInfos(loseCardNumber);
         CardManager.LossLists = list;
         byte[] by = PortAgreement.ReadACard("797979", 1);
         //byte[] by = DistanceLoss.PersonnelLoseOrRecovery(list,2);
         bool ret = SerialPortManager.WriteSerialPortData(SerialPortManager.Device1, by);
         if (ret)
         {
             ReceivedManager.SetReceivedFunction <PersonnelCardLoss>();
         }
         e.SetReturnValue(ret);
     }
     catch (Exception ex)
     {
         Log4Helper.ErrorInfo(ex.Message, ex);
         ViewCallFunction.ViewAlert(ex.Message);
     }
 }
Exemple #30
0
        private void GetTitleFormCSFunc_Execute(object sender, Chromium.Remote.Event.CfrV8HandlerExecuteEventArgs e)
        {
            var noteList         = noteUtils.GetNotesTitle();
            var jsObjectAccessor = new CfrV8Accessor();
            var jsObject         = CfrV8Value.CreateObject(jsObjectAccessor);
            var noteListArray    = CfrV8Value.CreateArray(noteList.Count);
            int i = 0;

            foreach (var note in noteList)
            {
                //jsObject.SetValue(note.id.ToString(), CfrV8Value.CreateString(note.n_title), CfxV8PropertyAttribute.ReadOnly);
                var jsArray = CfrV8Value.CreateArray(5);
                jsArray.SetValue("id", note.id, CfxV8PropertyAttribute.DontDelete);
                jsArray.SetValue("n_title", note.n_title, CfxV8PropertyAttribute.DontDelete);
                jsArray.SetValue("n_length", note.n_length, CfxV8PropertyAttribute.DontDelete);
                jsArray.SetValue("create_time", note.create_time, CfxV8PropertyAttribute.DontDelete);
                jsArray.SetValue("update_time", note.update_time, CfxV8PropertyAttribute.DontDelete);
                noteListArray.SetValue(i, jsArray);
                i++;
            }
            jsObject.SetValue("noteArray", noteListArray, CfxV8PropertyAttribute.DontDelete);
            e.SetReturnValue(jsObject);
        }