예제 #1
0
        private void AddHeader(Section section, ClientReport clientReport)
        {
            Image image = section.Headers.Primary.AddImage("D:/APDFData/Images/Nexstar.jpg");

            image.Height          = "2.0cm";
            image.LockAspectRatio = true;
            image.Top             = ShapePosition.Top;
            image.Left            = ShapePosition.Left;

            var header = section.Headers.Primary.AddParagraph();
            var myFont = new Font();

            myFont.Size = 18;
            header.AddFormattedText("(SymphonyMedia-Linear) Billing Summary by Agreement", myFont);
            //header.Format.Font.Size = "20px";
            header.AddTab();
            header.AddLineBreak();
            header.AddLineBreak();
            header.AddLineBreak();
            header.AddFormattedText("Report Date Range: 04/2019-05/2020");
            header.AddLineBreak();
            header.AddFormattedText("Type: CLOSE");
            header.AddLineBreak();
            header.AddFormattedText(clientReport.ReportParameters);
            header.AddLineBreak();
            header.AddFormattedText("Service:All");
            header.AddLineBreak();
        }
예제 #2
0
        /// <summary>
        /// 发送设定的参数
        /// </summary>
        /// <param name="address"></param>
        /// <param name="groupNumber"></param>
        /// <param name="parameterCount"></param>
        /// <param name="addressArray"></param>
        /// <param name="valueArray"></param>
        public bool ResponseSettingParameter(byte[] address, string groupNumber, List <string> addressArray, List <string> valueArray)
        {
            bool flag = true;

            try
            {
                ResponseValueData theResponseValueData = new ResponseValueData();
                theResponseValueData.DEVICE_ADDRESS        = address;
                theResponseValueData.VALUE_TYPE            = ByteWithString.strToToHexByte(groupNumber)[0];
                theResponseValueData.VALUE_COUNT           = (byte)addressArray.Count;
                theResponseValueData.theResponseValueArray = new List <ResponseValue>();
                for (int i = 0; i < addressArray.Count; i++)
                {
                    byte[]        theBytes         = ByteWithString.strToToHexByte(addressArray[i]);
                    ResponseValue theResponseValue = new ResponseValue();
                    theResponseValue.VALUE_ADDRESS = new byte[] { theBytes[1], theBytes[0] };
                    theResponseValue.VALUE         = StringConvertByte(addressArray[i], valueArray[i]);
                    theResponseValue.VALUE_LENGTH  = (byte)theResponseValue.VALUE.Length;
                    theResponseValueData.theResponseValueArray.Add(theResponseValue);
                }
                ClientReport theClientReport = CreateClientReport <ResponseValueData>(0x15, theResponseValueData);
                byte[]       bytes           = theScoket.clientReportUnSerialize(theClientReport);
                if (bytes.Length > 0)
                {
                    theScoket.sendInfo(bytes);
                }
            }
            catch (Exception msg)
            {
                Log.LogWrite(msg);
            }
            return(flag);
        }
예제 #3
0
 private void AddHeading(Section section, ClientReport clientReport)
 {
     section.Headers.Primary.AddParagraph("Report Date Range: 04/2019-05/2020");
     section.Headers.Primary.AddParagraph(clientReport.ReportParameters);
     section.Headers.Primary.AddParagraph("Service:All");
     section.Headers.Primary.AddParagraph("----------------------------------------------------------------------------------");
 }
예제 #4
0
        public void ClientReportsFilterTest()
        {
            User user = new User()
            {
                Id = 1, AgencyId = 1, RoleId = (int)FixedRoles.AgencyUser
            };
            IPermissionsBase          target = PermissionsFactory.GetPermissionsFor(user);
            Func <ClientReport, bool> ClientReportsFilter = target.ClientReportsFilter.Compile();
            ClientReport cr = new ClientReport()
            {
                Client = new Client()
                {
                    AgencyId = 0
                }, SubReport = new SubReport()
                {
                    AppBudgetService = new AppBudgetService()
                    {
                        AgencyId = 1
                    }
                }
            };

            Assert.IsFalse(ClientReportsFilter(cr));
            cr.Client.AgencyId = 1;
            cr.SubReport.AppBudgetService.AgencyId = 0;
            Assert.IsFalse(ClientReportsFilter(cr));
            cr.SubReport.AppBudgetService.AgencyId = 1;
            Assert.IsTrue(ClientReportsFilter(cr));
        }
예제 #5
0
        public void Execute(ClientCreatedEvent theEvent)
        {
            var client        = new ClientReport(theEvent.ClientId, theEvent.ClientName);
            var clientDetails = new ClientDetailsReport(theEvent.ClientId, theEvent.ClientName, theEvent.Street, theEvent.StreetNumber, theEvent.PostalCode, theEvent.City, theEvent.PhoneNumber);

            _reportingRepository.Save(client);
            _reportingRepository.Save(clientDetails);
        }
예제 #6
0
        public void Add(Section section, ClientReport clientReport)
        {
            //var table = AddPatientInfoTable(section);

            //AddLeftInfo(table.Rows[0].Cells[0], clientReport);
            //AddLeftInfo(table.Rows[0], clientReport);
            //AddRightInfo(table.Rows[0].Cells[1], clientReport);
        }
예제 #7
0
        public void Will_be_able_to_save_and_retrieve_a_client_dto()
        {
            var clientDto = new ClientReport(Guid.NewGuid(), "Mark Nijhof");

            _repository.Save(clientDto);
            var sut = _repository.GetByExample <ClientReport>(new { Name = "Mark Nijhof" }).FirstOrDefault();

            Assert.That(sut.Id, Is.EqualTo(clientDto.Id));
            Assert.That(sut.Name, Is.EqualTo(clientDto.Name));
        }
예제 #8
0
        /// <summary>
        /// 获得设备状态 0x01
        /// </summary>
        /// <param name="p"></param>
        internal void RequestDeviceStar(byte[] p, string code)
        {
            ClientReport theClientReport = CreateClientReport <string>(0x13, ByteWithString.byteToHexStr(p) + "|" + code);

            byte[] bytes = theScoket.clientReportUnSerialize(theClientReport);
            if (bytes.Length > 0)
            {
                theScoket.sendInfo(bytes);
            }
        }
예제 #9
0
        protected override void SetupDependencies()
        {
            OnDependency <IReportingRepository>()
            .Setup(x => x.Save(It.IsAny <ClientReport>()))
            .Callback <ClientReport>(a => SaveClientObject = a);

            OnDependency <IReportingRepository>()
            .Setup(x => x.Save(It.IsAny <ClientDetailsReport>()))
            .Callback <ClientDetailsReport>(a => SaveClientDetailsObject = a);
        }
예제 #10
0
        /// <summary>
        /// 目录发送格式
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="content"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static ClientReport CreateClientReport <T>(byte content, T body)
        {
            ClientReport theClientReport = new ClientReport();

            theClientReport.HEAD_FIELD    = 0x03;
            theClientReport.REPORT_LENGTH = new byte[] { 0x00, 0x00, 0x00, 0x00 };
            theClientReport.CONTROL_FIELD = content;
            theClientReport.REPORT_BODY   = body;
            theClientReport.END_FIELD     = 0x16;
            return(theClientReport);
        }
