示例#1
0
        public void Save()
        {
            channel.CallSPAsSQLText = this.checkBoxSQLText.Checked;

            channel.ChannelName   = txtChannelName.Text;
            channel.Enable        = checkBoxStatus.Checked;
            channel.OperationType = (ThrPartyDBOperationType)Enum.Parse(typeof(ThrPartyDBOperationType), enumCmbbxOperationType.Text);
            channel.OperationName = txtModeName.Text;

            //Save Query Criteria
            if (enumCmbbxOperationType.Text == ThrPartyDBOperationType.StorageProcedure.ToString())
            {
                channel.Rule.QueryCriteria.Type         = QueryCriteriaRuleType.DataSet;
                channel.Rule.QueryCriteria.SQLStatement = "";
                channel.Rule.QueryCriteria.MappingList  = criteriaItemList;
            }
            else
            {
                channel.Rule.QueryCriteria.Type         = QueryCriteriaRuleType.SQLStatement;
                channel.Rule.QueryCriteria.SQLStatement = txtStatement.Text;
                channel.Rule.QueryCriteria.MappingList.Clear();
            }

            //Save Query Result
            channel.Rule.QueryResult.MappingList = resultItemList;

            if (type == "Add")
            {
                channelSet.Add(channel);
            }
        }
示例#2
0
        private void LoadDefaultConfiguration()
        {
            // Identity

            EntityID    = Guid.NewGuid();
            Description = "CS Broker Outbound Adapter";
            DeviceName  = DEVICE_NAME;
            Name        = Program.Context.AppName;

            // Default Transferring(routing) Contract

            Interaction    = InteractionTypes.Subscriber;
            Direction      = DirectionTypes.Outbound;
            ResponseConfig = null;
            RequestConfig  = null;
            PublishConfig  = null;

            // Other Default Configuration

            CSBrokerOLEDBConnectionString          = "Provider=SQLNCLI;Server=(local)\\SQLExpress;Database=GWDataDB;UID=sa;Password=123456;";
            CSBrokerPassiveSQLInboundInterfaceName = "";
            EnableXMLTransform     = false;
            EnaleKanJiReplacement  = false;
            KanJiReplacementChar   = ".";
            XSLTFilePath           = "";
            EnableValueReplacement = false;
            _valueReplacement      = new XCollection <ValueReplacementRule>();
            _valueReplacement.Add(new ValueReplacementRule()
            {
                FieldName         = "ORDER_SCHEDULED_DT",
                MatchExpression   = @"\b(?<year>\d{2,4})(?<month>\d{1,2})(?<day>\d{1,2})(?<hour>\d{1,2})(?<minute>\d{1,2})(?<second>\d{1,2}).(?<fractal>\d{1,3})\b",
                ReplaceExpression = @"${year}-${month}-${day} ${hour}:${minute}:${second}"
            });
        }
示例#3
0
 private void GetGCFieldSet(XCollection <SQLInQueryResultItem> parameterList)
 {
     foreach (SQLInQueryResultItem parameter in parameterList)
     {
         resultList.Add(parameter.GWDataDBField);
     }
 }
示例#4
0
 private void CloneFilterItem(XCollection <QueryCriteriaItem> target, XCollection <QueryCriteriaItem> source)
 {
     foreach (QueryCriteriaItem item in source)
     {
         target.Add(item);
     }
 }
示例#5
0
        public T Add <T>(Form parentForm, XCollection <T> list)
            where T : MappingItem, IDicomMappingItem, new()
        {
            T selitem = GetSelectedItem() as T;

            FormElement2 <T> frm = new FormElement2 <T>(null, list, selitem, false, _gwDataDBConnection, _log, _asQueryResult, _isInbound);

            BeforeShowFormElement(ButtonType.Add, frm, selitem);
            if (frm.ShowDialog(parentForm) != DialogResult.OK)
            {
                return(null);
            }
            AfterShowFormElement(ButtonType.Add, frm, selitem);

            T newitem = frm.MappingItem;

            if (newitem == null)
            {
                return(null);
            }

            if (selitem == null)
            {
                list.Add(newitem);
            }
            else
            {
                newitem.DPath.Catagory = selitem.DPath.Catagory;
                int index = list.IndexOf(selitem);
                list.Insert(index, newitem);
            }

            return(newitem);
        }
示例#6
0
        private void Save()
        {
            resultItem.ThirdPartyDBPatamter.FieldName = this.txtThirdPartyFieldName.Text.Trim();
            resultItem.ThirdPartyDBPatamter.FieldType = (OleDbType)Enum.Parse(typeof(OleDbType), this.enumCmbbxThirdPartyFieldType.Text);
            resultItem.GWDataDBField.Table            = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), this.enumCmbbxTable.Text);
            resultItem.GWDataDBField.FieldName        = this.cmbbxGWField.Text.Trim();
            resultItem.SourceField      = this.cmbbxGWField.Text.Trim();
            resultItem.TargetField      = this.txtThirdPartyFieldName.Text.Trim();
            resultItem.Translating.Type = (TranslatingType)Enum.Parse(typeof(TranslatingType), this.enumCmbbxTranslation.Text);
            if (enumCmbbxTranslation.Text == TranslatingType.LookUpTable.ToString() || enumCmbbxTranslation.Text == TranslatingType.LookUpTableReverse.ToString())
            {
                LUTWrapper w = this.cmbbxResult.SelectedItem as LUTWrapper;
                if (w != null)
                {
                    resultItem.Translating.LutName    = w.TableName;
                    resultItem.Translating.ConstValue = "";
                }
            }
            else if (enumCmbbxTranslation.Text == TranslatingType.FixValue.ToString() || enumCmbbxTranslation.Text == TranslatingType.DefaultValue.ToString())
            {
                resultItem.Translating.LutName    = "";
                resultItem.Translating.ConstValue = this.txtTranslationValue.Text;
            }
            else
            {
                resultItem.Translating.LutName    = "";
                resultItem.Translating.ConstValue = "";
            }
            resultItem.RedundancyFlag = bool.Parse(enumCmbbxRedundancy.Text);

            if (type == "Add")
            {
                resultList.Add(resultItem);
            }
        }
示例#7
0
        public static void PreperatMappingList <T>(XCollection <T> target, XCollection <T> source)
            where T : XObject, IDicomMappingItem
        {
            if (target == null || source == null)
            {
                return;
            }

            target.Clear();
            int count = source.Count;

            for (int i = 0; i < source.Count; i++)
            {
                T t = source[i];
                if (t.DPath.Enable == false && t.DPath.Type == DPathType.Normal)
                {
                    if (t.DPath.VR == DVR.SQ)
                    {
                        EatDisableSequence(source, ref i);
                    }
                    continue;
                }
                target.Add(t);
            }
        }
