/// <summary>
        /// Iterate the docTypes (Label, Manifest, ...), until you find one that needs fetching
        /// This method calls itself indirectly, until there is nothing more to fetch.
        /// </summary>
        private async Task GetNextExpectedDocument()
        {
            bool requestStarted = false;
            bool moveSucceeded  = true;

            moveSucceeded = docIndex.MoveNext();
            while (moveSucceeded && !requestStarted)
            {
                DocTypes type = docIndex.Current;
                if (docStatus[type] == DocStatusses.OnTNTServer)
                {
                    requestStarted = true;
                    await GetDocument(type);
                }
                else
                {
                    moveSucceeded = docIndex.MoveNext();
                }
            }
            if (!moveSucceeded) //no more docTypes, it means we're ready
            {
                this.Status = Statusses.Ready;
                FireShipRequestReady();
            }
        }
Beispiel #2
0
 public void AddDocTypes(IList <Entities.DocType> docTypes)
 {
     foreach (Entities.DocType docType in docTypes)
     {
         var avm = new DocTypeViewModel(docType);
         DocTypes.Add(avm);
     }
 }
        private void FireDocumentRequest(DocTypes DocType)
        {
            EventHandler <DocEventArgs> handler = DocumentRequest;

            if (handler != null)
            {
                handler(this, new DocEventArgs(DocType));
            }
        }
Beispiel #4
0
 /// <summary>
 /// Returns detailed information about user or community documents.
 /// </summary>
 /// <param name="count">Number of documents to return. By default, all documents.</param>
 /// <param name="offset">Offset needed to return a specific subset of documents.</param>
 /// <param name="type">The type to filter on.</param>
 /// <param name="ownerId">ID of the user or community that owns the documents. Use a negative value to designate a community ID. </param>
 /// <returns>Returns a <see cref="List{T}"/> of <see cref="Doc"/> objects.</returns>
 public async Task <Response <ItemsList <Doc> > > Get(int?count     = null, int?offset = null,
                                                      DocTypes type = DocTypes.Undefined, int?ownerId = null)
 => await Request <ItemsList <Doc> >("get", new MethodParams
 {
     { "count", count },
     { "offset", offset },
     { "type", (int)type },
     { "owner_id", ownerId }
 });
        private void FireDocumentReceived(DocTypes DocType)
        {
            EventHandler <DocEventArgs> handler2 = DocumentReceived;

            if (handler2 != null)
            {
                handler2(this, new DocEventArgs(DocType));
            }
        }
        public ActionResult Create([Bind(Include = "DocTypeId,DocType,DocExt,DocIcon,IsActive,AddedBy,AddedOn,EditedBy,EditedOn,StatusId")] DocTypes docTypes)
        {
            if (ModelState.IsValid)
            {
                db.DocTypes.Add(docTypes);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(docTypes));
        }
        public ActionResult Edit([Bind(Include = "DocTypeId,DocType,DocExt,DocIcon,IsActive,EditedBy,EditedOn,StatusId", Exclude = "AddedBy,AddedOn")] DocTypes docTypes)
        {
            if (ModelState.IsValid)
            {
                db.Entry(docTypes).State = EntityState.Modified;
                db.Entry(docTypes).Property(uco => uco.AddedBy).IsModified = false;
                db.Entry(docTypes).Property(uco => uco.AddedOn).IsModified = false;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(docTypes));
        }