예제 #11
0
        void PayReceipt(User client)
        {
            if (client.Order.Products.Count == 0)
            {
                Console.WriteLine("You have not ordered yet!");
            }

            ClientReport clientReport = new ClientReport();

            clientReport.Visit(client.Order);

            float totalPrice = clientReport.TotalPrice;

            if (Enum.IsDefined(typeof(EOfferType), client.OfferType))
            {
                StrategyContext strategyContext = new StrategyContext(totalPrice);

                totalPrice = (float)strategyContext.ApplyStrategy(client.OfferType);
            }

            totalPrice = (float)Math.Round(totalPrice, 2);

            CashIn(totalPrice, GetMoneyType());
            GetTotalCash();

            DataExporter exporter = null;

            Console.WriteLine("In what format do you want your reciept? \n" +
                              "1 -> txt\n" +
                              "2 -> pdf\n");

            int option = Convert.ToInt32(Console.ReadLine());

            switch (option)
            {
            case 1:
                exporter = new Txt_Bill_Exporter();
                break;

            case 2:
                exporter = new PDF_Bill_Exporter();
                break;

            default:
                exporter = new Txt_Bill_Exporter();
                break;
            }

            ApplicationMode.Instance.sendAction($"Client {client.Name} paid order: {totalPrice}");

            List <BurgerDecorator> burgers = client.Order.Products;

            exporter.ExportFormatedData($"{client.Name}'s reciept", burgers, $"Total: {totalPrice}");
        }
예제 #12
0
        private void _Settings(int?id)
        {
            using (var service = new AimpService())
            {
                var response = service.GetClientReport(id);

                if (id == null)
                {
                    ClientReport          = new ClientReport();
                    _clientReportDocument = new ClientReportDocument();
                    _clientReport         = new ClientReport();
                    ClientBankStatus      = new ObservableCollection <ClientBankStatusViewModel>(response.Banks
                                                                                                 .Select(x => new ClientBankStatusViewModel()
                    {
                        Bank               = x,
                        BankStatuses       = response.BankStatuses,
                        SelectedBankStatus = response.BankStatuses.FirstOrDefault()
                    }));
                }
                else
                {
                    ClientReport              = response.Document.BankReportClients.First().ClientReport;
                    _clientReport             = TinyMapper.Map <ClientReport>(ClientReport);
                    ClientReport.ClientStatus = response.ClientStatuses.FirstOrDefault(x => x.Id == ClientReport.ClientStatus?.Id);

                    ClientReport.CreditProgramm = response.CreditProgramms.FirstOrDefault(x => x.Id == ClientReport.CreditProgramm?.Id);

                    _clientReportDocument = response.Document;

                    var clientBankStatuses = (from bRep in response.Banks
                                              join bClient in response.Document.BankReportClients
                                              on bRep.Id equals bClient.Bank.Id into bankDefault
                                              from bClient in bankDefault.DefaultIfEmpty()
                                              select new { bClient?.Id,
                                                           Enabled = bClient != null ? true : false,
                                                           Bank = bRep,
                                                           BankStatus = bClient?.BankStatus })
                                             .Select(x => new ClientBankStatusViewModel()
                    {
                        Id                 = x.Id != null ? (int)x.Id : 0,
                        Bank               = x.Bank,
                        Enable             = x.Enabled,
                        BankStatuses       = response.BankStatuses,
                        SelectedBankStatus = response.BankStatuses.FirstOrDefault(y => y.Id == x.BankStatus?.Id)
                    });

                    ClientBankStatus = new ObservableCollection <ClientBankStatusViewModel>(clientBankStatuses);
                }

                ClientStatuses = new ObservableCollection <ClientStatus>(response.ClientStatuses);

                CreditProgramms = new ObservableCollection <CreditProgramm>(response.CreditProgramms);
            }
        }
예제 #13
0
        protected override void SetupDependencies()
        {
            OnDependency <IPopupPresenter>()
            .Setup(x => x.CatchPossibleException(It.IsAny <Action>()))
            .Callback <Action>(x => x());

            _clientReport = new ClientReport(Guid.NewGuid(), "Client Name");

            OnDependency <IClientSearchFormView>()
            .Setup(x => x.GetSelectedClient())
            .Returns(_clientReport);
        }
예제 #14
0
        private void AddRightInfo(Cell cell, ClientReport clientReport)
        {
            var p = cell.AddParagraph();

            // Add birthdate
            p.AddText("Client Name: ");
            p.AddFormattedText((clientReport.ClientName), TextFormat.Bold);

            p.AddLineBreak();

            // Add doctor name
            p.AddText(" ");
            p.AddFormattedText($"{clientReport.ReportParameters}", TextFormat.Bold);
        }
예제 #15
0
        public ClientReport GetClientReport(int id)
        {
            try
            {
                using (var aimp = new Aimp(_login, _password))
                {
                    var response = new ClientReport(aimp.GetDocument <ClientReportDocument>(id), aimp.GetClientStatuses(), aimp.GetCreditProgramms(), aimp.GetBanks(), aimp.GetBankStatuses());

                    return(response);
                }
            }
            catch (Exception ex)
            {
                return(new ClientReport(ex));
            }
        }
예제 #16
0
        //private void AddLeftInfo(Cell cell, ClientReport clientReport )
        //{
        //    // Add patient name and sex symbol
        //    var p1 = cell.AddParagraph();
        //    p1.Style = CustomStyles.ReportName;
        //    /* p1.AddText($"{clientReport.ClientName}");*///(SymphonyMedia-Linear)BillingSummarybyAgreement
        //    p1.AddText("(SymphonyMedia-Linear) Billing Summary by Agreement");
        //    p1.AddSpace(2);
        //    //AddSexSymbol(p1, patient.Sex);

        //    // Add patient ID
        //   // var p2 = cell.AddParagraph();
        //    //p2.AddText("ID: ");
        //    //p2.AddFormattedText(patient.Id, TextFormat.Bold);
        //}

        private void AddLeftInfo(Row row, ClientReport clientReport)
        {
            // Add patient name and sex symbol
            //var p1 = row.Cells[0].AddParagraph();
            //p1.Style = CustomStyles.ReportName;
            /* p1.AddText($"{clientReport.ClientName}");*///(SymphonyMedia-Linear)BillingSummarybyAgreement
            //p1.AddText("(SymphonyMedia-Linear) Billing Summary by Agreement ");
            //p1.AddSpace(2);
            //AddSexSymbol(p1, patient.Sex);

            // Add patient ID
            // var p2 = cell.AddParagraph();
            //p2.AddText("ID: ");
            //p2.AddFormattedText(patient.Id, TextFormat.Bold);
            // var p2 = row.Cells[1].AddParagraph();
            // p2.AddText("Billing Summary by Agreement");
        }
예제 #17
0
        private void Download_Click(object sender, EventArgs e)
        {
            AdWordsAppConfig config = (AdWordsAppConfig)User.Config;

            string QUERY_REPORT_URL_FORMAT = "{0}/api/adwords/reportdownload/{1}?" + "__fmt={2}";

            string reportVersion = "v201302";
            string format        = DownloadFormat.GZIPPED_CSV.ToString();
            string downloadUrl   = string.Format(QUERY_REPORT_URL_FORMAT, config.AdWordsApiServer, reportVersion, format);
            string query         = this.AWQL_textBox.Text;
            string postData      = string.Format("__rdquery={0}", HttpUtility.UrlEncode(query));

            ClientReport retval = new ClientReport();

            FeedAttributeType f = new FeedAttributeType();


            ReportsException ex = null;

            this.response.Text += "\n Report download has started...";
            int    maxPollingAttempts = 30 * 60 * 1000 / 30000;
            string path = this.path.Text;

            for (int i = 0; i < 3; i++)
            {
                this.response.Text += "\n Attempt #1...";

                try
                {
                    using (FileStream fs = File.OpenWrite(path))
                    {
                        fs.SetLength(0);
                        bool isSuccess = DownloadReportToStream(downloadUrl, config, true, fs, postData, User);
                        if (!isSuccess)
                        {
                            string errors = File.ReadAllText(path);
                        }
                    }
                }
                catch (Exception exception)
                {
                    this.response.Text = exception.Message;
                }
            }
            this.response.Text += "\n DONE !";
        }