示例#8
0
        public XCollection<Book.SequenceInfo> GetSequences()
        {
            var sequences = new XCollection<Book.SequenceInfo>();
            if (series != null)
            {
                foreach (var seria in series)
                {
                    try
                    {
                        var imageUrl = string.Format("{0}{1}", "http://win10-ebook.litres.ru", seria.img);

                        sequences.Add(new Book.SequenceInfo
                        {
                            Id = int.Parse(seria.id),
                            Number = int.Parse(seria.total_arts),
                            Name = seria.name,
                            ImgUrl = imageUrl
                        });
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
            return sequences;
        }
示例#9
0
        public MessageEntityConfigConfig GetMessageEntityConfigConfig(string entityName)
        {
            MessageEntityConfigConfig cfg = null;

            if (string.IsNullOrEmpty(entityName))
            {
                return(cfg);
            }
            lock (_messageEntityConfigConfigs)
            {
                foreach (MessageEntityConfigConfig c in _messageEntityConfigConfigs)
                {
                    if (c.EntityName == entityName)
                    {
                        cfg = c;
                        break;
                    }
                }
                if (cfg == null)
                {
                    cfg            = new MessageEntityConfigConfig();
                    cfg.EntityName = entityName;
                    _messageEntityConfigConfigs.Add(cfg);
                }
            }
            return(cfg);
        }
示例#10
0
        /// <summary>
        /// You can create a replacement rule list in your configuration file for user to select.
        /// And use the this function to initialize it as default configuration.
        /// </summary>
        /// <returns></returns>
        public static XCollection <ReplacementRule> CreateDefaultReplacementRuleList()
        {
            XCollection <ReplacementRule> l = new XCollection <ReplacementRule>();

            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"(^\s*)|(\s*$)",
                ReplaceExpression = "",
                Description       = "Trim blank on the both sides of a string."
            });

            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"[\^]",
                ReplaceExpression = " ",
                Description       = "Replace ^ with blank in person name."
            });
            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"\b(?<family>\w+)\^(?<given>\w+)\b",
                ReplaceExpression = "${given}^${family}",
                Description       = "Transform person name from Family Name^Given Name to Given Name^Family Name."
            });

            l.Add(new ReplacementRule()
            {
                MatchExpression   = "[/]",
                ReplaceExpression = "-",
                Description       = "Replace / with - in date time string."
            });
            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"\b(?<month>\d{1,2})/(?<day>\d{1,2})/(?<year>\d{2,4})\b",
                ReplaceExpression = "${year}-${month}-${day}",
                Description       = "Transform date time from MM/DD/YYYY to YYYY-MM-DD."
            });
            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"\b(?<year>\d{2,4})(?<month>\d{1,2})(?<day>\d{1,2})\b",
                ReplaceExpression = "${year}-${month}-${day}",
                Description       = "Transform date time from YYYYMMDD to YYYY-MM-DD."
            });
            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"\b(?<year>\d{2,4})(?<month>\d{1,2})(?<day>\d{1,2})(?<hour>\d{1,2})(?<minute>\d{1,2})(?<second>\d{1,2})\b",
                ReplaceExpression = "${year}-${month}-${day} ${hour}:${minute}:${second}",
                Description       = "Transform date time from YYYYMMDDHHMMSS to YYYY-MM-DD HH:MM:SS."
            });
            l.Add(new ReplacementRule()
            {
                MatchExpression   = @"\b(?<year>\d{2,4})(?<month>\d{1,2})(?<day>\d{1,2})(?<hour>\d{1,2})(?<minute>\d{1,2})(?<second>\d{1,2}).(?<fractal>\d{1,3})\b",
                ReplaceExpression = "${year}-${month}-${day} ${hour}:${minute}:${second}",
                Description       = "Transform date time from YYYYMMDDHHMMSS.FFF to YYYY-MM-DD HH:MM:SS."
            });

            return(l);
        }
示例#11
0
        public static void SetAdditionalQueryCriteria <TC>(XCollection <TC> qcList, XCollection <TC> additionalQCList, QueryCriteriaType additionalQCJoinType)
            where TC : QueryCriteriaItem, IDicomMappingItem, new()
        {
            if (qcList == null || additionalQCList == null)
            {
                return;
            }

            if (qcList.Count < 1)
            {
                foreach (TC qcItem in additionalQCList)
                {
                    qcList.Add(qcItem);
                }
            }
            else if (additionalQCList.Count > 0)
            {
                qcList[0].Type           = QueryCriteriaType.None;
                additionalQCList[0].Type = QueryCriteriaType.None;

                TC qcLeft = new TC();
                qcLeft.Singal = QueryCriteriaSignal.LeftBracket;
                qcLeft.Type   = QueryCriteriaType.None;
                qcList.Insert(0, qcLeft);

                TC qcRight = new TC();
                qcRight.Singal = QueryCriteriaSignal.RightBracket;
                qcRight.Type   = QueryCriteriaType.None;
                qcList.Add(qcRight);

                TC qcAddLeft = new TC();
                qcAddLeft.Singal = QueryCriteriaSignal.LeftBracket;
                qcAddLeft.Type   = additionalQCJoinType;
                qcList.Add(qcAddLeft);

                foreach (TC qcItem in additionalQCList)
                {
                    qcList.Add(qcItem);
                }

                TC qcAddRight = new TC();
                qcAddRight.Singal = QueryCriteriaSignal.RightBracket;
                qcAddRight.Type   = QueryCriteriaType.None;
                qcList.Add(qcAddRight);
            }
        }
示例#12
0
        private XCollection <GWDataDBField> ParseTemplate()
        {
            XCollection <GWDataDBField> fields = new XCollection <GWDataDBField>();

            string s, sub;

            s = tbTemplate.Text;
            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Index))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Patient))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Order))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            foreach (GWDataDBField f in GWDataDBField.GetFields(GWDataDBTable.Report))
            {
                sub = "[%" + f.GetFullFieldName().Replace(".", "_") + "%]";
                if (s.IndexOf(sub) >= 0)
                {
                    fields.Add(f);
                }
            }

            return(fields);
        }