Beispiel #8
0
        /// <summary>
        /// Gets a documentation link given a reference
        /// </summary>
        /// <returns>The link.</returns>
        /// <param name="type">Type.</param>
        /// <param name="reference">Reference.</param>
        public static string GetLink(DocTypes type, string reference)
        {
            if (type == DocTypes.Api)
            {
                return(GetApiLink(reference));
            }

            if (type == DocTypes.Doc)
            {
                return(GetDocLink(reference));
            }

            return("https://doc.photonengine.com");
        }
        // GET: DocTypes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DocTypes docTypes = db.DocTypes.Find(id);

            if (docTypes == null)
            {
                return(HttpNotFound());
            }
            return(View(docTypes));
        }
        /// <summary>
        /// Fetch one of the 4 printable documents, as readonly, from the TNT server, apply an XSLT stylesheet,
        /// then send it to a printer (last point still TODO)
        /// </summary>
        /// <param name="type">One of the four document types</param>
        private async Task GetDocument(DocTypes type)
        {
            docStatus[type] = DocStatusses.Fetching;
            FireDocumentRequest(type);

            FormUrlEncodedContent content = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                { "xml_in", "GET_" + type.ToString().ToUpper() + ":" + this.accessCode }
            });
            PostResults resp = await PostAsync(content, expectXml : true);

            //Choose the stylsheet fitting to the doc type
            XslCompiledTransform xsl = new XslCompiledTransform();

            switch (type)
            {
            case DocTypes.Label:
                xsl.Load(typeof(AddressLabelXsl));
                break;

            case DocTypes.Manifest:
                xsl.Load(typeof(ManifestXsl));
                break;

            case DocTypes.Connote:
                xsl.Load(typeof(ConsignmentNoteXsl));
                break;

            case DocTypes.Invoice:
                xsl.Load(typeof(CommercialInvoiceXsl));
                break;
            }

            //Transform the response, with the stylesheet, then layout and print
            TextWriter       wri  = new StringWriter();
            XsltArgumentList args = new XsltArgumentList();

            xsl.Transform(resp.Xml.docR, args, wri);
            bool loadingProblems = printQueue.AddPrintJob(wri.ToString());   //Load into browser, then print

            if (loadingProblems)
            {
                FireDocumentLoadError(0, "One of the HTML documents to be printed did not load into the .NET browser properly.");
            }

            docStatus[type] = DocStatusses.Fetched;
            FireDocumentReceived(type);
            await GetNextExpectedDocument();  //the recursive call will end after max 4 iterations (the docTypes).
        }
        //Which documents are available on the TNT server, according to this Result doc?

        private bool IsPrintCreated(DocTypes type)
        {
            bool created = false;

            if (hasPrint)
            {
                string xpath = "/document/PRINT/" + type.ToString() + "/text()";
                var    node  = doc.nav.SelectSingleNode(xpath);
                if (node != null)
                {
                    created = node.Value == "CREATED";
                }
            }
            return(created);
        }
 public ActionResult DeleteConfirmed(int id)
 {
     try
     {
         DocTypes docTypes = db.DocTypes.Find(id);
         docTypes.StatusId        = 0; // on delete setting up the row status column to 0 for softdelete. 1 is active
         db.Entry(docTypes).State = EntityState.Modified;
         //db.Users.Remove(users);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw e;
     }
 }
        // GET: DocTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DocTypes docTypes = db.DocTypes.Find(id);

            if (docTypes == null)
            {
                return(HttpNotFound());
            }

            //ViewBag.UserTypeId = new SelectList(db.UserTypes, "UserTypeId", "UserType", users.UserTypeId);
            ViewBag.StatusId = new SelectList(db.RStatus, "StatusId", "StatusName", docTypes.StatusId);
            // ViewBag.UStatusId = new SelectList(db.UStatus, "UStatusId", "UStatusName", users.UStatusId);
            return(View(docTypes));
        }