예제 #18
0
        private void btn_clientReport_Click(object sender, EventArgs e)
        {
            if (conn.State != ConnectionState.Open)
            {
                conn.Open();
            }


            string         s    = "Select * FROM Client";
            SqlCommand     cmd  = new SqlCommand(s, conn);
            SqlDataAdapter adap = new SqlDataAdapter(cmd);
            DataSet        ds   = new DataSet();

            adap.Fill(ds, "Client");
            ClientReport cr1 = new ClientReport();

            cr1.SetDataSource(ds);
            CrisReport.ReportSource = cr1;
            conn.Close();
            CrisReport.Refresh();
        }
예제 #19
0
        /// <summary>
        /// metodo para agregar informacion a los reportes de los clientes
        /// </summary>
        /// <param name="id">int que indica el id del cliente</param>
        /// <param name="recipeCount">cantidad de platos que ha comprado el cliente</param>
        /// <returns>ClientReport</returns>
        static public ClientReport clientReportData(int id, int recipeCount)
        {
            string readFile    = File.ReadAllText(@"Data/clientReport.json");
            var    creportList = JsonConvert.DeserializeObject <List <ClientReport> >(readFile);
            var    creport     = creportList.SingleOrDefault(x => x.clientID == id);

            if (creport == null)
            {
                creport = new ClientReport()
                {
                    clientID = id, clientName = ClientData.getClientData(id).name, recipeCount = recipeCount
                };
                creportList.Add(creport);
                writeClientReportData(creportList);
                return(creport);
            }
            creportList.Remove(creport);
            creport.recipeCount = creport.recipeCount + recipeCount;
            creportList.Add(creport);
            writeClientReportData(creportList);
            return(creport);
        }
예제 #20
0
        public ClientReport GetClientReport(int id)
        {
            var document = _logic.GetDocument(id);

            var clientStatuses = _logic.GetClientStatuses();

            var creditProgramms = _logic.GetCreditProgramms();

            var banks = _logic.GetBanks();

            var bankStatuses = _logic.GetBankStatuses();

            var response = new ClientReport()
            {
                Banks           = banks,
                BankStatuses    = bankStatuses,
                ClientStatuses  = clientStatuses,
                CreditProgramms = creditProgramms,
                Document        = document
            };

            return(response);
        }
예제 #21
0
        public void ClientReportsFilterTest()
        {
            User user = new User()
            {
                Id = 1, AgencyId = 1, AgencyGroupId = 1, RoleId = (int)FixedRoles.Ser
            };
            IPermissionsBase          target = PermissionsFactory.GetPermissionsFor(user);
            Func <ClientReport, bool> ClientReportsFilter = target.ClientReportsFilter.Compile();
            ClientReport cr = new ClientReport()
            {
                Client = new Client()
                {
                    Agency = new Agency()
                    {
                        GroupId = 0
                    }
                }
            };

            Assert.IsFalse(ClientReportsFilter(cr));
            cr.Client.Agency.GroupId = 1;

            Assert.IsTrue(ClientReportsFilter(cr));
        }
예제 #22
0
        /// <summary>
        /// 发送
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public byte[] clientReportUnSerialize(ClientReport data)
        {
            List <byte> reportList = new List <byte>();

            try
            {
                reportList.Add(0x03);
                reportList.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00 });
                reportList.Add(data.CONTROL_FIELD);
                switch (data.CONTROL_FIELD)
                {
                case 0x01:    //Login
                    LoginReport lr = (LoginReport)data.REPORT_BODY;
                    reportList.Add(lr.USERNAME_LENGTH);
                    reportList = reportList.Concat(lr.USERNAME).ToList();
                    reportList.Add(lr.PASSWORD_LENGTH);
                    reportList = reportList.Concat(lr.PASSWORD).ToList();
                    break;

                case 0x04:    //DataGridView
                    TheCatalog theCatalog = (TheCatalog)data.REPORT_BODY;
                    reportList = reportList.Concat(theCatalog.DEVICE_ADDRESS).ToList();
                    reportList = reportList.Concat(theCatalog.CATALOG_NAME).ToList();
                    break;

                case 0x06:    //UpdataFileInfo
                    CatalogFiles theCatalogFiles = (CatalogFiles)data.REPORT_BODY;
                    reportList = reportList.Concat(theCatalogFiles.DeviceAddress).ToList();
                    reportList.Add(theCatalogFiles.FILE_LENGTH);
                    reportList = reportList.Concat(theCatalogFiles.FILE_NAME).ToList();
                    break;

                case 0x09:    //RequestRemoteData(请求遥信)
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x13:    //设备状态
                    string[] str = (data.REPORT_BODY as string).Split('|');
                    reportList = reportList.Concat(ByteWithString.strToToHexByte(str[0])).ToList();
                    reportList = reportList.Concat(ByteWithString.strToToHexByte(str[1])).ToList();
                    break;

                case 0x15:    //
                    ResponseValueData theResponseValueData = (ResponseValueData)data.REPORT_BODY;
                    reportList = reportList.Concat(theResponseValueData.DEVICE_ADDRESS).ToList();
                    reportList.Add(theResponseValueData.VALUE_TYPE);
                    reportList.Add(theResponseValueData.VALUE_COUNT);
                    for (int i = 0; i < theResponseValueData.theResponseValueArray.Count; i++)
                    {
                        string ss = ByteWithString.byteToHexStr(theResponseValueData.theResponseValueArray[i].VALUE_ADDRESS);
                        reportList = reportList.Concat(theResponseValueData.theResponseValueArray[i].VALUE_ADDRESS).ToList();
                        reportList.Add(theResponseValueData.theResponseValueArray[i].VALUE_LENGTH);
                        reportList = reportList.Concat(theResponseValueData.theResponseValueArray[i].VALUE).ToList();
                    }
                    break;

                case 0x17:
                    reportList = reportList.Concat((data.REPORT_BODY as TheCatalog).CATALOG_NAME).ToList();
                    break;

                case 0x18:
                    reportList = reportList.Concat((data.REPORT_BODY as TheCatalog).CATALOG_NAME).ToList();
                    break;

                case 0x19:
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x20:
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x22:
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x27:    //维护变电站
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x28:    //维护变电站
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x29:    //维护变电站
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x30:    //维护变电站
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x31:    //维护变电站
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x32:
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x34:    //获取线路参数
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x36:    //设定定时执行参数
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x37:    //请求返回设定参数
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                case 0x39:    //上传文件
                    reportList = reportList.Concat((byte[])data.REPORT_BODY).ToList();
                    break;

                default: break;
                }
                reportList.Add(0x00);
                reportList.Add(0x16);
                reportList[reportList.Count - 2] = makeValidateField(reportList);
                reportList[1] = Convert.ToByte(reportList.Count >> 24 & 0xff);
                reportList[2] = Convert.ToByte(reportList.Count >> 16 & 0xff);
                reportList[3] = Convert.ToByte(reportList.Count >> 8 & 0xff);
                reportList[4] = Convert.ToByte(reportList.Count & 0xff);
            }
            catch (Exception msg)
            {
                Log.LogWrite(msg);
            }
            return(reportList.ToArray <byte>());
        }