示例#13
0
        public static XCollection <T> GetSequence <T>(int sqItemIndex, XCollection <T> list)
            where T : XObject, IDicomMappingItem
        {
            if (list == null)
            {
                return(null);
            }
            if (sqItemIndex < -1 || sqItemIndex >= list.Count)
            {
                return(null);
            }
            // if sqItemIndex==-1 return root item list

            if (sqItemIndex >= 0)
            {
                T t = list[sqItemIndex];
                if (t.DPath.Type == DPathType.Normal && t.DPath.VR == DVR.SQ)
                {
                    if (!HasSequence <T>(sqItemIndex, list))
                    {
                        return(new XCollection <T>());
                    }
                }
            }

            int beginindex, endindex;

            beginindex = endindex = sqItemIndex >= 0 ? sqItemIndex + 1 : -1;

            XCollection <T> sqlist = new XCollection <T>();

            FindEndDPathIndex <T>(ref endindex, list);

            if (beginindex < 0)
            {
                beginindex = 0;
            }
            if (endindex >= list.Count)
            {
                endindex = list.Count - 1;
            }
            for (int i = beginindex; i <= endindex; i++)
            {
                T t = list[i];
                if (t.DPath.Type == DPathType.Normal)
                {
                    sqlist.Add(t);
                    if (t.DPath.VR == DVR.SQ && HasSequence <T>(i, list))
                    {
                        FindEndDPathIndex(ref i, list);
                    }
                }
            }

            return(sqlist);
        }
示例#14
0
        public static void Run()
        {
            XCollection coll = new XCollection();

            coll.Add("A");
            coll.Add("B");
            coll.Add("C");
            coll.Add("D");
            coll.Add("E");

            IXIterator it = coll.GetIterator();
            object     o;

            while ((o = it.Next()) != null)
            {
                Console.WriteLine(o);
            }

            // 출력 : A C E  (0, 2, 4 등 짝수만 출력함)
        }
示例#15
0
        private void LoadDefaultInboundSP()
        {
            channelSet.Clear();

            string interfaceName = Program.DeviceMgt.DeviceDirInfor.Header.Name;

            //Patient Table
            SQLInboundChanel chnPatient = channelSet.Add(new SQLInboundChanel());

            chnPatient.Rule.RuleID = GWDataDBTable.Patient.ToString();
            chnPatient.SPName      = "sp_" + interfaceName + "_" + GWDataDBTable.Patient.ToString();

            LoadTableParameter(chnPatient, GWDataDBTable.Index, interfaceName);
            LoadTableParameter(chnPatient, GWDataDBTable.Patient, interfaceName);
            chnPatient.SPStatement = RuleControl.GetInboundSP(interfaceName, chnPatient.Rule, false);

            //Order Table
            SQLInboundChanel chnOrder = channelSet.Add(new SQLInboundChanel());

            chnOrder.Rule.RuleID = GWDataDBTable.Order.ToString();
            chnOrder.SPName      = "sp_" + interfaceName + "_" + GWDataDBTable.Order.ToString();

            LoadTableParameter(chnOrder, GWDataDBTable.Index, interfaceName);
            LoadTableParameter(chnOrder, GWDataDBTable.Patient, interfaceName);
            LoadTableParameter(chnOrder, GWDataDBTable.Order, interfaceName);
            chnOrder.SPStatement = RuleControl.GetInboundSP(interfaceName, chnOrder.Rule, false);


            //Report Table
            SQLInboundChanel chnReport = channelSet.Add(new SQLInboundChanel());

            chnReport.Rule.RuleID = GWDataDBTable.Report.ToString();
            chnReport.SPName      = "sp_" + interfaceName + "_" + GWDataDBTable.Report.ToString();

            LoadTableParameter(chnReport, GWDataDBTable.Index, interfaceName);
            LoadTableParameter(chnReport, GWDataDBTable.Patient, interfaceName);
            LoadTableParameter(chnReport, GWDataDBTable.Order, interfaceName);
            LoadTableParameter(chnReport, GWDataDBTable.Report, interfaceName);
            chnReport.SPStatement = RuleControl.GetInboundSP(interfaceName, chnReport.Rule, false);
        }
示例#16
0
        private void Save()
        {
            criteriaItem.ThirdPartyDBPatamter.FieldName = this.txtThirdpartyFieldName.Text.Trim();
            criteriaItem.ThirdPartyDBPatamter.FieldType = (OleDbType)Enum.Parse(typeof(OleDbType), enumCmbbxThirdPartyFieldType.Text);
            criteriaItem.Operator = (QueryCriteriaOperator)Enum.Parse(typeof(QueryCriteriaOperator), enumCmbbxOperator.Text);
            criteriaItem.Translating.ConstValue = this.txtValue.Text;
            criteriaItem.Type = (QueryCriteriaType)Enum.Parse(typeof(QueryCriteriaType), enumCmbbxJoin.Text);

            if (type == "Add")
            {
                criteriaList.Add(criteriaItem);
            }
        }
示例#17
0
        private void Save()
        {
            filterItem.GWDataDBField.Table     = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), enumCmbbxTable.Text);
            filterItem.GWDataDBField.FieldName = cmbbxGWField.Text;
            filterItem.Operator = (QueryCriteriaOperator)Enum.Parse(typeof(QueryCriteriaOperator), enumCmbbxOperator.Text);
            filterItem.Translating.ConstValue = txtValue.Text;
            filterItem.Type = (QueryCriteriaType)Enum.Parse(typeof(QueryCriteriaType), enumCmbbxJoin.Text);

            if (type == "Add")
            {
                filterItemList.Add(filterItem);
            }
        }
示例#18
0
        private static void AddEventTypeItem(XCollection <StorageItem> itemList, string value)
        {
            if (itemList == null)
            {
                return;
            }
            StorageItem item = new StorageItem();

            item.GWDataDBField          = GWDataDBField.i_EventType.Clone();
            item.Translating.Type       = TranslatingType.FixValue;
            item.Translating.ConstValue = value;
            itemList.Add(item);
        }
示例#19
0
 public XCollection<Book> GetBooks()
 {
     var artsCollection = new XCollection<Book>();
     if (arts != null)
     {
         foreach (var art in arts)
         {
             var book = art.ToBook();
             artsCollection.Add(book);
         }
     }
     return artsCollection;
 }
示例#20
0
 public XCollection<Person> GetPersons()
 {
     var persons = new XCollection<Person>();
     if (authors != null)
     {
         foreach (var author in authors)
         {
             var person = author.ToPerson();
             persons.Add(person);
         }
     }
     return persons;
 }
示例#21
0
        public static void SetDataIDMapping <TR>(XCollection <TR> mappingList)
            where TR : QueryResultItem, new()
        {
            if (mappingList == null)
            {
                return;
            }
            TR item = new TR();

            item.GWDataDBField = GWDataDBField.i_IndexGuid;
            item.TargetField   = DATAID;
            mappingList.Add(item);
        }
示例#22
0
        private void Save()
        {
            criteriaItem.GWDataDBField.Table     = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), enumCmbbxTable.Text.Trim());
            criteriaItem.GWDataDBField.FieldName = this.cmbbxGatewayField.Text.Trim();
            criteriaItem.Operator               = (QueryCriteriaOperator)Enum.Parse(typeof(QueryCriteriaOperator), this.enumCmbbxOperator.Text.Trim());
            criteriaItem.Translating.Type       = TranslatingType.FixValue;
            criteriaItem.Translating.ConstValue = this.txtValue.Text;
            criteriaItem.Type = (QueryCriteriaType)Enum.Parse(typeof(QueryCriteriaType), enumCmbbxJoin.Text.Trim());

            if (type == "Add")
            {
                criteriaList.Add(criteriaItem);
            }
        }