Beispiel #14
0
        private void InitRepository()
        {
            _testRepository = new List <ContentEditorModel>();

            var tabIds = _docTypes.SelectMany(tabs => tabs.DefinedTabs).Select(x => x.Id).ToList();

            var currTab = 0;

            XmlData.Root.Descendants()
            .Where(x => x.Attribute("isDoc") != null)
            .ToList()
            .ForEach(x =>
            {
                var customProperties = new List <ContentProperty>();
                //create the model
                var parentId = x.Attribute("parentID");
                var publishedScheduledDate   = x.Attribute("publishedScheduledDate");
                var unpublishedScheduledDate = x.Attribute("unPublishedScheduledDate");
                var publishedDate            = x.Attribute("publishedDate");

                //BUG: We need to change this back once the Hive IO provider is fixed and it get its ProviderMetadata.MappingRoot  set
                // (APN) - I've changed back
                //var template = ((string)x.Attribute("template")).IsNullOrWhiteSpace() ? HiveId.Empty : new HiveId((Uri)null, "templates", new HiveIdValue((string)x.Attribute("template")));
                var template = ((string)x.Attribute("template")).IsNullOrWhiteSpace() ? HiveId.Empty : new HiveId(new Uri("storage://templates"), "templates", new HiveIdValue((string)x.Attribute("template")));

                var docType = string.IsNullOrEmpty((string)x.Attribute("nodeType"))
                                      ? null
                                      : DocTypes.Where(d => d.Id == HiveId.ConvertIntToGuid((int)x.Attribute("nodeType"))).SingleOrDefault();

                var contentNode = new ContentEditorModel(HiveId.ConvertIntToGuid((int)x.Attribute("id")))
                {
                    Name              = (string)x.Attribute("nodeName"),
                    DocumentTypeId    = docType == null ? HiveId.Empty : docType.Id,
                    DocumentTypeName  = docType == null ? "" : docType.Name,
                    DocumentTypeAlias = docType == null ? "" : docType.Alias,
                    ParentId          = parentId != null ? HiveId.ConvertIntToGuid((int)parentId) : HiveId.Empty,
                    //assign the properties
                    Properties = GetNodeProperties((int)x.Attribute("id"), template)
                };

                //add the new model
                _testRepository.Add(contentNode);
            });
        }
        private void ReplaceDocTypeForm_Load(object sender, EventArgs e)
        {
            // инициализация таблиц
            _docTypesTable = DocTypes.CreatetTable();

            // инициализация биндинг сорса
            _docTypesBS                 = new BindingSource();
            _docTypesBS.DataSource      = _docTypesTable;
            _docTypesBS.CurrentChanged += new EventHandler(_docTypesBS_CurrentChanged);

            //биндинг сорс как источник для выпадающего меню
            docTypesComboBox.DataSource    = _docTypesBS;
            docTypesComboBox.ValueMember   = DocTypes.id;
            docTypesComboBox.DisplayMember = DocTypes.name;

            //формирование строки запроса, где 2 - тип пакета из таблицы List_Types
            string commandStr = DocTypes.GetSelectText(2);

            //заполнение таблицы
            _docTypesAdapter = new SQLiteDataAdapter(commandStr, new SQLiteConnection(_connection));
            _docTypesAdapter.Fill(_docTypesTable);

            curDocRadioButton.Checked = true;
        }
 public DocErrorArgs(DocTypes DocType, int ErrorNumber, string Description)
 {
     this.DocType     = DocType;
     this.ErrorNumber = ErrorNumber;
     this.Description = Description;
 }
 public DocEventArgs(DocTypes DocType)
 {
     this.DocType = DocType;
 }