예제 #23
0
 public void SetClient(ClientReport clientReport)
 {
     _clientReport = clientReport;
 }
예제 #24
0
        /// <summary>
        /// 接收
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public ClientReport clientReportSerialize(byte[] data)
        {
            HandelControls theHandelControls = HandelControls.createHandelControls();
            ClientReport   theClientReport   = new ClientReport();

            try
            {
                theClientReport.HEAD_FIELD    = data[0];
                theClientReport.REPORT_LENGTH = data.Skip(1).Take(4).ToArray();

                byte[] dataLength    = data.Skip(1).Take(4).ToArray();
                int    dataLengthInt = returnByteLengthRight(dataLength);
                data = data.Skip(0).Take(dataLengthInt).ToArray();
                theClientReport.CONTROL_FIELD = data[5];
                // theClientReport.REPORT_BODY = data.Skip(6).Take(dataLengthInt-8);
                theClientReport.END_FIELD = data[data.Length - 1];
                data = data.Skip(6).Take(dataLengthInt - 8).ToArray();
                int                fileCount          = 0;                        //默认文件长度;
                int                nowIndex           = 0;                        //当前位置;
                int                dataCount          = 0;
                TheCatalog         theCatalog         = new TheCatalog();         //文件目录
                CatalogFiles       theCatalogFiles    = new CatalogFiles();       //文件
                TheRemoteDataArray theRemoteDataArray = new TheRemoteDataArray(); //遥信
                ResponseValueData  theResponseValue   = new ResponseValueData();  //设定值
                switch (theClientReport.CONTROL_FIELD)
                {
                case 0x02:
                    returnLoginInfo theReturnLoginInfo = new returnLoginInfo();
                    byte[]          theByte            = data;
                    theReturnLoginInfo.isOk     = theByte[0];
                    theClientReport.REPORT_BODY = theReturnLoginInfo;
                    break;

                case 0x03:
                    byte[]     checkData        = data;
                    DeviceData theTreeArrayData = new DeviceData();
                    theTreeArrayData.theDeviceData = new List <DeviceDataInfo>();
                    int count = checkData[0];
                    checkData = checkData.Skip(1).ToArray();
                    while (count > 0)
                    {
                        DeviceDataInfo theDeviceDataInfo = new DeviceDataInfo();
                        int            ct = checkData.Skip(nowIndex).Take(1).ToArray()[0];//设备名称长度
                        theDeviceDataInfo.DeviceName       = checkData.Skip(nowIndex + 1).Take(ct).ToArray <byte>();
                        theDeviceDataInfo.DeviceAddress    = checkData.Skip(nowIndex + ct + 1).Take(2).ToArray <byte>();
                        theDeviceDataInfo.DeviceStatue     = checkData.Skip(nowIndex + ct + 3).Take(1).ToArray()[0];
                        theDeviceDataInfo.DeviceLastOnline = checkData.Skip(nowIndex + ct + 4).Take(7).ToArray();
                        nowIndex += ct + 11;
                        theTreeArrayData.theDeviceData.Add(theDeviceDataInfo);
                        count--;
                    }
                    theClientReport.REPORT_BODY = theTreeArrayData;

                    break;

                case 0x05:
                    byte[] checkCatalogData = data;
                    theCatalog.DEVICE_ADDRESS = checkCatalogData.Take(2).ToArray <byte>(); //设备地址
                    theCatalog.FILES_COUNT    = checkCatalogData[2];                       //文件数量
                    fileCount = theCatalog.FILES_COUNT;
                    theCatalog.THE_CATALOG_FILES = new List <CatalogFiles>();
                    byte[] nowCatalogData = checkCatalogData.Skip(3).Take(checkCatalogData.Length - 2).ToArray <byte>();
                    while (fileCount > 0)
                    {
                        CatalogFiles catalogFiles = new CatalogFiles();
                        catalogFiles.FILE_LENGTH = nowCatalogData[nowIndex];
                        catalogFiles.FILE_NAME   = nowCatalogData.Skip(nowIndex + 1).Take(catalogFiles.FILE_LENGTH).ToArray <byte>();
                        theCatalog.THE_CATALOG_FILES.Add(catalogFiles);
                        nowIndex += catalogFiles.FILE_LENGTH + 1;
                        fileCount--;
                    }
                    theClientReport.REPORT_BODY = theCatalog;
                    break;

                case 0x07:
                    byte[] updateCatalogData = data;
                    theCatalogFiles.DeviceAddress = updateCatalogData.Take(2).ToArray <byte>();                                   //文件地址
                    theCatalogFiles.FILE_LENGTH   = updateCatalogData[2];                                                         //文件名长度
                    theCatalogFiles.FILE_NAME     = updateCatalogData.Skip(3).Take(theCatalogFiles.FILE_LENGTH).ToArray <byte>(); //文件名
                    int fileContent = theCatalogFiles.FILE_NAME.Length + 3;
                    theCatalogFiles.FILE_CONTENT = updateCatalogData.Skip(fileContent).ToArray <byte>();                          //文件长度
                    theClientReport.REPORT_BODY  = theCatalogFiles;
                    break;

                case 0x10:    //遥信返回(不带时标)
                    byte[] notHaveTimeMark = data;
                    theRemoteDataArray.DEVICE_ADDRESS = notHaveTimeMark.Take(2).ToArray <byte>();
                    theRemoteDataArray.THE_COUNT      = notHaveTimeMark[2];
                    theRemoteDataArray.THE_TYPE_NAME  = "遥信";
                    fileCount = theRemoteDataArray.THE_COUNT;
                    theRemoteDataArray.THE_REMOTE_DATA = new List <TheRemoteData>();
                    notHaveTimeMark = notHaveTimeMark.Skip(3).ToArray <byte>();
                    while (fileCount > 0)
                    {
                        TheRemoteData theRemoteData = new TheRemoteData();
                        theRemoteData.RemoteAddress = notHaveTimeMark.Skip(nowIndex).Take(2).ToArray <byte>();
                        theRemoteData.RemoteValue   = notHaveTimeMark.Skip(nowIndex + 2).Take(1).ToArray <byte>();
                        nowIndex = nowIndex + 3;
                        fileCount--;
                        theRemoteDataArray.THE_REMOTE_DATA.Add(theRemoteData);
                    }
                    theClientReport.REPORT_BODY  = theRemoteDataArray;
                    theThreadMethod              = new Thread(forEachList);
                    theThreadMethod.IsBackground = true;
                    theThreadMethod.Start(theRemoteDataArray);
                    break;

                case 0x11:    //遥信返回(带时标)
                    byte[] haveTimeMark = data;
                    theRemoteDataArray.DEVICE_ADDRESS = haveTimeMark.Take(2).ToArray <byte>();
                    theRemoteDataArray.THE_COUNT      = haveTimeMark[2];
                    theRemoteDataArray.THE_COUNT      = haveTimeMark[2];
                    theRemoteDataArray.THE_TYPE_NAME  = "遥信";
                    fileCount = theRemoteDataArray.THE_COUNT;
                    theRemoteDataArray.THE_REMOTE_DATA = new List <TheRemoteData>();
                    haveTimeMark = haveTimeMark.Skip(3).ToArray <byte>();
                    while (fileCount > 0)
                    {
                        TheRemoteData theRemoteData = new TheRemoteData();
                        theRemoteData.RemoteAddress = haveTimeMark.Skip(nowIndex).Take(2).ToArray <byte>();
                        theRemoteData.RemoteValue   = haveTimeMark.Skip(nowIndex + 2).Take(1).ToArray <byte>();
                        theRemoteData.LastestModify = haveTimeMark.Skip(nowIndex + 3).Take(7).ToArray <byte>();
                        nowIndex = nowIndex + 10;
                        fileCount--;
                        theRemoteDataArray.THE_REMOTE_DATA.Add(theRemoteData);
                    }
                    theClientReport.REPORT_BODY  = theRemoteDataArray;
                    theThreadMethod              = new Thread(forEachList);
                    theThreadMethod.IsBackground = true;
                    theThreadMethod.Start(theRemoteDataArray);
                    break;

                case 0x12:    //遥测
                    byte[] telemeteringTimeMark = data;
                    theRemoteDataArray.DEVICE_ADDRESS = telemeteringTimeMark.Take(2).ToArray <byte>();
                    theRemoteDataArray.THE_COUNT      = telemeteringTimeMark[2];
                    theRemoteDataArray.THE_TYPE_NAME  = "遥测";
                    fileCount = theRemoteDataArray.THE_COUNT;
                    theRemoteDataArray.THE_REMOTE_DATA = new List <TheRemoteData>();
                    telemeteringTimeMark = telemeteringTimeMark.Skip(3).ToArray <byte>();
                    while (fileCount > 0)
                    {
                        TheRemoteData theRemoteData = new TheRemoteData();
                        theRemoteData.LastestModify = new byte[] { 0x00 };
                        theRemoteData.RemoteAddress = telemeteringTimeMark.Skip(nowIndex).Take(2).ToArray <byte>();
                        theRemoteData.RemoteValue   = telemeteringTimeMark.Skip(nowIndex + 2).Take(2).ToArray <byte>();
                        theRemoteData.quility       = telemeteringTimeMark.Skip(nowIndex + 4).Take(1).ToArray <byte>()[0];
                        nowIndex = nowIndex + 5;
                        fileCount--;
                        theRemoteDataArray.THE_REMOTE_DATA.Add(theRemoteData);
                    }
                    theClientReport.REPORT_BODY  = theRemoteDataArray;
                    theThreadMethod              = new Thread(forEachList);
                    theThreadMethod.IsBackground = true;
                    theThreadMethod.Start(theRemoteDataArray);
                    break;

                case 0x14:
                    byte[] responseValueTimeMark = data;
                    theResponseValue.DEVICE_ADDRESS = responseValueTimeMark.Take(2).ToArray <byte>();
                    theResponseValue.VALUE_TYPE     = responseValueTimeMark[2];
                    theResponseValue.VALUE_COUNT    = responseValueTimeMark[3];
                    fileCount = theResponseValue.VALUE_COUNT;
                    theResponseValue.theResponseValueArray = new List <ResponseValue>();
                    responseValueTimeMark = responseValueTimeMark.Skip(4).ToArray <byte>();
                    while (fileCount > 0)
                    {
                        ResponseValue rsponseValue = new ResponseValue();
                        rsponseValue.VALUE_ADDRESS = responseValueTimeMark.Skip(nowIndex).Take(2).ToArray <byte>();
                        int length = responseValueTimeMark.Skip(nowIndex + 2).Take(1).ToArray <byte>()[0];
                        rsponseValue.VALUE = responseValueTimeMark.Skip(nowIndex + 3).Take(length).ToArray <byte>();
                        nowIndex           = nowIndex + 3 + length;
                        theResponseValue.theResponseValueArray.Add(rsponseValue);
                        fileCount--;
                    }
                    theClientReport.REPORT_BODY = theResponseValue;
                    break;

                case 0x0a:
                    byte[]            contentText      = data;
                    ReportContentText theReportContent = new ReportContentText();
                    theReportContent.ReportType     = contentText[0];
                    theReportContent.ReportDateTime = contentText.Skip(1).Take(7).ToArray <byte>();
                    theReportContent.ReportContent  = contentText.Skip(8).ToArray <byte>();
                    theClientReport.REPORT_BODY     = theReportContent;
                    break;

                case 0x21:
                    byte[]    writeBytes   = data;
                    WriteFile theWriteFile = new WriteFile();
                    theWriteFile.DEVICE_ADDRESS = writeBytes.Take(2).ToArray();
                    theWriteFile.FILE_LENGTH    = writeBytes.Skip(2).Take(1).ToArray()[0];
                    theWriteFile.FILE_NAME      = writeBytes.Skip(3).Take(theWriteFile.FILE_LENGTH).ToArray();
                    theWriteFile.FILE_COUNT     = writeBytes.Skip(3 + theWriteFile.FILE_LENGTH).ToArray();
                    break;

                case 0x23:    //接收变电站
                    List <ConvertingStation> theConvertingStationArray = new List <ConvertingStation>();
                    dataCount = returnByteLengthRight(data.Take(4).ToArray());
                    data      = data.Skip(4).ToArray();
                    while (dataCount > 0)
                    {
                        ConvertingStation theConvertingStation = new ConvertingStation();
                        int convertingNameLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theConvertingStation.stationName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingNameLength).ToArray(), "utf-8");
                        nowIndex += convertingNameLength;
                        int remarksLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theConvertingStation.stationRemarks = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(remarksLength).ToArray(), "utf-8");
                        nowIndex += remarksLength;
                        theConvertingStation.stationID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        dataCount--;
                        theConvertingStationArray.Add(theConvertingStation);
                    }
                    theClientReport.REPORT_BODY = theConvertingStationArray;
                    break;

                case 0x24:    //接收母线
                    List <Generatrix> theGeneratrixArray = new List <Generatrix>();
                    dataCount = returnByteLengthRight(data.Take(4).ToArray());
                    data      = data.Skip(4).ToArray();
                    while (dataCount > 0)
                    {
                        Generatrix theGeneratrix        = new Generatrix();
                        int        convertingNameLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theGeneratrix.GeneratrixName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingNameLength).ToArray(), "utf-8");
                        nowIndex += convertingNameLength;
                        int remarksLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theGeneratrix.GeneratrixNumber = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(remarksLength).ToArray(), "utf-8");
                        nowIndex += remarksLength;
                        theGeneratrix.GeneratrixID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        int convertingLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theGeneratrix.GeneratrixToName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingLength).ToArray(), "utf-8");
                        nowIndex += convertingLength;
                        theGeneratrix.GeneratrixToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        dataCount--;
                        theGeneratrixArray.Add(theGeneratrix);
                    }
                    theClientReport.REPORT_BODY = theGeneratrixArray;
                    break;

                case 0x25:    //接收线路
                    List <Circuit> theCircuitArray = new List <Circuit>();
                    dataCount = returnByteLengthRight(data.Take(4).ToArray());
                    data      = data.Skip(4).ToArray();
                    while (dataCount > 0)
                    {
                        Circuit theCircuit           = new Circuit();
                        int     convertingNameLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theCircuit.CircuitName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingNameLength).ToArray(), "utf-8");
                        nowIndex += convertingNameLength;
                        int remarksLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theCircuit.CircuitNumber = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(remarksLength).ToArray(), "utf-8");
                        nowIndex            += remarksLength;
                        theCircuit.CircuitID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex            += 4;
                        int convertingLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theCircuit.CircuitToName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingLength).ToArray(), "utf-8");
                        nowIndex += convertingLength;
                        theCircuit.CircuitToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        dataCount--;
                        theCircuitArray.Add(theCircuit);
                    }
                    theClientReport.REPORT_BODY = theCircuitArray;
                    break;

                case 0x26:    //接收检测点
                    List <Detection> theDetectionArray = new List <Detection>();
                    dataCount = returnByteLengthRight(data.Take(4).ToArray());
                    data      = data.Skip(4).ToArray();
                    while (dataCount > 0)
                    {
                        Detection theDetection         = new Detection();
                        int       convertingNameLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.DetectionName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingNameLength).ToArray(), "utf-8");
                        nowIndex += convertingNameLength;
                        int theNumber = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.DetectionNumber = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(theNumber).ToArray(), "utf-8");
                        nowIndex += theNumber;
                        theDetection.DetectionID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        int detectionToSecondName = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.DetectionToSecondName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(detectionToSecondName).ToArray(), "utf-8");
                        nowIndex += detectionToSecondName;
                        theDetection.DetectionToSecondID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex            += 4;
                        theDetection.RemoteA = ByteWithString.byteToHexStr(data.Skip(nowIndex).Take(2).ToArray());
                        nowIndex            += 2;
                        theDetection.RemoteB = ByteWithString.byteToHexStr(data.Skip(nowIndex).Take(2).ToArray());
                        nowIndex            += 2;
                        theDetection.RemoteC = ByteWithString.byteToHexStr(data.Skip(nowIndex).Take(2).ToArray());
                        nowIndex            += 2;
                        int circuitLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.DetectionToName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(circuitLength).ToArray(), "utf-8");
                        nowIndex += circuitLength;
                        theDetection.DetectionToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        dataCount--;
                        theDetectionArray.Add(theDetection);
                    }
                    theClientReport.REPORT_BODY = theDetectionArray;
                    break;

                case 0x33:
                    List <DeviceDataSetting> theDeviceDataArray = new List <DeviceDataSetting>();
                    dataCount = returnByteLengthRight(data.Take(4).ToArray());
                    data      = data.Skip(4).ToArray();
                    while (dataCount > 0)
                    {
                        DeviceDataSetting theDetection = new DeviceDataSetting();
                        int convertingNameLength       = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.DeviceDataName = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(convertingNameLength).ToArray(), "utf-8");    //ok
                        nowIndex += convertingNameLength;
                        theDetection.DeviceDataID = ByteWithString.byteToHexStr(data.Skip(nowIndex).Take(2).ToArray()).ToString();
                        nowIndex += 2;
                        theDetection.LastDateTime = ByteWithString.ConvertCP56TIME2aToDateTime(data.Skip(nowIndex).Take(7).ToArray()).ToString("yyyy-MM-dd HH:mm:ss");
                        nowIndex += 7;
                        int ALength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.TheRemoteA = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(ALength).ToArray(), "utf-8");
                        nowIndex += ALength;
                        theDetection.RemoteAToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        int BLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.TheRemoteB = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(BLength).ToArray(), "utf-8");
                        nowIndex += BLength;
                        theDetection.RemoteBToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        int CLength = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray());
                        nowIndex += 4;
                        theDetection.TheRemoteC = ByteWithString.bytetoCodeString(data.Skip(nowIndex).Take(CLength).ToArray(), "utf-8");
                        nowIndex += CLength;
                        theDetection.RemoteCToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        theDetection.DeviceDataToID = returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()).ToString();
                        nowIndex += 4;
                        dataCount--;
                        theDeviceDataArray.Add(theDetection);
                    }
                    theClientReport.REPORT_BODY = theDeviceDataArray;
                    break;

                case 0x35:
                    List <int> valueBuilder = new List <int>();
                    valueBuilder.Add(returnByteLengthRight(data.Skip(0).Take(4).ToArray()));
                    valueBuilder.Add(returnByteLengthRight(data.Skip(4).Take(4).ToArray()));
                    valueBuilder.Add(returnByteLengthRight(data.Skip(8).Take(4).ToArray()));
                    theClientReport.REPORT_BODY = valueBuilder;
                    break;

                case 0x38:
                    Hitch theHitch = new Hitch();
                    theHitch.COUNT  = dataCount = returnByteLengthRight(data.Take(4).ToArray());
                    theHitch.NOW_ID = new List <int>();
                    data            = data.Skip(4).ToArray();
                    while (dataCount > 0)
                    {
                        theHitch.NOW_ID.Add(returnByteLengthRight(data.Skip(nowIndex).Take(4).ToArray()));
                        nowIndex += 4;
                        dataCount--;
                    }
                    theClientReport.REPORT_BODY = theHitch;
                    break;

                default: break;
                }
                theClientReport.VALIDATE_FIELD = data.Skip(data.Length - 2).Take(1).ToArray()[0];
                theClientReport.END_FIELD      = 0x16;
            }
            catch (Exception msg)
            {
                Log.LogWrite(msg);
            }
            return(theClientReport);
        }