示例#23
0
        private void SaveChecked()
        {
            _FileFields.Clear();

            for (int i = 0; i < this.listView1.Items.Count; i++)
            {
                ListViewItem  lvi = this.listView1.Items[i];
                GWDataDBField dbf = (GWDataDBField)lvi.Tag;

                if (lvi.Checked)
                {
                    _FileFields.Add(dbf);
                }
            }
        }
示例#24
0
        public void UpdatePrivateTagList()
        {
            Dictionary <string, PrivateTag> dic = new Dictionary <string, PrivateTag>();

            foreach (MWLQueryCriteriaItem qcItem in Rule.QueryCriteria.MappingList)
            {
                if (qcItem.DPath.Type != DPathType.Normal)
                {
                    continue;
                }
                int tag = qcItem.DPath.GetTag();
                if (PrivateTagHelper.IsPrivateTag(tag))
                {
                    string strTag = DHelper.Int2HexString(tag);
                    if (!dic.ContainsKey(strTag))
                    {
                        dic.Add(strTag, new PrivateTag(strTag, qcItem.DPath.VR));
                    }
                }
            }

            // do not keep manually added item, refresh the whole private tag list

            //if (PrivateTagList != null)
            //{
            //    foreach (PrivateTag tag in PrivateTagList)
            //    {
            //        string strTag = tag.Tag;
            //        if (!dic.ContainsKey(strTag))
            //        {
            //            dic.Add(strTag, tag);
            //        }
            //    }
            //}

            XCollection <PrivateTag> xlist = new XCollection <PrivateTag>();

            foreach (KeyValuePair <string, PrivateTag> p in dic)
            {
                xlist.Add(p.Value);
            }
            PrivateTagList = xlist;
        }
示例#25
0
        private void Add()
        {
            FormQCItem frm = new FormQCItem(null, _qcList);

            if (frm.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            QueryCriteriaItem item = frm.QCItem;

            if (item == null)
            {
                return;
            }

            _qcList.Add(item);

            RefreshList();
            SelectItem(item);
        }
示例#26
0
        public void Save()
        {
            channel.ChannelName   = txtChannelName.Text;
            channel.Enable        = checkBoxStatus.Checked;
            channel.OperationType = (ThrPartyDBOperationType)Enum.Parse(typeof(ThrPartyDBOperationType), enumCmbbxOperationType.Text);
            channel.OperationName = txtModeName.Text;
            channel.Rule.RuleName = "SP_" + Program.DeviceMgt.DeviceDirInfor.Header.Name + "_" + this.txtChannelName.Text;

            //Save Query Criteria
            channel.Rule.QueryCriteria.Type         = QueryCriteriaRuleType.DataSet;
            channel.Rule.QueryCriteria.SQLStatement = "";
            channel.Rule.QueryCriteria.MappingList  = criteriaItemList;

            //Save Query Result
            channel.Rule.QueryResult.MappingList = resultItemList;

            if (type == "Add")
            {
                channelSet.Add(channel);
            }
        }
示例#27
0
        private void Save()
        {
            channel.Rule.RuleID = txtSPName.Text.Substring(SPPrefixLenth);
            channel.SPName      = txtSPName.Text;
            if (statementPage.IsChanged)
            {
                channel.Modified = true;
            }
            else
            {
                channel.Modified = false;
            }

            parameterPage.Save();
            statementPage.Save();

            if (type == "Add")
            {
                channelSet.Add(channel);
            }
        }
示例#28
0
        private void Save()
        {
            if (enumCmbbxTranslation.Text == TranslatingType.FixValue.ToString())
            {
                txtParameter.Text = "";
            }

            parameterItem.SourceField             = txtParameter.Text;
            parameterItem.GWDataDBField.FieldName = cmbbxGWField.Text;
            parameterItem.GWDataDBField.Table     = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), enumCmbbxTable.Text);
            parameterItem.Operator = (QueryCriteriaOperator)Enum.Parse(typeof(QueryCriteriaOperator), enumCmbbxOperator.Text);

            if (enumCmbbxTranslation.Text == TranslatingType.LookUpTable.ToString() || enumCmbbxTranslation.Text == TranslatingType.LookUpTableReverse.ToString())
            {
                string str = this.cmbbxResult.SelectedItem as string;
                parameterItem.Translating.Type       = (TranslatingType)Enum.Parse(typeof(TranslatingType), enumCmbbxTranslation.Text);
                parameterItem.Translating.LutName    = (str == null) ? "" : str;
                parameterItem.Translating.ConstValue = "";
            }
            else if (enumCmbbxTranslation.Text == TranslatingType.FixValue.ToString() || enumCmbbxTranslation.Text == TranslatingType.DefaultValue.ToString())
            {
                parameterItem.Translating.Type       = (TranslatingType)Enum.Parse(typeof(TranslatingType), enumCmbbxTranslation.Text);
                parameterItem.Translating.LutName    = "";
                parameterItem.Translating.ConstValue = txtTranslationValue.Text;
            }
            else
            {
                parameterItem.Translating.Type       = (TranslatingType)Enum.Parse(typeof(TranslatingType), enumCmbbxTranslation.Text);
                parameterItem.Translating.LutName    = "";
                parameterItem.Translating.ConstValue = "";
            }

            parameterItem.Type = (QueryCriteriaType)Enum.Parse(typeof(QueryCriteriaType), enumCmbbxJoin.Text);

            if (type == "Add")
            {
                parameterList.Add(parameterItem);
            }
        }
示例#29
0
        private void Save()
        {
            if (enumCmbbxTranslation.Text == TranslatingType.FixValue.ToString())
            {
                enumCmbbxTable.Text = GWDataDBTable.None.ToString();
                cmbbxGWField.Text   = "";
            }

            parameterItem.ThirdPartyDBPatamter.FieldName = txtParameter.Text;
            parameterItem.GWDataDBField.FieldName        = cmbbxGWField.Text;
            parameterItem.GWDataDBField.Table            = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), enumCmbbxTable.Text);
            parameterItem.SourceField = cmbbxGWField.Text;
            parameterItem.TargetField = txtParameter.Text;
            if (enumCmbbxTranslation.Text == TranslatingType.LookUpTable.ToString() || enumCmbbxTranslation.Text == TranslatingType.LookUpTableReverse.ToString())
            {
                string str = this.cmbbxResult.SelectedItem as string;
                parameterItem.Translating.Type       = (TranslatingType)Enum.Parse(typeof(TranslatingType), enumCmbbxTranslation.Text);
                parameterItem.Translating.LutName    = (str == null) ? "" : str;
                parameterItem.Translating.ConstValue = "";
            }
            else if (enumCmbbxTranslation.Text == TranslatingType.FixValue.ToString() || enumCmbbxTranslation.Text == TranslatingType.DefaultValue.ToString())
            {
                parameterItem.Translating.Type       = (TranslatingType)Enum.Parse(typeof(TranslatingType), enumCmbbxTranslation.Text);
                parameterItem.Translating.LutName    = "";
                parameterItem.Translating.ConstValue = txtTranslationValue.Text;
            }
            else
            {
                parameterItem.Translating.Type       = (TranslatingType)Enum.Parse(typeof(TranslatingType), enumCmbbxTranslation.Text);
                parameterItem.Translating.LutName    = "";
                parameterItem.Translating.ConstValue = "";
            }

            if (type == "Add")
            {
                parameterList.Add(parameterItem);
            }
        }