Beispiel #18
0
        public override void UpdateDatabaseAfterUpdateSchema()
        {
            base.UpdateDatabaseAfterUpdateSchema();
            //string name = "MyName";
            //DomainObject1 theObject = ObjectSpace.FindObject<DomainObject1>(CriteriaOperator.Parse("Name=?", name));
            //if(theObject == null) {
            //    theObject = ObjectSpace.CreateObject<DomainObject1>();
            //    theObject.Name = name;
            //}

            string temp     = "";
            string tempname = "";

            temp     = GeneralSettings.hq;
            tempname = GeneralSettings.hq;
            Companies company = ObjectSpace.FindObject <Companies>(new BinaryOperator("BoCode", temp));

            if (company == null)
            {
                company        = ObjectSpace.CreateObject <Companies>();
                company.BoCode = temp;
                company.BoName = tempname;
            }

            SystemUsers sampleUser = ObjectSpace.FindObject <SystemUsers>(new BinaryOperator("UserName", "User"));

            if (sampleUser == null)
            {
                sampleUser          = ObjectSpace.CreateObject <SystemUsers>();
                sampleUser.UserName = "******";
                sampleUser.Company  = sampleUser.Session.FindObject <Companies>(new BinaryOperator("BoCode", GeneralSettings.hq));
                sampleUser.SetPassword("");
            }
            PermissionPolicyRole defaultRole = CreateDefaultRole();

            sampleUser.Roles.Add(defaultRole);

            SystemUsers userAdmin = ObjectSpace.FindObject <SystemUsers>(new BinaryOperator("UserName", "Admin"));

            if (userAdmin == null)
            {
                userAdmin          = ObjectSpace.CreateObject <SystemUsers>();
                userAdmin.UserName = "******";
                userAdmin.Company  = userAdmin.Session.FindObject <Companies>(new BinaryOperator("BoCode", GeneralSettings.hq));
                // Set a password if the standard authentication type is used
                userAdmin.SetPassword("");
            }
            // If a role with the Administrators name doesn't exist in the database, create this role
            PermissionPolicyRole adminRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", "SA"));

            if (adminRole == null)
            {
                adminRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                adminRole.Name = "SA";
            }
            adminRole.IsAdministrative = true;
            userAdmin.Roles.Add(adminRole);

            temp = GeneralSettings.claimrole;
            PermissionPolicyRole claimRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (claimRole == null)
            {
                claimRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                claimRole.Name = temp;
            }
            temp = GeneralSettings.claimsuperrole;
            PermissionPolicyRole claimsuperRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (claimsuperRole == null)
            {
                claimsuperRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                claimsuperRole.Name = temp;
            }
            temp = GeneralSettings.verifyrole;
            PermissionPolicyRole verifyRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (verifyRole == null)
            {
                verifyRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                verifyRole.Name = temp;
            }
            temp = GeneralSettings.Acceptancerole;
            PermissionPolicyRole AcceptanceRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (AcceptanceRole == null)
            {
                AcceptanceRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                AcceptanceRole.Name = temp;
            }
            temp = GeneralSettings.postrole;
            PermissionPolicyRole postRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (postRole == null)
            {
                postRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                postRole.Name = temp;
            }
            temp = GeneralSettings.ApprovalRole;
            PermissionPolicyRole approveRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (approveRole == null)
            {
                approveRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                approveRole.Name = temp;
            }
            temp = GeneralSettings.RejectApproveRole;
            PermissionPolicyRole RejectApproveRole = ObjectSpace.FindObject <PermissionPolicyRole>(new BinaryOperator("Name", temp));

            if (RejectApproveRole == null)
            {
                RejectApproveRole      = ObjectSpace.CreateObject <PermissionPolicyRole>();
                RejectApproveRole.Name = temp;
            }

            temp     = GeneralSettings.defclaimdoc;
            tempname = "Normal Claim";
            DocTypes doctype = ObjectSpace.FindObject <DocTypes>(new BinaryOperator("BoCode", temp));

            if (doctype == null)
            {
                doctype        = ObjectSpace.CreateObject <DocTypes>();
                doctype.BoCode = temp;
                doctype.BoName = tempname;
            }

            ObjectSpace.CommitChanges(); //This line persists created object(s).


            temp     = GeneralSettings.defaulttax;
            tempname = GeneralSettings.defaulttax;
            Taxes tax = ObjectSpace.FindObject <Taxes>(new BinaryOperator("BoCode", temp));

            if (tax == null)
            {
                tax        = ObjectSpace.CreateObject <Taxes>();
                tax.BoCode = temp;
                tax.BoName = tempname;
            }
            if (GeneralSettings.defaultmileagetax != GeneralSettings.defaulttax)
            {
                temp     = GeneralSettings.defaultmileagetax;
                tempname = GeneralSettings.defaultmileagetax;
                Taxes mtax = ObjectSpace.FindObject <Taxes>(new BinaryOperator("BoCode", temp));
                if (mtax == null)
                {
                    mtax        = ObjectSpace.CreateObject <Taxes>();
                    mtax.BoCode = temp;
                    mtax.BoName = tempname;
                }
            }
            temp     = GeneralSettings.defmileage;
            tempname = GeneralSettings.defmileage;
            Mileages mileage = ObjectSpace.FindObject <Mileages>(new BinaryOperator("BoCode", temp));

            if (mileage == null)
            {
                mileage        = ObjectSpace.CreateObject <Mileages>();
                mileage.BoCode = temp;
                mileage.BoName = tempname;
            }

            temp     = GeneralSettings.defaultregion;
            tempname = "Local";
            Regions region = ObjectSpace.FindObject <Regions>(new BinaryOperator("BoCode", temp));

            if (region == null)
            {
                region        = ObjectSpace.CreateObject <Regions>();
                region.BoCode = temp;
                region.BoName = tempname;
            }

            ObjectSpace.CommitChanges(); //This line persists created object(s).
        }