예제 #25
0
        public ActionResult Index(ClientReportScreen crs, int[] Reports, int[] PipeSystems, int[] Pipelines, int[] ClientImports, string FromDate, string ToDate, string importFile)
        {
            if (ModelState.IsValid)
            {
                ClientReport cr = new ClientReport();
                cr.CreatedOn        = DateTime.Now;
                cr.CreatedBy_UserID = Convert.ToInt64(Session["UserID"].ToString());
                cr.FromDate         = Convert.ToDateTime(FromDate);
                cr.ToDate           = Convert.ToDateTime(ToDate);
                cr.ImportFile       = importFile;
                cr.PermanentImport  = true;
                cr.Processed        = false;

                db.ClientReports.Add(cr);
                db.SaveChanges();
                Int64 clientreportID = db.ClientReports.Select(c => c.ClientReportID).Max();

                if (Reports != null)
                {
                    ClientReportReportList crrl = new ClientReportReportList();
                    foreach (var ReportID in Reports)
                    {
                        crrl.ClientReportID = clientreportID;
                        crrl.ReportID       = ReportID;
                        db.ClientReportReportLists.Add(crrl);
                        db.SaveChanges();
                    }
                }
                if (PipeSystems != null)
                {
                    ClientReportPipeSystem crps = new ClientReportPipeSystem();
                    foreach (var PipeSystemID in PipeSystems)
                    {
                        crps.ClientReportID = clientreportID;
                        crps.PipeSystemID   = PipeSystemID;
                        db.ClientReportPipeSystems.Add(crps);
                        db.SaveChanges();
                    }
                }
                if (Pipelines != null)
                {
                    ClientReportPipeline crpl = new ClientReportPipeline();
                    foreach (var PipelineID in Pipelines)
                    {
                        crpl.ClientReportID = clientreportID;
                        crpl.PipelineID     = PipelineID;
                        db.ClientReportPipelines.Add(crpl);
                        db.SaveChanges();
                    }
                }
                if (ClientImports != null)
                {
                    ClientReportImportList cril = new ClientReportImportList();
                    foreach (var ClientImportID in ClientImports)
                    {
                        cril.ClientReportID     = clientreportID;
                        cril.ClientImportListID = ClientImportID;
                        db.ClientReportImportLists.Add(cril);
                        db.SaveChanges();
                    }
                }
                return(RedirectToAction("Index", "Admin", null));
            }

            return(View(crs));
        }