示例#30
0
        private void Save()
        {
            channel.ChannelName = this.txtChannelName.Text;
            channel.Enable      = this.checkBoxStatus.Checked;
            if (radiobtnStatement.Checked == true)
            {
                channel.Rule.QueryCriteria.Type         = QueryCriteriaRuleType.SQLStatement;
                channel.Rule.QueryCriteria.SQLStatement = this.txtStatement.Text;
                channel.Rule.QueryCriteria.MappingList.Clear();
            }
            else
            {
                channel.Rule.QueryCriteria.Type         = QueryCriteriaRuleType.DataSet;
                channel.Rule.QueryCriteria.SQLStatement = "";
                channel.Rule.QueryCriteria.MappingList  = criteriaList;
            }
            channel.Rule.QueryResult.MappingList = resultList;

            if (type == "Add")
            {
                channelSet.Add(channel);
            }
        }
示例#31
0
        private void LoadDefaultConfiguration()
        {
            // Identity

            EntityID    = Guid.NewGuid();
            Description = "CS Broker Inbound Adapter";
            DeviceName  = DEVICE_NAME;
            Name        = Program.Context.AppName;

            // Default Transferring(routing) Contract

            Interaction = InteractionTypes.Publisher;
            Direction   = DirectionTypes.Inbound;
            PublishConfig.Publication.MessageTypeList.Add(MessageRegistry.GENERIC_NotificationMessageType);
            SubscribeConfig = null;
            ResponseConfig  = null;

            // Other Default Configuration
            CSBrokerConnectionString = "Provider=SQLNCLI;Server=(local)\\SQLExpress;Database=GWDataDB;UID=sa;Password=123456;";
            CSBrokerSQLOutboundName  = "SQL_OUT";
            TimerInterval            = 3000;
            EnaleKanJiReplacement    = false;
            KanJiReplacementChar     = ".";

            EnableValueReplacement = false;
            _valueReplacement      = new XCollection <ValueReplacementRule>();
            _valueReplacement.Add(new ValueReplacementRule()
            {
                FieldName         = "ORDER_SCHEDULED_DT",
                MatchExpression   = @"\b(?<year>\d{2,4})(?<month>\d{1,2})(?<day>\d{1,2})(?<hour>\d{1,2})(?<minute>\d{1,2})(?<second>\d{1,2}).(?<fractal>\d{1,3})\b",
                ReplaceExpression = @"${year}-${month}-${day} ${hour}:${minute}:${second}"
            });

            MessageDispatchConfig.Model     = MessageDispatchModel.Request;
            MessageDispatchConfig.TableName = GWDataDBTable.None.ToString();
            MessageDispatchConfig.FieldName = string.Empty;
        }
示例#32
0
        public XCollection<Book> GetMyBooksByTimeLocal()
        {
            if (_myBooksByTime != null && _myBooksByTime.Count > 0)
            {
                var userBooks = new XCollection<Book>();
                foreach (var book in _myBooksByTime)
                {
                    if (book.IsMyBook) userBooks.Add(book);
                }
                return userBooks;
            }

            return _myBooksByTime;
        }
示例#33
0
        public XCollection<Book.CollectionsInfo> GetCollection()
        {
            var sequences = new XCollection<Book.CollectionsInfo>();
            if (collections != null)
            {
                foreach (var collection in collections)
                {
                    try
                    {
                        var imageUrl = string.Format("{0}{1}", "http://win10-ebook.litres.ru", collection.img);

                        sequences.Add(new Book.CollectionsInfo
                        {
                            Id = int.Parse(collection.id),
                            Number = int.Parse(collection.arts_count),
                            Name = collection.name,
                            ImgUrl = imageUrl
                        });
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
            return sequences;
        }
示例#34
0
        public async Task<XCollection<Book>> GetPopularBooks(int fromPosition, CancellationToken cancellationToken, int customBooksOnPage = 0)
        {
            int booksOnPage = customBooksOnPage > 0 ? customBooksOnPage : BooksInPage;
            if (_popularBooks == null)
            {
                string limit = string.Format("{0},{1}", fromPosition, booksOnPage);

                var parameters = new Dictionary<string, object>
                {
                    {"sort", "pop_desc"},
                    {"limit", limit},
                };

                var books = await _client.SearchCatalog(parameters, cancellationToken);

                CheckMyBooks(books.Books);

                _popularBooks = books.Books;
            }
            else
            {
                int lastIndex = fromPosition + booksOnPage;

                var collection = new XCollection<Book>(_popularBooks.Take(lastIndex));

                if (collection.Count() + BooksInPageShift < lastIndex)
                {
                    lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, booksOnPage);

                    var parameters = new Dictionary<string, object>
                    {
                        {"sort", "pop_desc"},
                        {"limit", limit},
                    };

                    var books = await _client.SearchCatalog(parameters, cancellationToken);

                    if (books != null && books.Books != null && books.Books.Any())
                    {
                        CheckMyBooks(books.Books);

                        foreach (var book in books.Books)
                        {
                            if (!collection.ContainsKey(book.GetKey()))
                            {
                                collection.Add(book);
                            }
                        }
                    }

                    _popularBooks = collection;
                }
                _dataCacheService.PutItem(_popularBooks, PopularBooksCacheItemName, cancellationToken);
                return collection;
            }
            _dataCacheService.PutItem(_popularBooks, PopularBooksCacheItemName, cancellationToken);
            return _popularBooks;
        }
示例#35
0
        public async Task<XCollection<Book>> GetNoveltyBooks(int fromPosition, CancellationToken cancellationToken, int customBooksOnPage = 0)
		{
            int booksOnPage = customBooksOnPage > 0 ? customBooksOnPage : BooksInPage;
			if (_interestingBooks == null)
			{
                string limit = string.Format("{0},{1}", fromPosition, booksOnPage);

				var parameters = new Dictionary<string, object>
						{						
							{"sort", "time_desc"},									
							{"min_person_rating", "6"},								
							{"limit", limit},
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_interestingBooks = books.Books;
			}
			else
			{
                int lastIndex = fromPosition + booksOnPage;

				var collection = new XCollection<Book>( _interestingBooks.Take( lastIndex ) );

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, booksOnPage);

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif									
							{"rating", "authors"},								
							{"limit", limit},
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey( book.GetKey() ))
							{
								collection.Add( book );
							}
						}
					}

					_interestingBooks = collection;
				}
                _dataCacheService.PutItem(_interestingBooks, InterestingBooksCacheItemName, cancellationToken);
                return collection;
			}
            _dataCacheService.PutItem(_interestingBooks, InterestingBooksCacheItemName, cancellationToken);
            return _interestingBooks;
		}
示例#36
0
		public async Task<XCollection<Book>> GetNoveltyBooksByGenre(int fromPosition, int genreId, CancellationToken cancellationToken)
		{
			if (_noveltyBooksByGenre == null || _noveltyBooksByGenreId != genreId)
			{
				string limit = string.Format( "{0},{1}", fromPosition, BooksInPage );

				var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif								
							{"genre", genreId},														
							{"limit", limit},									
							{"sort", "time_desc"},
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_noveltyBooksByGenreId = genreId;

				_noveltyBooksByGenre = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				XCollection<Book> collection = new XCollection<Book>( _noveltyBooksByGenre.Take( lastIndex ) );

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format( "{0},{1}", lastIndex, BooksInPage );

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
                        {"genre", genreId},													
							{"limit", limit},										
							{"sort", "time_desc"},		
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey( book.GetKey() ))
							{
								collection.Add( book );
							}
						}
					}

					_noveltyBooksByGenre = collection;
				}

				return collection;
			}
			return _noveltyBooksByGenre;
		}
示例#37
0
        private void Save()
        {
            resultItem.ThirdPartyDBPatamter.FileFieldFlag = this.ckbSaveContentToFile.Checked;

            resultItem.ThirdPartyDBPatamter.SectionName = this.tbSectionName.Text.Trim();
            resultItem.ThirdPartyDBPatamter.FieldName   = this.txtThirdPartyFieldName.Text.Trim();
            resultItem.ThirdPartyDBPatamter.FieldType   = (OleDbType)Enum.Parse(typeof(OleDbType), this.enumCmbbxThirdPartyFieldType.Text.Trim());
            resultItem.TargetField = this.tbSectionName.Text.Trim() + "_" + this.txtThirdPartyFieldName.Text.Trim();
            resultItem.SourceField = resultItem.TargetField;


            if (this.ckbSaveContentToFile.Checked)
            {
                resultItem.ThirdPartyDBPatamter = m_FFileField.CurrThrPartyDBParamterExOut;
                if (resultItem.ThirdPartyDBPatamter.FileFields.Count > 0)
                {
                    resultItem.GWDataDBField    = resultItem.ThirdPartyDBPatamter.FileFields[0];
                    resultItem.SourceField      = resultItem.ThirdPartyDBPatamter.FileFields[0].GetFullFieldName();
                    resultItem.Translating.Type = TranslatingType.None;
                }
                else
                {
                    resultItem.Translating.Type       = TranslatingType.FixValue;
                    resultItem.Translating.ConstValue = "";
                }
            }
            else
            {
                resultItem.GWDataDBField.Table              = (GWDataDBTable)Enum.Parse(typeof(GWDataDBTable), this.enumCmbbxTable.Text.Trim());
                resultItem.GWDataDBField.FieldName          = this.cmbbxGWField.Text.Trim();
                resultItem.ThirdPartyDBPatamter.SectionName = this.tbSectionName.Text.Trim();
                resultItem.ThirdPartyDBPatamter.FieldName   = this.txtThirdPartyFieldName.Text.Trim();
                resultItem.ThirdPartyDBPatamter.FieldType   = (OleDbType)Enum.Parse(typeof(OleDbType), this.enumCmbbxThirdPartyFieldType.Text.Trim());
                resultItem.SourceField      = this.cmbbxGWField.Text.Trim();
                resultItem.TargetField      = this.txtThirdPartyFieldName.Text.Trim();
                resultItem.Translating.Type = (TranslatingType)Enum.Parse(typeof(TranslatingType), this.enumCmbbxTranslation.Text.Trim());
                if (enumCmbbxTranslation.Text == TranslatingType.LookUpTable.ToString() || enumCmbbxTranslation.Text == TranslatingType.LookUpTableReverse.ToString())
                {
                    LUTWrapper w = this.cmbbxResult.SelectedItem as LUTWrapper;
                    if (w != null)
                    {
                        resultItem.Translating.LutName    = w.TableName;
                        resultItem.Translating.ConstValue = "";
                    }
                }
                else if (enumCmbbxTranslation.Text == TranslatingType.FixValue.ToString() || enumCmbbxTranslation.Text == TranslatingType.DefaultValue.ToString())
                {
                    resultItem.Translating.LutName    = "";
                    resultItem.Translating.ConstValue = this.txtTranslationValue.Text;
                }
                else
                {
                    resultItem.Translating.LutName    = "";
                    resultItem.Translating.ConstValue = "";
                }
                resultItem.RedundancyFlag = bool.Parse(enumCmbbxRedundancy.Text);
            }
            if (type == "Add")
            {
                resultList.Add(resultItem);
            }
        }