예제 #26
0
        static void Main(string[] args)
        {
#warning ПРИ ИЗМЕНЕНИИ БД НЕ ЗАБУДЬ СОЗДАТЬ ТРИГЕРЫ
            using (var aimp = new aimpEntities())
            {
                using (var newDb = new SqlContext())
                {
                    newDb.StatusesCardTrancport.Add(new StatusCardTrancport()
                    {
                        Name = "В наличии"
                    });
                    newDb.StatusesCardTrancport.Add(new StatusCardTrancport()
                    {
                        Name = "Продана"
                    });
                    newDb.StatusesCardTrancport.Add(new StatusCardTrancport()
                    {
                        Name = "Зобрали с комиссии"
                    });

                    foreach (ШАБЛОНЫ шаблоны in aimp.ШАБЛОНЫ)
                    {
                        string type = string.Empty;
                        switch (шаблоны.типы_шаблонов)
                        {
                        case 1:
                            type = PrintedDocumentTemplateType.Сделка.ToString();
                            break;

                        case 2:
                            type = PrintedDocumentTemplateType.Кредит.ToString();
                            break;

                        case 3:
                            type = PrintedDocumentTemplateType.Дкп.ToString();
                            break;

                        case 4:
                            type = PrintedDocumentTemplateType.Акт.ToString();
                            break;

                        case 5:
                            type = PrintedDocumentTemplateType.Комиссия.ToString();
                            break;
                        }
                        PrintedDocumentTemplate reportTemplate = new PrintedDocumentTemplate()
                        {
                            Name     = шаблоны.наименование,
                            File     = шаблоны.файл,
                            FileName = шаблоны.файл_наим,
                            Type     = type
                        };
                        newDb.PrintedDocumentTemplates.Add(reportTemplate);
                    }

                    foreach (ОТЧЁТЫ_КЛИЕНТОВ отчётыКлиентов in aimp.ОТЧЁТЫ_КЛИЕНТОВ)
                    {
                        спр_СТАТУСЫ_КЛИЕНТОВ спрСтатусыКлиентов =
                            aimp.спр_СТАТУСЫ_КЛИЕНТОВ.First(
                                x => x.код == отчётыКлиентов.спр_статусы_клиентов);

                        спр_ПРОГРАММЫ_КРЕДИТОВАНИЯ программыКредитования =
                            aimp.спр_ПРОГРАММЫ_КРЕДИТОВАНИЯ.First(
                                x => x.код == отчётыКлиентов.спр_программы_кредитования);

                        ClientReport clientReport = new ClientReport()
                        {
                            Date              = отчётыКлиентов.дата ?? DateTime.Now,
                            Source            = отчётыКлиентов.источник,
                            FullName          = отчётыКлиентов.фио,
                            Price             = Convert.ToDecimal(отчётыКлиентов.стоимость),
                            TotalContribution =
                                Convert.ToDecimal(отчётыКлиентов.общий_взнос),
                            ClientStatus =
                                newDb.ClientStatuses.Local.FirstOrDefault(
                                    x => x.Name == спрСтатусыКлиентов.наименование) ??
                                new ClientStatus()
                            {
                                Name       = спрСтатусыКлиентов.наименование,
                                UsedFilter = nullBye(спрСтатусыКлиентов.фильтр)
                            },
                            Telefon        = отчётыКлиентов.телефон,
                            CreditProgramm =
                                newDb.CreditProgramms.Local.FirstOrDefault(
                                    x => x.Name == программыКредитования.наименование) ??
                                new CreditProgramm()
                            {
                                Name = программыКредитования.наименование
                            },
                            CreditSum         = Convert.ToDecimal(отчётыКлиентов.сумма_кредита),
                            CommissionKnow    = nullBye(отчётыКлиентов.комиссии_знает),
                            CommissionRemoval =
                                Convert.ToDecimal(отчётыКлиентов.комиссия_за_снятие),
                            CommissionCredit = nullBye(отчётыКлиентов.комиссии_в_кредите),
                            ActAssessment    = Convert.ToDecimal(отчётыКлиентов.акт_оценки),
                            DKP_DK           = отчётыКлиентов.дкп_дк,
                            Comment          = отчётыКлиентов.комментарий,
                            CommissionSalon  = отчётыКлиентов.комиссия_салона,
                            User             = NewUser(отчётыКлиентов.ПОЛЬЗОВАТЕЛИ1, newDb),
                            Trancport        = отчётыКлиентов.тс
                        };

                        foreach (БАНКИ_ДЛЯ_ОТЧЁТЫ_КЛИЕНТОВ банкиДляОтчётыКлиентов in отчётыКлиентов.БАНКИ_ДЛЯ_ОТЧЁТЫ_КЛИЕНТОВ)
                        {
                            BankReportClient bankReportClient = new BankReportClient();
                            bankReportClient.ClientReport = clientReport;
                            bankReportClient.Bank         =
                                newDb.Banks.Local.FirstOrDefault(
                                    x => x.Name == банкиДляОтчётыКлиентов.спр_БАНКИ_ОТЧЁТЫ_КЛИЕНТОВ1.наименование) ??
                                new Bank()
                            {
                                Name = банкиДляОтчётыКлиентов.спр_БАНКИ_ОТЧЁТЫ_КЛИЕНТОВ1.наименование
                            };

                            bankReportClient.BankStatus =
                                newDb.BankStatuses.Local.FirstOrDefault(
                                    x => x.Name == банкиДляОтчётыКлиентов.спр_СТАТУСЫ_БАНКА1.наименование) ??
                                new BankStatus()
                            {
                                Name       = банкиДляОтчётыКлиентов.спр_СТАТУСЫ_БАНКА1.наименование,
                                MiddleName = банкиДляОтчётыКлиентов.спр_СТАТУСЫ_БАНКА1.наименование2
                            };

                            bankReportClient.Used = банкиДляОтчётыКлиентов.используется == null
                                ? false
                                : банкиДляОтчётыКлиентов.используется == 1 ? true : false;

                            newDb.BankReportClients.Add(bankReportClient);
                        }
                    }


                    foreach (var сделка in aimp.СДЕЛКИ)
                    {
                        CashTransaction cash = new CashTransaction();

                        cash.Date   = сделка.дата ?? DateTime.Now;
                        cash.Number = Convert.ToInt32(сделка.номер);

                        if (сделка.КОНТРАГЕНТЫ1 != null)
                        {
                            cash.Buyer = NewContractor(сделка.КОНТРАГЕНТЫ1, newDb);
                        }

                        if (сделка.КОНТРАГЕНТЫ2 != null)
                        {
                            cash.Owner = NewContractor(сделка.КОНТРАГЕНТЫ2, newDb);
                        }

                        cash.Trancport = NewTrancport(сделка.ТРАНСПОРТ1, newDb);
                        cash.Price     = Convert.ToDecimal(сделка.стоимость);
                        cash.User      = NewUser(сделка.ПОЛЬЗОВАТЕЛИ1, newDb);

                        cash.DateProxy      = сделка.дата_доверенность;
                        cash.NumberProxy    = сделка.номер_доверенность;
                        cash.NumberRegistry = сделка.номер_реестр;

                        if (сделка.КОНТРАГЕНТЫ != null)
                        {
                            cash.Seller = NewContractor(сделка.КОНТРАГЕНТЫ, newDb);
                        }

                        switch (сделка.тип)
                        {
                        case 1:
                            newDb.CashTransactions.Add(cash);
                            break;

                        case 2:
                            CreditTransaction credit = new CreditTransaction()
                            {
                                Date           = cash.Date,
                                Number         = cash.Number,
                                Seller         = cash.Seller,
                                Buyer          = cash.Buyer,
                                Owner          = cash.Owner,
                                Trancport      = cash.Trancport,
                                Price          = cash.Price,
                                User           = cash.User,
                                DateProxy      = cash.DateProxy,
                                NumberProxy    = cash.NumberProxy,
                                NumberRegistry = cash.NumberRegistry
                            };
                            credit.AgentDocument = new UserFile()
                            {
                                Name = сделка.агенский_наим,
                                File = сделка.агенский
                            };
                            credit.DkpDocument = new UserFile()
                            {
                                Name = сделка.дкп_наим,
                                File = сделка.дкп
                            };
                            credit.DateAgent          = сделка.дата_ад ?? DateTime.Now;
                            credit.DateDkp            = сделка.дата ?? DateTime.Now;
                            credit.PriceBank          = Convert.ToDecimal(сделка.стоимость_банк);
                            credit.DownPayment        = Convert.ToDecimal(сделка.первый_взнос);
                            credit.CreditSumm         = Convert.ToDecimal(сделка.сумма_кредит);
                            credit.RealPrice          = Convert.ToDecimal(сделка.стоимость_реальная);
                            credit.DownPaymentCashbox = Convert.ToDecimal(сделка.первый_взнос_касса);
                            string creditor = aimp.КРЕДИТОРЫ.FirstOrDefault(x => x.код == сделка.кредиторы)?.наименование;
                            if (!string.IsNullOrWhiteSpace(creditor))
                            {
                                credit.Creditor = newDb.Creditors.Local.FirstOrDefault(x => x.Name == creditor) ??
                                                  new Creditor()
                                {
                                    Name = creditor
                                };
                            }
                            ЕКВИЗИТЫ реквизит = aimp.ЕКВИЗИТЫ.First(x => x.код == сделка.реквизиты);

                            credit.Requisit =
                                newDb.Requisits.Local.FirstOrDefault(
                                    x => x.Name == реквизит.наименование && x.Bik == реквизит.бик) ??
                                new Requisit()
                            {
                                Name      = реквизит.наименование,
                                Bik       = реквизит.бик,
                                InBank    = реквизит.в_банке,
                                Kor_schet = реквизит.кор_счет,
                                Ros_schet = реквизит.рос_счет
                            };

                            credit.ReportInsurance   = Convert.ToDecimal(сделка.отчёт_по_страховым);
                            credit.Rollback          = Convert.ToDecimal(сделка.откат);
                            credit.Source            = сделка.источник;
                            credit.IsCredit          = сделка.кредит == 1 ? true : false;
                            credit.CommissionCashbox = Convert.ToDecimal(сделка.комиссия_Касса);

                            newDb.CreditTransactions.Add(credit);
                            break;

                        case 3:
                        case 5:
                            CommissionTransaction commission = new CommissionTransaction()
                            {
                                Date           = cash.Date,
                                Number         = cash.Number,
                                Seller         = cash.Seller,
                                Buyer          = cash.Buyer,
                                Owner          = cash.Owner,
                                Trancport      = cash.Trancport,
                                Price          = cash.Price,
                                User           = cash.User,
                                DateProxy      = cash.DateProxy,
                                NumberProxy    = cash.NumberProxy,
                                NumberRegistry = cash.NumberRegistry
                            };

                            commission.Commission  = Convert.ToDecimal(сделка.комиссия);
                            commission.Parking     = Convert.ToDecimal(сделка.стоянка);
                            commission.IsTwoMounth = сделка.второй_месяц == null
                                    ? false
                                    : сделка.второй_месяц == 1 ? true : false;

                            newDb.CommissionTransactions.Add(commission);
                            break;
                        }
                    }
                    newDb.SaveChanges();
                }
            }
        }