示例#38
0
        public async Task<XCollection<Book>> GetPopularBooksByCollection(int fromPosition, int collectionId, CancellationToken cancellationToken)
        {
            if (_popularBooksByCollection == null || _popularBooksByCollectionIdCollection != collectionId)
            {
                var limit = string.Format("{0},{1}", fromPosition, BooksInPage);

                var parameters = new Dictionary<string, object>
						{	
							{"sort", "pop_desc"},
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif									
							{"collection", collectionId},							
							{"limit", limit},
						};

                var books = await _client.SearchCatalog(parameters, cancellationToken);

                CheckMyBooks(books.Books);

                _popularBooksByCollection = books.Books;
                _popularBooksByCollectionIdCollection = collectionId;
            }
            else
            {
                int lastIndex = fromPosition + BooksInPage;

                var collection = new XCollection<Book>(_popularBooksByCollection.Take(lastIndex));

                if (collection.Count() + BooksInPageShift < lastIndex)
                {
                    lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, BooksInPage);

                    var parameters = new Dictionary<string, object>
						{	
                            {"sort", "pop_desc"},							
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif									
							{"collection", collectionId},							
							{"limit", limit},
						};

                    var books = await _client.SearchCatalog(parameters, cancellationToken);

                    if (books != null && books.Books != null && books.Books.Any())
                    {
                        CheckMyBooks(books.Books);

                        foreach (var book in books.Books)
                        {
                            if (!collection.ContainsKey(book.GetKey()))
                            {
                                collection.Add(book);
                            }
                        }
                    }

                    _popularBooksByCollection = collection;
                    _popularBooksByCollectionIdCollection = collectionId;
                }

                return collection;
            }
            return _popularBooksByCollection;
        }
 private XCollection<Book> getExpireBooks(XCollection<Book> books, DateTime nextBookTime)
 {
     var booksToExpire = new XCollection<Book>();
     books.ForEach(book =>
     {
         if (!string.IsNullOrEmpty(book.ExpiredDateStr) &&
             !book.IsExpiredBook &&
             book.ExpiredDate == nextBookTime)
         {
             booksToExpire.Add(book);
         }
     });
     return booksToExpire;
 }
		public async Task DeleteNotifications( XCollection<Notification> notifications, CancellationToken cancellationToken )
		{
			var exits = await RefreshNotifications( cancellationToken );

			var newcollection = new XCollection<Notification>();
			foreach (var notification in exits)
			{
				if (notifications.All( x => x.NotifiedPerson != notification.NotifiedPerson ))
				{
					newcollection.Add( notification );
				}
			}

			var authors = new List<string>();
			foreach (var notification in newcollection)
			{
				if (!string.IsNullOrEmpty( notification.NotifiedPerson ))
				{
					authors.Add( notification.NotifiedPerson );
				}				
			}

			string authorsString = string.Join( "||", authors );

			XCollection<Notification> result;

			Dictionary<string, object> parameters;
			if( string.IsNullOrEmpty( authorsString ) )
			{
				if( exits.Count > 0 )
				{
                    for (int i = notifications.Count - 1; i >= 0; i--)
                    {
                        var notif = exits.FirstOrDefault(x => x.NotifiedPerson == notifications[i].NotifiedPerson);
                        if (notif != null) exits.Remove(notif);
                    }

                    string newAuthorsString = string.Join("||", exits);

                    parameters = new Dictionary<string, object>
					{							
						{ "update_subscr", newAuthorsString }								
					};

					result = (await _client.Subscriptions( parameters, cancellationToken )).Notifications;

                    //parameters = new Dictionary<string, object>
                    //{							
                    //    { "del_subscr", exits[0].NotifiedPerson }								
                    //};

                    //result = ( await _client.Subscriptions( parameters, cancellationToken ) ).Notifications;
				}
				else
				{
					result = new XCollection<Notification>();
				}
			}
			else
			{
				parameters = new Dictionary<string, object>
					{							
						{ "update_subscr", authorsString }								
					};

				result = (await _client.Subscriptions( parameters, cancellationToken )).Notifications;
			}

			UpdateNotificationList( result, cancellationToken );
		}
示例#41
0
 public async Task ClearLibrariesBooks(CancellationToken token)
 {
     var books = await GetExistBooks(token);
     if (books != null && books.Count > 0)
     {
         var booksWillBeClear = new XCollection<Book>();
         foreach (var book in books)
         {
             if (!string.IsNullOrEmpty(book.ExpiredDateStr)) booksWillBeClear.Add(book);
         }
         if (booksWillBeClear.Count > 0)
         {
             foreach (var book in booksWillBeClear)
             {
                 await RemoveFullBookInLocalStorage(book);
             }
         }
     }
 }
示例#42
0
		public async Task<XCollection<Book>> SearchBooks(int fromPosition, string searchString, CancellationToken cancellationToken)
		{
			if (_foundedBooks == null || _foundedBooksQuery != searchString)
			{
				string limit = string.Format("{0},{1}", fromPosition, BooksInPage);

				var parameters = new Dictionary<string, object>
						{								
                        {"search_types", "0"},	

							{"search", searchString},					
							{"limit", limit},			
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_foundedBooksQuery = searchString;
				_foundedBooks = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				var collection = new XCollection<Book>(_foundedBooks.Take(lastIndex));

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format("{0},{1}", lastIndex, BooksInPage);

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
							{"search_title", searchString},						
							{"limit", limit},
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey(book.GetKey()))
							{
								collection.Add(book);
							}
						}
					}

					_foundedBooks = collection;
				}

				return collection;
			}
			return _foundedBooks;
		}
示例#43
0
		private XCollection<Genre> GetGenresInCollectionByTokens(XCollection<Genre> genres, List<string> tokens)
		{
			XCollection<Genre> res = new XCollection<Genre>();
			if (genres != null)
			{
				foreach (var genre in genres)
				{
					if(tokens.Contains( genre.Token ) && res.FirstOrDefault( x => x.Id == genre.Id ) == null)
					{
						res.Add( genre );
					}
					var subcollection = GetGenresInCollectionByTokens(genre.Children, tokens);
					foreach (var subgenre in subcollection)
					{
						if(res.FirstOrDefault( x => x.Id == subgenre.Id ) == null)
						{
							res.Add(subgenre);
						}
					}
				}
			}
			return res;
		}
示例#44
0
		public async Task<XCollection<Book>> GetBooksByAuthor(int fromPosition, string authorId, CancellationToken cancellationToken)
		{
			if (_booksByAuthor == null || _booksByAuthorID != authorId)
			{
				string limit = string.Format("{0},{1}", fromPosition, BooksInPage);

				var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
                            {"person", authorId},									
							{"limit", limit},			
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_booksByAuthorID = authorId;
				_booksByAuthor = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				var collection = new XCollection<Book>(_booksByAuthor.Take(lastIndex));

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format("{0},{1}", lastIndex, BooksInPage);

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
							{"person", authorId},								
							{"limit", limit},
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey(book.GetKey()))
							{
								collection.Add(book);
							}
						}
					}

					_booksByAuthor = collection;
				}

				return collection;
			}
			return _booksByAuthor;
		}
示例#45
0
 private void AddSave()
 {
     table.DisplayName = this.txtTableName.Text;
     table.Table       = LUItemList;
     tableSet.Add(table);
 }
示例#46
0
 public async Task LoadOffers(Session session)
 {
     GiftInfo.GiftAvailable = false;
     var result = await _profileProvider.GetOffers(session.Token);
     var offers = result.Offers;
     Offers = new XCollection<Offer>();
     foreach (var offer in offers.Where(offer => offer.Campaign == 2))
     {
         Offers.Add(offer);
     }
     PresentValidTime = DateTime.MinValue;
     foreach (var time in Offers.Select(offer => DateTime.ParseExact(offer.ValidTill, "yyyy-MM-dd HH:mm:ss", new CultureInfo("ru-RU"), DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal)).Where(time => time > PresentValidTime))
     {
         PresentValidTime = time;
     }
     var count = Offers.Count(of => of.Class == 2);
     if (count <= 0) return;
     GiftInfo.GiftAvailable = true;
     var giftPrice = (from offer in Offers where offer.Xml.Hidden.Present.Price > 0 select offer.Xml.Hidden.Present.Price).Concat(new double[] {99999}).Min();
     GiftInfo.MinGiftPrice = giftPrice;
 }
示例#47
0
	    public async Task<XCollection<Book>> GetBooksByTag(int fromPosition, int tagId, CancellationToken cancellationToken)
	    {
            if (_booksByTag == null || _booksByTagId != tagId)
            {
                string limit = string.Format("{0},{1}", fromPosition, BooksInPage);

                var parameters = new Dictionary<string, object>
                        {
                            {"tag", tagId},
                            {"limit", limit},
                        };

                var books = await _client.SearchCatalog(parameters, cancellationToken);

                CheckMyBooks(books.Books);

                _booksByTagId = tagId;

                _booksByTag = books.Books;
            }
            else
            {
                int lastIndex = fromPosition + BooksInPage;

                var collection = new XCollection<Book>(_booksByTag.Take(lastIndex));

                if (collection.Count() + BooksInPageShift < lastIndex)
                {
                    lastIndex = collection.Count();

                    string limit = string.Format("{0},{1}", lastIndex, BooksInPage);

                    var parameters = new Dictionary<string, object>
                        {
                            {"genre", tagId},
                            {"limit", limit},
                        };

                    var books = await _client.SearchCatalog(parameters, cancellationToken);

                    if (books != null && books.Books != null && books.Books.Any())
                    {
                        CheckMyBooks(books.Books);

                        foreach (var book in books.Books)
                        {
                            if (!collection.ContainsKey(book.GetKey()))
                            {
                                collection.Add(book);
                            }
                        }
                    }

                    _booksByTag = collection;
                }

                return collection;
            }
            return _booksByTag;
        }
		private async Task LoadBookmarks( Session session )
		{
			XCollection<Bookmark> bookmarks = null;
			try
			{
				bookmarks = await _bookmarksProvider.GetBookmarks( session.Token );
			}
			catch (CatalitNoCredentialException)
			{
				//ToDo: Do something? Message?
			}

			XCollection<Book> books = new XCollection<Book>();

			foreach (var bookmark in bookmarks)
			{
				if( bookmark.Group != "0" )
				{
					var exits = books.FirstOrDefault( x => x.Description.Hidden.DocumentInfo.Id == bookmark.ArtId );

					if( exits != null )
					{
						exits.BookmarksCount++;
					}
					else
					{
						var book = await _catalogProvider.GetBookByDocumentId( bookmark.ArtId, session.Token );
						if( book != null )
						{
							book.BookmarksCount = 1;
							books.Add( book );
						}
					}
				}
			}

			//sort books by last opened
			int top = 0;
			var myBooksHistory = await _catalogProvider.GetBooksIdsFromHistory( session.Token );

			foreach( var mybook in myBooksHistory )
			{
				var inbookmarked = books.FirstOrDefault(x => x.Id == mybook );

				if( inbookmarked != null )
				{
					books.Remove( inbookmarked );
					books.Insert( top, inbookmarked );
					top++;
				}
			}

			BookmarkedBooks.Update( books );

			BookmarkedBooksEmpty = BookmarkedBooks.Count == 0;

			if (bookmarks != null)
			{
				Bookmarks.Update(bookmarks);
			}
		}
示例#49
0
 public async Task ClearNotLoadedBooks(CancellationToken token)
 {
     var exists = await GetExistBooks(token);
     if (exists != null && exists.Count > 0)
     {
         var booksWillBeClear = new XCollection<Book>();
         foreach (var book in exists)
         {
             if (!FullBookExistsInLocalStorage(book.Id)) booksWillBeClear.Add(book);
         }
         if (booksWillBeClear.Count > 0)
         {
             foreach (var book in booksWillBeClear)
             {
                 exists.Remove(book);
             }
             _dataCacheService.PutItem(exists, StorageSettingName, CancellationToken.None);
         }
     }
 }
示例#50
0
		public async Task<XCollection<Book>> GetPopularBooksByGenres(int fromPosition, List<int> genreId, CancellationToken cancellationToken)
		{
			if( _popularBooksByGenres == null || _popularBooksByGenresIds == null || !_popularBooksByGenresIds.SequenceEqual( genreId ) )
			{
				string limit = string.Format( "{0},{1}", fromPosition, BooksInPage );

				var parameters = new Dictionary<string, object>
						{																	
							{"genre", genreId},							
							{"limit", limit},																
							{"sort", "pop_desc"},								
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_popularBooksByGenresIds = genreId;

				_popularBooksByGenres = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				var collection = new XCollection<Book>( _popularBooksByGenres.Take( lastIndex ) );

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format( "{0},{1}", lastIndex, BooksInPage );

					var parameters = new Dictionary<string, object>
						{															
							{"genre", genreId},							
							{"limit", limit},															
							{"sort", "pop_desc"},		
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey( book.GetKey() ))
							{
								collection.Add( book );
							}
						}
					}

					_popularBooksByGenres = collection;
				}

				return collection;
			}
			return _popularBooksByGenres;
		}
示例#51
0
		public async Task<XCollection<Book>> GetBooksAreReadWithThisBook(int fromPosition, int bookId, CancellationToken cancellationToken)
		{
			if (_booksByBook == null || _booksByBookID != bookId)
			{
				//string limit = string.Format("{0},{1}", fromPosition, BooksInPage);
				//Get only 5 elements
				var limit = string.Format( "{0},{1}", 0, 5 );

				var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
							{"rating", "with"},
							{"art", bookId},				
							{"limit", limit},			
						};

				var books = await _client.SearchCatalog(parameters, cancellationToken);

				CheckMyBooks( books.Books );

				_booksByBookID = bookId;
				_booksByBook = books.Books;
			}
			else
			{
				int lastIndex = fromPosition + BooksInPage;

				var collection = new XCollection<Book>(_booksByBook.Take(lastIndex));

				if (collection.Count() + BooksInPageShift < lastIndex)
				{
					lastIndex = collection.Count();

					string limit = string.Format("{0},{1}", lastIndex, BooksInPage);

					var parameters = new Dictionary<string, object>
						{								
#if PDF_ENABLED	
                        {"search_types", "4"},	
#else
                        {"search_types", "0"},	
#endif
							{"rating", "with"},
							{"uuid", bookId},					
							{"limit", limit},
						};

					var books = await _client.SearchCatalog(parameters, cancellationToken);

					if (books != null && books.Books != null && books.Books.Any())
					{
						CheckMyBooks( books.Books );

						foreach (var book in books.Books)
						{
							if (!collection.ContainsKey(book.GetKey()))
							{
								collection.Add(book);
							}
						}
					}

					_booksByBook = collection;
				}

				return collection;
			}
			return _booksByBook;
		}