예제 #27
0
        private void AnalyzeData()
        {
            while (true)
            {
                try
                {
                    if (reports.Count > 0)
                    {
                        ClientReport theClientReport = clientReportSerialize(reports[0]);
                        reports.RemoveAt(0);
                        switch (theClientReport.CONTROL_FIELD)
                        {
                        case 0x02:    //登录
                            logDataEventArg.data = (theClientReport.REPORT_BODY as returnLoginInfo).isOk.ToString();
                            loginHandler(this, logDataEventArg);
                            break;

                        case 0x03:    //获得设备
                            logDataEventArg.theTreeArrayData = theClientReport.REPORT_BODY as DeviceData;
                            getTreeDataHandler(this, logDataEventArg);
                            break;

                        case 0x05:    //获得目录
                            logDataEventArg.obj = theClientReport.REPORT_BODY as TheCatalog;
                            summonDirectoryHandler(this, logDataEventArg);
                            break;

                        case 0x07:    //下载文件
                            logDataEventArg.obj = theClientReport.REPORT_BODY as CatalogFiles;
                            updateDirectoryHandler(this, logDataEventArg);
                            break;

                        case 0x10:    //不带时标的遥信标数据
                            logDataEventArg.obj = theClientReport.REPORT_BODY as TheRemoteDataArray;
                            theRemoteDataArrayHandler(this, logDataEventArg);
                            break;

                        case 0x11:    //带时标的遥信标数据
                            logDataEventArg.obj = theClientReport.REPORT_BODY as TheRemoteDataArray;
                            theRemoteDataArrayHandler(this, logDataEventArg);
                            break;

                        case 0x12:    //遥测表数据
                            logDataEventArg.obj = theClientReport.REPORT_BODY as TheRemoteDataArray;
                            theTelemeteringHandler(this, logDataEventArg);
                            break;

                        case 0x14:    //参数设定
                            logDataEventArg.obj = theClientReport.REPORT_BODY as ResponseValueData;
                            theResponseValueHandler(this, logDataEventArg);
                            break;

                        case 0x0a:    //服务器报文
                            logDataEventArg.obj = theClientReport.REPORT_BODY as ReportContentText;
                            sendReceiveLogHandler(this, logDataEventArg);
                            break;

                        case 0x23:    //接收变电站
                            logDataEventArg.obj = theClientReport.REPORT_BODY as List <ConvertingStation>;
                            convertingStationHandel(this, logDataEventArg);
                            break;

                        case 0x24:    //接收母线
                            logDataEventArg.obj = theClientReport.REPORT_BODY as List <Generatrix>;
                            generatrixHandel(this, logDataEventArg);
                            break;

                        case 0x25:    //接收线路
                            logDataEventArg.obj = theClientReport.REPORT_BODY as List <Circuit>;
                            circuitHandel(this, logDataEventArg);
                            break;

                        case 0x26:    //接收检测点
                            logDataEventArg.obj = theClientReport.REPORT_BODY as List <Detection>;
                            detectionHandel(this, logDataEventArg);
                            break;

                        case 0x33:    //接收设备
                            logDataEventArg.obj = theClientReport.REPORT_BODY as List <DeviceDataSetting>;
                            deviceSettingHandel(this, logDataEventArg);
                            break;

                        case 0x35:    //返回定时执行参数
                            logDataEventArg.obj = theClientReport.REPORT_BODY as List <int>;
                            timeParameterHandel(this, logDataEventArg);
                            break;

                        case 0x38:    //故障检测点id
                            logDataEventArg.obj = theClientReport.REPORT_BODY as Hitch;
                            theHitchHandler(this, logDataEventArg);
                            break;
                        }
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                }
                catch
                {
                    continue;
                }
            }
        }
예제 #28
0
 private void AddPatientInfo(Section section, ClientReport clientReport)
 {
     new ClientInfo().Add(section, clientReport);
 }